repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
neos/flow-development-collection | Neos.Flow/Classes/Cli/ConsoleOutput.php | ConsoleOutput.getProgressBar | protected function getProgressBar(): ProgressBar
{
if ($this->progressBar === null) {
$this->progressBar = new ProgressBar($this->output);
}
return $this->progressBar;
} | php | protected function getProgressBar(): ProgressBar
{
if ($this->progressBar === null) {
$this->progressBar = new ProgressBar($this->output);
}
return $this->progressBar;
} | [
"protected",
"function",
"getProgressBar",
"(",
")",
":",
"ProgressBar",
"{",
"if",
"(",
"$",
"this",
"->",
"progressBar",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"progressBar",
"=",
"new",
"ProgressBar",
"(",
"$",
"this",
"->",
"output",
")",
";",
... | Returns or initializes the symfony/console ProgressHelper
@return ProgressBar | [
"Returns",
"or",
"initializes",
"the",
"symfony",
"/",
"console",
"ProgressHelper"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/ConsoleOutput.php#L388-L394 |
neos/flow-development-collection | Neos.Flow/Classes/Cli/ConsoleOutput.php | ConsoleOutput.getTable | protected function getTable(): Table
{
if ($this->table === null) {
$this->table = new Table($this->output);
}
return $this->table;
} | php | protected function getTable(): Table
{
if ($this->table === null) {
$this->table = new Table($this->output);
}
return $this->table;
} | [
"protected",
"function",
"getTable",
"(",
")",
":",
"Table",
"{",
"if",
"(",
"$",
"this",
"->",
"table",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"table",
"=",
"new",
"Table",
"(",
"$",
"this",
"->",
"output",
")",
";",
"}",
"return",
"$",
"th... | Returns or initializes the symfony/console Table
@return Table | [
"Returns",
"or",
"initializes",
"the",
"symfony",
"/",
"console",
"Table"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/ConsoleOutput.php#L401-L407 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/FileMonitor.php | FileMonitor.createFileMonitorAtBoot | public static function createFileMonitorAtBoot($identifier, Bootstrap $bootstrap)
{
$fileMonitorCache = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Monitor');
// The change detector needs to be instantiated and registered manually because
// it has a complex dependency... | php | public static function createFileMonitorAtBoot($identifier, Bootstrap $bootstrap)
{
$fileMonitorCache = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Monitor');
// The change detector needs to be instantiated and registered manually because
// it has a complex dependency... | [
"public",
"static",
"function",
"createFileMonitorAtBoot",
"(",
"$",
"identifier",
",",
"Bootstrap",
"$",
"bootstrap",
")",
"{",
"$",
"fileMonitorCache",
"=",
"$",
"bootstrap",
"->",
"getEarlyInstance",
"(",
"CacheManager",
"::",
"class",
")",
"->",
"getCache",
... | Helper method to create a FileMonitor instance during boot sequence as injections have to be done manually.
@param string $identifier
@param Bootstrap $bootstrap
@return FileMonitor | [
"Helper",
"method",
"to",
"create",
"a",
"FileMonitor",
"instance",
"during",
"boot",
"sequence",
"as",
"injections",
"have",
"to",
"be",
"done",
"manually",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/FileMonitor.php#L106-L123 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/FileMonitor.php | FileMonitor.injectChangeDetectionStrategy | public function injectChangeDetectionStrategy(ChangeDetectionStrategyInterface $changeDetectionStrategy)
{
$this->changeDetectionStrategy = $changeDetectionStrategy;
$this->changeDetectionStrategy->setFileMonitor($this);
} | php | public function injectChangeDetectionStrategy(ChangeDetectionStrategyInterface $changeDetectionStrategy)
{
$this->changeDetectionStrategy = $changeDetectionStrategy;
$this->changeDetectionStrategy->setFileMonitor($this);
} | [
"public",
"function",
"injectChangeDetectionStrategy",
"(",
"ChangeDetectionStrategyInterface",
"$",
"changeDetectionStrategy",
")",
"{",
"$",
"this",
"->",
"changeDetectionStrategy",
"=",
"$",
"changeDetectionStrategy",
";",
"$",
"this",
"->",
"changeDetectionStrategy",
"-... | Injects the Change Detection Strategy
@param ChangeDetectionStrategyInterface $changeDetectionStrategy The strategy to use for detecting changes
@return void | [
"Injects",
"the",
"Change",
"Detection",
"Strategy"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/FileMonitor.php#L131-L135 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/FileMonitor.php | FileMonitor.monitorFile | public function monitorFile($pathAndFilename)
{
if (!is_string($pathAndFilename)) {
throw new \InvalidArgumentException('String expected, ' . gettype($pathAndFilename), ' given.', 1231171809);
}
$pathAndFilename = Files::getUnixStylePath($pathAndFilename);
if (array_searc... | php | public function monitorFile($pathAndFilename)
{
if (!is_string($pathAndFilename)) {
throw new \InvalidArgumentException('String expected, ' . gettype($pathAndFilename), ' given.', 1231171809);
}
$pathAndFilename = Files::getUnixStylePath($pathAndFilename);
if (array_searc... | [
"public",
"function",
"monitorFile",
"(",
"$",
"pathAndFilename",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"pathAndFilename",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'String expected, '",
".",
"gettype",
"(",
"$",
"pathAn... | Adds the specified file to the list of files to be monitored.
The file in question does not necessarily have to exist.
@param string $pathAndFilename Absolute path and filename of the file to monitor
@return void
@throws \InvalidArgumentException
@api | [
"Adds",
"the",
"specified",
"file",
"to",
"the",
"list",
"of",
"files",
"to",
"be",
"monitored",
".",
"The",
"file",
"in",
"question",
"does",
"not",
"necessarily",
"have",
"to",
"exist",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/FileMonitor.php#L190-L199 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/FileMonitor.php | FileMonitor.monitorDirectory | public function monitorDirectory($path, $filenamePattern = null)
{
if (!is_string($path)) {
throw new \InvalidArgumentException('String expected, ' . gettype($path), ' given.', 1231171810);
}
$path = Files::getNormalizedPath(Files::getUnixStylePath($path));
if (!array_key... | php | public function monitorDirectory($path, $filenamePattern = null)
{
if (!is_string($path)) {
throw new \InvalidArgumentException('String expected, ' . gettype($path), ' given.', 1231171810);
}
$path = Files::getNormalizedPath(Files::getUnixStylePath($path));
if (!array_key... | [
"public",
"function",
"monitorDirectory",
"(",
"$",
"path",
",",
"$",
"filenamePattern",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'String expected, '",
".",
... | Adds the specified directory to the list of directories to be monitored.
All files in these directories will be monitored too.
@param string $path Absolute path of the directory to monitor
@param string $filenamePattern A pattern for filenames to consider for file monitoring (regular expression)
@return void
@throws \... | [
"Adds",
"the",
"specified",
"directory",
"to",
"the",
"list",
"of",
"directories",
"to",
"be",
"monitored",
".",
"All",
"files",
"in",
"these",
"directories",
"will",
"be",
"monitored",
"too",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/FileMonitor.php#L211-L220 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/FileMonitor.php | FileMonitor.detectChanges | public function detectChanges()
{
if ($this->changedFiles === null || $this->changedPaths === null) {
$this->loadDetectedDirectoriesAndFiles();
$changesDetected = false;
$this->changedPaths = $this->changedFiles = [];
$this->changedFiles = $this->detectChanged... | php | public function detectChanges()
{
if ($this->changedFiles === null || $this->changedPaths === null) {
$this->loadDetectedDirectoriesAndFiles();
$changesDetected = false;
$this->changedPaths = $this->changedFiles = [];
$this->changedFiles = $this->detectChanged... | [
"public",
"function",
"detectChanges",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"changedFiles",
"===",
"null",
"||",
"$",
"this",
"->",
"changedPaths",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"loadDetectedDirectoriesAndFiles",
"(",
")",
";",
"$",
... | Detects changes of the files and directories to be monitored and emits signals
accordingly.
@return void
@api | [
"Detects",
"changes",
"of",
"the",
"files",
"and",
"directories",
"to",
"be",
"monitored",
"and",
"emits",
"signals",
"accordingly",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/FileMonitor.php#L251-L281 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/FileMonitor.php | FileMonitor.detectChangesOnPath | protected function detectChangesOnPath($path, $filenamePattern)
{
$currentDirectoryChanged = false;
try {
$currentSubDirectoriesAndFiles = $this->readMonitoredDirectoryRecursively($path, $filenamePattern);
} catch (\Exception $exception) {
$currentSubDirectoriesAndFil... | php | protected function detectChangesOnPath($path, $filenamePattern)
{
$currentDirectoryChanged = false;
try {
$currentSubDirectoriesAndFiles = $this->readMonitoredDirectoryRecursively($path, $filenamePattern);
} catch (\Exception $exception) {
$currentSubDirectoriesAndFil... | [
"protected",
"function",
"detectChangesOnPath",
"(",
"$",
"path",
",",
"$",
"filenamePattern",
")",
"{",
"$",
"currentDirectoryChanged",
"=",
"false",
";",
"try",
"{",
"$",
"currentSubDirectoriesAndFiles",
"=",
"$",
"this",
"->",
"readMonitoredDirectoryRecursively",
... | Detect changes for one of the monitored paths.
@param string $path
@param string $filenamePattern
@return boolean true if any changes were detected in this path | [
"Detect",
"changes",
"for",
"one",
"of",
"the",
"monitored",
"paths",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/FileMonitor.php#L290-L338 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/FileMonitor.php | FileMonitor.readMonitoredDirectoryRecursively | protected function readMonitoredDirectoryRecursively($path, $filenamePattern)
{
$directories = [Files::getNormalizedPath($path)];
while ($directories !== []) {
$currentDirectory = array_pop($directories);
if (is_file($currentDirectory . '.flowFileMonitorIgnore')) {
... | php | protected function readMonitoredDirectoryRecursively($path, $filenamePattern)
{
$directories = [Files::getNormalizedPath($path)];
while ($directories !== []) {
$currentDirectory = array_pop($directories);
if (is_file($currentDirectory . '.flowFileMonitorIgnore')) {
... | [
"protected",
"function",
"readMonitoredDirectoryRecursively",
"(",
"$",
"path",
",",
"$",
"filenamePattern",
")",
"{",
"$",
"directories",
"=",
"[",
"Files",
"::",
"getNormalizedPath",
"(",
"$",
"path",
")",
"]",
";",
"while",
"(",
"$",
"directories",
"!==",
... | Read a monitored directory recursively, taking into account filename patterns
@param string $path The path of a monitored directory
@param string $filenamePattern
@return \Generator<string> A generator returning filenames with full path | [
"Read",
"a",
"monitored",
"directory",
"recursively",
"taking",
"into",
"account",
"filename",
"patterns"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/FileMonitor.php#L347-L370 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/FileMonitor.php | FileMonitor.loadDetectedDirectoriesAndFiles | protected function loadDetectedDirectoriesAndFiles()
{
if ($this->directoriesAndFiles === null) {
$this->directoriesAndFiles = json_decode($this->cache->get($this->identifier . '_directoriesAndFiles'), true);
if (!is_array($this->directoriesAndFiles)) {
$this->directo... | php | protected function loadDetectedDirectoriesAndFiles()
{
if ($this->directoriesAndFiles === null) {
$this->directoriesAndFiles = json_decode($this->cache->get($this->identifier . '_directoriesAndFiles'), true);
if (!is_array($this->directoriesAndFiles)) {
$this->directo... | [
"protected",
"function",
"loadDetectedDirectoriesAndFiles",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"directoriesAndFiles",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"directoriesAndFiles",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"cache",
"->",
"get",... | Loads the last detected files for this monitor.
@return void | [
"Loads",
"the",
"last",
"detected",
"files",
"for",
"this",
"monitor",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/FileMonitor.php#L377-L385 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/FileMonitor.php | FileMonitor.detectChangedFiles | protected function detectChangedFiles(array $pathAndFilenames)
{
$changedFiles = [];
foreach ($pathAndFilenames as $pathAndFilename) {
$status = $this->changeDetectionStrategy->getFileStatus($pathAndFilename);
if ($status !== ChangeDetectionStrategyInterface::STATUS_UNCHANGED... | php | protected function detectChangedFiles(array $pathAndFilenames)
{
$changedFiles = [];
foreach ($pathAndFilenames as $pathAndFilename) {
$status = $this->changeDetectionStrategy->getFileStatus($pathAndFilename);
if ($status !== ChangeDetectionStrategyInterface::STATUS_UNCHANGED... | [
"protected",
"function",
"detectChangedFiles",
"(",
"array",
"$",
"pathAndFilenames",
")",
"{",
"$",
"changedFiles",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"pathAndFilenames",
"as",
"$",
"pathAndFilename",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
... | Detects changes in the given list of files and emits signals if necessary.
@param array $pathAndFilenames A list of full path and filenames of files to check
@return array An array of changed files (key = path and filenmae) and their status (value) | [
"Detects",
"changes",
"in",
"the",
"given",
"list",
"of",
"files",
"and",
"emits",
"signals",
"if",
"necessary",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/FileMonitor.php#L413-L423 |
bramus/monolog-colored-line-formatter | src/Formatter/ColorSchemes/ColorSchemeTrait.php | ColorSchemeTrait.setColorizeArray | public function setColorizeArray(array $colorScheme)
{
// Only store entries that exist as Monolog\Logger levels
$allowedLogLevels = array_values(\Monolog\Logger::getLevels());
$colorScheme = array_intersect_key($colorScheme, array_flip($allowedLogLevels));
// Store the filtered col... | php | public function setColorizeArray(array $colorScheme)
{
// Only store entries that exist as Monolog\Logger levels
$allowedLogLevels = array_values(\Monolog\Logger::getLevels());
$colorScheme = array_intersect_key($colorScheme, array_flip($allowedLogLevels));
// Store the filtered col... | [
"public",
"function",
"setColorizeArray",
"(",
"array",
"$",
"colorScheme",
")",
"{",
"// Only store entries that exist as Monolog\\Logger levels",
"$",
"allowedLogLevels",
"=",
"array_values",
"(",
"\\",
"Monolog",
"\\",
"Logger",
"::",
"getLevels",
"(",
")",
")",
";... | Set the Color Scheme Array
@param array $colorScheme The Color Scheme Array | [
"Set",
"the",
"Color",
"Scheme",
"Array"
] | train | https://github.com/bramus/monolog-colored-line-formatter/blob/38475caf0f207fdb6d84ee0a08492dc3f49ef8e6/src/Formatter/ColorSchemes/ColorSchemeTrait.php#L35-L43 |
bramus/monolog-colored-line-formatter | src/Formatter/ColoredLineFormatter.php | ColoredLineFormatter.format | public function format(array $record) : string
{
// Get the Color Scheme
$colorScheme = $this->getColorScheme();
// Let the parent class to the formatting, yet wrap it in the color linked to the level
return $colorScheme->getColorizeString($record['level']).trim(parent::format($reco... | php | public function format(array $record) : string
{
// Get the Color Scheme
$colorScheme = $this->getColorScheme();
// Let the parent class to the formatting, yet wrap it in the color linked to the level
return $colorScheme->getColorizeString($record['level']).trim(parent::format($reco... | [
"public",
"function",
"format",
"(",
"array",
"$",
"record",
")",
":",
"string",
"{",
"// Get the Color Scheme",
"$",
"colorScheme",
"=",
"$",
"this",
"->",
"getColorScheme",
"(",
")",
";",
"// Let the parent class to the formatting, yet wrap it in the color linked to the... | {@inheritdoc} | [
"{"
] | train | https://github.com/bramus/monolog-colored-line-formatter/blob/38475caf0f207fdb6d84ee0a08492dc3f49ef8e6/src/Formatter/ColoredLineFormatter.php#L58-L65 |
alexdebril/rss-atom-bundle | Provider/MockProvider.php | MockProvider.getFeedContent | public function getFeedContent(array $options) : FeedInterface
{
$feed = new Feed();
$id = array_key_exists('id', $options) ? $options['id'] : null;
if ($id === 'not-found') {
throw new FeedNotFoundException();
}
$feed->setPublicId($id);
$feed->setTitl... | php | public function getFeedContent(array $options) : FeedInterface
{
$feed = new Feed();
$id = array_key_exists('id', $options) ? $options['id'] : null;
if ($id === 'not-found') {
throw new FeedNotFoundException();
}
$feed->setPublicId($id);
$feed->setTitl... | [
"public",
"function",
"getFeedContent",
"(",
"array",
"$",
"options",
")",
":",
"FeedInterface",
"{",
"$",
"feed",
"=",
"new",
"Feed",
"(",
")",
";",
"$",
"id",
"=",
"array_key_exists",
"(",
"'id'",
",",
"$",
"options",
")",
"?",
"$",
"options",
"[",
... | @param array $options
@return FeedInterface
@throws FeedNotFoundException | [
"@param",
"array",
"$options"
] | train | https://github.com/alexdebril/rss-atom-bundle/blob/87b93273eb7e995547060ac17d9a1b21061013e3/Provider/MockProvider.php#L31-L49 |
alexdebril/rss-atom-bundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder() : TreeBuilder
{
$treeBuilder = new TreeBuilder();
$treeBuilder->root('debril_rss_atom')
->children()
->booleanNode('private')
->info('Change cache headers so the RSS feed is not cached by public cache... | php | public function getConfigTreeBuilder() : TreeBuilder
{
$treeBuilder = new TreeBuilder();
$treeBuilder->root('debril_rss_atom')
->children()
->booleanNode('private')
->info('Change cache headers so the RSS feed is not cached by public cache... | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
":",
"TreeBuilder",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"treeBuilder",
"->",
"root",
"(",
"'debril_rss_atom'",
")",
"->",
"children",
"(",
")",
"->",
"booleanNode",
"... | {@inheritDoc} | [
"{"
] | train | https://github.com/alexdebril/rss-atom-bundle/blob/87b93273eb7e995547060ac17d9a1b21061013e3/DependencyInjection/Configuration.php#L18-L50 |
alexdebril/rss-atom-bundle | Provider/DoctrineFeedContentProvider.php | DoctrineFeedContentProvider.getFeedContent | public function getFeedContent(array $options) : FeedInterface
{
// fetch feed from data repository
$feed = $this->getDoctrine()
->getManager()
->getRepository($this->getRepositoryName())
->findOneById($this->getIdFromOptions($options));
// if... | php | public function getFeedContent(array $options) : FeedInterface
{
// fetch feed from data repository
$feed = $this->getDoctrine()
->getManager()
->getRepository($this->getRepositoryName())
->findOneById($this->getIdFromOptions($options));
// if... | [
"public",
"function",
"getFeedContent",
"(",
"array",
"$",
"options",
")",
":",
"FeedInterface",
"{",
"// fetch feed from data repository",
"$",
"feed",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"getRepository",
"(",
... | @param array $options
@return FeedInterface
@throws FeedNotFoundException | [
"@param",
"array",
"$options"
] | train | https://github.com/alexdebril/rss-atom-bundle/blob/87b93273eb7e995547060ac17d9a1b21061013e3/Provider/DoctrineFeedContentProvider.php#L71-L86 |
alexdebril/rss-atom-bundle | Provider/DoctrineFeedContentProvider.php | DoctrineFeedContentProvider.getIdFromOptions | public function getIdFromOptions(array $options) : string
{
$optionsResolver = new OptionsResolver();
$optionsResolver->setRequired('id');
$options = $optionsResolver->resolve($options);
return $options['id'];
} | php | public function getIdFromOptions(array $options) : string
{
$optionsResolver = new OptionsResolver();
$optionsResolver->setRequired('id');
$options = $optionsResolver->resolve($options);
return $options['id'];
} | [
"public",
"function",
"getIdFromOptions",
"(",
"array",
"$",
"options",
")",
":",
"string",
"{",
"$",
"optionsResolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"optionsResolver",
"->",
"setRequired",
"(",
"'id'",
")",
";",
"$",
"options",
"=",
... | @param array $options
@return string | [
"@param",
"array",
"$options"
] | train | https://github.com/alexdebril/rss-atom-bundle/blob/87b93273eb7e995547060ac17d9a1b21061013e3/Provider/DoctrineFeedContentProvider.php#L101-L109 |
alexdebril/rss-atom-bundle | Controller/StreamController.php | StreamController.getModifiedSince | protected function getModifiedSince() : \DateTime
{
if (is_null($this->since)) {
$this->since = new \DateTime('@0');
}
return $this->since;
} | php | protected function getModifiedSince() : \DateTime
{
if (is_null($this->since)) {
$this->since = new \DateTime('@0');
}
return $this->since;
} | [
"protected",
"function",
"getModifiedSince",
"(",
")",
":",
"\\",
"DateTime",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"since",
")",
")",
"{",
"$",
"this",
"->",
"since",
"=",
"new",
"\\",
"DateTime",
"(",
"'@0'",
")",
";",
"}",
"return",
... | Extract the 'If-Modified-Since' value from the headers.
@return \DateTime | [
"Extract",
"the",
"If",
"-",
"Modified",
"-",
"Since",
"value",
"from",
"the",
"headers",
"."
] | train | https://github.com/alexdebril/rss-atom-bundle/blob/87b93273eb7e995547060ac17d9a1b21061013e3/Controller/StreamController.php#L50-L57 |
alexdebril/rss-atom-bundle | Controller/StreamController.php | StreamController.setModifiedSince | protected function setModifiedSince(Request $request) : self
{
$this->since = new \DateTime();
if ($request->headers->has('If-Modified-Since')) {
$string = $request->headers->get('If-Modified-Since');
$this->since = \DateTime::createFromFormat(\DateTime::RSS, $string);
... | php | protected function setModifiedSince(Request $request) : self
{
$this->since = new \DateTime();
if ($request->headers->has('If-Modified-Since')) {
$string = $request->headers->get('If-Modified-Since');
$this->since = \DateTime::createFromFormat(\DateTime::RSS, $string);
... | [
"protected",
"function",
"setModifiedSince",
"(",
"Request",
"$",
"request",
")",
":",
"self",
"{",
"$",
"this",
"->",
"since",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"'If-Modified-Since... | @param Request $request
@return $this | [
"@param",
"Request",
"$request"
] | train | https://github.com/alexdebril/rss-atom-bundle/blob/87b93273eb7e995547060ac17d9a1b21061013e3/Controller/StreamController.php#L64-L75 |
alexdebril/rss-atom-bundle | Controller/StreamController.php | StreamController.createStreamResponse | protected function createStreamResponse(array $options, string $format, FeedContentProviderInterface $provider, FeedIo $feedIo) : Response
{
$content = $this->getContent($options, $provider);
if ($this->mustForceRefresh() || $content->getLastModified() > $this->getModifiedSince()) {
$re... | php | protected function createStreamResponse(array $options, string $format, FeedContentProviderInterface $provider, FeedIo $feedIo) : Response
{
$content = $this->getContent($options, $provider);
if ($this->mustForceRefresh() || $content->getLastModified() > $this->getModifiedSince()) {
$re... | [
"protected",
"function",
"createStreamResponse",
"(",
"array",
"$",
"options",
",",
"string",
"$",
"format",
",",
"FeedContentProviderInterface",
"$",
"provider",
",",
"FeedIo",
"$",
"feedIo",
")",
":",
"Response",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
... | Generate the HTTP response
200 : a full body containing the stream
304 : Not modified.
@param array $options
@param $format
@param FeedContentProviderInterface $provider
@param FeedIo $feedIo
@return Response
@throws \Exception | [
"Generate",
"the",
"HTTP",
"response",
"200",
":",
"a",
"full",
"body",
"containing",
"the",
"stream",
"304",
":",
"Not",
"modified",
"."
] | train | https://github.com/alexdebril/rss-atom-bundle/blob/87b93273eb7e995547060ac17d9a1b21061013e3/Controller/StreamController.php#L91-L105 |
alexdebril/rss-atom-bundle | Controller/StreamController.php | StreamController.getContent | protected function getContent(array $options, FeedContentProviderInterface $provider) : FeedInterface
{
try {
return $provider->getFeedContent($options);
} catch (FeedNotFoundException $e) {
throw $this->createNotFoundException('feed not found');
}
} | php | protected function getContent(array $options, FeedContentProviderInterface $provider) : FeedInterface
{
try {
return $provider->getFeedContent($options);
} catch (FeedNotFoundException $e) {
throw $this->createNotFoundException('feed not found');
}
} | [
"protected",
"function",
"getContent",
"(",
"array",
"$",
"options",
",",
"FeedContentProviderInterface",
"$",
"provider",
")",
":",
"FeedInterface",
"{",
"try",
"{",
"return",
"$",
"provider",
"->",
"getFeedContent",
"(",
"$",
"options",
")",
";",
"}",
"catch... | Get the Stream's content using a FeedContentProviderInterface
The FeedContentProviderInterface instance is provided as a service
default : debril.provider.service.
@param array $options
@param FeedContentProviderInterface $provider
@return FeedInterface
@throws \Exception | [
"Get",
"the",
"Stream",
"s",
"content",
"using",
"a",
"FeedContentProviderInterface",
"The",
"FeedContentProviderInterface",
"instance",
"is",
"provided",
"as",
"a",
"service",
"default",
":",
"debril",
".",
"provider",
".",
"service",
"."
] | train | https://github.com/alexdebril/rss-atom-bundle/blob/87b93273eb7e995547060ac17d9a1b21061013e3/Controller/StreamController.php#L143-L150 |
wp-cli/db-command | src/DB_Command.php | DB_Command.create | public function create( $_, $assoc_args ) {
self::run_query( self::get_create_query(), self::get_dbuser_dbpass_args( $assoc_args ) );
WP_CLI::success( 'Database created.' );
} | php | public function create( $_, $assoc_args ) {
self::run_query( self::get_create_query(), self::get_dbuser_dbpass_args( $assoc_args ) );
WP_CLI::success( 'Database created.' );
} | [
"public",
"function",
"create",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"self",
"::",
"run_query",
"(",
"self",
"::",
"get_create_query",
"(",
")",
",",
"self",
"::",
"get_dbuser_dbpass_args",
"(",
"$",
"assoc_args",
")",
")",
";",
"WP_CLI",
"::... | Creates a new database.
Runs `CREATE_DATABASE` SQL statement using `DB_HOST`, `DB_NAME`,
`DB_USER` and `DB_PASSWORD` database credentials specified in
wp-config.php.
## OPTIONS
[--dbuser=<value>]
: Username to pass to mysql. Defaults to DB_USER.
[--dbpass=<value>]
: Password to pass to mysql. Defaults to DB_PASSWOR... | [
"Creates",
"a",
"new",
"database",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L50-L55 |
wp-cli/db-command | src/DB_Command.php | DB_Command.drop | public function drop( $_, $assoc_args ) {
WP_CLI::confirm( "Are you sure you want to drop the '" . DB_NAME . "' database?", $assoc_args );
self::run_query( sprintf( 'DROP DATABASE `%s`', DB_NAME ), self::get_dbuser_dbpass_args( $assoc_args ) );
WP_CLI::success( 'Database dropped.' );
} | php | public function drop( $_, $assoc_args ) {
WP_CLI::confirm( "Are you sure you want to drop the '" . DB_NAME . "' database?", $assoc_args );
self::run_query( sprintf( 'DROP DATABASE `%s`', DB_NAME ), self::get_dbuser_dbpass_args( $assoc_args ) );
WP_CLI::success( 'Database dropped.' );
} | [
"public",
"function",
"drop",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"WP_CLI",
"::",
"confirm",
"(",
"\"Are you sure you want to drop the '\"",
".",
"DB_NAME",
".",
"\"' database?\"",
",",
"$",
"assoc_args",
")",
";",
"self",
"::",
"run_query",
"(",
... | Deletes the existing database.
Runs `DROP_DATABASE` SQL statement using `DB_HOST`, `DB_NAME`,
`DB_USER` and `DB_PASSWORD` database credentials specified in
wp-config.php.
## OPTIONS
[--dbuser=<value>]
: Username to pass to mysql. Defaults to DB_USER.
[--dbpass=<value>]
: Password to pass to mysql. Defaults to DB_PA... | [
"Deletes",
"the",
"existing",
"database",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L80-L86 |
wp-cli/db-command | src/DB_Command.php | DB_Command.reset | public function reset( $_, $assoc_args ) {
WP_CLI::confirm( "Are you sure you want to reset the '" . DB_NAME . "' database?", $assoc_args );
$mysql_args = self::get_dbuser_dbpass_args( $assoc_args );
self::run_query( sprintf( 'DROP DATABASE IF EXISTS `%s`', DB_NAME ), $mysql_args );
self::run_query( self::get... | php | public function reset( $_, $assoc_args ) {
WP_CLI::confirm( "Are you sure you want to reset the '" . DB_NAME . "' database?", $assoc_args );
$mysql_args = self::get_dbuser_dbpass_args( $assoc_args );
self::run_query( sprintf( 'DROP DATABASE IF EXISTS `%s`', DB_NAME ), $mysql_args );
self::run_query( self::get... | [
"public",
"function",
"reset",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"WP_CLI",
"::",
"confirm",
"(",
"\"Are you sure you want to reset the '\"",
".",
"DB_NAME",
".",
"\"' database?\"",
",",
"$",
"assoc_args",
")",
";",
"$",
"mysql_args",
"=",
"self"... | Removes all tables from the database.
Runs `DROP_DATABASE` and `CREATE_DATABASE` SQL statements using
`DB_HOST`, `DB_NAME`, `DB_USER` and `DB_PASSWORD` database credentials
specified in wp-config.php.
## OPTIONS
[--dbuser=<value>]
: Username to pass to mysql. Defaults to DB_USER.
[--dbpass=<value>]
: Password to pa... | [
"Removes",
"all",
"tables",
"from",
"the",
"database",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L111-L120 |
wp-cli/db-command | src/DB_Command.php | DB_Command.clean | public function clean( $_, $assoc_args ) {
global $wpdb;
WP_CLI::confirm(
sprintf(
"Are you sure you want to drop all the tables on '%s' that use the current site's database prefix ('%s')?",
DB_NAME,
$wpdb->get_blog_prefix()
),
$assoc_args
);
$mysql_args = self::get_dbuser_dbpass_args( $a... | php | public function clean( $_, $assoc_args ) {
global $wpdb;
WP_CLI::confirm(
sprintf(
"Are you sure you want to drop all the tables on '%s' that use the current site's database prefix ('%s')?",
DB_NAME,
$wpdb->get_blog_prefix()
),
$assoc_args
);
$mysql_args = self::get_dbuser_dbpass_args( $a... | [
"public",
"function",
"clean",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"global",
"$",
"wpdb",
";",
"WP_CLI",
"::",
"confirm",
"(",
"sprintf",
"(",
"\"Are you sure you want to drop all the tables on '%s' that use the current site's database prefix ('%s')?\"",
",",... | Removes all tables with `$table_prefix` from the database.
Runs `DROP_TABLE` for each table that has a `$table_prefix` as specified
in wp-config.php.
## OPTIONS
[--dbuser=<value>]
: Username to pass to mysql. Defaults to DB_USER.
[--dbpass=<value>]
: Password to pass to mysql. Defaults to DB_PASSWORD.
[--yes]
: An... | [
"Removes",
"all",
"tables",
"with",
"$table_prefix",
"from",
"the",
"database",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L147-L178 |
wp-cli/db-command | src/DB_Command.php | DB_Command.check | public function check( $_, $assoc_args ) {
$assoc_args['check'] = true;
self::run(
Utils\esc_cmd( '/usr/bin/env mysqlcheck --no-defaults %s', DB_NAME ),
$assoc_args
);
WP_CLI::success( 'Database checked.' );
} | php | public function check( $_, $assoc_args ) {
$assoc_args['check'] = true;
self::run(
Utils\esc_cmd( '/usr/bin/env mysqlcheck --no-defaults %s', DB_NAME ),
$assoc_args
);
WP_CLI::success( 'Database checked.' );
} | [
"public",
"function",
"check",
"(",
"$",
"_",
",",
"$",
"assoc_args",
")",
"{",
"$",
"assoc_args",
"[",
"'check'",
"]",
"=",
"true",
";",
"self",
"::",
"run",
"(",
"Utils",
"\\",
"esc_cmd",
"(",
"'/usr/bin/env mysqlcheck --no-defaults %s'",
",",
"DB_NAME",
... | Checks the current status of the database.
Runs `mysqlcheck` utility with `--check` using `DB_HOST`,
`DB_NAME`, `DB_USER` and `DB_PASSWORD` database credentials
specified in wp-config.php.
[See docs](http://dev.mysql.com/doc/refman/5.7/en/check-table.html)
for more details on the `CHECK TABLE` statement.
## OPTIONS
... | [
"Checks",
"the",
"current",
"status",
"of",
"the",
"database",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L206-L214 |
wp-cli/db-command | src/DB_Command.php | DB_Command.cli | public function cli( $args, $assoc_args ) {
if ( ! isset( $assoc_args['database'] ) ) {
$assoc_args['database'] = DB_NAME;
}
self::run( '/usr/bin/env mysql --no-defaults --no-auto-rehash', $assoc_args );
} | php | public function cli( $args, $assoc_args ) {
if ( ! isset( $assoc_args['database'] ) ) {
$assoc_args['database'] = DB_NAME;
}
self::run( '/usr/bin/env mysql --no-defaults --no-auto-rehash', $assoc_args );
} | [
"public",
"function",
"cli",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"assoc_args",
"[",
"'database'",
"]",
")",
")",
"{",
"$",
"assoc_args",
"[",
"'database'",
"]",
"=",
"DB_NAME",
";",
"}",
"self",
":... | Opens a MySQL console using credentials from wp-config.php
## OPTIONS
[--database=<database>]
: Use a specific database. Defaults to DB_NAME.
[--default-character-set=<character-set>]
: Use a specific character set. Defaults to DB_CHARSET when defined.
[--dbuser=<value>]
: Username to pass to mysql. Defaults to DB_... | [
"Opens",
"a",
"MySQL",
"console",
"using",
"credentials",
"from",
"wp",
"-",
"config",
".",
"php"
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L316-L322 |
wp-cli/db-command | src/DB_Command.php | DB_Command.query | public function query( $args, $assoc_args ) {
$assoc_args['database'] = DB_NAME;
// The query might come from STDIN.
if ( ! empty( $args ) ) {
$assoc_args['execute'] = $args[0];
}
self::run( '/usr/bin/env mysql --no-defaults --no-auto-rehash', $assoc_args );
} | php | public function query( $args, $assoc_args ) {
$assoc_args['database'] = DB_NAME;
// The query might come from STDIN.
if ( ! empty( $args ) ) {
$assoc_args['execute'] = $args[0];
}
self::run( '/usr/bin/env mysql --no-defaults --no-auto-rehash', $assoc_args );
} | [
"public",
"function",
"query",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"assoc_args",
"[",
"'database'",
"]",
"=",
"DB_NAME",
";",
"// The query might come from STDIN.",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"$",
"asso... | Executes a SQL query against the database.
Executes an arbitrary SQL query using `DB_HOST`, `DB_NAME`, `DB_USER`
and `DB_PASSWORD` database credentials specified in wp-config.php.
## OPTIONS
[<sql>]
: A SQL query. If not passed, will try to read from STDIN.
[--dbuser=<value>]
: Username to pass to mysql. Defaults t... | [
"Executes",
"a",
"SQL",
"query",
"against",
"the",
"database",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L374-L383 |
wp-cli/db-command | src/DB_Command.php | DB_Command.export | public function export( $args, $assoc_args ) {
if ( ! empty( $args[0] ) ) {
$result_file = $args[0];
} else {
// phpcs:ignore WordPress.WP.AlternativeFunctions.rand_mt_rand -- WordPress is not loaded.
$hash = substr( md5( mt_rand() ), 0, 7 );
$result_file = sprintf( '%s-%s-%s.sql', DB_NAME, date(... | php | public function export( $args, $assoc_args ) {
if ( ! empty( $args[0] ) ) {
$result_file = $args[0];
} else {
// phpcs:ignore WordPress.WP.AlternativeFunctions.rand_mt_rand -- WordPress is not loaded.
$hash = substr( md5( mt_rand() ), 0, 7 );
$result_file = sprintf( '%s-%s-%s.sql', DB_NAME, date(... | [
"public",
"function",
"export",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"result_file",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"// phpcs:i... | Exports the database to a file or to STDOUT.
Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
`DB_PASSWORD` database credentials specified in wp-config.php.
## OPTIONS
[<file>]
: The name of the SQL file to export. If '-', then outputs to STDOUT. If
omitted, it will be '{dbname}-{Y-m-d}-{random-has... | [
"Exports",
"the",
"database",
"to",
"a",
"file",
"or",
"to",
"STDOUT",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L464-L528 |
wp-cli/db-command | src/DB_Command.php | DB_Command.import | public function import( $args, $assoc_args ) {
if ( ! empty( $args[0] ) ) {
$result_file = $args[0];
} else {
$result_file = sprintf( '%s.sql', DB_NAME );
}
$mysql_args = array(
'database' => DB_NAME,
);
$mysql_args = array_merge( self::get_dbuser_dbpass_args( $assoc_args ), $mysql_args );
if (... | php | public function import( $args, $assoc_args ) {
if ( ! empty( $args[0] ) ) {
$result_file = $args[0];
} else {
$result_file = sprintf( '%s.sql', DB_NAME );
}
$mysql_args = array(
'database' => DB_NAME,
);
$mysql_args = array_merge( self::get_dbuser_dbpass_args( $assoc_args ), $mysql_args );
if (... | [
"public",
"function",
"import",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"result_file",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"res... | Imports a database from a file or from STDIN.
Runs SQL queries using `DB_HOST`, `DB_NAME`, `DB_USER` and
`DB_PASSWORD` database credentials specified in wp-config.php. This
does not create database by itself and only performs whatever tasks are
defined in the SQL.
## OPTIONS
[<file>]
: The name of the SQL file to im... | [
"Imports",
"a",
"database",
"from",
"a",
"file",
"or",
"from",
"STDIN",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L561-L590 |
wp-cli/db-command | src/DB_Command.php | DB_Command.tables | public function tables( $args, $assoc_args ) {
$format = Utils\get_flag_value( $assoc_args, 'format' );
unset( $assoc_args['format'] );
if ( empty( $args ) && empty( $assoc_args ) ) {
$assoc_args['scope'] = 'all';
}
$tables = Utils\wp_get_table_names( $args, $assoc_args );
if ( 'csv' === $format ) {
... | php | public function tables( $args, $assoc_args ) {
$format = Utils\get_flag_value( $assoc_args, 'format' );
unset( $assoc_args['format'] );
if ( empty( $args ) && empty( $assoc_args ) ) {
$assoc_args['scope'] = 'all';
}
$tables = Utils\wp_get_table_names( $args, $assoc_args );
if ( 'csv' === $format ) {
... | [
"public",
"function",
"tables",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"format",
"=",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'format'",
")",
";",
"unset",
"(",
"$",
"assoc_args",
"[",
"'format'",
"]",
")",
";",... | Lists the database tables.
Defaults to all tables registered to the $wpdb database handler.
## OPTIONS
[<table>...]
: List tables based on wildcard search, e.g. 'wp_*_options' or 'wp_post?'.
[--scope=<scope>]
: Can be all, global, ms_global, blog, or old tables. Defaults to all.
[--network]
: List all the tables i... | [
"Lists",
"the",
"database",
"tables",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L643-L661 |
wp-cli/db-command | src/DB_Command.php | DB_Command.size | public function size( $args, $assoc_args ) {
global $wpdb;
$format = Utils\get_flag_value( $assoc_args, 'format' );
$size_format = Utils\get_flag_value( $assoc_args, 'size_format' );
$human_readable = Utils\get_flag_value( $assoc_args, 'human-readable', false );
$tables ... | php | public function size( $args, $assoc_args ) {
global $wpdb;
$format = Utils\get_flag_value( $assoc_args, 'format' );
$size_format = Utils\get_flag_value( $assoc_args, 'size_format' );
$human_readable = Utils\get_flag_value( $assoc_args, 'human-readable', false );
$tables ... | [
"public",
"function",
"size",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"format",
"=",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'format'",
")",
";",
"$",
"size_format",
"=",
"Utils",
"\\"... | Displays the database name and size.
Display the database name and size for `DB_NAME` specified in wp-config.php.
The size defaults to a human-readable number.
Available size formats include:
* b (bytes)
* kb (kilobytes)
* mb (megabytes)
* gb (gigabytes)
* tb (terabytes)
* B (ISO Byte setting, with no conversion)
*... | [
"Displays",
"the",
"database",
"name",
"and",
"size",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L773-L926 |
wp-cli/db-command | src/DB_Command.php | DB_Command.search | public function search( $args, $assoc_args ) {
global $wpdb;
$start_run_time = microtime( true );
$search = array_shift( $args );
$before_context = Utils\get_flag_value( $assoc_args, 'before_context', 40 );
$before_context = '' === $before_context ? $before_context : (int) $before_context;
$after_contex... | php | public function search( $args, $assoc_args ) {
global $wpdb;
$start_run_time = microtime( true );
$search = array_shift( $args );
$before_context = Utils\get_flag_value( $assoc_args, 'before_context', 40 );
$before_context = '' === $before_context ? $before_context : (int) $before_context;
$after_contex... | [
"public",
"function",
"search",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"start_run_time",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"search",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"befor... | Finds a string in the database.
Searches through all or a selection of database tables for a given string, Outputs colorized references to the string.
Defaults to searching through all tables registered to $wpdb. On multisite, this default is limited to the tables for the current site.
## OPTIONS
<search>
: String ... | [
"Finds",
"a",
"string",
"in",
"the",
"database",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L1082-L1284 |
wp-cli/db-command | src/DB_Command.php | DB_Command.columns | public function columns( $args, $assoc_args ) {
global $wpdb;
$format = Utils\get_flag_value( $assoc_args, 'format' );
Utils\wp_get_table_names( array( $args[0] ), array() );
$columns = $wpdb->get_results(
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Asserted to be a valid table name through wp... | php | public function columns( $args, $assoc_args ) {
global $wpdb;
$format = Utils\get_flag_value( $assoc_args, 'format' );
Utils\wp_get_table_names( array( $args[0] ), array() );
$columns = $wpdb->get_results(
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Asserted to be a valid table name through wp... | [
"public",
"function",
"columns",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"format",
"=",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'format'",
")",
";",
"Utils",
"\\",
"wp_get_table_names",
... | Displays information about a given table.
## OPTIONS
[<table>]
: Name of the database table.
[--format]
: Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
---
## EXAMPLES
$ wp db columns wp_posts
+-----------------------+---------------------+------+-----+--------------... | [
"Displays",
"information",
"about",
"a",
"given",
"table",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L1338-L1357 |
wp-cli/db-command | src/DB_Command.php | DB_Command.get_dbuser_dbpass_args | private static function get_dbuser_dbpass_args( $assoc_args ) {
$mysql_args = array();
$dbuser = Utils\get_flag_value( $assoc_args, 'dbuser' );
if ( null !== $dbuser ) {
$mysql_args['dbuser'] = $dbuser;
}
$dbpass = Utils\get_flag_value( $assoc_args, 'dbpass' );
if ( null !== $dbpass ) {
$mysql_arg... | php | private static function get_dbuser_dbpass_args( $assoc_args ) {
$mysql_args = array();
$dbuser = Utils\get_flag_value( $assoc_args, 'dbuser' );
if ( null !== $dbuser ) {
$mysql_args['dbuser'] = $dbuser;
}
$dbpass = Utils\get_flag_value( $assoc_args, 'dbpass' );
if ( null !== $dbpass ) {
$mysql_arg... | [
"private",
"static",
"function",
"get_dbuser_dbpass_args",
"(",
"$",
"assoc_args",
")",
"{",
"$",
"mysql_args",
"=",
"array",
"(",
")",
";",
"$",
"dbuser",
"=",
"Utils",
"\\",
"get_flag_value",
"(",
"$",
"assoc_args",
",",
"'dbuser'",
")",
";",
"if",
"(",
... | Helper to pluck 'dbuser' and 'dbpass' from associative args array.
@param array $assoc_args Associative args array.
@return array Array with `dbuser' and 'dbpass' set if in passed-in associative args array. | [
"Helper",
"to",
"pluck",
"dbuser",
"and",
"dbpass",
"from",
"associative",
"args",
"array",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L1407-L1418 |
wp-cli/db-command | src/DB_Command.php | DB_Command.get_columns | private static function get_columns( $table ) {
global $wpdb;
$table_sql = self::esc_sql_ident( $table );
$primary_keys = array();
$text_columns = array();
$all_columns = array();
$suppress_errors = $wpdb->suppress_errors();
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepare... | php | private static function get_columns( $table ) {
global $wpdb;
$table_sql = self::esc_sql_ident( $table );
$primary_keys = array();
$text_columns = array();
$all_columns = array();
$suppress_errors = $wpdb->suppress_errors();
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepare... | [
"private",
"static",
"function",
"get_columns",
"(",
"$",
"table",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"table_sql",
"=",
"self",
"::",
"esc_sql_ident",
"(",
"$",
"table",
")",
";",
"$",
"primary_keys",
"=",
"array",
"(",
")",
";",
"$",
"text_col... | Gets the column names of a db table differentiated into key columns and text columns and all columns.
@param string $table The table name.
@return array A 3 element array consisting of an array of primary key column names, an array of text column names, and an array containing all column names. | [
"Gets",
"the",
"column",
"names",
"of",
"a",
"db",
"table",
"differentiated",
"into",
"key",
"columns",
"and",
"text",
"columns",
"and",
"all",
"columns",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L1426-L1452 |
wp-cli/db-command | src/DB_Command.php | DB_Command.get_mysql_args | private static function get_mysql_args( $assoc_args ) {
$allowed_mysql_options = [
'auto-rehash',
'auto-vertical-output',
'batch',
'binary-as-hex',
'binary-mode',
'bind-address',
'character-sets-dir',
'column-names',
'column-type-info',
'comments',
'compress',
'connect-expired-pas... | php | private static function get_mysql_args( $assoc_args ) {
$allowed_mysql_options = [
'auto-rehash',
'auto-vertical-output',
'batch',
'binary-as-hex',
'binary-mode',
'bind-address',
'character-sets-dir',
'column-names',
'column-type-info',
'comments',
'compress',
'connect-expired-pas... | [
"private",
"static",
"function",
"get_mysql_args",
"(",
"$",
"assoc_args",
")",
"{",
"$",
"allowed_mysql_options",
"=",
"[",
"'auto-rehash'",
",",
"'auto-vertical-output'",
",",
"'batch'",
",",
"'binary-as-hex'",
",",
"'binary-mode'",
",",
"'bind-address'",
",",
"'c... | Helper to pluck `mysql` options from associative args array.
@param array $assoc_args Associative args array.
@return array Array with `mysql` options set if in passed-in associative args array. | [
"Helper",
"to",
"pluck",
"mysql",
"options",
"from",
"associative",
"args",
"array",
"."
] | train | https://github.com/wp-cli/db-command/blob/dc0f8e4d5783d8a4ee01da1119b8fe8038fe1aa0/src/DB_Command.php#L1531-L1632 |
itbdw/ip-database | src/IpLocation.php | IpLocation.getAddr | private function getAddr($ip)
{
$result = [];
$is_china = false;
$seperator_sheng = '省';
$seperator_shi = '市';
$seperator_xian = '县';
$seperator_qu = '区';
if (!$this->isValidIpV4($ip)) {
$result['error'] = 'ip invalid';
return $result;... | php | private function getAddr($ip)
{
$result = [];
$is_china = false;
$seperator_sheng = '省';
$seperator_shi = '市';
$seperator_xian = '县';
$seperator_qu = '区';
if (!$this->isValidIpV4($ip)) {
$result['error'] = 'ip invalid';
return $result;... | [
"private",
"function",
"getAddr",
"(",
"$",
"ip",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"is_china",
"=",
"false",
";",
"$",
"seperator_sheng",
"=",
"'省';",
"",
"$",
"seperator_shi",
"=",
"'市';",
"",
"$",
"seperator_xian",
"=",
"'县';",
"",... | 如果ip错误,返回 $result['error'] 信息
province city county isp 对中国以外的ip无法识别
<code>
$result 是返回的数组
$result['ip'] 输入的ip
$result['country'] 国家 如 中国
$result['province'] 省份信息 如 河北省
$result['city'] 市区 如 邢台市
$result['county'] 郡县 如 威县
$result['isp'] 运营商 如 联通
$result['area'] 最完整的... | [
"如果ip错误,返回",
"$result",
"[",
"error",
"]",
"信息",
"province",
"city",
"county",
"isp",
"对中国以外的ip无法识别",
"<code",
">",
"$result",
"是返回的数组",
"$result",
"[",
"ip",
"]",
"输入的ip",
"$result",
"[",
"country",
"]",
"国家",
"如",
"中国",
"$result",
"[",
"province",
"]",
... | train | https://github.com/itbdw/ip-database/blob/24c203c50080d4ef2f1744930253095c76a58c3d/src/IpLocation.php#L193-L330 |
itbdw/ip-database | src/IpLocation.php | IpLocation.getlocationfromip | private function getlocationfromip($ip)
{
if (!$this->fp) {
return null;
} // 如果数据文件没有被正确打开,则直接返回空
$location['ip'] = $ip;
$ip = $this->packip($location['ip']); // 将输入的IP地址转化为可比较的IP地址
// 不合法的IP地址会被转化为255.255.255.255
// 对分搜索
$l = 0; // 搜索的下边界
... | php | private function getlocationfromip($ip)
{
if (!$this->fp) {
return null;
} // 如果数据文件没有被正确打开,则直接返回空
$location['ip'] = $ip;
$ip = $this->packip($location['ip']); // 将输入的IP地址转化为可比较的IP地址
// 不合法的IP地址会被转化为255.255.255.255
// 对分搜索
$l = 0; // 搜索的下边界
... | [
"private",
"function",
"getlocationfromip",
"(",
"$",
"ip",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fp",
")",
"{",
"return",
"null",
";",
"}",
"// 如果数据文件没有被正确打开,则直接返回空",
"$",
"location",
"[",
"'ip'",
"]",
"=",
"$",
"ip",
";",
"$",
"ip",
"=",
... | 根据所给 IP 地址或域名返回所在地区信息
@access public
@param string $ip
@return array | [
"根据所给",
"IP",
"地址或域名返回所在地区信息"
] | train | https://github.com/itbdw/ip-database/blob/24c203c50080d4ef2f1744930253095c76a58c3d/src/IpLocation.php#L350-L432 |
itbdw/ip-database | src/IpLocation.php | IpLocation.ip2long | private function ip2long($ip)
{
$ip_arr = explode('.', $ip);
$iplong = (16777216 * intval($ip_arr[0])) + (65536 * intval($ip_arr[1])) + (256 * intval($ip_arr[2])) + intval($ip_arr[3]);
return $iplong;
} | php | private function ip2long($ip)
{
$ip_arr = explode('.', $ip);
$iplong = (16777216 * intval($ip_arr[0])) + (65536 * intval($ip_arr[1])) + (256 * intval($ip_arr[2])) + intval($ip_arr[3]);
return $iplong;
} | [
"private",
"function",
"ip2long",
"(",
"$",
"ip",
")",
"{",
"$",
"ip_arr",
"=",
"explode",
"(",
"'.'",
",",
"$",
"ip",
")",
";",
"$",
"iplong",
"=",
"(",
"16777216",
"*",
"intval",
"(",
"$",
"ip_arr",
"[",
"0",
"]",
")",
")",
"+",
"(",
"65536",... | Ip 地址转为数字地址
php 的 ip2long 这个函数有问题
133.205.0.0 ==>> 2244804608
@param string $ip 要转换的 ip 地址
@return int 转换完成的数字 | [
"Ip",
"地址转为数字地址",
"php",
"的",
"ip2long",
"这个函数有问题",
"133",
".",
"205",
".",
"0",
".",
"0",
"==",
">>",
"2244804608"
] | train | https://github.com/itbdw/ip-database/blob/24c203c50080d4ef2f1744930253095c76a58c3d/src/IpLocation.php#L456-L462 |
spatie/dropbox-api | src/Client.php | Client.copy | public function copy(string $fromPath, string $toPath): array
{
$parameters = [
'from_path' => $this->normalizePath($fromPath),
'to_path' => $this->normalizePath($toPath),
];
return $this->rpcEndpointRequest('files/copy_v2', $parameters);
} | php | public function copy(string $fromPath, string $toPath): array
{
$parameters = [
'from_path' => $this->normalizePath($fromPath),
'to_path' => $this->normalizePath($toPath),
];
return $this->rpcEndpointRequest('files/copy_v2', $parameters);
} | [
"public",
"function",
"copy",
"(",
"string",
"$",
"fromPath",
",",
"string",
"$",
"toPath",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"'from_path'",
"=>",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"fromPath",
")",
",",
"'to_path'",
"=>",
... | Copy a file or folder to a different location in the user's Dropbox.
If the source path is a folder all its contents will be copied.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-copy_v2 | [
"Copy",
"a",
"file",
"or",
"folder",
"to",
"a",
"different",
"location",
"in",
"the",
"user",
"s",
"Dropbox",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L67-L75 |
spatie/dropbox-api | src/Client.php | Client.createFolder | public function createFolder(string $path): array
{
$parameters = [
'path' => $this->normalizePath($path),
];
$object = $this->rpcEndpointRequest('files/create_folder', $parameters);
$object['.tag'] = 'folder';
return $object;
} | php | public function createFolder(string $path): array
{
$parameters = [
'path' => $this->normalizePath($path),
];
$object = $this->rpcEndpointRequest('files/create_folder', $parameters);
$object['.tag'] = 'folder';
return $object;
} | [
"public",
"function",
"createFolder",
"(",
"string",
"$",
"path",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
",",
"]",
";",
"$",
"object",
"=",
"$",
"this",
"->",
... | Create a folder at a given path.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder | [
"Create",
"a",
"folder",
"at",
"a",
"given",
"path",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L82-L93 |
spatie/dropbox-api | src/Client.php | Client.createSharedLinkWithSettings | public function createSharedLinkWithSettings(string $path, array $settings = [])
{
$parameters = [
'path' => $this->normalizePath($path),
];
if (count($settings)) {
$parameters = array_merge(compact('settings'), $parameters);
}
return $this->rpcEndpo... | php | public function createSharedLinkWithSettings(string $path, array $settings = [])
{
$parameters = [
'path' => $this->normalizePath($path),
];
if (count($settings)) {
$parameters = array_merge(compact('settings'), $parameters);
}
return $this->rpcEndpo... | [
"public",
"function",
"createSharedLinkWithSettings",
"(",
"string",
"$",
"path",
",",
"array",
"$",
"settings",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"=",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
",",
"]",
... | Create a shared link with custom settings.
If no settings are given then the default visibility is RequestedVisibility.public.
The resolved visibility, though, may depend on other aspects such as team and
shared folder settings). Only for paid users.
@link https://www.dropbox.com/developers/documentation/http/documen... | [
"Create",
"a",
"shared",
"link",
"with",
"custom",
"settings",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L104-L115 |
spatie/dropbox-api | src/Client.php | Client.listSharedLinks | public function listSharedLinks(string $path = null, bool $direct_only = false, string $cursor = null): array
{
$parameters = [
'path' => $path ? $this->normalizePath($path) : null,
'cursor' => $cursor,
'direct_only' => $direct_only,
];
$body = $this->rpc... | php | public function listSharedLinks(string $path = null, bool $direct_only = false, string $cursor = null): array
{
$parameters = [
'path' => $path ? $this->normalizePath($path) : null,
'cursor' => $cursor,
'direct_only' => $direct_only,
];
$body = $this->rpc... | [
"public",
"function",
"listSharedLinks",
"(",
"string",
"$",
"path",
"=",
"null",
",",
"bool",
"$",
"direct_only",
"=",
"false",
",",
"string",
"$",
"cursor",
"=",
"null",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"'path'",
"=>",
"$",
"path"... | List shared links.
For empty path returns a list of all shared links. For non-empty path
returns a list of all shared links with access to the given path.
If direct_only is set true, only direct links to the path will be returned, otherwise
it may return link to the path itself and parent folders as described on docs... | [
"List",
"shared",
"links",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L128-L139 |
spatie/dropbox-api | src/Client.php | Client.delete | public function delete(string $path): array
{
$parameters = [
'path' => $this->normalizePath($path),
];
return $this->rpcEndpointRequest('files/delete', $parameters);
} | php | public function delete(string $path): array
{
$parameters = [
'path' => $this->normalizePath($path),
];
return $this->rpcEndpointRequest('files/delete', $parameters);
} | [
"public",
"function",
"delete",
"(",
"string",
"$",
"path",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
",",
"]",
";",
"return",
"$",
"this",
"->",
"rpcEndpointRequest"... | Delete the file or folder at a given path.
If the path is a folder, all its contents will be deleted too.
A successful response indicates that the file or folder was deleted.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-delete | [
"Delete",
"the",
"file",
"or",
"folder",
"at",
"a",
"given",
"path",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L149-L156 |
spatie/dropbox-api | src/Client.php | Client.download | public function download(string $path)
{
$arguments = [
'path' => $this->normalizePath($path),
];
$response = $this->contentEndpointRequest('files/download', $arguments);
return StreamWrapper::getResource($response->getBody());
} | php | public function download(string $path)
{
$arguments = [
'path' => $this->normalizePath($path),
];
$response = $this->contentEndpointRequest('files/download', $arguments);
return StreamWrapper::getResource($response->getBody());
} | [
"public",
"function",
"download",
"(",
"string",
"$",
"path",
")",
"{",
"$",
"arguments",
"=",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"contentEndpointReque... | Download a file from a user's Dropbox.
@param string $path
@return resource
@link https://www.dropbox.com/developers/documentation/http/documentation#files-download | [
"Download",
"a",
"file",
"from",
"a",
"user",
"s",
"Dropbox",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L167-L176 |
spatie/dropbox-api | src/Client.php | Client.getMetadata | public function getMetadata(string $path): array
{
$parameters = [
'path' => $this->normalizePath($path),
];
return $this->rpcEndpointRequest('files/get_metadata', $parameters);
} | php | public function getMetadata(string $path): array
{
$parameters = [
'path' => $this->normalizePath($path),
];
return $this->rpcEndpointRequest('files/get_metadata', $parameters);
} | [
"public",
"function",
"getMetadata",
"(",
"string",
"$",
"path",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
",",
"]",
";",
"return",
"$",
"this",
"->",
"rpcEndpointReq... | Returns the metadata for a file or folder.
Note: Metadata for the root folder is unsupported.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata | [
"Returns",
"the",
"metadata",
"for",
"a",
"file",
"or",
"folder",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L185-L192 |
spatie/dropbox-api | src/Client.php | Client.getTemporaryLink | public function getTemporaryLink(string $path): string
{
$parameters = [
'path' => $this->normalizePath($path),
];
$body = $this->rpcEndpointRequest('files/get_temporary_link', $parameters);
return $body['link'];
} | php | public function getTemporaryLink(string $path): string
{
$parameters = [
'path' => $this->normalizePath($path),
];
$body = $this->rpcEndpointRequest('files/get_temporary_link', $parameters);
return $body['link'];
} | [
"public",
"function",
"getTemporaryLink",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"$",
"parameters",
"=",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
",",
"]",
";",
"$",
"body",
"=",
"$",
"this",
"->",... | Get a temporary link to stream content of a file.
This link will expire in four hours and afterwards you will get 410 Gone.
Content-Type of the link is determined automatically by the file's mime type.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link | [
"Get",
"a",
"temporary",
"link",
"to",
"stream",
"content",
"of",
"a",
"file",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L202-L211 |
spatie/dropbox-api | src/Client.php | Client.getThumbnail | public function getThumbnail(string $path, string $format = 'jpeg', string $size = 'w64h64'): string
{
$arguments = [
'path' => $this->normalizePath($path),
'format' => $format,
'size' => $size,
];
$response = $this->contentEndpointRequest('files/get_thum... | php | public function getThumbnail(string $path, string $format = 'jpeg', string $size = 'w64h64'): string
{
$arguments = [
'path' => $this->normalizePath($path),
'format' => $format,
'size' => $size,
];
$response = $this->contentEndpointRequest('files/get_thum... | [
"public",
"function",
"getThumbnail",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"format",
"=",
"'jpeg'",
",",
"string",
"$",
"size",
"=",
"'w64h64'",
")",
":",
"string",
"{",
"$",
"arguments",
"=",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"normali... | Get a thumbnail for an image.
This method currently supports files with the following file extensions:
jpg, jpeg, png, tiff, tif, gif and bmp.
Photos that are larger than 20MB in size won't be converted to a thumbnail.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail | [
"Get",
"a",
"thumbnail",
"for",
"an",
"image",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L223-L234 |
spatie/dropbox-api | src/Client.php | Client.listFolder | public function listFolder(string $path = '', bool $recursive = false): array
{
$parameters = [
'path' => $this->normalizePath($path),
'recursive' => $recursive,
];
return $this->rpcEndpointRequest('files/list_folder', $parameters);
} | php | public function listFolder(string $path = '', bool $recursive = false): array
{
$parameters = [
'path' => $this->normalizePath($path),
'recursive' => $recursive,
];
return $this->rpcEndpointRequest('files/list_folder', $parameters);
} | [
"public",
"function",
"listFolder",
"(",
"string",
"$",
"path",
"=",
"''",
",",
"bool",
"$",
"recursive",
"=",
"false",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
",... | Starts returning the contents of a folder.
If the result's ListFolderResult.has_more field is true, call
list_folder/continue with the returned ListFolderResult.cursor to retrieve more entries.
Note: auth.RateLimitError may be returned if multiple list_folder or list_folder/continue calls
with same parameters are mad... | [
"Starts",
"returning",
"the",
"contents",
"of",
"a",
"folder",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L248-L256 |
spatie/dropbox-api | src/Client.php | Client.move | public function move(string $fromPath, string $toPath): array
{
$parameters = [
'from_path' => $this->normalizePath($fromPath),
'to_path' => $this->normalizePath($toPath),
];
return $this->rpcEndpointRequest('files/move_v2', $parameters);
} | php | public function move(string $fromPath, string $toPath): array
{
$parameters = [
'from_path' => $this->normalizePath($fromPath),
'to_path' => $this->normalizePath($toPath),
];
return $this->rpcEndpointRequest('files/move_v2', $parameters);
} | [
"public",
"function",
"move",
"(",
"string",
"$",
"fromPath",
",",
"string",
"$",
"toPath",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"'from_path'",
"=>",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"fromPath",
")",
",",
"'to_path'",
"=>",
... | Move a file or folder to a different location in the user's Dropbox.
If the source path is a folder all its contents will be moved.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-move_v2 | [
"Move",
"a",
"file",
"or",
"folder",
"to",
"a",
"different",
"location",
"in",
"the",
"user",
"s",
"Dropbox",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L276-L284 |
spatie/dropbox-api | src/Client.php | Client.shouldUploadChunked | protected function shouldUploadChunked($contents): bool
{
$size = is_string($contents) ? strlen($contents) : fstat($contents)['size'];
if ($this->isPipe($contents)) {
return true;
}
if ($size === null) {
return true;
}
return $size > $this->... | php | protected function shouldUploadChunked($contents): bool
{
$size = is_string($contents) ? strlen($contents) : fstat($contents)['size'];
if ($this->isPipe($contents)) {
return true;
}
if ($size === null) {
return true;
}
return $size > $this->... | [
"protected",
"function",
"shouldUploadChunked",
"(",
"$",
"contents",
")",
":",
"bool",
"{",
"$",
"size",
"=",
"is_string",
"(",
"$",
"contents",
")",
"?",
"strlen",
"(",
"$",
"contents",
")",
":",
"fstat",
"(",
"$",
"contents",
")",
"[",
"'size'",
"]"... | The file should be uploaded in chunks if it size exceeds the 150 MB threshold
or if the resource size could not be determined (eg. a popen() stream).
@param string|resource $contents
@return bool | [
"The",
"file",
"should",
"be",
"uploaded",
"in",
"chunks",
"if",
"it",
"size",
"exceeds",
"the",
"150",
"MB",
"threshold",
"or",
"if",
"the",
"resource",
"size",
"could",
"not",
"be",
"determined",
"(",
"eg",
".",
"a",
"popen",
"()",
"stream",
")",
"."... | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L294-L307 |
spatie/dropbox-api | src/Client.php | Client.upload | public function upload(string $path, $contents, $mode = 'add'): array
{
if ($this->shouldUploadChunked($contents)) {
return $this->uploadChunked($path, $contents, $mode);
}
$arguments = [
'path' => $this->normalizePath($path),
'mode' => $mode,
];
... | php | public function upload(string $path, $contents, $mode = 'add'): array
{
if ($this->shouldUploadChunked($contents)) {
return $this->uploadChunked($path, $contents, $mode);
}
$arguments = [
'path' => $this->normalizePath($path),
'mode' => $mode,
];
... | [
"public",
"function",
"upload",
"(",
"string",
"$",
"path",
",",
"$",
"contents",
",",
"$",
"mode",
"=",
"'add'",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"shouldUploadChunked",
"(",
"$",
"contents",
")",
")",
"{",
"return",
"$",
"this",... | Create a new file with the contents provided in the request.
Do not use this to upload a file larger than 150 MB. Instead, create an upload session with upload_session/start.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-upload
@param string $path
@param string|resource $contents
@p... | [
"Create",
"a",
"new",
"file",
"with",
"the",
"contents",
"provided",
"in",
"the",
"request",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L334-L352 |
spatie/dropbox-api | src/Client.php | Client.uploadChunked | public function uploadChunked(string $path, $contents, $mode = 'add', $chunkSize = null): array
{
if ($chunkSize === null || $chunkSize > $this->maxChunkSize) {
$chunkSize = $this->maxChunkSize;
}
$stream = $this->getStream($contents);
$cursor = $this->uploadChunk(self:... | php | public function uploadChunked(string $path, $contents, $mode = 'add', $chunkSize = null): array
{
if ($chunkSize === null || $chunkSize > $this->maxChunkSize) {
$chunkSize = $this->maxChunkSize;
}
$stream = $this->getStream($contents);
$cursor = $this->uploadChunk(self:... | [
"public",
"function",
"uploadChunked",
"(",
"string",
"$",
"path",
",",
"$",
"contents",
",",
"$",
"mode",
"=",
"'add'",
",",
"$",
"chunkSize",
"=",
"null",
")",
":",
"array",
"{",
"if",
"(",
"$",
"chunkSize",
"===",
"null",
"||",
"$",
"chunkSize",
"... | Upload file split in chunks. This allows uploading large files, since
Dropbox API v2 limits the content size to 150MB.
The chunk size will affect directly the memory usage, so be careful.
Large chunks tends to speed up the upload, while smaller optimizes memory usage.
@param string $path
@param string|resource $conte... | [
"Upload",
"file",
"split",
"in",
"chunks",
".",
"This",
"allows",
"uploading",
"large",
"files",
"since",
"Dropbox",
"API",
"v2",
"limits",
"the",
"content",
"size",
"to",
"150MB",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L368-L383 |
spatie/dropbox-api | src/Client.php | Client.uploadSessionStart | public function uploadSessionStart($contents, bool $close = false): UploadSessionCursor
{
$arguments = compact('close');
$response = json_decode(
$this->contentEndpointRequest('files/upload_session/start', $arguments, $contents)->getBody(),
true
);
return ne... | php | public function uploadSessionStart($contents, bool $close = false): UploadSessionCursor
{
$arguments = compact('close');
$response = json_decode(
$this->contentEndpointRequest('files/upload_session/start', $arguments, $contents)->getBody(),
true
);
return ne... | [
"public",
"function",
"uploadSessionStart",
"(",
"$",
"contents",
",",
"bool",
"$",
"close",
"=",
"false",
")",
":",
"UploadSessionCursor",
"{",
"$",
"arguments",
"=",
"compact",
"(",
"'close'",
")",
";",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"thi... | Upload sessions allow you to upload a single file in one or more requests,
for example where the size of the file is greater than 150 MB.
This call starts a new upload session with the given data.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start
@param string|Stream... | [
"Upload",
"sessions",
"allow",
"you",
"to",
"upload",
"a",
"single",
"file",
"in",
"one",
"or",
"more",
"requests",
"for",
"example",
"where",
"the",
"size",
"of",
"the",
"file",
"is",
"greater",
"than",
"150",
"MB",
".",
"This",
"call",
"starts",
"a",
... | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L437-L447 |
spatie/dropbox-api | src/Client.php | Client.uploadSessionAppend | public function uploadSessionAppend($contents, UploadSessionCursor $cursor, bool $close = false): UploadSessionCursor
{
$arguments = compact('cursor', 'close');
$pos = $contents instanceof StreamInterface ? $contents->tell() : 0;
$this->contentEndpointRequest('files/upload_session/append_v2... | php | public function uploadSessionAppend($contents, UploadSessionCursor $cursor, bool $close = false): UploadSessionCursor
{
$arguments = compact('cursor', 'close');
$pos = $contents instanceof StreamInterface ? $contents->tell() : 0;
$this->contentEndpointRequest('files/upload_session/append_v2... | [
"public",
"function",
"uploadSessionAppend",
"(",
"$",
"contents",
",",
"UploadSessionCursor",
"$",
"cursor",
",",
"bool",
"$",
"close",
"=",
"false",
")",
":",
"UploadSessionCursor",
"{",
"$",
"arguments",
"=",
"compact",
"(",
"'cursor'",
",",
"'close'",
")",... | Append more data to an upload session.
When the parameter close is set, this call will close the session.
A single request should not upload more than 150 MB.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2
@param string|StreamInterface $contents
@param UploadS... | [
"Append",
"more",
"data",
"to",
"an",
"upload",
"session",
".",
"When",
"the",
"parameter",
"close",
"is",
"set",
"this",
"call",
"will",
"close",
"the",
"session",
".",
"A",
"single",
"request",
"should",
"not",
"upload",
"more",
"than",
"150",
"MB",
".... | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L462-L472 |
spatie/dropbox-api | src/Client.php | Client.uploadSessionFinish | public function uploadSessionFinish($contents, UploadSessionCursor $cursor, string $path, $mode = 'add', $autorename = false, $mute = false): array
{
$arguments = compact('cursor');
$arguments['commit'] = compact('path', 'mode', 'autorename', 'mute');
$response = $this->contentEndpointReque... | php | public function uploadSessionFinish($contents, UploadSessionCursor $cursor, string $path, $mode = 'add', $autorename = false, $mute = false): array
{
$arguments = compact('cursor');
$arguments['commit'] = compact('path', 'mode', 'autorename', 'mute');
$response = $this->contentEndpointReque... | [
"public",
"function",
"uploadSessionFinish",
"(",
"$",
"contents",
",",
"UploadSessionCursor",
"$",
"cursor",
",",
"string",
"$",
"path",
",",
"$",
"mode",
"=",
"'add'",
",",
"$",
"autorename",
"=",
"false",
",",
"$",
"mute",
"=",
"false",
")",
":",
"arr... | Finish an upload session and save the uploaded data to the given file path.
A single request should not upload more than 150 MB.
@link https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish
@param string|StreamInterface $contents
@param \Spatie\Dropbox\UploadSessionCursor $cur... | [
"Finish",
"an",
"upload",
"session",
"and",
"save",
"the",
"uploaded",
"data",
"to",
"the",
"given",
"file",
"path",
".",
"A",
"single",
"request",
"should",
"not",
"upload",
"more",
"than",
"150",
"MB",
"."
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L489-L505 |
spatie/dropbox-api | src/Client.php | Client.contentEndpointRequest | public function contentEndpointRequest(string $endpoint, array $arguments, $body = ''): ResponseInterface
{
$headers = ['Dropbox-API-Arg' => json_encode($arguments)];
if ($body !== '') {
$headers['Content-Type'] = 'application/octet-stream';
}
try {
$respons... | php | public function contentEndpointRequest(string $endpoint, array $arguments, $body = ''): ResponseInterface
{
$headers = ['Dropbox-API-Arg' => json_encode($arguments)];
if ($body !== '') {
$headers['Content-Type'] = 'application/octet-stream';
}
try {
$respons... | [
"public",
"function",
"contentEndpointRequest",
"(",
"string",
"$",
"endpoint",
",",
"array",
"$",
"arguments",
",",
"$",
"body",
"=",
"''",
")",
":",
"ResponseInterface",
"{",
"$",
"headers",
"=",
"[",
"'Dropbox-API-Arg'",
"=>",
"json_encode",
"(",
"$",
"ar... | @param string $endpoint
@param array $arguments
@param string|resource|StreamInterface $body
@return \Psr\Http\Message\ResponseInterface
@throws \Exception | [
"@param",
"string",
"$endpoint",
"@param",
"array",
"$arguments",
"@param",
"string|resource|StreamInterface",
"$body"
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L558-L576 |
spatie/dropbox-api | src/Client.php | Client.getStream | protected function getStream($contents)
{
if ($this->isPipe($contents)) {
/* @var resource $contents */
return new PumpStream(function ($length) use ($contents) {
$data = fread($contents, $length);
if (strlen($data) === 0) {
return ... | php | protected function getStream($contents)
{
if ($this->isPipe($contents)) {
/* @var resource $contents */
return new PumpStream(function ($length) use ($contents) {
$data = fread($contents, $length);
if (strlen($data) === 0) {
return ... | [
"protected",
"function",
"getStream",
"(",
"$",
"contents",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPipe",
"(",
"$",
"contents",
")",
")",
"{",
"/* @var resource $contents */",
"return",
"new",
"PumpStream",
"(",
"function",
"(",
"$",
"length",
")",
"us... | @param $contents
@return \GuzzleHttp\Psr7\PumpStream|\GuzzleHttp\Psr7\Stream | [
"@param",
"$contents"
] | train | https://github.com/spatie/dropbox-api/blob/dc930cde4fdb802d20d0aeef5a98c3805fdcf9c2/src/Client.php#L611-L626 |
wp-cli/media-command | src/Media_Command.php | Media_Command.regenerate | public function regenerate( $args, $assoc_args = array() ) {
$assoc_args = wp_parse_args(
$assoc_args,
[ 'image_size' => '' ]
);
$image_size = $assoc_args['image_size'];
if ( $image_size && ! in_array( $image_size, get_intermediate_image_sizes(), true ) ) {
WP_CLI::error( sprintf( 'Unknown image size ... | php | public function regenerate( $args, $assoc_args = array() ) {
$assoc_args = wp_parse_args(
$assoc_args,
[ 'image_size' => '' ]
);
$image_size = $assoc_args['image_size'];
if ( $image_size && ! in_array( $image_size, get_intermediate_image_sizes(), true ) ) {
WP_CLI::error( sprintf( 'Unknown image size ... | [
"public",
"function",
"regenerate",
"(",
"$",
"args",
",",
"$",
"assoc_args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"assoc_args",
"=",
"wp_parse_args",
"(",
"$",
"assoc_args",
",",
"[",
"'image_size'",
"=>",
"''",
"]",
")",
";",
"$",
"image_size",
"="... | Regenerates thumbnails for one or more attachments.
## OPTIONS
[<attachment-id>...]
: One or more IDs of the attachments to regenerate.
[--image_size=<image_size>]
: Name of the image size to regenerate. Only thumbnails of this image size will be regenerated, thumbnails of other image sizes will not.
[--skip-delete... | [
"Regenerates",
"thumbnails",
"for",
"one",
"or",
"more",
"attachments",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L102-L170 |
wp-cli/media-command | src/Media_Command.php | Media_Command.import | public function import( $args, $assoc_args = array() ) {
$assoc_args = wp_parse_args(
$assoc_args,
array(
'title' => '',
'caption' => '',
'alt' => '',
'desc' => '',
)
);
// Assume the most generic term
$noun = 'item';
// Current site's timezone offset.
$gmt_offset = get_o... | php | public function import( $args, $assoc_args = array() ) {
$assoc_args = wp_parse_args(
$assoc_args,
array(
'title' => '',
'caption' => '',
'alt' => '',
'desc' => '',
)
);
// Assume the most generic term
$noun = 'item';
// Current site's timezone offset.
$gmt_offset = get_o... | [
"public",
"function",
"import",
"(",
"$",
"args",
",",
"$",
"assoc_args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"assoc_args",
"=",
"wp_parse_args",
"(",
"$",
"assoc_args",
",",
"array",
"(",
"'title'",
"=>",
"''",
",",
"'caption'",
"=>",
"''",
",",
... | Creates attachments from local files or URLs.
## OPTIONS
<file>...
: Path to file or files to be imported. Supports the glob(3) capabilities of the current shell.
If file is recognized as a URL (for example, with a scheme of http or ftp), the file will be
downloaded to a temp file before being sideloaded.
[--post_id... | [
"Creates",
"attachments",
"from",
"local",
"files",
"or",
"URLs",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L240-L430 |
wp-cli/media-command | src/Media_Command.php | Media_Command.image_size | public function image_size( $args, $assoc_args ) {
$assoc_args = array_merge(
array(
'fields' => 'name,width,height,crop,ratio',
),
$assoc_args
);
$sizes = $this->get_registered_image_sizes();
usort(
$sizes,
function( $a, $b ) {
if ( $a['width'] === $b['width'] ) {
return 0;
}
... | php | public function image_size( $args, $assoc_args ) {
$assoc_args = array_merge(
array(
'fields' => 'name,width,height,crop,ratio',
),
$assoc_args
);
$sizes = $this->get_registered_image_sizes();
usort(
$sizes,
function( $a, $b ) {
if ( $a['width'] === $b['width'] ) {
return 0;
}
... | [
"public",
"function",
"image_size",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"assoc_args",
"=",
"array_merge",
"(",
"array",
"(",
"'fields'",
"=>",
"'name,width,height,crop,ratio'",
",",
")",
",",
"$",
"assoc_args",
")",
";",
"$",
"sizes",
... | Lists image sizes registered with WordPress.
## OPTIONS
[--fields=<fields>]
: Limit the output to specific fields. Defaults to all fields.
[--format=<format>]
: Render output in a specific format
---
default: table
options:
- table
- json
- csv
- yaml
- count
---
## AVAILABLE FIELDS
These fields will be displayed ... | [
"Lists",
"image",
"sizes",
"registered",
"with",
"WordPress",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L478-L508 |
wp-cli/media-command | src/Media_Command.php | Media_Command.make_copy | private function make_copy( $path ) {
$dir = get_temp_dir();
$filename = Utils\basename( $path );
if ( empty( $filename ) ) {
$filename = time();
}
$filename = $dir . wp_unique_filename( $dir, $filename );
if ( ! copy( $path, $filename ) ) {
WP_CLI::error( "Could not create temporary file for $p... | php | private function make_copy( $path ) {
$dir = get_temp_dir();
$filename = Utils\basename( $path );
if ( empty( $filename ) ) {
$filename = time();
}
$filename = $dir . wp_unique_filename( $dir, $filename );
if ( ! copy( $path, $filename ) ) {
WP_CLI::error( "Could not create temporary file for $p... | [
"private",
"function",
"make_copy",
"(",
"$",
"path",
")",
"{",
"$",
"dir",
"=",
"get_temp_dir",
"(",
")",
";",
"$",
"filename",
"=",
"Utils",
"\\",
"basename",
"(",
"$",
"path",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"filename",
")",
")",
"{",
... | wp_tempnam() inexplicably forces a .tmp extension, which spoils MIME type detection | [
"wp_tempnam",
"()",
"inexplicably",
"forces",
"a",
".",
"tmp",
"extension",
"which",
"spoils",
"MIME",
"type",
"detection"
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L536-L549 |
wp-cli/media-command | src/Media_Command.php | Media_Command.image_sizes_differ | private function image_sizes_differ( $image_sizes, $meta_sizes ) {
// Check if have new image size(s).
if ( array_diff( array_keys( $image_sizes ), array_keys( $meta_sizes ) ) ) {
return true;
}
// Check if image sizes have changed.
foreach ( $image_sizes as $name => $image_size ) {
if ( $image_size['wi... | php | private function image_sizes_differ( $image_sizes, $meta_sizes ) {
// Check if have new image size(s).
if ( array_diff( array_keys( $image_sizes ), array_keys( $meta_sizes ) ) ) {
return true;
}
// Check if image sizes have changed.
foreach ( $image_sizes as $name => $image_size ) {
if ( $image_size['wi... | [
"private",
"function",
"image_sizes_differ",
"(",
"$",
"image_sizes",
",",
"$",
"meta_sizes",
")",
"{",
"// Check if have new image size(s).",
"if",
"(",
"array_diff",
"(",
"array_keys",
"(",
"$",
"image_sizes",
")",
",",
"array_keys",
"(",
"$",
"meta_sizes",
")",... | Whether there's new image sizes or the width/height of existing image sizes have changed. | [
"Whether",
"there",
"s",
"new",
"image",
"sizes",
"or",
"the",
"width",
"/",
"height",
"of",
"existing",
"image",
"sizes",
"have",
"changed",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L724-L736 |
wp-cli/media-command | src/Media_Command.php | Media_Command.get_intermediate_image_sizes_for_attachment | private function get_intermediate_image_sizes_for_attachment( $fullsizepath, $is_pdf, $metadata ) {
// Need to get width, height of attachment for image_resize_dimensions().
$editor = wp_get_image_editor( $fullsizepath );
if ( is_wp_error( $editor ) ) {
return $editor;
}
$result = $editor->load();
if ( ... | php | private function get_intermediate_image_sizes_for_attachment( $fullsizepath, $is_pdf, $metadata ) {
// Need to get width, height of attachment for image_resize_dimensions().
$editor = wp_get_image_editor( $fullsizepath );
if ( is_wp_error( $editor ) ) {
return $editor;
}
$result = $editor->load();
if ( ... | [
"private",
"function",
"get_intermediate_image_sizes_for_attachment",
"(",
"$",
"fullsizepath",
",",
"$",
"is_pdf",
",",
"$",
"metadata",
")",
"{",
"// Need to get width, height of attachment for image_resize_dimensions().",
"$",
"editor",
"=",
"wp_get_image_editor",
"(",
"$"... | and returns associative array with size name => width/height entries, resolved to crop values if applicable. | [
"and",
"returns",
"associative",
"array",
"with",
"size",
"name",
"=",
">",
"width",
"/",
"height",
"entries",
"resolved",
"to",
"crop",
"values",
"if",
"applicable",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L740-L768 |
wp-cli/media-command | src/Media_Command.php | Media_Command.get_intermediate_sizes | private function get_intermediate_sizes( $is_pdf, $metadata ) {
if ( $is_pdf ) {
// Copied from wp_generate_attachment_metadata() in "wp-admin/includes/image.php".
$fallback_sizes = array(
'thumbnail',
'medium',
'large',
);
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefix... | php | private function get_intermediate_sizes( $is_pdf, $metadata ) {
if ( $is_pdf ) {
// Copied from wp_generate_attachment_metadata() in "wp-admin/includes/image.php".
$fallback_sizes = array(
'thumbnail',
'medium',
'large',
);
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefix... | [
"private",
"function",
"get_intermediate_sizes",
"(",
"$",
"is_pdf",
",",
"$",
"metadata",
")",
"{",
"if",
"(",
"$",
"is_pdf",
")",
"{",
"// Copied from wp_generate_attachment_metadata() in \"wp-admin/includes/image.php\".",
"$",
"fallback_sizes",
"=",
"array",
"(",
"'t... | Like WP's get_intermediate_image_sizes(), but returns associative array with name => size info entries (and caters for PDFs also). | [
"Like",
"WP",
"s",
"get_intermediate_image_sizes",
"()",
"but",
"returns",
"associative",
"array",
"with",
"name",
"=",
">",
"size",
"info",
"entries",
"(",
"and",
"caters",
"for",
"PDFs",
"also",
")",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L771-L831 |
wp-cli/media-command | src/Media_Command.php | Media_Command.add_image_size_filters | private function add_image_size_filters( $image_size ) {
$image_size_filters = array();
// For images.
$image_size_filters['intermediate_image_sizes_advanced'] = function ( $sizes ) use ( $image_size ) {
// $sizes is associative array of name => size info entries.
if ( isset( $sizes[ $image_size ] ) ) {
... | php | private function add_image_size_filters( $image_size ) {
$image_size_filters = array();
// For images.
$image_size_filters['intermediate_image_sizes_advanced'] = function ( $sizes ) use ( $image_size ) {
// $sizes is associative array of name => size info entries.
if ( isset( $sizes[ $image_size ] ) ) {
... | [
"private",
"function",
"add_image_size_filters",
"(",
"$",
"image_size",
")",
"{",
"$",
"image_size_filters",
"=",
"array",
"(",
")",
";",
"// For images.",
"$",
"image_size_filters",
"[",
"'intermediate_image_sizes_advanced'",
"]",
"=",
"function",
"(",
"$",
"sizes... | Add filters to only process a particular intermediate image size in wp_generate_attachment_metadata(). | [
"Add",
"filters",
"to",
"only",
"process",
"a",
"particular",
"intermediate",
"image",
"size",
"in",
"wp_generate_attachment_metadata",
"()",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L834-L860 |
wp-cli/media-command | src/Media_Command.php | Media_Command.remove_image_size_filters | private function remove_image_size_filters( $image_size_filters ) {
foreach ( $image_size_filters as $name => $filter ) {
remove_filter( $name, $filter, PHP_INT_MAX );
}
} | php | private function remove_image_size_filters( $image_size_filters ) {
foreach ( $image_size_filters as $name => $filter ) {
remove_filter( $name, $filter, PHP_INT_MAX );
}
} | [
"private",
"function",
"remove_image_size_filters",
"(",
"$",
"image_size_filters",
")",
"{",
"foreach",
"(",
"$",
"image_size_filters",
"as",
"$",
"name",
"=>",
"$",
"filter",
")",
"{",
"remove_filter",
"(",
"$",
"name",
",",
"$",
"filter",
",",
"PHP_INT_MAX"... | Remove above intermediate image size filters. | [
"Remove",
"above",
"intermediate",
"image",
"size",
"filters",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L863-L867 |
wp-cli/media-command | src/Media_Command.php | Media_Command.update_attachment_metadata_for_image_size | private function update_attachment_metadata_for_image_size( $id, $new_metadata, $image_size ) {
$metadata = wp_get_attachment_metadata( $id );
if ( ! is_array( $metadata ) ) {
return false;
}
// If have metadata for image_size.
if ( ! empty( $new_metadata['sizes'][ $image_size ] ) ) {
$metadata['sizes... | php | private function update_attachment_metadata_for_image_size( $id, $new_metadata, $image_size ) {
$metadata = wp_get_attachment_metadata( $id );
if ( ! is_array( $metadata ) ) {
return false;
}
// If have metadata for image_size.
if ( ! empty( $new_metadata['sizes'][ $image_size ] ) ) {
$metadata['sizes... | [
"private",
"function",
"update_attachment_metadata_for_image_size",
"(",
"$",
"id",
",",
"$",
"new_metadata",
",",
"$",
"image_size",
")",
"{",
"$",
"metadata",
"=",
"wp_get_attachment_metadata",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
... | Update attachment sizes metadata just for a particular intermediate image size. | [
"Update",
"attachment",
"sizes",
"metadata",
"just",
"for",
"a",
"particular",
"intermediate",
"image",
"size",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L870-L891 |
wp-cli/media-command | src/Media_Command.php | Media_Command.get_images | private function get_images( $args = array(), $additional_mime_types = array() ) {
$mime_types = array_merge( array( 'image' ), $additional_mime_types );
$query_args = array(
'post_type' => 'attachment',
'post__in' => $args,
'post_mime_type' => $mime_types,
'post_status' => 'any',
'pos... | php | private function get_images( $args = array(), $additional_mime_types = array() ) {
$mime_types = array_merge( array( 'image' ), $additional_mime_types );
$query_args = array(
'post_type' => 'attachment',
'post__in' => $args,
'post_mime_type' => $mime_types,
'post_status' => 'any',
'pos... | [
"private",
"function",
"get_images",
"(",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"additional_mime_types",
"=",
"array",
"(",
")",
")",
"{",
"$",
"mime_types",
"=",
"array_merge",
"(",
"array",
"(",
"'image'",
")",
",",
"$",
"additional_mime_types",... | Get images from the installation.
@param array $args The query arguments to use. Optional.
@param array $additional_mime_types The additional mime types to search for. Optional.
@return WP_Query The query result. | [
"Get",
"images",
"from",
"the",
"installation",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L901-L913 |
wp-cli/media-command | src/Media_Command.php | Media_Command.get_intermediate_size_metadata | private function get_intermediate_size_metadata( $size ) {
$width = intval( get_option( "{$size}_size_w" ) );
$height = intval( get_option( "{$size}_size_h" ) );
$crop = get_option( "{$size}_crop" );
return array(
'name' => $size,
'width' => $width,
'height' => $height,
'crop' => false !== ... | php | private function get_intermediate_size_metadata( $size ) {
$width = intval( get_option( "{$size}_size_w" ) );
$height = intval( get_option( "{$size}_size_h" ) );
$crop = get_option( "{$size}_crop" );
return array(
'name' => $size,
'width' => $width,
'height' => $height,
'crop' => false !== ... | [
"private",
"function",
"get_intermediate_size_metadata",
"(",
"$",
"size",
")",
"{",
"$",
"width",
"=",
"intval",
"(",
"get_option",
"(",
"\"{$size}_size_w\"",
")",
")",
";",
"$",
"height",
"=",
"intval",
"(",
"get_option",
"(",
"\"{$size}_size_h\"",
")",
")",... | Get the metadata for the passed intermediate image size.
@param string $size The image size to get the metadata for.
@return array The image size metadata. | [
"Get",
"the",
"metadata",
"for",
"the",
"passed",
"intermediate",
"image",
"size",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L922-L934 |
wp-cli/media-command | src/Media_Command.php | Media_Command.get_registered_image_sizes | private function get_registered_image_sizes() {
global $_wp_additional_image_sizes;
$image_sizes = array();
$default_image_sizes = get_intermediate_image_sizes();
foreach ( $default_image_sizes as $size ) {
$image_sizes[] = $this->get_intermediate_size_metadata( $size );
}
if ( is_array( $_wp_... | php | private function get_registered_image_sizes() {
global $_wp_additional_image_sizes;
$image_sizes = array();
$default_image_sizes = get_intermediate_image_sizes();
foreach ( $default_image_sizes as $size ) {
$image_sizes[] = $this->get_intermediate_size_metadata( $size );
}
if ( is_array( $_wp_... | [
"private",
"function",
"get_registered_image_sizes",
"(",
")",
"{",
"global",
"$",
"_wp_additional_image_sizes",
";",
"$",
"image_sizes",
"=",
"array",
"(",
")",
";",
"$",
"default_image_sizes",
"=",
"get_intermediate_image_sizes",
"(",
")",
";",
"foreach",
"(",
"... | Get all the registered image sizes along with their dimensions.
@global array $_wp_additional_image_sizes The additional image sizes to parse.
@link https://wordpress.stackexchange.com/a/251602 Original solution.
@return array $image_sizes The image sizes | [
"Get",
"all",
"the",
"registered",
"image",
"sizes",
"along",
"with",
"their",
"dimensions",
"."
] | train | https://github.com/wp-cli/media-command/blob/68e2402dcef11ae10e8902cf93a1d370db07ed78/src/Media_Command.php#L945-L969 |
opensoft/rollout | src/Storage/PDOStorageAdapter.php | PDOStorageAdapter.get | public function get($key)
{
$statement = $this->pdoConnection->prepare($this->getSQLStatement(self::STMT_SELECT));
$statement->bindParam('key', $key);
$statement->setFetchMode(\PDO::FETCH_ASSOC);
$statement->execute();
$result = $statement->fetch();
if (false === ... | php | public function get($key)
{
$statement = $this->pdoConnection->prepare($this->getSQLStatement(self::STMT_SELECT));
$statement->bindParam('key', $key);
$statement->setFetchMode(\PDO::FETCH_ASSOC);
$statement->execute();
$result = $statement->fetch();
if (false === ... | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"pdoConnection",
"->",
"prepare",
"(",
"$",
"this",
"->",
"getSQLStatement",
"(",
"self",
"::",
"STMT_SELECT",
")",
")",
";",
"$",
"statement",
"->",
"bin... | {@inheritdoc} | [
"{"
] | train | https://github.com/opensoft/rollout/blob/4df1b6888654c02506f5da813055934d414a8678/src/Storage/PDOStorageAdapter.php#L36-L52 |
opensoft/rollout | src/Storage/PDOStorageAdapter.php | PDOStorageAdapter.set | public function set($key, $value)
{
if (null === $this->get($key)) {
$sql = self::STMT_INSERT;
} else {
$sql = self::STMT_UPDATE;
}
$statement = $this->pdoConnection->prepare($this->getSQLStatement($sql));
$statement->bindParam('key', $key);
... | php | public function set($key, $value)
{
if (null === $this->get($key)) {
$sql = self::STMT_INSERT;
} else {
$sql = self::STMT_UPDATE;
}
$statement = $this->pdoConnection->prepare($this->getSQLStatement($sql));
$statement->bindParam('key', $key);
... | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
")",
"{",
"$",
"sql",
"=",
"self",
"::",
"STMT_INSERT",
";",
"}",
"else",
"{",
"$",
"sql",
"=... | {@inheritdoc} | [
"{"
] | train | https://github.com/opensoft/rollout/blob/4df1b6888654c02506f5da813055934d414a8678/src/Storage/PDOStorageAdapter.php#L57-L71 |
opensoft/rollout | src/Feature.php | Feature.clear | public function clear()
{
$this->groups = array();
$this->users = array();
$this->percentage = 0;
$this->requestParam = '';
$this->data = array();
} | php | public function clear()
{
$this->groups = array();
$this->users = array();
$this->percentage = 0;
$this->requestParam = '';
$this->data = array();
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"groups",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"users",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"percentage",
"=",
"0",
";",
"$",
"this",
"->",
"requestParam",
"=... | Clear the feature of all configuration | [
"Clear",
"the",
"feature",
"of",
"all",
"configuration"
] | train | https://github.com/opensoft/rollout/blob/4df1b6888654c02506f5da813055934d414a8678/src/Feature.php#L202-L209 |
opensoft/rollout | src/Feature.php | Feature.isActive | public function isActive(Rollout $rollout, RolloutUserInterface $user = null, array $requestParameters = array())
{
if (null == $user) {
return $this->isParamInRequestParams($requestParameters)
|| $this->percentage == 100
|| $this->isInActiveGroup($rollout);
... | php | public function isActive(Rollout $rollout, RolloutUserInterface $user = null, array $requestParameters = array())
{
if (null == $user) {
return $this->isParamInRequestParams($requestParameters)
|| $this->percentage == 100
|| $this->isInActiveGroup($rollout);
... | [
"public",
"function",
"isActive",
"(",
"Rollout",
"$",
"rollout",
",",
"RolloutUserInterface",
"$",
"user",
"=",
"null",
",",
"array",
"$",
"requestParameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"user",
")",
"{",
"return",
... | Is the feature active?
@param Rollout $rollout
@param RolloutUserInterface|null $user
@param array $requestParameters
@return bool | [
"Is",
"the",
"feature",
"active?"
] | train | https://github.com/opensoft/rollout/blob/4df1b6888654c02506f5da813055934d414a8678/src/Feature.php#L219-L231 |
opensoft/rollout | src/Rollout.php | Rollout.remove | public function remove($feature)
{
$this->storage->remove($this->key($feature));
$features = $this->features();
if (in_array($feature, $features)) {
$features = array_diff($features, array($feature));
}
$this->storage->set($this->featuresKey(), implode(',', $feat... | php | public function remove($feature)
{
$this->storage->remove($this->key($feature));
$features = $this->features();
if (in_array($feature, $features)) {
$features = array_diff($features, array($feature));
}
$this->storage->set($this->featuresKey(), implode(',', $feat... | [
"public",
"function",
"remove",
"(",
"$",
"feature",
")",
"{",
"$",
"this",
"->",
"storage",
"->",
"remove",
"(",
"$",
"this",
"->",
"key",
"(",
"$",
"feature",
")",
")",
";",
"$",
"features",
"=",
"$",
"this",
"->",
"features",
"(",
")",
";",
"i... | Remove a feature definition from rollout
@param string $feature | [
"Remove",
"a",
"feature",
"definition",
"from",
"rollout"
] | train | https://github.com/opensoft/rollout/blob/4df1b6888654c02506f5da813055934d414a8678/src/Rollout.php#L224-L233 |
opensoft/rollout | src/Rollout.php | Rollout.setFeatureData | public function setFeatureData($feature, array $data)
{
$feature = $this->get($feature);
if ($feature) {
$feature->setData(array_merge($feature->getData(), $data));
$this->save($feature);
}
} | php | public function setFeatureData($feature, array $data)
{
$feature = $this->get($feature);
if ($feature) {
$feature->setData(array_merge($feature->getData(), $data));
$this->save($feature);
}
} | [
"public",
"function",
"setFeatureData",
"(",
"$",
"feature",
",",
"array",
"$",
"data",
")",
"{",
"$",
"feature",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"feature",
")",
";",
"if",
"(",
"$",
"feature",
")",
"{",
"$",
"feature",
"->",
"setData",
"(... | Update feature specific data
@example $rollout->setFeatureData('chat', array(
'description' => 'foo',
'release_date' => 'bar',
'whatever' => 'baz'
));
@param string $feature
@param array $data | [
"Update",
"feature",
"specific",
"data"
] | train | https://github.com/opensoft/rollout/blob/4df1b6888654c02506f5da813055934d414a8678/src/Rollout.php#L247-L254 |
opensoft/rollout | src/Rollout.php | Rollout.clearFeatureData | public function clearFeatureData($feature)
{
$feature = $this->get($feature);
if ($feature) {
$feature->setData(array());
$this->save($feature);
}
} | php | public function clearFeatureData($feature)
{
$feature = $this->get($feature);
if ($feature) {
$feature->setData(array());
$this->save($feature);
}
} | [
"public",
"function",
"clearFeatureData",
"(",
"$",
"feature",
")",
"{",
"$",
"feature",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"feature",
")",
";",
"if",
"(",
"$",
"feature",
")",
"{",
"$",
"feature",
"->",
"setData",
"(",
"array",
"(",
")",
")"... | Clear all feature data
@param string $feature | [
"Clear",
"all",
"feature",
"data"
] | train | https://github.com/opensoft/rollout/blob/4df1b6888654c02506f5da813055934d414a8678/src/Rollout.php#L261-L268 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.addClass | public function addClass($name)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
$classes = preg_split('/\s+/s', $node->getAttribute('class'));
$found = false;
$count = count($classes);
... | php | public function addClass($name)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
$classes = preg_split('/\s+/s', $node->getAttribute('class'));
$found = false;
$count = count($classes);
... | [
"public",
"function",
"addClass",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"DOMElement",
")",
"{",
"/** @var \\DOMElement $node */",
"$",
"classes",
"=",
"preg_split",... | Adds the specified class(es) to each element in the set of matched elements.
@param string $name One or more space-separated classes to be added to the class attribute of each matched element.
@return HtmlPageCrawler $this for chaining
@api | [
"Adds",
"the",
"specified",
"class",
"(",
"es",
")",
"to",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L47-L67 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.after | public function after($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
/** @var \DOMNode $node */
$refnode = $node->nextSibling;
foreach ($content as $newnode) {
/** @var \DOMNode $newnode... | php | public function after($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
/** @var \DOMNode $node */
$refnode = $node->nextSibling;
foreach ($content as $newnode) {
/** @var \DOMNode $newnode... | [
"public",
"function",
"after",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"self",
"::",
"create",
"(",
"$",
"content",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"i",
"=>",
"$",
"node"... | Insert content, specified by the parameter, after each element in the set of matched elements.
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $content
@return HtmlPageCrawler $this for chaining
@api | [
"Insert",
"content",
"specified",
"by",
"the",
"parameter",
"after",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L76-L97 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.append | public function append($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
/** @var \DOMNode $node */
foreach ($content as $newnode) {
/** @var \DOMNode $newnode */
$newnode = static::imp... | php | public function append($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
/** @var \DOMNode $node */
foreach ($content as $newnode) {
/** @var \DOMNode $newnode */
$newnode = static::imp... | [
"public",
"function",
"append",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"self",
"::",
"create",
"(",
"$",
"content",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"i",
"=>",
"$",
"node... | Insert HTML content as child nodes of each element after existing children
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $content HTML code fragment or DOMNode to append
@return HtmlPageCrawler $this for chaining
@api | [
"Insert",
"HTML",
"content",
"as",
"child",
"nodes",
"of",
"each",
"element",
"after",
"existing",
"children"
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L106-L122 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.appendTo | public function appendTo($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
/** @var \DOMNode $node */
foreach ($this as $newnode) {
/** @var \DOMNode $newnode */
if ($node !== $newnode) {
... | php | public function appendTo($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
/** @var \DOMNode $node */
foreach ($this as $newnode) {
/** @var \DOMNode $newnode */
if ($node !== $newnode) {
... | [
"public",
"function",
"appendTo",
"(",
"$",
"element",
")",
"{",
"$",
"e",
"=",
"self",
"::",
"create",
"(",
"$",
"element",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"e",
"as",
"$",
"i",
"=>",
"$",
"node",
")... | Insert every element in the set of matched elements to the end of the target.
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $element
@return \Wa72\HtmlPageDom\HtmlPageCrawler A new Crawler object containing all elements appended to the target elements
@api | [
"Insert",
"every",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"to",
"the",
"end",
"of",
"the",
"target",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L131-L147 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.setAttribute | public function setAttribute($name, $value)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
$node->setAttribute($name, $value);
}
}
return $this;
} | php | public function setAttribute($name, $value)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
$node->setAttribute($name, $value);
}
}
return $this;
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"DOMElement",
")",
"{",
"/** @var \\DOMElement $node */",
"$",
"nod... | Sets an attribute on each element
@param string $name
@param string $value
@return HtmlPageCrawler $this for chaining | [
"Sets",
"an",
"attribute",
"on",
"each",
"element"
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L176-L185 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.getAttribute | public function getAttribute($name)
{
if (!count($this)) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$node = $this->getNode(0);
return $node->hasAttribute($name) ? $node->getAttribute($name) : null;
} | php | public function getAttribute($name)
{
if (!count($this)) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$node = $this->getNode(0);
return $node->hasAttribute($name) ? $node->getAttribute($name) : null;
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The current node list is empty.'",
")",
";",
"}",
"$",
"node",
"=",
"$",
... | Returns the attribute value of the first node of the list.
@param string $name The attribute name
@return string|null The attribute value or null if the attribute does not exist
@throws \InvalidArgumentException When current node is empty | [
"Returns",
"the",
"attribute",
"value",
"of",
"the",
"first",
"node",
"of",
"the",
"list",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L195-L202 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.before | public function before($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
/** @var \DOMNode $node */
foreach ($content as $newnode) {
/** @var \DOMNode $newnode */
if ($node !== $newnode... | php | public function before($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
/** @var \DOMNode $node */
foreach ($content as $newnode) {
/** @var \DOMNode $newnode */
if ($node !== $newnode... | [
"public",
"function",
"before",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"self",
"::",
"create",
"(",
"$",
"content",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"i",
"=>",
"$",
"node... | Insert content, specified by the parameter, before each element in the set of matched elements.
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $content
@return HtmlPageCrawler $this for chaining
@api | [
"Insert",
"content",
"specified",
"by",
"the",
"parameter",
"before",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L211-L229 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.css | public function css($key, $value = null)
{
if (null === $value) {
return $this->getStyle($key);
} else {
return $this->setStyle($key, $value);
}
} | php | public function css($key, $value = null)
{
if (null === $value) {
return $this->getStyle($key);
} else {
return $this->setStyle($key, $value);
}
} | [
"public",
"function",
"css",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"getStyle",
"(",
"$",
"key",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this... | Get one CSS style property of the first element or set it for all elements in the list
Function is here for compatibility with jQuery; it is the same as getStyle() and setStyle()
@see HtmlPageCrawler::getStyle()
@see HtmlPageCrawler::setStyle()
@param string $key The name of the style property
@param null|string $va... | [
"Get",
"one",
"CSS",
"style",
"property",
"of",
"the",
"first",
"element",
"or",
"set",
"it",
"for",
"all",
"elements",
"in",
"the",
"list"
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L268-L275 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.getStyle | public function getStyle($key)
{
$styles = Helpers::cssStringToArray($this->getAttribute('style'));
return (isset($styles[$key]) ? $styles[$key] : null);
} | php | public function getStyle($key)
{
$styles = Helpers::cssStringToArray($this->getAttribute('style'));
return (isset($styles[$key]) ? $styles[$key] : null);
} | [
"public",
"function",
"getStyle",
"(",
"$",
"key",
")",
"{",
"$",
"styles",
"=",
"Helpers",
"::",
"cssStringToArray",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"'style'",
")",
")",
";",
"return",
"(",
"isset",
"(",
"$",
"styles",
"[",
"$",
"key",
... | get one CSS style property of the first element
@param string $key name of the property
@return string|null value of the property | [
"get",
"one",
"CSS",
"style",
"property",
"of",
"the",
"first",
"element"
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L283-L287 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.setStyle | public function setStyle($key, $value)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
$styles = Helpers::cssStringToArray($node->getAttribute('style'));
if ($value != '') {
$styles... | php | public function setStyle($key, $value)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
$styles = Helpers::cssStringToArray($node->getAttribute('style'));
if ($value != '') {
$styles... | [
"public",
"function",
"setStyle",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"DOMElement",
")",
"{",
"/** @var \\DOMElement $node */",
"$",
"styles",... | set one CSS style property for all elements in the list
@param string $key name of the property
@param string $value value of the property
@return HtmlPageCrawler $this for chaining | [
"set",
"one",
"CSS",
"style",
"property",
"for",
"all",
"elements",
"in",
"the",
"list"
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L296-L311 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.hasClass | public function hasClass($name)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement && $class = $node->getAttribute('class')) {
$classes = preg_split('/\s+/s', $class);
if (in_array($name, $classes)) {
return true;
}
... | php | public function hasClass($name)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement && $class = $node->getAttribute('class')) {
$classes = preg_split('/\s+/s', $class);
if (in_array($name, $classes)) {
return true;
}
... | [
"public",
"function",
"hasClass",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"DOMElement",
"&&",
"$",
"class",
"=",
"$",
"node",
"->",
"getAttribute",
"(",
"'class... | Determine whether any of the matched elements are assigned the given class.
@param string $name
@return bool
@api | [
"Determine",
"whether",
"any",
"of",
"the",
"matched",
"elements",
"are",
"assigned",
"the",
"given",
"class",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L335-L346 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.setInnerHtml | public function setInnerHtml($content)
{
$content = self::create($content);
foreach ($this as $node) {
$node->nodeValue = '';
foreach ($content as $newnode) {
/** @var \DOMNode $node */
/** @var \DOMNode $newnode */
$newnode = s... | php | public function setInnerHtml($content)
{
$content = self::create($content);
foreach ($this as $node) {
$node->nodeValue = '';
foreach ($content as $newnode) {
/** @var \DOMNode $node */
/** @var \DOMNode $newnode */
$newnode = s... | [
"public",
"function",
"setInnerHtml",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"self",
"::",
"create",
"(",
"$",
"content",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"nodeValue",
"=",
"''",
";... | Set the HTML contents of each element
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $content HTML code fragment
@return HtmlPageCrawler $this for chaining | [
"Set",
"the",
"HTML",
"contents",
"of",
"each",
"element"
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L354-L367 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.insertAfter | public function insertAfter($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
/** @var \DOMNode $node */
$refnode = $node->nextSibling;
foreach ($this as $newnode) {
/** @var \DOMNode $newnode */
... | php | public function insertAfter($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
/** @var \DOMNode $node */
$refnode = $node->nextSibling;
foreach ($this as $newnode) {
/** @var \DOMNode $newnode */
... | [
"public",
"function",
"insertAfter",
"(",
"$",
"element",
")",
"{",
"$",
"e",
"=",
"self",
"::",
"create",
"(",
"$",
"element",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"e",
"as",
"$",
"i",
"=>",
"$",
"node",
... | Insert every element in the set of matched elements after the target.
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $element
@return \Wa72\HtmlPageDom\HtmlPageCrawler A new Crawler object containing all elements appended to the target elements
@api | [
"Insert",
"every",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"after",
"the",
"target",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L376-L395 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.insertBefore | public function insertBefore($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
/** @var \DOMNode $node */
foreach ($this as $newnode) {
/** @var \DOMNode $newnode */
$newnode = static::importNew... | php | public function insertBefore($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
/** @var \DOMNode $node */
foreach ($this as $newnode) {
/** @var \DOMNode $newnode */
$newnode = static::importNew... | [
"public",
"function",
"insertBefore",
"(",
"$",
"element",
")",
"{",
"$",
"e",
"=",
"self",
"::",
"create",
"(",
"$",
"element",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"e",
"as",
"$",
"i",
"=>",
"$",
"node",
... | Insert every element in the set of matched elements before the target.
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $element
@return \Wa72\HtmlPageDom\HtmlPageCrawler A new Crawler object containing all elements appended to the target elements
@api | [
"Insert",
"every",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"before",
"the",
"target",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L404-L420 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.prepend | public function prepend($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
$refnode = $node->firstChild;
/** @var \DOMNode $node */
foreach ($content as $newnode) {
/** @var \DOMNode $newnod... | php | public function prepend($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
$refnode = $node->firstChild;
/** @var \DOMNode $node */
foreach ($content as $newnode) {
/** @var \DOMNode $newnod... | [
"public",
"function",
"prepend",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"self",
"::",
"create",
"(",
"$",
"content",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"i",
"=>",
"$",
"nod... | Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $content HTML code fragment
@return HtmlPageCrawler $this for chaining
@api | [
"Insert",
"content",
"specified",
"by",
"the",
"parameter",
"to",
"the",
"beginning",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L429-L450 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.prependTo | public function prependTo($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
$refnode = $node->firstChild;
/** @var \DOMNode $node */
foreach ($this as $newnode) {
/** @var \DOMNode $newnode */
... | php | public function prependTo($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
$refnode = $node->firstChild;
/** @var \DOMNode $node */
foreach ($this as $newnode) {
/** @var \DOMNode $newnode */
... | [
"public",
"function",
"prependTo",
"(",
"$",
"element",
")",
"{",
"$",
"e",
"=",
"self",
"::",
"create",
"(",
"$",
"element",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"e",
"as",
"$",
"i",
"=>",
"$",
"node",
"... | Insert every element in the set of matched elements to the beginning of the target.
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $element
@return \Wa72\HtmlPageDom\HtmlPageCrawler A new Crawler object containing all elements prepended to the target elements
@api | [
"Insert",
"every",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"to",
"the",
"beginning",
"of",
"the",
"target",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L459-L480 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.remove | public function remove()
{
foreach ($this as $node) {
/**
* @var \DOMNode $node
*/
if ($node->parentNode instanceof \DOMElement) {
$node->parentNode->removeChild($node);
}
}
$this->clear();
} | php | public function remove()
{
foreach ($this as $node) {
/**
* @var \DOMNode $node
*/
if ($node->parentNode instanceof \DOMElement) {
$node->parentNode->removeChild($node);
}
}
$this->clear();
} | [
"public",
"function",
"remove",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
")",
"{",
"/**\n * @var \\DOMNode $node\n */",
"if",
"(",
"$",
"node",
"->",
"parentNode",
"instanceof",
"\\",
"DOMElement",
")",
"{",
"$",
"... | Remove the set of matched elements from the DOM.
(as opposed to Crawler::clear() which detaches the nodes only from Crawler
but leaves them in the DOM)
@api | [
"Remove",
"the",
"set",
"of",
"matched",
"elements",
"from",
"the",
"DOM",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L490-L501 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.removeAttribute | public function removeAttribute($name)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
if ($node->hasAttribute($name)) {
$node->removeAttribute($name);
}
}
}
... | php | public function removeAttribute($name)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
if ($node->hasAttribute($name)) {
$node->removeAttribute($name);
}
}
}
... | [
"public",
"function",
"removeAttribute",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"DOMElement",
")",
"{",
"/** @var \\DOMElement $node */",
"if",
"(",
"$",
"node",
"... | Remove an attribute from each element in the set of matched elements.
@param string $name
@return HtmlPageCrawler | [
"Remove",
"an",
"attribute",
"from",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L523-L534 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.removeClass | public function removeClass($name)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
$classes = preg_split('/\s+/s', $node->getAttribute('class'));
$count = count($classes);
for ($i = 0; ... | php | public function removeClass($name)
{
foreach ($this as $node) {
if ($node instanceof \DOMElement) {
/** @var \DOMElement $node */
$classes = preg_split('/\s+/s', $node->getAttribute('class'));
$count = count($classes);
for ($i = 0; ... | [
"public",
"function",
"removeClass",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"DOMElement",
")",
"{",
"/** @var \\DOMElement $node */",
"$",
"classes",
"=",
"preg_spli... | Remove a class from each element in the list
@param string $name
@return HtmlPageCrawler $this for chaining
@api | [
"Remove",
"a",
"class",
"from",
"each",
"element",
"in",
"the",
"list"
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L543-L559 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.replaceAll | public function replaceAll($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
/** @var \DOMNode $node */
$parent = $node->parentNode;
$refnode = $node->nextSibling;
foreach ($this as $j => $newnode) {
... | php | public function replaceAll($element)
{
$e = self::create($element);
$newnodes = array();
foreach ($e as $i => $node) {
/** @var \DOMNode $node */
$parent = $node->parentNode;
$refnode = $node->nextSibling;
foreach ($this as $j => $newnode) {
... | [
"public",
"function",
"replaceAll",
"(",
"$",
"element",
")",
"{",
"$",
"e",
"=",
"self",
"::",
"create",
"(",
"$",
"element",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"e",
"as",
"$",
"i",
"=>",
"$",
"node",
... | Replace each target element with the set of matched elements.
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $element
@return \Wa72\HtmlPageDom\HtmlPageCrawler A new Crawler object containing all elements appended to the target elements
@api | [
"Replace",
"each",
"target",
"element",
"with",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L568-L588 |
wasinger/htmlpagedom | src/HtmlPageCrawler.php | HtmlPageCrawler.replaceWith | public function replaceWith($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
/** @var \DOMNode $node */
$parent = $node->parentNode;
$refnode = $node->nextSibling;
foreach ($content as $j => ... | php | public function replaceWith($content)
{
$content = self::create($content);
$newnodes = array();
foreach ($this as $i => $node) {
/** @var \DOMNode $node */
$parent = $node->parentNode;
$refnode = $node->nextSibling;
foreach ($content as $j => ... | [
"public",
"function",
"replaceWith",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"self",
"::",
"create",
"(",
"$",
"content",
")",
";",
"$",
"newnodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"i",
"=>",
"$",
... | Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed.
@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $content
@return \Wa72\HtmlPageDom\HtmlPageCrawler $this for chaining
@api | [
"Replace",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"with",
"the",
"provided",
"new",
"content",
"and",
"return",
"the",
"set",
"of",
"elements",
"that",
"was",
"removed",
"."
] | train | https://github.com/wasinger/htmlpagedom/blob/d7b8854f695d30569d16f60d5c2e617b2b49789d/src/HtmlPageCrawler.php#L597-L619 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.