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
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
php-lug/lug
src/Bundle/RegistryBundle/Model/LazyRegistry.php
LazyRegistry.setLazy
public function setLazy($type, $service) { if ($this->hasLazy($type)) { throw new LazyServiceAlreadyExistsException(sprintf('The lazy service "%s" already exists.', $type)); } $this->services[$type] = $service; }
php
public function setLazy($type, $service) { if ($this->hasLazy($type)) { throw new LazyServiceAlreadyExistsException(sprintf('The lazy service "%s" already exists.', $type)); } $this->services[$type] = $service; }
[ "public", "function", "setLazy", "(", "$", "type", ",", "$", "service", ")", "{", "if", "(", "$", "this", "->", "hasLazy", "(", "$", "type", ")", ")", "{", "throw", "new", "LazyServiceAlreadyExistsException", "(", "sprintf", "(", "'The lazy service \"%s\" already exists.'", ",", "$", "type", ")", ")", ";", "}", "$", "this", "->", "services", "[", "$", "type", "]", "=", "$", "service", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/RegistryBundle/Model/LazyRegistry.php#L77-L84
php-lug/lug
src/Bundle/RegistryBundle/Model/LazyRegistry.php
LazyRegistry.removeLazy
public function removeLazy($type) { if (!$this->hasLazy($type)) { throw new LazyServiceNotFoundException(sprintf('The lazy service "%s" could not be found.', $type)); } unset($this->services[$type]); if (isset($this->registry[$type])) { unset($this->registry[$type]); } }
php
public function removeLazy($type) { if (!$this->hasLazy($type)) { throw new LazyServiceNotFoundException(sprintf('The lazy service "%s" could not be found.', $type)); } unset($this->services[$type]); if (isset($this->registry[$type])) { unset($this->registry[$type]); } }
[ "public", "function", "removeLazy", "(", "$", "type", ")", "{", "if", "(", "!", "$", "this", "->", "hasLazy", "(", "$", "type", ")", ")", "{", "throw", "new", "LazyServiceNotFoundException", "(", "sprintf", "(", "'The lazy service \"%s\" could not be found.'", ",", "$", "type", ")", ")", ";", "}", "unset", "(", "$", "this", "->", "services", "[", "$", "type", "]", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "registry", "[", "$", "type", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "registry", "[", "$", "type", "]", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/RegistryBundle/Model/LazyRegistry.php#L89-L100
php-lug/lug
src/Bundle/RegistryBundle/Model/LazyRegistry.php
LazyRegistry.offsetSet
public function offsetSet($offset, $value) { if ($this->hasLazy($offset)) { $this->lazyLoad($offset); } $this->registry[$offset] = $value; }
php
public function offsetSet($offset, $value) { if ($this->hasLazy($offset)) { $this->lazyLoad($offset); } $this->registry[$offset] = $value; }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "hasLazy", "(", "$", "offset", ")", ")", "{", "$", "this", "->", "lazyLoad", "(", "$", "offset", ")", ";", "}", "$", "this", "->", "registry", "[", "$", "offset", "]", "=", "$", "value", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/RegistryBundle/Model/LazyRegistry.php#L123-L130
php-lug/lug
src/Bundle/RegistryBundle/Model/LazyRegistry.php
LazyRegistry.offsetUnset
public function offsetUnset($offset) { if ($this->hasLazy($offset)) { $this->lazyLoad($offset); } unset($this->registry[$offset]); if ($this->hasLazy($offset)) { $this->removeLazy($offset); } }
php
public function offsetUnset($offset) { if ($this->hasLazy($offset)) { $this->lazyLoad($offset); } unset($this->registry[$offset]); if ($this->hasLazy($offset)) { $this->removeLazy($offset); } }
[ "public", "function", "offsetUnset", "(", "$", "offset", ")", "{", "if", "(", "$", "this", "->", "hasLazy", "(", "$", "offset", ")", ")", "{", "$", "this", "->", "lazyLoad", "(", "$", "offset", ")", ";", "}", "unset", "(", "$", "this", "->", "registry", "[", "$", "offset", "]", ")", ";", "if", "(", "$", "this", "->", "hasLazy", "(", "$", "offset", ")", ")", "{", "$", "this", "->", "removeLazy", "(", "$", "offset", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/RegistryBundle/Model/LazyRegistry.php#L135-L146
Danack/GithubArtaxService
lib/GithubService/Operation/getRepoArchiveLink.php
getRepoArchiveLink.call
public function call() { $request = $this->createRequest(); $response = $this->api->execute($request, $this); $this->response = $response; if ($this->shouldResponseBeProcessed($response)) { return $response->getBody(); } return $response; }
php
public function call() { $request = $this->createRequest(); $response = $this->api->execute($request, $this); $this->response = $response; if ($this->shouldResponseBeProcessed($response)) { return $response->getBody(); } return $response; }
[ "public", "function", "call", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequest", "(", ")", ";", "$", "response", "=", "$", "this", "->", "api", "->", "execute", "(", "$", "request", ",", "$", "this", ")", ";", "$", "this", "->", "response", "=", "$", "response", ";", "if", "(", "$", "this", "->", "shouldResponseBeProcessed", "(", "$", "response", ")", ")", "{", "return", "$", "response", "->", "getBody", "(", ")", ";", "}", "return", "$", "response", ";", "}" ]
Create and execute the operation, then return the processed response. @return mixed|\
[ "Create", "and", "execute", "the", "operation", "then", "return", "the", "processed", "response", "." ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/Operation/getRepoArchiveLink.php#L121-L130
Danack/GithubArtaxService
lib/GithubService/Operation/getRepoArchiveLink.php
getRepoArchiveLink.dispatch
public function dispatch(\Amp\Artax\Request $request) { $response = $this->api->execute($request, $this); $this->response = $response; return $response->getBody(); }
php
public function dispatch(\Amp\Artax\Request $request) { $response = $this->api->execute($request, $this); $this->response = $response; return $response->getBody(); }
[ "public", "function", "dispatch", "(", "\\", "Amp", "\\", "Artax", "\\", "Request", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "api", "->", "execute", "(", "$", "request", ",", "$", "this", ")", ";", "$", "this", "->", "response", "=", "$", "response", ";", "return", "$", "response", "->", "getBody", "(", ")", ";", "}" ]
Dispatch the request for this operation and process the response. Allows you to modify the request before it is sent. @return mixed @param \Amp\Artax\Request $request The request to be processed
[ "Dispatch", "the", "request", "for", "this", "operation", "and", "process", "the", "response", ".", "Allows", "you", "to", "modify", "the", "request", "before", "it", "is", "sent", "." ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/Operation/getRepoArchiveLink.php#L160-L164
alevilar/ristorantino-vendor
Printers/Lib/DriverView/Helper/PrinterHelperSkel.php
PrinterHelperSkel.cm
public function cm ($name){ $name = strtoupper($name); if (array_key_exists($name, $this->_cm)) { return $this->_cm[$name]; } CakeLog::write('debug',"no existe el comando $name para la funcion chr() configurado para esta impresora En los Helpers por modelo"); return ''; }
php
public function cm ($name){ $name = strtoupper($name); if (array_key_exists($name, $this->_cm)) { return $this->_cm[$name]; } CakeLog::write('debug',"no existe el comando $name para la funcion chr() configurado para esta impresora En los Helpers por modelo"); return ''; }
[ "public", "function", "cm", "(", "$", "name", ")", "{", "$", "name", "=", "strtoupper", "(", "$", "name", ")", ";", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "_cm", ")", ")", "{", "return", "$", "this", "->", "_cm", "[", "$", "name", "]", ";", "}", "CakeLog", "::", "write", "(", "'debug'", ",", "\"no existe el comando $name para la funcion chr() configurado para esta impresora En los Helpers por modelo\"", ")", ";", "return", "''", ";", "}" ]
Returns the string corresponding to the $_cmd var @param string $name @return string
[ "Returns", "the", "string", "corresponding", "to", "the", "$_cmd", "var" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/PrinterHelperSkel.php#L21-L30
maestroprog/saw-php
src/Standalone/Controller.php
Controller.start
public function start() { if (extension_loaded('pcntl')) { pcntl_signal(SIGINT, function ($sig) { $this->stop(); }); } if (false === file_put_contents($this->myPidFile, getmypid())) { throw new \RuntimeException('Cannot save the pid in pid file.'); } if (!$this->server->isConnected()) { throw new \Exception('Cannot start: not connected'); } $this->server->onFound($this->onConnectPeer()); register_shutdown_function(function () { $this->stop(); }); // $this->server->block(); $this->work(); }
php
public function start() { if (extension_loaded('pcntl')) { pcntl_signal(SIGINT, function ($sig) { $this->stop(); }); } if (false === file_put_contents($this->myPidFile, getmypid())) { throw new \RuntimeException('Cannot save the pid in pid file.'); } if (!$this->server->isConnected()) { throw new \Exception('Cannot start: not connected'); } $this->server->onFound($this->onConnectPeer()); register_shutdown_function(function () { $this->stop(); }); // $this->server->block(); $this->work(); }
[ "public", "function", "start", "(", ")", "{", "if", "(", "extension_loaded", "(", "'pcntl'", ")", ")", "{", "pcntl_signal", "(", "SIGINT", ",", "function", "(", "$", "sig", ")", "{", "$", "this", "->", "stop", "(", ")", ";", "}", ")", ";", "}", "if", "(", "false", "===", "file_put_contents", "(", "$", "this", "->", "myPidFile", ",", "getmypid", "(", ")", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Cannot save the pid in pid file.'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "server", "->", "isConnected", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Cannot start: not connected'", ")", ";", "}", "$", "this", "->", "server", "->", "onFound", "(", "$", "this", "->", "onConnectPeer", "(", ")", ")", ";", "register_shutdown_function", "(", "function", "(", ")", "{", "$", "this", "->", "stop", "(", ")", ";", "}", ")", ";", "// $this->server->block();", "$", "this", "->", "work", "(", ")", ";", "}" ]
Старт контроллера. @throws \Exception
[ "Старт", "контроллера", "." ]
train
https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Standalone/Controller.php#L66-L86
molbiodiv/biom-conversion-server
src/biomcs/BiomCS.php
BiomCS.executeBiomCommand
private function executeBiomCommand($parameter, $content) { $tempFile = tempnam(sys_get_temp_dir(), 'biomcs'); file_put_contents($tempFile, $content); $result = array(); $errorCode = 0; exec('biom convert -i '.escapeshellarg($tempFile). ' -o '.escapeshellarg($tempFile).'.out '.escapeshellarg($parameter)." 2>&1", $result, $errorCode); unlink($tempFile); if ($errorCode !== 0) { if (file_exists($tempFile.".out")) { // @codeCoverageIgnoreStart unlink($tempFile.".out"); // @codeCoverageIgnoreEnd } throw new \Exception("Error executing biom command: ".implode("\n", $result)." ".$errorCode); } $output = file_get_contents($tempFile.".out"); unlink($tempFile.".out"); return $output; }
php
private function executeBiomCommand($parameter, $content) { $tempFile = tempnam(sys_get_temp_dir(), 'biomcs'); file_put_contents($tempFile, $content); $result = array(); $errorCode = 0; exec('biom convert -i '.escapeshellarg($tempFile). ' -o '.escapeshellarg($tempFile).'.out '.escapeshellarg($parameter)." 2>&1", $result, $errorCode); unlink($tempFile); if ($errorCode !== 0) { if (file_exists($tempFile.".out")) { // @codeCoverageIgnoreStart unlink($tempFile.".out"); // @codeCoverageIgnoreEnd } throw new \Exception("Error executing biom command: ".implode("\n", $result)." ".$errorCode); } $output = file_get_contents($tempFile.".out"); unlink($tempFile.".out"); return $output; }
[ "private", "function", "executeBiomCommand", "(", "$", "parameter", ",", "$", "content", ")", "{", "$", "tempFile", "=", "tempnam", "(", "sys_get_temp_dir", "(", ")", ",", "'biomcs'", ")", ";", "file_put_contents", "(", "$", "tempFile", ",", "$", "content", ")", ";", "$", "result", "=", "array", "(", ")", ";", "$", "errorCode", "=", "0", ";", "exec", "(", "'biom convert -i '", ".", "escapeshellarg", "(", "$", "tempFile", ")", ".", "' -o '", ".", "escapeshellarg", "(", "$", "tempFile", ")", ".", "'.out '", ".", "escapeshellarg", "(", "$", "parameter", ")", ".", "\" 2>&1\"", ",", "$", "result", ",", "$", "errorCode", ")", ";", "unlink", "(", "$", "tempFile", ")", ";", "if", "(", "$", "errorCode", "!==", "0", ")", "{", "if", "(", "file_exists", "(", "$", "tempFile", ".", "\".out\"", ")", ")", "{", "// @codeCoverageIgnoreStart", "unlink", "(", "$", "tempFile", ".", "\".out\"", ")", ";", "// @codeCoverageIgnoreEnd", "}", "throw", "new", "\\", "Exception", "(", "\"Error executing biom command: \"", ".", "implode", "(", "\"\\n\"", ",", "$", "result", ")", ".", "\" \"", ".", "$", "errorCode", ")", ";", "}", "$", "output", "=", "file_get_contents", "(", "$", "tempFile", ".", "\".out\"", ")", ";", "unlink", "(", "$", "tempFile", ".", "\".out\"", ")", ";", "return", "$", "output", ";", "}" ]
Executes the biom command line tool with given parameter on the content (using temp files) and throws an exception if it fails @param $parameter string - parameters to pass to 'biom convert ' command beside -i and -o (handled by filename). e.g. "--to-json" or "--to-hdf5" @param $content string - content of a file @throws \Exception if the command fails @return string - content in the desired format
[ "Executes", "the", "biom", "command", "line", "tool", "with", "given", "parameter", "on", "the", "content", "(", "using", "temp", "files", ")", "and", "throws", "an", "exception", "if", "it", "fails" ]
train
https://github.com/molbiodiv/biom-conversion-server/blob/451cde2a05bd5c8c4b37a529e703c022b12e2472/src/biomcs/BiomCS.php#L36-L56
blast-project/BaseEntitiesBundle
src/EventListener/SortableListener.php
SortableListener.loadClassMetadata
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); $reflectionClass = $metadata->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Sortable')) { return; } // return if current entity doesn't use Sortable trait $this->logger->debug('[SortableListener] Entering SortableListener for « loadClassMetadata » event'); // setting default mapping configuration for Sortable // sortRank $metadata->mapField([ 'fieldName' => 'sortRank', 'type' => 'float', 'nullable' => false, 'default' => 65536, ]); // add index on sort_rank column if (!isset($metadata->table['indexes'])) { $metadata->table['indexes'] = []; } $metadata->table['indexes']['sort_rank'] = ['columns' => ['sort_rank']]; $this->logger->debug( '[SortableListener] Added Sortable mapping metadata to Entity', ['class' => $metadata->getName()] ); }
php
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); $reflectionClass = $metadata->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Sortable')) { return; } // return if current entity doesn't use Sortable trait $this->logger->debug('[SortableListener] Entering SortableListener for « loadClassMetadata » event'); // setting default mapping configuration for Sortable // sortRank $metadata->mapField([ 'fieldName' => 'sortRank', 'type' => 'float', 'nullable' => false, 'default' => 65536, ]); // add index on sort_rank column if (!isset($metadata->table['indexes'])) { $metadata->table['indexes'] = []; } $metadata->table['indexes']['sort_rank'] = ['columns' => ['sort_rank']]; $this->logger->debug( '[SortableListener] Added Sortable mapping metadata to Entity', ['class' => $metadata->getName()] ); }
[ "public", "function", "loadClassMetadata", "(", "LoadClassMetadataEventArgs", "$", "eventArgs", ")", "{", "/** @var ClassMetadata $metadata */", "$", "metadata", "=", "$", "eventArgs", "->", "getClassMetadata", "(", ")", ";", "$", "reflectionClass", "=", "$", "metadata", "->", "getReflectionClass", "(", ")", ";", "if", "(", "!", "$", "reflectionClass", "||", "!", "$", "this", "->", "hasTrait", "(", "$", "reflectionClass", ",", "'Blast\\BaseEntitiesBundle\\Entity\\Traits\\Sortable'", ")", ")", "{", "return", ";", "}", "// return if current entity doesn't use Sortable trait", "$", "this", "->", "logger", "->", "debug", "(", "'[SortableListener] Entering SortableListener for « loadClassMetadata » event');", "", "", "// setting default mapping configuration for Sortable", "// sortRank", "$", "metadata", "->", "mapField", "(", "[", "'fieldName'", "=>", "'sortRank'", ",", "'type'", "=>", "'float'", ",", "'nullable'", "=>", "false", ",", "'default'", "=>", "65536", ",", "]", ")", ";", "// add index on sort_rank column", "if", "(", "!", "isset", "(", "$", "metadata", "->", "table", "[", "'indexes'", "]", ")", ")", "{", "$", "metadata", "->", "table", "[", "'indexes'", "]", "=", "[", "]", ";", "}", "$", "metadata", "->", "table", "[", "'indexes'", "]", "[", "'sort_rank'", "]", "=", "[", "'columns'", "=>", "[", "'sort_rank'", "]", "]", ";", "$", "this", "->", "logger", "->", "debug", "(", "'[SortableListener] Added Sortable mapping metadata to Entity'", ",", "[", "'class'", "=>", "$", "metadata", "->", "getName", "(", ")", "]", ")", ";", "}" ]
define Sortable mapping at runtime. @param LoadClassMetadataEventArgs $eventArgs
[ "define", "Sortable", "mapping", "at", "runtime", "." ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/EventListener/SortableListener.php#L47-L78
blast-project/BaseEntitiesBundle
src/EventListener/SortableListener.php
SortableListener.prePersist
public function prePersist(EventArgs $args) { $em = $args->getEntityManager(); $object = $args->getObject(); $class = get_class($object); $meta = $em->getClassMetadata($class); $reflectionClass = $meta->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Sortable')) { return; } // return if current entity doesn't use Sortable trait if ($object->getSortRank()) { return; } $maxPos = $this->getMaxPosition($em, $meta); $maxPos = $maxPos ? $maxPos + 1000 : 65536; $object->setSortRank($maxPos); $this->maxPositions[$class] = $maxPos; }
php
public function prePersist(EventArgs $args) { $em = $args->getEntityManager(); $object = $args->getObject(); $class = get_class($object); $meta = $em->getClassMetadata($class); $reflectionClass = $meta->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Sortable')) { return; } // return if current entity doesn't use Sortable trait if ($object->getSortRank()) { return; } $maxPos = $this->getMaxPosition($em, $meta); $maxPos = $maxPos ? $maxPos + 1000 : 65536; $object->setSortRank($maxPos); $this->maxPositions[$class] = $maxPos; }
[ "public", "function", "prePersist", "(", "EventArgs", "$", "args", ")", "{", "$", "em", "=", "$", "args", "->", "getEntityManager", "(", ")", ";", "$", "object", "=", "$", "args", "->", "getObject", "(", ")", ";", "$", "class", "=", "get_class", "(", "$", "object", ")", ";", "$", "meta", "=", "$", "em", "->", "getClassMetadata", "(", "$", "class", ")", ";", "$", "reflectionClass", "=", "$", "meta", "->", "getReflectionClass", "(", ")", ";", "if", "(", "!", "$", "reflectionClass", "||", "!", "$", "this", "->", "hasTrait", "(", "$", "reflectionClass", ",", "'Blast\\BaseEntitiesBundle\\Entity\\Traits\\Sortable'", ")", ")", "{", "return", ";", "}", "// return if current entity doesn't use Sortable trait", "if", "(", "$", "object", "->", "getSortRank", "(", ")", ")", "{", "return", ";", "}", "$", "maxPos", "=", "$", "this", "->", "getMaxPosition", "(", "$", "em", ",", "$", "meta", ")", ";", "$", "maxPos", "=", "$", "maxPos", "?", "$", "maxPos", "+", "1000", ":", "65536", ";", "$", "object", "->", "setSortRank", "(", "$", "maxPos", ")", ";", "$", "this", "->", "maxPositions", "[", "$", "class", "]", "=", "$", "maxPos", ";", "}" ]
Compute sortRank for entities that are created. @param EventArgs $args
[ "Compute", "sortRank", "for", "entities", "that", "are", "created", "." ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/EventListener/SortableListener.php#L85-L107
odiaseo/pagebuilder
src/PageBuilder/Model/ResourceModel.php
ResourceModel.getGenericResources
public function getGenericResources($limit = 10, $mode = AbstractQuery::HYDRATE_OBJECT) { $builder = $this->getEntityManager()->createQueryBuilder(); $builder->select('e') ->from($this->getEntity(), 'e') ->where('e.isGeneric = 1') ->setMaxResults($limit); $query = LocaleAwareTrait::addHints($builder->getQuery()); return $query->execute($mode); }
php
public function getGenericResources($limit = 10, $mode = AbstractQuery::HYDRATE_OBJECT) { $builder = $this->getEntityManager()->createQueryBuilder(); $builder->select('e') ->from($this->getEntity(), 'e') ->where('e.isGeneric = 1') ->setMaxResults($limit); $query = LocaleAwareTrait::addHints($builder->getQuery()); return $query->execute($mode); }
[ "public", "function", "getGenericResources", "(", "$", "limit", "=", "10", ",", "$", "mode", "=", "AbstractQuery", "::", "HYDRATE_OBJECT", ")", "{", "$", "builder", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "createQueryBuilder", "(", ")", ";", "$", "builder", "->", "select", "(", "'e'", ")", "->", "from", "(", "$", "this", "->", "getEntity", "(", ")", ",", "'e'", ")", "->", "where", "(", "'e.isGeneric = 1'", ")", "->", "setMaxResults", "(", "$", "limit", ")", ";", "$", "query", "=", "LocaleAwareTrait", "::", "addHints", "(", "$", "builder", "->", "getQuery", "(", ")", ")", ";", "return", "$", "query", "->", "execute", "(", "$", "mode", ")", ";", "}" ]
List Generic Resources @param int $limit @param int $mode @return mixed
[ "List", "Generic", "Resources" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/ResourceModel.php#L26-L38
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/Commands/LaravelSeederAllCommand.php
LaravelSeederAllCommand.fire
public function fire() { $seeder = $this->getLaravelSeeder(); $seeder->all(); $this->call('db:seed'); $seeder->restore(); if ($seeder->getSeeded() == 0) { $this->info('No seeders were ran!'); } }
php
public function fire() { $seeder = $this->getLaravelSeeder(); $seeder->all(); $this->call('db:seed'); $seeder->restore(); if ($seeder->getSeeded() == 0) { $this->info('No seeders were ran!'); } }
[ "public", "function", "fire", "(", ")", "{", "$", "seeder", "=", "$", "this", "->", "getLaravelSeeder", "(", ")", ";", "$", "seeder", "->", "all", "(", ")", ";", "$", "this", "->", "call", "(", "'db:seed'", ")", ";", "$", "seeder", "->", "restore", "(", ")", ";", "if", "(", "$", "seeder", "->", "getSeeded", "(", ")", "==", "0", ")", "{", "$", "this", "->", "info", "(", "'No seeders were ran!'", ")", ";", "}", "}" ]
Execute the console command. @return mixed
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/Commands/LaravelSeederAllCommand.php#L65-L79
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/Routers/ExceptionRouter.php
ExceptionRouter.handleException
private function handleException(\Throwable $t, Request $request) { if ($this->log !== null) { $this->log->error('Exception thrown inside a controller.', array( 'exception' => $t, )); } else { // If no logger is set, let's log in PHP error_log error_log($t->getMessage().' - '.$t->getTraceAsString()); } $response = SplashUtils::buildControllerResponse( function () use ($t, $request) { return $this->errorController->serverError($t, $request); } ); return $response; }
php
private function handleException(\Throwable $t, Request $request) { if ($this->log !== null) { $this->log->error('Exception thrown inside a controller.', array( 'exception' => $t, )); } else { // If no logger is set, let's log in PHP error_log error_log($t->getMessage().' - '.$t->getTraceAsString()); } $response = SplashUtils::buildControllerResponse( function () use ($t, $request) { return $this->errorController->serverError($t, $request); } ); return $response; }
[ "private", "function", "handleException", "(", "\\", "Throwable", "$", "t", ",", "Request", "$", "request", ")", "{", "if", "(", "$", "this", "->", "log", "!==", "null", ")", "{", "$", "this", "->", "log", "->", "error", "(", "'Exception thrown inside a controller.'", ",", "array", "(", "'exception'", "=>", "$", "t", ",", ")", ")", ";", "}", "else", "{", "// If no logger is set, let's log in PHP error_log", "error_log", "(", "$", "t", "->", "getMessage", "(", ")", ".", "' - '", ".", "$", "t", "->", "getTraceAsString", "(", ")", ")", ";", "}", "$", "response", "=", "SplashUtils", "::", "buildControllerResponse", "(", "function", "(", ")", "use", "(", "$", "t", ",", "$", "request", ")", "{", "return", "$", "this", "->", "errorController", "->", "serverError", "(", "$", "t", ",", "$", "request", ")", ";", "}", ")", ";", "return", "$", "response", ";", "}" ]
Actually handle the exception. @param \Throwable $t @param Request $request @return ResponseInterface
[ "Actually", "handle", "the", "exception", "." ]
train
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Routers/ExceptionRouter.php#L55-L73
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/Routers/ExceptionRouter.php
ExceptionRouter.process
public function process(Request $request, RequestHandlerInterface $delegate): ResponseInterface { try { return $delegate->handle($request); } catch (\Throwable $t) { return $this->handleException($t, $request); } }
php
public function process(Request $request, RequestHandlerInterface $delegate): ResponseInterface { try { return $delegate->handle($request); } catch (\Throwable $t) { return $this->handleException($t, $request); } }
[ "public", "function", "process", "(", "Request", "$", "request", ",", "RequestHandlerInterface", "$", "delegate", ")", ":", "ResponseInterface", "{", "try", "{", "return", "$", "delegate", "->", "handle", "(", "$", "request", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "t", ")", "{", "return", "$", "this", "->", "handleException", "(", "$", "t", ",", "$", "request", ")", ";", "}", "}" ]
Process an incoming server request and return a response, optionally delegating to the next middleware component to create the response. @param Request $request @param RequestHandlerInterface $delegate @return Response
[ "Process", "an", "incoming", "server", "request", "and", "return", "a", "response", "optionally", "delegating", "to", "the", "next", "middleware", "component", "to", "create", "the", "response", "." ]
train
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Routers/ExceptionRouter.php#L84-L91
php-lug/lug
src/Component/Locale/Form/Type/LocaleType.php
LocaleType.buildForm
public function buildForm(FormBuilderInterface $builder, array $options) { $childOptions = ['disabled' => $builder->getData() === $this->localeProvider->getDefaultLocale()]; $builder ->add('code', LocaleCodeType::class, $childOptions) ->add('enabled', CheckboxType::class, array_merge( ['invalid_message' => 'lug.locale.enabled.invalid'], $childOptions )) ->add('required', CheckboxType::class, array_merge( ['invalid_message' => 'lug.locale.required.invalid'], $childOptions )) ->add('submit', SubmitType::class); }
php
public function buildForm(FormBuilderInterface $builder, array $options) { $childOptions = ['disabled' => $builder->getData() === $this->localeProvider->getDefaultLocale()]; $builder ->add('code', LocaleCodeType::class, $childOptions) ->add('enabled', CheckboxType::class, array_merge( ['invalid_message' => 'lug.locale.enabled.invalid'], $childOptions )) ->add('required', CheckboxType::class, array_merge( ['invalid_message' => 'lug.locale.required.invalid'], $childOptions )) ->add('submit', SubmitType::class); }
[ "public", "function", "buildForm", "(", "FormBuilderInterface", "$", "builder", ",", "array", "$", "options", ")", "{", "$", "childOptions", "=", "[", "'disabled'", "=>", "$", "builder", "->", "getData", "(", ")", "===", "$", "this", "->", "localeProvider", "->", "getDefaultLocale", "(", ")", "]", ";", "$", "builder", "->", "add", "(", "'code'", ",", "LocaleCodeType", "::", "class", ",", "$", "childOptions", ")", "->", "add", "(", "'enabled'", ",", "CheckboxType", "::", "class", ",", "array_merge", "(", "[", "'invalid_message'", "=>", "'lug.locale.enabled.invalid'", "]", ",", "$", "childOptions", ")", ")", "->", "add", "(", "'required'", ",", "CheckboxType", "::", "class", ",", "array_merge", "(", "[", "'invalid_message'", "=>", "'lug.locale.required.invalid'", "]", ",", "$", "childOptions", ")", ")", "->", "add", "(", "'submit'", ",", "SubmitType", "::", "class", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Locale/Form/Type/LocaleType.php#L50-L65
alevilar/ristorantino-vendor
Mesa/Controller/MesasController.php
MesasController.cerrarMesa
public function cerrarMesa ( $mesa_id, $imprimir_ticket = true) { $this->Mesa->id = $mesa_id; if( !$this->Mesa->cerrar_mesa() ) { if( !$this->request->is('ajax') ){ $this->setFlash('Error al cerrar la mesa', 'flash_error'); } } if( !$this->request->is('ajax') ){ $this->redirect( $this->referer() ); } }
php
public function cerrarMesa ( $mesa_id, $imprimir_ticket = true) { $this->Mesa->id = $mesa_id; if( !$this->Mesa->cerrar_mesa() ) { if( !$this->request->is('ajax') ){ $this->setFlash('Error al cerrar la mesa', 'flash_error'); } } if( !$this->request->is('ajax') ){ $this->redirect( $this->referer() ); } }
[ "public", "function", "cerrarMesa", "(", "$", "mesa_id", ",", "$", "imprimir_ticket", "=", "true", ")", "{", "$", "this", "->", "Mesa", "->", "id", "=", "$", "mesa_id", ";", "if", "(", "!", "$", "this", "->", "Mesa", "->", "cerrar_mesa", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "request", "->", "is", "(", "'ajax'", ")", ")", "{", "$", "this", "->", "setFlash", "(", "'Error al cerrar la mesa'", ",", "'flash_error'", ")", ";", "}", "}", "if", "(", "!", "$", "this", "->", "request", "->", "is", "(", "'ajax'", ")", ")", "{", "$", "this", "->", "redirect", "(", "$", "this", "->", "referer", "(", ")", ")", ";", "}", "}" ]
Cierra la mesa, calculando el total y, si se lo indica, imprime el ticket fiscal. @param type $mesa_id @param type $imprimir_ticket @return type
[ "Cierra", "la", "mesa", "calculando", "el", "total", "y", "si", "se", "lo", "indica", "imprime", "el", "ticket", "fiscal", "." ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Controller/MesasController.php#L128-L140
alevilar/ristorantino-vendor
Mesa/Controller/MesasController.php
MesasController.ajax_edit
function ajax_edit() { $this->autoRender = false; $returnFlag = 1; if (!empty($this->request->data)) { if(isset($this->request->data['Mesa']['id'])) { if(($this->request->data['Mesa']['id'] != '') || ($this->request->data['Mesa']['id'] != null) || ($this->request->data['Mesa']['id'] != 0)) { $this->Mesa->recursive = -1; $this->Mesa->id = $this->request->data['Mesa']['id']; foreach($this->request->data['Mesa'] as $field=>$valor): if($field == 'id') continue;// el id no lo tengo que actualizar $valor = (strtolower($valor) == 'now()') ? date('Y-m-d H:i:s') : $valor; if (!$this->Mesa->saveField($field, $valor, $validate = true)) { debug($this->Mesa->validationErrors); throw new InternalErrorException("Error de Validacion al guardar"); header("HTTP/1.0 500 Internal Server Error"); if($returnFlag == 1){ $returnFlag = 0; } $returnFlag--; } endforeach; } } else { throw new InternalErrorException("Id de Mesa vino vacio"); } } else { throw new InternalErrorException("data vino vacio"); } exit; }
php
function ajax_edit() { $this->autoRender = false; $returnFlag = 1; if (!empty($this->request->data)) { if(isset($this->request->data['Mesa']['id'])) { if(($this->request->data['Mesa']['id'] != '') || ($this->request->data['Mesa']['id'] != null) || ($this->request->data['Mesa']['id'] != 0)) { $this->Mesa->recursive = -1; $this->Mesa->id = $this->request->data['Mesa']['id']; foreach($this->request->data['Mesa'] as $field=>$valor): if($field == 'id') continue;// el id no lo tengo que actualizar $valor = (strtolower($valor) == 'now()') ? date('Y-m-d H:i:s') : $valor; if (!$this->Mesa->saveField($field, $valor, $validate = true)) { debug($this->Mesa->validationErrors); throw new InternalErrorException("Error de Validacion al guardar"); header("HTTP/1.0 500 Internal Server Error"); if($returnFlag == 1){ $returnFlag = 0; } $returnFlag--; } endforeach; } } else { throw new InternalErrorException("Id de Mesa vino vacio"); } } else { throw new InternalErrorException("data vino vacio"); } exit; }
[ "function", "ajax_edit", "(", ")", "{", "$", "this", "->", "autoRender", "=", "false", ";", "$", "returnFlag", "=", "1", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "request", "->", "data", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "request", "->", "data", "[", "'Mesa'", "]", "[", "'id'", "]", ")", ")", "{", "if", "(", "(", "$", "this", "->", "request", "->", "data", "[", "'Mesa'", "]", "[", "'id'", "]", "!=", "''", ")", "||", "(", "$", "this", "->", "request", "->", "data", "[", "'Mesa'", "]", "[", "'id'", "]", "!=", "null", ")", "||", "(", "$", "this", "->", "request", "->", "data", "[", "'Mesa'", "]", "[", "'id'", "]", "!=", "0", ")", ")", "{", "$", "this", "->", "Mesa", "->", "recursive", "=", "-", "1", ";", "$", "this", "->", "Mesa", "->", "id", "=", "$", "this", "->", "request", "->", "data", "[", "'Mesa'", "]", "[", "'id'", "]", ";", "foreach", "(", "$", "this", "->", "request", "->", "data", "[", "'Mesa'", "]", "as", "$", "field", "=>", "$", "valor", ")", ":", "if", "(", "$", "field", "==", "'id'", ")", "continue", ";", "// el id no lo tengo que actualizar", "$", "valor", "=", "(", "strtolower", "(", "$", "valor", ")", "==", "'now()'", ")", "?", "date", "(", "'Y-m-d H:i:s'", ")", ":", "$", "valor", ";", "if", "(", "!", "$", "this", "->", "Mesa", "->", "saveField", "(", "$", "field", ",", "$", "valor", ",", "$", "validate", "=", "true", ")", ")", "{", "debug", "(", "$", "this", "->", "Mesa", "->", "validationErrors", ")", ";", "throw", "new", "InternalErrorException", "(", "\"Error de Validacion al guardar\"", ")", ";", "header", "(", "\"HTTP/1.0 500 Internal Server Error\"", ")", ";", "if", "(", "$", "returnFlag", "==", "1", ")", "{", "$", "returnFlag", "=", "0", ";", "}", "$", "returnFlag", "--", ";", "}", "endforeach", ";", "}", "}", "else", "{", "throw", "new", "InternalErrorException", "(", "\"Id de Mesa vino vacio\"", ")", ";", "}", "}", "else", "{", "throw", "new", "InternalErrorException", "(", "\"data vino vacio\"", ")", ";", "}", "exit", ";", "}" ]
Esta accion edita cualquiera de los campos de la mesa, pero hay que pasar en la variabla $this->request->data el ID de la mesa si o si para que funcione @return boolean 1 on success 0 fail
[ "Esta", "accion", "edita", "cualquiera", "de", "los", "campos", "de", "la", "mesa", "pero", "hay", "que", "pasar", "en", "la", "variabla", "$this", "-", ">", "request", "-", ">", "data", "el", "ID", "de", "la", "mesa", "si", "o", "si", "para", "que", "funcione" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Controller/MesasController.php#L151-L183
alevilar/ristorantino-vendor
Mesa/Controller/MesasController.php
MesasController.checkout
public function checkout ( $id ) { if ( $this->Mesa->checkout( $id ) ) { if ( !$this->request->is('ajax') ) { $this->Session->setFlash( __('Se hizo checkout de la %s', Configure::read('Mesa.tituloMesa') ), 'Risto.flash_success'); $this->redirect($this->referer()); } else { exit(0); } } else { throw new CakeException(__("Falló al reabrir la mesa")); } }
php
public function checkout ( $id ) { if ( $this->Mesa->checkout( $id ) ) { if ( !$this->request->is('ajax') ) { $this->Session->setFlash( __('Se hizo checkout de la %s', Configure::read('Mesa.tituloMesa') ), 'Risto.flash_success'); $this->redirect($this->referer()); } else { exit(0); } } else { throw new CakeException(__("Falló al reabrir la mesa")); } }
[ "public", "function", "checkout", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "Mesa", "->", "checkout", "(", "$", "id", ")", ")", "{", "if", "(", "!", "$", "this", "->", "request", "->", "is", "(", "'ajax'", ")", ")", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "__", "(", "'Se hizo checkout de la %s'", ",", "Configure", "::", "read", "(", "'Mesa.tituloMesa'", ")", ")", ",", "'Risto.flash_success'", ")", ";", "$", "this", "->", "redirect", "(", "$", "this", "->", "referer", "(", ")", ")", ";", "}", "else", "{", "exit", "(", "0", ")", ";", "}", "}", "else", "{", "throw", "new", "CakeException", "(", "__", "(", "\"Falló al reabrir la mesa\")", ")", ";", "", "}", "}" ]
/* public function abiertas() { $options = array( 'conditions' => array( "Mesa.estado_id" => MESA_ABIERTA, ), 'order' => 'Mesa.created DESC', 'contain' => array( 'Mozo', 'Cliente' => 'Descuento', 'Comanda' ) ); $mesas = $this->Mesa->find('all', $options); $this->set('mesas', $mesas); $this->render('mesas'); }
[ "/", "*", "public", "function", "abiertas", "()", "{", "$options", "=", "array", "(", "conditions", "=", ">", "array", "(", "Mesa", ".", "estado_id", "=", ">", "MESA_ABIERTA", ")", "order", "=", ">", "Mesa", ".", "created", "DESC", "contain", "=", ">", "array", "(", "Mozo", "Cliente", "=", ">", "Descuento", "Comanda", ")", ")", ";" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Controller/MesasController.php#L358-L370
expectation-php/expect
src/matcher/ToBeWithin.php
ToBeWithin.match
public function match($actual) { $this->actual = $actual; return ($this->actual >= $this->from && $this->actual <= $this->to); }
php
public function match($actual) { $this->actual = $actual; return ($this->actual >= $this->from && $this->actual <= $this->to); }
[ "public", "function", "match", "(", "$", "actual", ")", "{", "$", "this", "->", "actual", "=", "$", "actual", ";", "return", "(", "$", "this", "->", "actual", ">=", "$", "this", "->", "from", "&&", "$", "this", "->", "actual", "<=", "$", "this", "->", "to", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToBeWithin.php#L58-L63
expectation-php/expect
src/matcher/ToBeWithin.php
ToBeWithin.reportFailed
public function reportFailed(FailedMessage $message) { $message->appendText('Expected ') ->appendValue($this->actual) ->appendText(' to be within '); $this->appendRange($message); }
php
public function reportFailed(FailedMessage $message) { $message->appendText('Expected ') ->appendValue($this->actual) ->appendText(' to be within '); $this->appendRange($message); }
[ "public", "function", "reportFailed", "(", "FailedMessage", "$", "message", ")", "{", "$", "message", "->", "appendText", "(", "'Expected '", ")", "->", "appendValue", "(", "$", "this", "->", "actual", ")", "->", "appendText", "(", "' to be within '", ")", ";", "$", "this", "->", "appendRange", "(", "$", "message", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToBeWithin.php#L68-L75
expectation-php/expect
src/matcher/ToBeWithin.php
ToBeWithin.reportNegativeFailed
public function reportNegativeFailed(FailedMessage $message) { $message->appendText('Expected ') ->appendValue($this->actual) ->appendText(' not to be within '); $this->appendRange($message); }
php
public function reportNegativeFailed(FailedMessage $message) { $message->appendText('Expected ') ->appendValue($this->actual) ->appendText(' not to be within '); $this->appendRange($message); }
[ "public", "function", "reportNegativeFailed", "(", "FailedMessage", "$", "message", ")", "{", "$", "message", "->", "appendText", "(", "'Expected '", ")", "->", "appendValue", "(", "$", "this", "->", "actual", ")", "->", "appendText", "(", "' not to be within '", ")", ";", "$", "this", "->", "appendRange", "(", "$", "message", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToBeWithin.php#L80-L87
webandco/neos-wireframe
Classes/ViewHelpers/RenderBoxViewHelper.php
RenderBoxViewHelper.render
public function render($mode, $node) { return ($mode > 0 || $node->hasProperty('renderBox') == false || $node->getProperty('renderBox') === null || $node->getProperty('renderBox') === true) ? true : false; }
php
public function render($mode, $node) { return ($mode > 0 || $node->hasProperty('renderBox') == false || $node->getProperty('renderBox') === null || $node->getProperty('renderBox') === true) ? true : false; }
[ "public", "function", "render", "(", "$", "mode", ",", "$", "node", ")", "{", "return", "(", "$", "mode", ">", "0", "||", "$", "node", "->", "hasProperty", "(", "'renderBox'", ")", "==", "false", "||", "$", "node", "->", "getProperty", "(", "'renderBox'", ")", "===", "null", "||", "$", "node", "->", "getProperty", "(", "'renderBox'", ")", "===", "true", ")", "?", "true", ":", "false", ";", "}" ]
Decide if box should be rendered or not based on renderMode and node properties @param integer $mode Value to check @param NodeInterface $node @return boolean
[ "Decide", "if", "box", "should", "be", "rendered", "or", "not", "based", "on", "renderMode", "and", "node", "properties" ]
train
https://github.com/webandco/neos-wireframe/blob/b1dfd9bedee80001a9a0cf0f483d0261633d12cb/Classes/ViewHelpers/RenderBoxViewHelper.php#L19-L21
php-lug/lug
src/Component/Grid/Model/Builder/ActionBuilder.php
ActionBuilder.build
public function build(array $config) { return new Action( $this->buildName($config), $this->buildLabel($config), $this->buildType($config), $this->buildOptions($config) ); }
php
public function build(array $config) { return new Action( $this->buildName($config), $this->buildLabel($config), $this->buildType($config), $this->buildOptions($config) ); }
[ "public", "function", "build", "(", "array", "$", "config", ")", "{", "return", "new", "Action", "(", "$", "this", "->", "buildName", "(", "$", "config", ")", ",", "$", "this", "->", "buildLabel", "(", "$", "config", ")", ",", "$", "this", "->", "buildType", "(", "$", "config", ")", ",", "$", "this", "->", "buildOptions", "(", "$", "config", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Builder/ActionBuilder.php#L25-L33
alevilar/ristorantino-vendor
Printers/Controller/PrintersController.php
PrintersController.index
public function index() { $this->Printer->recursive = 0; $impresoras = $this->Paginator->paginate(); $impresorasModificadas = array(); foreach( $impresoras as $imp ) { // por cada impresora, le agrego la cantidad de productos relacionados que tiene $printerId = $imp['Printer']['id']; $cant = $this->Printer->cantidadDeProductosEnImpresora($printerId); $imp['Printer']['cantidad_productos'] = $cant; $impresorasModificadas[] = $imp; } $this->set('printers', $impresorasModificadas); }
php
public function index() { $this->Printer->recursive = 0; $impresoras = $this->Paginator->paginate(); $impresorasModificadas = array(); foreach( $impresoras as $imp ) { // por cada impresora, le agrego la cantidad de productos relacionados que tiene $printerId = $imp['Printer']['id']; $cant = $this->Printer->cantidadDeProductosEnImpresora($printerId); $imp['Printer']['cantidad_productos'] = $cant; $impresorasModificadas[] = $imp; } $this->set('printers', $impresorasModificadas); }
[ "public", "function", "index", "(", ")", "{", "$", "this", "->", "Printer", "->", "recursive", "=", "0", ";", "$", "impresoras", "=", "$", "this", "->", "Paginator", "->", "paginate", "(", ")", ";", "$", "impresorasModificadas", "=", "array", "(", ")", ";", "foreach", "(", "$", "impresoras", "as", "$", "imp", ")", "{", "// por cada impresora, le agrego la cantidad de productos relacionados que tiene", "$", "printerId", "=", "$", "imp", "[", "'Printer'", "]", "[", "'id'", "]", ";", "$", "cant", "=", "$", "this", "->", "Printer", "->", "cantidadDeProductosEnImpresora", "(", "$", "printerId", ")", ";", "$", "imp", "[", "'Printer'", "]", "[", "'cantidad_productos'", "]", "=", "$", "cant", ";", "$", "impresorasModificadas", "[", "]", "=", "$", "imp", ";", "}", "$", "this", "->", "set", "(", "'printers'", ",", "$", "impresorasModificadas", ")", ";", "}" ]
index method @return void
[ "index", "method" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Controller/PrintersController.php#L59-L74
alevilar/ristorantino-vendor
Printers/Controller/PrintersController.php
PrintersController.view
public function view($id = null) { if (!$this->Printer->exists($id)) { throw new NotFoundException(__('Invalid printer')); } $options = array('conditions' => array('Printer.' . $this->Printer->primaryKey => $id)); $this->set('printer', $this->Printer->find('first', $options)); }
php
public function view($id = null) { if (!$this->Printer->exists($id)) { throw new NotFoundException(__('Invalid printer')); } $options = array('conditions' => array('Printer.' . $this->Printer->primaryKey => $id)); $this->set('printer', $this->Printer->find('first', $options)); }
[ "public", "function", "view", "(", "$", "id", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "Printer", "->", "exists", "(", "$", "id", ")", ")", "{", "throw", "new", "NotFoundException", "(", "__", "(", "'Invalid printer'", ")", ")", ";", "}", "$", "options", "=", "array", "(", "'conditions'", "=>", "array", "(", "'Printer.'", ".", "$", "this", "->", "Printer", "->", "primaryKey", "=>", "$", "id", ")", ")", ";", "$", "this", "->", "set", "(", "'printer'", ",", "$", "this", "->", "Printer", "->", "find", "(", "'first'", ",", "$", "options", ")", ")", ";", "}" ]
view method @throws NotFoundException @param string $id @return void
[ "view", "method" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Controller/PrintersController.php#L83-L89
alevilar/ristorantino-vendor
Printers/Controller/PrintersController.php
PrintersController.add
public function add() { if ($this->request->is('post')) { $this->Printer->create(); if ($this->Printer->save($this->request->data)) { $this->Session->setFlash(__('The printer has been saved.')); return $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The printer could not be saved. Please, try again.')); } } $this->request->data['Printer']['output'] = Configure::read('Printers.output'); $this->set('drivers', $this->drivers ); $this->set('driverModels', $this->driver_models); $this->set('outputs', $this->outputs); }
php
public function add() { if ($this->request->is('post')) { $this->Printer->create(); if ($this->Printer->save($this->request->data)) { $this->Session->setFlash(__('The printer has been saved.')); return $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The printer could not be saved. Please, try again.')); } } $this->request->data['Printer']['output'] = Configure::read('Printers.output'); $this->set('drivers', $this->drivers ); $this->set('driverModels', $this->driver_models); $this->set('outputs', $this->outputs); }
[ "public", "function", "add", "(", ")", "{", "if", "(", "$", "this", "->", "request", "->", "is", "(", "'post'", ")", ")", "{", "$", "this", "->", "Printer", "->", "create", "(", ")", ";", "if", "(", "$", "this", "->", "Printer", "->", "save", "(", "$", "this", "->", "request", "->", "data", ")", ")", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "__", "(", "'The printer has been saved.'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "array", "(", "'action'", "=>", "'index'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "__", "(", "'The printer could not be saved. Please, try again.'", ")", ")", ";", "}", "}", "$", "this", "->", "request", "->", "data", "[", "'Printer'", "]", "[", "'output'", "]", "=", "Configure", "::", "read", "(", "'Printers.output'", ")", ";", "$", "this", "->", "set", "(", "'drivers'", ",", "$", "this", "->", "drivers", ")", ";", "$", "this", "->", "set", "(", "'driverModels'", ",", "$", "this", "->", "driver_models", ")", ";", "$", "this", "->", "set", "(", "'outputs'", ",", "$", "this", "->", "outputs", ")", ";", "}" ]
add method @return void
[ "add", "method" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Controller/PrintersController.php#L96-L111
alevilar/ristorantino-vendor
Printers/Controller/PrintersController.php
PrintersController.edit
public function edit($id = null) { if (!$this->Printer->exists($id)) { throw new NotFoundException(__('Invalid printer')); } if ($this->request->is(array('post', 'put'))) { if ($this->Printer->save($this->request->data)) { $this->Session->setFlash(__('The printer has been saved.')); return $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The printer could not be saved. Please, try again.')); } } else { $options = array( 'conditions' => array('Printer.' . $this->Printer->primaryKey => $id), 'recursive' => -1, ); $this->request->data = $this->Printer->find('first', $options); } if (empty( $this->request->data['Printer']['output'] ) ) { $this->request->data['Printer']['output'] = Configure::read('Printers.output'); } $this->set('drivers', $this->drivers ); $this->set('driverModels', $this->driver_models); $this->set('outputs', $this->outputs); }
php
public function edit($id = null) { if (!$this->Printer->exists($id)) { throw new NotFoundException(__('Invalid printer')); } if ($this->request->is(array('post', 'put'))) { if ($this->Printer->save($this->request->data)) { $this->Session->setFlash(__('The printer has been saved.')); return $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The printer could not be saved. Please, try again.')); } } else { $options = array( 'conditions' => array('Printer.' . $this->Printer->primaryKey => $id), 'recursive' => -1, ); $this->request->data = $this->Printer->find('first', $options); } if (empty( $this->request->data['Printer']['output'] ) ) { $this->request->data['Printer']['output'] = Configure::read('Printers.output'); } $this->set('drivers', $this->drivers ); $this->set('driverModels', $this->driver_models); $this->set('outputs', $this->outputs); }
[ "public", "function", "edit", "(", "$", "id", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "Printer", "->", "exists", "(", "$", "id", ")", ")", "{", "throw", "new", "NotFoundException", "(", "__", "(", "'Invalid printer'", ")", ")", ";", "}", "if", "(", "$", "this", "->", "request", "->", "is", "(", "array", "(", "'post'", ",", "'put'", ")", ")", ")", "{", "if", "(", "$", "this", "->", "Printer", "->", "save", "(", "$", "this", "->", "request", "->", "data", ")", ")", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "__", "(", "'The printer has been saved.'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "array", "(", "'action'", "=>", "'index'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "__", "(", "'The printer could not be saved. Please, try again.'", ")", ")", ";", "}", "}", "else", "{", "$", "options", "=", "array", "(", "'conditions'", "=>", "array", "(", "'Printer.'", ".", "$", "this", "->", "Printer", "->", "primaryKey", "=>", "$", "id", ")", ",", "'recursive'", "=>", "-", "1", ",", ")", ";", "$", "this", "->", "request", "->", "data", "=", "$", "this", "->", "Printer", "->", "find", "(", "'first'", ",", "$", "options", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "request", "->", "data", "[", "'Printer'", "]", "[", "'output'", "]", ")", ")", "{", "$", "this", "->", "request", "->", "data", "[", "'Printer'", "]", "[", "'output'", "]", "=", "Configure", "::", "read", "(", "'Printers.output'", ")", ";", "}", "$", "this", "->", "set", "(", "'drivers'", ",", "$", "this", "->", "drivers", ")", ";", "$", "this", "->", "set", "(", "'driverModels'", ",", "$", "this", "->", "driver_models", ")", ";", "$", "this", "->", "set", "(", "'outputs'", ",", "$", "this", "->", "outputs", ")", ";", "}" ]
edit method @throws NotFoundException @param string $id @return void
[ "edit", "method" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Controller/PrintersController.php#L120-L146
alevilar/ristorantino-vendor
Printers/Controller/PrintersController.php
PrintersController.delete
public function delete($id = null) { $this->Printer->id = $id; if (!$this->Printer->exists($id)) { throw new NotFoundException(__('Invalid printer')); } if ($this->Printer->delete()) { $this->Printer->modificaImpresoraProductos($id); $this->Session->setFlash(__('The printer has been deleted.')); } else { $this->Session->setFlash(__('The printer could not be deleted. Please, try again.')); } return $this->redirect(array('action' => 'index')); }
php
public function delete($id = null) { $this->Printer->id = $id; if (!$this->Printer->exists($id)) { throw new NotFoundException(__('Invalid printer')); } if ($this->Printer->delete()) { $this->Printer->modificaImpresoraProductos($id); $this->Session->setFlash(__('The printer has been deleted.')); } else { $this->Session->setFlash(__('The printer could not be deleted. Please, try again.')); } return $this->redirect(array('action' => 'index')); }
[ "public", "function", "delete", "(", "$", "id", "=", "null", ")", "{", "$", "this", "->", "Printer", "->", "id", "=", "$", "id", ";", "if", "(", "!", "$", "this", "->", "Printer", "->", "exists", "(", "$", "id", ")", ")", "{", "throw", "new", "NotFoundException", "(", "__", "(", "'Invalid printer'", ")", ")", ";", "}", "if", "(", "$", "this", "->", "Printer", "->", "delete", "(", ")", ")", "{", "$", "this", "->", "Printer", "->", "modificaImpresoraProductos", "(", "$", "id", ")", ";", "$", "this", "->", "Session", "->", "setFlash", "(", "__", "(", "'The printer has been deleted.'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "__", "(", "'The printer could not be deleted. Please, try again.'", ")", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "array", "(", "'action'", "=>", "'index'", ")", ")", ";", "}" ]
delete method @throws NotFoundException @param string $id @return void
[ "delete", "method" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Controller/PrintersController.php#L155-L168
hametuha/wpametu
src/WPametu/API/Rest/RestBase.php
RestBase.handle_request
protected function handle_request( $method, $request_method, array $arguments = [] ) { if ( empty( $method ) || 'page' === $method ) { $page = max( ( isset( $arguments[0] ) ? intval( $arguments[0] ) : 1 ), 1 ); $this->pager( $page ); exit; } else { // Call method if exists. if ( $this->invoke( $method, $request_method, $arguments ) ) { exit; } else { $this->method_not_found(); } } }
php
protected function handle_request( $method, $request_method, array $arguments = [] ) { if ( empty( $method ) || 'page' === $method ) { $page = max( ( isset( $arguments[0] ) ? intval( $arguments[0] ) : 1 ), 1 ); $this->pager( $page ); exit; } else { // Call method if exists. if ( $this->invoke( $method, $request_method, $arguments ) ) { exit; } else { $this->method_not_found(); } } }
[ "protected", "function", "handle_request", "(", "$", "method", ",", "$", "request_method", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "method", ")", "||", "'page'", "===", "$", "method", ")", "{", "$", "page", "=", "max", "(", "(", "isset", "(", "$", "arguments", "[", "0", "]", ")", "?", "intval", "(", "$", "arguments", "[", "0", "]", ")", ":", "1", ")", ",", "1", ")", ";", "$", "this", "->", "pager", "(", "$", "page", ")", ";", "exit", ";", "}", "else", "{", "// Call method if exists.", "if", "(", "$", "this", "->", "invoke", "(", "$", "method", ",", "$", "request_method", ",", "$", "arguments", ")", ")", "{", "exit", ";", "}", "else", "{", "$", "this", "->", "method_not_found", "(", ")", ";", "}", "}", "}" ]
Handle request @param string $method Method name. @param string $request_method GET, POST, PUT, DELETE. @param array $arguments Arguments as array.
[ "Handle", "request" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/RestBase.php#L64-L77
hametuha/wpametu
src/WPametu/API/Rest/RestBase.php
RestBase.url
public function url( $uri = '', $ssl = false ) { $class_name = get_called_class(); $seg = explode( '\\', $class_name ); $base = $seg[ count( $seg ) - 1 ]; $prefix = trim( $class_name::$prefix ?: $this->str->camel_to_hyphen( $base ), '/' ); $uri = ltrim( $uri, '/' ); return home_url( $prefix . '/' . $uri, $ssl ? 'https' : 'http' ); }
php
public function url( $uri = '', $ssl = false ) { $class_name = get_called_class(); $seg = explode( '\\', $class_name ); $base = $seg[ count( $seg ) - 1 ]; $prefix = trim( $class_name::$prefix ?: $this->str->camel_to_hyphen( $base ), '/' ); $uri = ltrim( $uri, '/' ); return home_url( $prefix . '/' . $uri, $ssl ? 'https' : 'http' ); }
[ "public", "function", "url", "(", "$", "uri", "=", "''", ",", "$", "ssl", "=", "false", ")", "{", "$", "class_name", "=", "get_called_class", "(", ")", ";", "$", "seg", "=", "explode", "(", "'\\\\'", ",", "$", "class_name", ")", ";", "$", "base", "=", "$", "seg", "[", "count", "(", "$", "seg", ")", "-", "1", "]", ";", "$", "prefix", "=", "trim", "(", "$", "class_name", "::", "$", "prefix", "?", ":", "$", "this", "->", "str", "->", "camel_to_hyphen", "(", "$", "base", ")", ",", "'/'", ")", ";", "$", "uri", "=", "ltrim", "(", "$", "uri", ",", "'/'", ")", ";", "return", "home_url", "(", "$", "prefix", ".", "'/'", ".", "$", "uri", ",", "$", "ssl", "?", "'https'", ":", "'http'", ")", ";", "}" ]
Return url @param string $uri Get URI. @param bool $ssl If SSL, set true. @return string
[ "Return", "url" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/RestBase.php#L106-L114
gordalina/mangopay-php
src/Gordalina/Mangopay/Authentication/SignerPlugin.php
SignerPlugin.onRequestBeforeSend
public function onRequestBeforeSend(Event $event) { $request = $event['request']; $timestamp = $this->getTimestamp($event); $url = $request->getUrl(true); $url->getQuery()->add('ts', $timestamp); $body = ''; $path = sprintf('%s?%s', $url->getPath(), (string) $url->getQuery()); if ($request instanceof EntityEnclosingRequest) { $body = $request->getBody(); } $signature = $this->signer->getSignature($request->getMethod(), $path, $body); $request->setUrl($url); $request->setHeader('Content-Type', 'application/json'); $request->setHeader('X-Leetchi-Signature', $signature); }
php
public function onRequestBeforeSend(Event $event) { $request = $event['request']; $timestamp = $this->getTimestamp($event); $url = $request->getUrl(true); $url->getQuery()->add('ts', $timestamp); $body = ''; $path = sprintf('%s?%s', $url->getPath(), (string) $url->getQuery()); if ($request instanceof EntityEnclosingRequest) { $body = $request->getBody(); } $signature = $this->signer->getSignature($request->getMethod(), $path, $body); $request->setUrl($url); $request->setHeader('Content-Type', 'application/json'); $request->setHeader('X-Leetchi-Signature', $signature); }
[ "public", "function", "onRequestBeforeSend", "(", "Event", "$", "event", ")", "{", "$", "request", "=", "$", "event", "[", "'request'", "]", ";", "$", "timestamp", "=", "$", "this", "->", "getTimestamp", "(", "$", "event", ")", ";", "$", "url", "=", "$", "request", "->", "getUrl", "(", "true", ")", ";", "$", "url", "->", "getQuery", "(", ")", "->", "add", "(", "'ts'", ",", "$", "timestamp", ")", ";", "$", "body", "=", "''", ";", "$", "path", "=", "sprintf", "(", "'%s?%s'", ",", "$", "url", "->", "getPath", "(", ")", ",", "(", "string", ")", "$", "url", "->", "getQuery", "(", ")", ")", ";", "if", "(", "$", "request", "instanceof", "EntityEnclosingRequest", ")", "{", "$", "body", "=", "$", "request", "->", "getBody", "(", ")", ";", "}", "$", "signature", "=", "$", "this", "->", "signer", "->", "getSignature", "(", "$", "request", "->", "getMethod", "(", ")", ",", "$", "path", ",", "$", "body", ")", ";", "$", "request", "->", "setUrl", "(", "$", "url", ")", ";", "$", "request", "->", "setHeader", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "$", "request", "->", "setHeader", "(", "'X-Leetchi-Signature'", ",", "$", "signature", ")", ";", "}" ]
Request before-send event handler @param Event $event Event received @return null
[ "Request", "before", "-", "send", "event", "handler" ]
train
https://github.com/gordalina/mangopay-php/blob/6807992416d964e25670d961b66dbccd7a46ef62/src/Gordalina/Mangopay/Authentication/SignerPlugin.php#L46-L66
GrupaZero/api
src/Gzero/Api/Transformer/RoleTransformer.php
RoleTransformer.transform
public function transform($role) { $role = $this->entityToArray(Role::class, $role); return [ 'id' => (int) $role['id'], 'name' => $role['name'], 'createdAt' => $role['created_at'], 'updatedAt' => $role['updated_at'] ]; }
php
public function transform($role) { $role = $this->entityToArray(Role::class, $role); return [ 'id' => (int) $role['id'], 'name' => $role['name'], 'createdAt' => $role['created_at'], 'updatedAt' => $role['updated_at'] ]; }
[ "public", "function", "transform", "(", "$", "role", ")", "{", "$", "role", "=", "$", "this", "->", "entityToArray", "(", "Role", "::", "class", ",", "$", "role", ")", ";", "return", "[", "'id'", "=>", "(", "int", ")", "$", "role", "[", "'id'", "]", ",", "'name'", "=>", "$", "role", "[", "'name'", "]", ",", "'createdAt'", "=>", "$", "role", "[", "'created_at'", "]", ",", "'updatedAt'", "=>", "$", "role", "[", "'updated_at'", "]", "]", ";", "}" ]
Transforms role entity @param Role|array $role Role entity @return array
[ "Transforms", "role", "entity" ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/RoleTransformer.php#L26-L35
nathan-fiscaletti/extended-arrays
src/ExtendedArrays/IndexedArray.php
IndexedArray.offsetSet
public function offsetSet($offset, $value) { if (is_null($offset)) { $this->_args[count($this->_args)] = $value; } else { if (is_int($offset)) { $this->_args[$offset] = $value; } else { throw new \Exception('Cannot set offset \''.$offset.'\' of IndexedArray.'); } } }
php
public function offsetSet($offset, $value) { if (is_null($offset)) { $this->_args[count($this->_args)] = $value; } else { if (is_int($offset)) { $this->_args[$offset] = $value; } else { throw new \Exception('Cannot set offset \''.$offset.'\' of IndexedArray.'); } } }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "offset", ")", ")", "{", "$", "this", "->", "_args", "[", "count", "(", "$", "this", "->", "_args", ")", "]", "=", "$", "value", ";", "}", "else", "{", "if", "(", "is_int", "(", "$", "offset", ")", ")", "{", "$", "this", "->", "_args", "[", "$", "offset", "]", "=", "$", "value", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Cannot set offset \\''", ".", "$", "offset", ".", "'\\' of IndexedArray.'", ")", ";", "}", "}", "}" ]
Override the offsetSet function to enforce integral keys only. @param mixed $offset @param mixed $value @throws \Exception
[ "Override", "the", "offsetSet", "function", "to", "enforce", "integral", "keys", "only", "." ]
train
https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/IndexedArray.php#L40-L51
nathan-fiscaletti/extended-arrays
src/ExtendedArrays/IndexedArray.php
IndexedArray.offsetGet
public function offsetGet($offset) { if (isset($this->_args[$offset])) { if (is_array($this->_args[$offset])) { return new AssociativeArray($this->_args[$offset]); } else { return $this->_args[$offset]; } } else { throw new \Exception('Undefined offset \''.$offset.'\'.'); } }
php
public function offsetGet($offset) { if (isset($this->_args[$offset])) { if (is_array($this->_args[$offset])) { return new AssociativeArray($this->_args[$offset]); } else { return $this->_args[$offset]; } } else { throw new \Exception('Undefined offset \''.$offset.'\'.'); } }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_args", "[", "$", "offset", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_args", "[", "$", "offset", "]", ")", ")", "{", "return", "new", "AssociativeArray", "(", "$", "this", "->", "_args", "[", "$", "offset", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "_args", "[", "$", "offset", "]", ";", "}", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Undefined offset \\''", ".", "$", "offset", ".", "'\\'.'", ")", ";", "}", "}" ]
Override the offsetGet function to throw an undefined offset error when a key is not found. @param mixed $offset @return mixed @throws \Exception
[ "Override", "the", "offsetGet", "function", "to", "throw", "an", "undefined", "offset", "error", "when", "a", "key", "is", "not", "found", "." ]
train
https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/IndexedArray.php#L63-L74
nathan-fiscaletti/extended-arrays
src/ExtendedArrays/IndexedArray.php
IndexedArray.isPrefixedKey
private function isPrefixedKey($key) { if (strlen($key) > 1) { if (substr($key, 0, 1) == '_') { try { intval(substr($key, 1, strlen($key) - 1)); return true; } catch (\Exception $e) { return false; } } } }
php
private function isPrefixedKey($key) { if (strlen($key) > 1) { if (substr($key, 0, 1) == '_') { try { intval(substr($key, 1, strlen($key) - 1)); return true; } catch (\Exception $e) { return false; } } } }
[ "private", "function", "isPrefixedKey", "(", "$", "key", ")", "{", "if", "(", "strlen", "(", "$", "key", ")", ">", "1", ")", "{", "if", "(", "substr", "(", "$", "key", ",", "0", ",", "1", ")", "==", "'_'", ")", "{", "try", "{", "intval", "(", "substr", "(", "$", "key", ",", "1", ",", "strlen", "(", "$", "key", ")", "-", "1", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "}", "}", "}" ]
Check if a string is in the proper format to be a prefixed integral array key. @param string $key @return bool
[ "Check", "if", "a", "string", "is", "in", "the", "proper", "format", "to", "be", "a", "prefixed", "integral", "array", "key", "." ]
train
https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/IndexedArray.php#L183-L196
zhouyl/mellivora
Mellivora/Database/Console/Seeds/SeedCommand.php
SeedCommand.fire
public function fire() { if (!$this->confirmToProceed()) { return; } $this->container['db']->setDefaultConnection($this->getDatabase()); Model::unguarded(function () { $this->getSeeder()->__invoke(); }); }
php
public function fire() { if (!$this->confirmToProceed()) { return; } $this->container['db']->setDefaultConnection($this->getDatabase()); Model::unguarded(function () { $this->getSeeder()->__invoke(); }); }
[ "public", "function", "fire", "(", ")", "{", "if", "(", "!", "$", "this", "->", "confirmToProceed", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "container", "[", "'db'", "]", "->", "setDefaultConnection", "(", "$", "this", "->", "getDatabase", "(", ")", ")", ";", "Model", "::", "unguarded", "(", "function", "(", ")", "{", "$", "this", "->", "getSeeder", "(", ")", "->", "__invoke", "(", ")", ";", "}", ")", ";", "}" ]
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Console/Seeds/SeedCommand.php#L35-L46
zhouyl/mellivora
Mellivora/Database/Console/Seeds/SeedCommand.php
SeedCommand.getSeeder
protected function getSeeder() { $class = $this->getClassName(); if (!class_exists($class)) { $file = database_path('/seeds/' . $class . '.php'); if (is_file($file)) { require_once $file; } } return new $class($this->container, $this); }
php
protected function getSeeder() { $class = $this->getClassName(); if (!class_exists($class)) { $file = database_path('/seeds/' . $class . '.php'); if (is_file($file)) { require_once $file; } } return new $class($this->container, $this); }
[ "protected", "function", "getSeeder", "(", ")", "{", "$", "class", "=", "$", "this", "->", "getClassName", "(", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "$", "file", "=", "database_path", "(", "'/seeds/'", ".", "$", "class", ".", "'.php'", ")", ";", "if", "(", "is_file", "(", "$", "file", ")", ")", "{", "require_once", "$", "file", ";", "}", "}", "return", "new", "$", "class", "(", "$", "this", "->", "container", ",", "$", "this", ")", ";", "}" ]
Get a seeder instance from the container. @return \Mellivora\Database\Seeder
[ "Get", "a", "seeder", "instance", "from", "the", "container", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Console/Seeds/SeedCommand.php#L53-L66
oroinc/OroLayoutComponent
BlockTypeHelper.php
BlockTypeHelper.isInstanceOf
public function isInstanceOf($blockType, $targetName) { $name = $this->ensureInitialized($blockType); return isset($this->nameMap[$name][$targetName]); }
php
public function isInstanceOf($blockType, $targetName) { $name = $this->ensureInitialized($blockType); return isset($this->nameMap[$name][$targetName]); }
[ "public", "function", "isInstanceOf", "(", "$", "blockType", ",", "$", "targetName", ")", "{", "$", "name", "=", "$", "this", "->", "ensureInitialized", "(", "$", "blockType", ")", ";", "return", "isset", "(", "$", "this", "->", "nameMap", "[", "$", "name", "]", "[", "$", "targetName", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockTypeHelper.php#L30-L35
oroinc/OroLayoutComponent
BlockTypeHelper.php
BlockTypeHelper.ensureInitialized
protected function ensureInitialized($blockType) { if ($blockType instanceof BlockTypeInterface) { $name = $blockType->getName(); $type = $blockType; } else { $name = $blockType; $type = null; } if (!isset($this->types[$name])) { if (!$type) { $type = $this->registry->getType($name); } $types = [$type]; $typeName = $type->getName(); $names = [$typeName]; $nameMap = [$typeName => true]; $parentName = $type->getParent(); while ($parentName) { if (isset($this->types[$parentName])) { // use data from already loaded parent type $types = array_merge($this->types[$parentName], array_reverse($types)); $names = array_merge($this->names[$parentName], array_reverse($names)); $nameMap = array_merge($nameMap, $this->nameMap[$parentName]); break; } else { $type = $this->registry->getType($parentName); $typeName = $type->getName(); $types[] = $type; $names[] = $typeName; $nameMap[$typeName] = true; $parentName = $type->getParent(); } } if (null === $parentName) { $types = array_reverse($types); $names = array_reverse($names); } $this->types[$name] = $types; $this->names[$name] = $names; $this->nameMap[$name] = $nameMap; // initialise all parent types if them are not initialized yet $typeNames = array_keys($nameMap); $offset = 0; while (false !== ($typeName = next($typeNames))) { if (isset($this->nameMap[$typeName])) { break; } $offset++; $this->types[$typeName] = array_slice($types, 0, -$offset); $this->names[$typeName] = array_slice($names, 0, -$offset); $this->nameMap[$typeName] = array_slice($nameMap, $offset); } } return $name; }
php
protected function ensureInitialized($blockType) { if ($blockType instanceof BlockTypeInterface) { $name = $blockType->getName(); $type = $blockType; } else { $name = $blockType; $type = null; } if (!isset($this->types[$name])) { if (!$type) { $type = $this->registry->getType($name); } $types = [$type]; $typeName = $type->getName(); $names = [$typeName]; $nameMap = [$typeName => true]; $parentName = $type->getParent(); while ($parentName) { if (isset($this->types[$parentName])) { // use data from already loaded parent type $types = array_merge($this->types[$parentName], array_reverse($types)); $names = array_merge($this->names[$parentName], array_reverse($names)); $nameMap = array_merge($nameMap, $this->nameMap[$parentName]); break; } else { $type = $this->registry->getType($parentName); $typeName = $type->getName(); $types[] = $type; $names[] = $typeName; $nameMap[$typeName] = true; $parentName = $type->getParent(); } } if (null === $parentName) { $types = array_reverse($types); $names = array_reverse($names); } $this->types[$name] = $types; $this->names[$name] = $names; $this->nameMap[$name] = $nameMap; // initialise all parent types if them are not initialized yet $typeNames = array_keys($nameMap); $offset = 0; while (false !== ($typeName = next($typeNames))) { if (isset($this->nameMap[$typeName])) { break; } $offset++; $this->types[$typeName] = array_slice($types, 0, -$offset); $this->names[$typeName] = array_slice($names, 0, -$offset); $this->nameMap[$typeName] = array_slice($nameMap, $offset); } } return $name; }
[ "protected", "function", "ensureInitialized", "(", "$", "blockType", ")", "{", "if", "(", "$", "blockType", "instanceof", "BlockTypeInterface", ")", "{", "$", "name", "=", "$", "blockType", "->", "getName", "(", ")", ";", "$", "type", "=", "$", "blockType", ";", "}", "else", "{", "$", "name", "=", "$", "blockType", ";", "$", "type", "=", "null", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "types", "[", "$", "name", "]", ")", ")", "{", "if", "(", "!", "$", "type", ")", "{", "$", "type", "=", "$", "this", "->", "registry", "->", "getType", "(", "$", "name", ")", ";", "}", "$", "types", "=", "[", "$", "type", "]", ";", "$", "typeName", "=", "$", "type", "->", "getName", "(", ")", ";", "$", "names", "=", "[", "$", "typeName", "]", ";", "$", "nameMap", "=", "[", "$", "typeName", "=>", "true", "]", ";", "$", "parentName", "=", "$", "type", "->", "getParent", "(", ")", ";", "while", "(", "$", "parentName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "types", "[", "$", "parentName", "]", ")", ")", "{", "// use data from already loaded parent type", "$", "types", "=", "array_merge", "(", "$", "this", "->", "types", "[", "$", "parentName", "]", ",", "array_reverse", "(", "$", "types", ")", ")", ";", "$", "names", "=", "array_merge", "(", "$", "this", "->", "names", "[", "$", "parentName", "]", ",", "array_reverse", "(", "$", "names", ")", ")", ";", "$", "nameMap", "=", "array_merge", "(", "$", "nameMap", ",", "$", "this", "->", "nameMap", "[", "$", "parentName", "]", ")", ";", "break", ";", "}", "else", "{", "$", "type", "=", "$", "this", "->", "registry", "->", "getType", "(", "$", "parentName", ")", ";", "$", "typeName", "=", "$", "type", "->", "getName", "(", ")", ";", "$", "types", "[", "]", "=", "$", "type", ";", "$", "names", "[", "]", "=", "$", "typeName", ";", "$", "nameMap", "[", "$", "typeName", "]", "=", "true", ";", "$", "parentName", "=", "$", "type", "->", "getParent", "(", ")", ";", "}", "}", "if", "(", "null", "===", "$", "parentName", ")", "{", "$", "types", "=", "array_reverse", "(", "$", "types", ")", ";", "$", "names", "=", "array_reverse", "(", "$", "names", ")", ";", "}", "$", "this", "->", "types", "[", "$", "name", "]", "=", "$", "types", ";", "$", "this", "->", "names", "[", "$", "name", "]", "=", "$", "names", ";", "$", "this", "->", "nameMap", "[", "$", "name", "]", "=", "$", "nameMap", ";", "// initialise all parent types if them are not initialized yet", "$", "typeNames", "=", "array_keys", "(", "$", "nameMap", ")", ";", "$", "offset", "=", "0", ";", "while", "(", "false", "!==", "(", "$", "typeName", "=", "next", "(", "$", "typeNames", ")", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "nameMap", "[", "$", "typeName", "]", ")", ")", "{", "break", ";", "}", "$", "offset", "++", ";", "$", "this", "->", "types", "[", "$", "typeName", "]", "=", "array_slice", "(", "$", "types", ",", "0", ",", "-", "$", "offset", ")", ";", "$", "this", "->", "names", "[", "$", "typeName", "]", "=", "array_slice", "(", "$", "names", ",", "0", ",", "-", "$", "offset", ")", ";", "$", "this", "->", "nameMap", "[", "$", "typeName", "]", "=", "array_slice", "(", "$", "nameMap", ",", "$", "offset", ")", ";", "}", "}", "return", "$", "name", ";", "}" ]
@param string|BlockTypeInterface $blockType The block type name or instance of BlockTypeInterface @return string The name of the given block type
[ "@param", "string|BlockTypeInterface", "$blockType", "The", "block", "type", "name", "or", "instance", "of", "BlockTypeInterface" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockTypeHelper.php#L62-L126
php-lug/lug
src/Bundle/GridBundle/Action/Type/LinkType.php
LinkType.render
public function render($data, array $options) { return $this->urlGenerator->generate( $options['route'], $this->resolveRouteParameters($options['route_parameters'], $data), $options['route_reference_type'] ); }
php
public function render($data, array $options) { return $this->urlGenerator->generate( $options['route'], $this->resolveRouteParameters($options['route_parameters'], $data), $options['route_reference_type'] ); }
[ "public", "function", "render", "(", "$", "data", ",", "array", "$", "options", ")", "{", "return", "$", "this", "->", "urlGenerator", "->", "generate", "(", "$", "options", "[", "'route'", "]", ",", "$", "this", "->", "resolveRouteParameters", "(", "$", "options", "[", "'route_parameters'", "]", ",", "$", "data", ")", ",", "$", "options", "[", "'route_reference_type'", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Action/Type/LinkType.php#L47-L54
php-lug/lug
src/Bundle/GridBundle/Action/Type/LinkType.php
LinkType.configureOptions
public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver ->setDefaults([ 'route_parameters' => [], 'route_reference_type' => UrlGeneratorInterface::ABSOLUTE_PATH, ]) ->setRequired('route') ->setAllowedTypes('route', 'string') ->setAllowedTypes('route_parameters', 'array') ->setAllowedValues('route_reference_type', [ UrlGeneratorInterface::ABSOLUTE_PATH, UrlGeneratorInterface::ABSOLUTE_URL, UrlGeneratorInterface::NETWORK_PATH, UrlGeneratorInterface::RELATIVE_PATH, ]); }
php
public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver ->setDefaults([ 'route_parameters' => [], 'route_reference_type' => UrlGeneratorInterface::ABSOLUTE_PATH, ]) ->setRequired('route') ->setAllowedTypes('route', 'string') ->setAllowedTypes('route_parameters', 'array') ->setAllowedValues('route_reference_type', [ UrlGeneratorInterface::ABSOLUTE_PATH, UrlGeneratorInterface::ABSOLUTE_URL, UrlGeneratorInterface::NETWORK_PATH, UrlGeneratorInterface::RELATIVE_PATH, ]); }
[ "public", "function", "configureOptions", "(", "OptionsResolver", "$", "resolver", ")", "{", "parent", "::", "configureOptions", "(", "$", "resolver", ")", ";", "$", "resolver", "->", "setDefaults", "(", "[", "'route_parameters'", "=>", "[", "]", ",", "'route_reference_type'", "=>", "UrlGeneratorInterface", "::", "ABSOLUTE_PATH", ",", "]", ")", "->", "setRequired", "(", "'route'", ")", "->", "setAllowedTypes", "(", "'route'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'route_parameters'", ",", "'array'", ")", "->", "setAllowedValues", "(", "'route_reference_type'", ",", "[", "UrlGeneratorInterface", "::", "ABSOLUTE_PATH", ",", "UrlGeneratorInterface", "::", "ABSOLUTE_URL", ",", "UrlGeneratorInterface", "::", "NETWORK_PATH", ",", "UrlGeneratorInterface", "::", "RELATIVE_PATH", ",", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Action/Type/LinkType.php#L59-L77
php-lug/lug
src/Bundle/GridBundle/Action/Type/LinkType.php
LinkType.resolveRouteParameters
private function resolveRouteParameters(array $parameters, $data) { $routeParameters = []; foreach ($parameters as $parameter) { $routeParameters[$parameter] = $this->propertyAccessor->getValue($data, $parameter); } return $routeParameters; }
php
private function resolveRouteParameters(array $parameters, $data) { $routeParameters = []; foreach ($parameters as $parameter) { $routeParameters[$parameter] = $this->propertyAccessor->getValue($data, $parameter); } return $routeParameters; }
[ "private", "function", "resolveRouteParameters", "(", "array", "$", "parameters", ",", "$", "data", ")", "{", "$", "routeParameters", "=", "[", "]", ";", "foreach", "(", "$", "parameters", "as", "$", "parameter", ")", "{", "$", "routeParameters", "[", "$", "parameter", "]", "=", "$", "this", "->", "propertyAccessor", "->", "getValue", "(", "$", "data", ",", "$", "parameter", ")", ";", "}", "return", "$", "routeParameters", ";", "}" ]
@param mixed[] $parameters @param mixed[] $data @return mixed[]
[ "@param", "mixed", "[]", "$parameters", "@param", "mixed", "[]", "$data" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Action/Type/LinkType.php#L93-L102
songshenzong/log
src/Bridge/Propel2Collector.php
Propel2Collector.getStatements
protected function getStatements($records, $config) { $statements = []; foreach ($records as $record) { $duration = null; $memory = null; $isSuccess = (LogLevel::INFO === strtolower($record['level_name'])); $detailsCount = count($config['details']); $parameters = explode($config['outerGlue'], $record['message'], $detailsCount + 1); if (count($parameters) === ($detailsCount + 1)) { $parameters = array_map('trim', $parameters); $_details = []; foreach (array_splice($parameters, 0, $detailsCount) as $string) { list($key, $value) = array_map('trim', explode($config['innerGlue'], $string, 2)); $_details[$key] = $value; } $details = []; foreach ($config['details'] as $key => $detail) { if (isset($_details[$detail['name']])) { $value = $_details[$detail['name']]; if ('time' === $key) { if (substr_count($value, 'ms')) { $value = (float) $value / 1000; } else { $value = (float) $value; } } else { $suffixes = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $suffix = substr($value, -2); $i = array_search($suffix, $suffixes, true); $i = (false === $i) ? 0 : $i; $value = ((float) $value) * pow(1024, $i); } $details[$key] = $value; } } if (isset($details['time'])) { $duration = $details['time']; } if (isset($details['memDelta'])) { $memory = $details['memDelta']; } $message = end($parameters); if ($isSuccess) { $this->queryCount++; } } else { $message = $record['message']; } $statement = [ 'sql' => $message, 'is_success' => $isSuccess, 'duration' => $duration, 'duration_str' => $this->getDataFormatter()->formatDuration($duration), 'memory' => $memory, 'memory_str' => $this->getDataFormatter()->formatBytes($memory), ]; if (false === $isSuccess) { $statement['sql'] = ''; $statement['error_code'] = $record['level']; $statement['error_message'] = $message; } $statements[] = $statement; } return $statements; }
php
protected function getStatements($records, $config) { $statements = []; foreach ($records as $record) { $duration = null; $memory = null; $isSuccess = (LogLevel::INFO === strtolower($record['level_name'])); $detailsCount = count($config['details']); $parameters = explode($config['outerGlue'], $record['message'], $detailsCount + 1); if (count($parameters) === ($detailsCount + 1)) { $parameters = array_map('trim', $parameters); $_details = []; foreach (array_splice($parameters, 0, $detailsCount) as $string) { list($key, $value) = array_map('trim', explode($config['innerGlue'], $string, 2)); $_details[$key] = $value; } $details = []; foreach ($config['details'] as $key => $detail) { if (isset($_details[$detail['name']])) { $value = $_details[$detail['name']]; if ('time' === $key) { if (substr_count($value, 'ms')) { $value = (float) $value / 1000; } else { $value = (float) $value; } } else { $suffixes = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $suffix = substr($value, -2); $i = array_search($suffix, $suffixes, true); $i = (false === $i) ? 0 : $i; $value = ((float) $value) * pow(1024, $i); } $details[$key] = $value; } } if (isset($details['time'])) { $duration = $details['time']; } if (isset($details['memDelta'])) { $memory = $details['memDelta']; } $message = end($parameters); if ($isSuccess) { $this->queryCount++; } } else { $message = $record['message']; } $statement = [ 'sql' => $message, 'is_success' => $isSuccess, 'duration' => $duration, 'duration_str' => $this->getDataFormatter()->formatDuration($duration), 'memory' => $memory, 'memory_str' => $this->getDataFormatter()->formatBytes($memory), ]; if (false === $isSuccess) { $statement['sql'] = ''; $statement['error_code'] = $record['level']; $statement['error_message'] = $message; } $statements[] = $statement; } return $statements; }
[ "protected", "function", "getStatements", "(", "$", "records", ",", "$", "config", ")", "{", "$", "statements", "=", "[", "]", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "$", "duration", "=", "null", ";", "$", "memory", "=", "null", ";", "$", "isSuccess", "=", "(", "LogLevel", "::", "INFO", "===", "strtolower", "(", "$", "record", "[", "'level_name'", "]", ")", ")", ";", "$", "detailsCount", "=", "count", "(", "$", "config", "[", "'details'", "]", ")", ";", "$", "parameters", "=", "explode", "(", "$", "config", "[", "'outerGlue'", "]", ",", "$", "record", "[", "'message'", "]", ",", "$", "detailsCount", "+", "1", ")", ";", "if", "(", "count", "(", "$", "parameters", ")", "===", "(", "$", "detailsCount", "+", "1", ")", ")", "{", "$", "parameters", "=", "array_map", "(", "'trim'", ",", "$", "parameters", ")", ";", "$", "_details", "=", "[", "]", ";", "foreach", "(", "array_splice", "(", "$", "parameters", ",", "0", ",", "$", "detailsCount", ")", "as", "$", "string", ")", "{", "list", "(", "$", "key", ",", "$", "value", ")", "=", "array_map", "(", "'trim'", ",", "explode", "(", "$", "config", "[", "'innerGlue'", "]", ",", "$", "string", ",", "2", ")", ")", ";", "$", "_details", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "details", "=", "[", "]", ";", "foreach", "(", "$", "config", "[", "'details'", "]", "as", "$", "key", "=>", "$", "detail", ")", "{", "if", "(", "isset", "(", "$", "_details", "[", "$", "detail", "[", "'name'", "]", "]", ")", ")", "{", "$", "value", "=", "$", "_details", "[", "$", "detail", "[", "'name'", "]", "]", ";", "if", "(", "'time'", "===", "$", "key", ")", "{", "if", "(", "substr_count", "(", "$", "value", ",", "'ms'", ")", ")", "{", "$", "value", "=", "(", "float", ")", "$", "value", "/", "1000", ";", "}", "else", "{", "$", "value", "=", "(", "float", ")", "$", "value", ";", "}", "}", "else", "{", "$", "suffixes", "=", "[", "'B'", ",", "'kB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", ",", "'PB'", ",", "'EB'", ",", "'ZB'", ",", "'YB'", "]", ";", "$", "suffix", "=", "substr", "(", "$", "value", ",", "-", "2", ")", ";", "$", "i", "=", "array_search", "(", "$", "suffix", ",", "$", "suffixes", ",", "true", ")", ";", "$", "i", "=", "(", "false", "===", "$", "i", ")", "?", "0", ":", "$", "i", ";", "$", "value", "=", "(", "(", "float", ")", "$", "value", ")", "*", "pow", "(", "1024", ",", "$", "i", ")", ";", "}", "$", "details", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "if", "(", "isset", "(", "$", "details", "[", "'time'", "]", ")", ")", "{", "$", "duration", "=", "$", "details", "[", "'time'", "]", ";", "}", "if", "(", "isset", "(", "$", "details", "[", "'memDelta'", "]", ")", ")", "{", "$", "memory", "=", "$", "details", "[", "'memDelta'", "]", ";", "}", "$", "message", "=", "end", "(", "$", "parameters", ")", ";", "if", "(", "$", "isSuccess", ")", "{", "$", "this", "->", "queryCount", "++", ";", "}", "}", "else", "{", "$", "message", "=", "$", "record", "[", "'message'", "]", ";", "}", "$", "statement", "=", "[", "'sql'", "=>", "$", "message", ",", "'is_success'", "=>", "$", "isSuccess", ",", "'duration'", "=>", "$", "duration", ",", "'duration_str'", "=>", "$", "this", "->", "getDataFormatter", "(", ")", "->", "formatDuration", "(", "$", "duration", ")", ",", "'memory'", "=>", "$", "memory", ",", "'memory_str'", "=>", "$", "this", "->", "getDataFormatter", "(", ")", "->", "formatBytes", "(", "$", "memory", ")", ",", "]", ";", "if", "(", "false", "===", "$", "isSuccess", ")", "{", "$", "statement", "[", "'sql'", "]", "=", "''", ";", "$", "statement", "[", "'error_code'", "]", "=", "$", "record", "[", "'level'", "]", ";", "$", "statement", "[", "'error_message'", "]", "=", "$", "message", ";", "}", "$", "statements", "[", "]", "=", "$", "statement", ";", "}", "return", "$", "statements", ";", "}" ]
@param array $records @param array $config @return array
[ "@param", "array", "$records", "@param", "array", "$config" ]
train
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/Bridge/Propel2Collector.php#L143-L218
ClementIV/yii-rest-rbac2.0
components/ItemController.php
ItemController.actionIndex
public function actionIndex() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['index']); } $searchModel = new AuthItemSearch(['type' => $this->type]); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $dataProvider; }
php
public function actionIndex() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['index']); } $searchModel = new AuthItemSearch(['type' => $this->type]); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $dataProvider; }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'index'", "]", ")", ";", "}", "$", "searchModel", "=", "new", "AuthItemSearch", "(", "[", "'type'", "=>", "$", "this", "->", "type", "]", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "getQueryParams", "(", ")", ")", ";", "return", "$", "dataProvider", ";", "}" ]
Lists all AuthItem models. @return mixed
[ "Lists", "all", "AuthItem", "models", "." ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/components/ItemController.php#L62-L71
ClementIV/yii-rest-rbac2.0
components/ItemController.php
ItemController.actionView
public function actionView($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['view']); } $model = $this->findModel($id); return ['model'=>$model,'items'=>$model->getItems(),]; }
php
public function actionView($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['view']); } $model = $this->findModel($id); return ['model'=>$model,'items'=>$model->getItems(),]; }
[ "public", "function", "actionView", "(", "$", "id", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'view'", "]", ")", ";", "}", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "return", "[", "'model'", "=>", "$", "model", ",", "'items'", "=>", "$", "model", "->", "getItems", "(", ")", ",", "]", ";", "}" ]
Displays a single AuthItem model. @param string $id @return mixed
[ "Displays", "a", "single", "AuthItem", "model", "." ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/components/ItemController.php#L78-L87
ClementIV/yii-rest-rbac2.0
components/ItemController.php
ItemController.actionCreate
public function actionCreate() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['create']); } $model = new AuthItem(null); $model->type = $this->type; try{ // $model->load(Yii::$app->getRequest()->post()); // return $model; if ($model->load(Yii::$app->getRequest()->post()) && (!$model->find($model['name']))&&$model->save()) { return ['success'=>true,'message'=>'创建成功!']; } return ['success'=>false,'message'=>'参数错误!']; } catch(Exception $e){ throw new Exception($e); } }
php
public function actionCreate() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['create']); } $model = new AuthItem(null); $model->type = $this->type; try{ // $model->load(Yii::$app->getRequest()->post()); // return $model; if ($model->load(Yii::$app->getRequest()->post()) && (!$model->find($model['name']))&&$model->save()) { return ['success'=>true,'message'=>'创建成功!']; } return ['success'=>false,'message'=>'参数错误!']; } catch(Exception $e){ throw new Exception($e); } }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'create'", "]", ")", ";", "}", "$", "model", "=", "new", "AuthItem", "(", "null", ")", ";", "$", "model", "->", "type", "=", "$", "this", "->", "type", ";", "try", "{", "// $model->load(Yii::$app->getRequest()->post());", "// return $model;", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", ")", ")", "&&", "(", "!", "$", "model", "->", "find", "(", "$", "model", "[", "'name'", "]", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "return", "[", "'success'", "=>", "true", ",", "'message'", "=>", "'创建成功!'];", "", "", "}", "return", "[", "'success'", "=>", "false", ",", "'message'", "=>", "'参数错误!'];", "", "", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
Creates a new AuthItem model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "AuthItem", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/components/ItemController.php#L94-L116
ClementIV/yii-rest-rbac2.0
components/ItemController.php
ItemController.actionUpdate
public function actionUpdate($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['update']); } $model = $this->findModel($id); try{ if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) { return ['success'=>true,'message'=>'更新成功!']; }else{ return ['success'=>false,'message'=>'更新失败,参数错误']; } }catch (Exception $e){ throw new Exception($e); } }
php
public function actionUpdate($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['update']); } $model = $this->findModel($id); try{ if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) { return ['success'=>true,'message'=>'更新成功!']; }else{ return ['success'=>false,'message'=>'更新失败,参数错误']; } }catch (Exception $e){ throw new Exception($e); } }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'update'", "]", ")", ";", "}", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "try", "{", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "return", "[", "'success'", "=>", "true", ",", "'message'", "=>", "'更新成功!'];", "", "", "}", "else", "{", "return", "[", "'success'", "=>", "false", ",", "'message'", "=>", "'更新失败,参数错误'];", "", "", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
Updates an existing AuthItem model. If update is successful, the browser will be redirected to the 'view' page. @param string $id @return mixed
[ "Updates", "an", "existing", "AuthItem", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/components/ItemController.php#L124-L141
ClementIV/yii-rest-rbac2.0
components/ItemController.php
ItemController.actionAssign
public function actionAssign($id) { $request = \Yii::$app->request; try { if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['assign']); } $items = Yii::$app->getRequest()->post('items', []); $model = $this->findModel($id); $success = $model->addChildren($items); return array_merge($model->getItems(), ['success' => $success]); } catch(Exception $e){ throw new Exception ($e); } }
php
public function actionAssign($id) { $request = \Yii::$app->request; try { if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['assign']); } $items = Yii::$app->getRequest()->post('items', []); $model = $this->findModel($id); $success = $model->addChildren($items); return array_merge($model->getItems(), ['success' => $success]); } catch(Exception $e){ throw new Exception ($e); } }
[ "public", "function", "actionAssign", "(", "$", "id", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "try", "{", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'assign'", "]", ")", ";", "}", "$", "items", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", "'items'", ",", "[", "]", ")", ";", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "success", "=", "$", "model", "->", "addChildren", "(", "$", "items", ")", ";", "return", "array_merge", "(", "$", "model", "->", "getItems", "(", ")", ",", "[", "'success'", "=>", "$", "success", "]", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
Assign items @param string $id @return array
[ "Assign", "items" ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/components/ItemController.php#L172-L188
ClementIV/yii-rest-rbac2.0
components/ItemController.php
ItemController.actionRemove
public function actionRemove($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['remove']); } $items = Yii::$app->getRequest()->post('items', []); $model = $this->findModel($id); $success = $model->removeChildren($items); return array_merge($model->getItems(), ['success' => $success]); }
php
public function actionRemove($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['remove']); } $items = Yii::$app->getRequest()->post('items', []); $model = $this->findModel($id); $success = $model->removeChildren($items); return array_merge($model->getItems(), ['success' => $success]); }
[ "public", "function", "actionRemove", "(", "$", "id", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'remove'", "]", ")", ";", "}", "$", "items", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", "'items'", ",", "[", "]", ")", ";", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "success", "=", "$", "model", "->", "removeChildren", "(", "$", "items", ")", ";", "return", "array_merge", "(", "$", "model", "->", "getItems", "(", ")", ",", "[", "'success'", "=>", "$", "success", "]", ")", ";", "}" ]
Assign or remove items @param string $id @return array
[ "Assign", "or", "remove", "items" ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/components/ItemController.php#L195-L206
mothership-ec/composer
src/Composer/Package/Locker.php
Locker.getPlatformRequirements
public function getPlatformRequirements($withDevReqs = false) { $lockData = $this->getLockData(); $versionParser = new VersionParser(); $requirements = array(); if (!empty($lockData['platform'])) { $requirements = $versionParser->parseLinks( '__ROOT__', '1.0.0', 'requires', isset($lockData['platform']) ? $lockData['platform'] : array() ); } if ($withDevReqs && !empty($lockData['platform-dev'])) { $devRequirements = $versionParser->parseLinks( '__ROOT__', '1.0.0', 'requires', isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array() ); $requirements = array_merge($requirements, $devRequirements); } return $requirements; }
php
public function getPlatformRequirements($withDevReqs = false) { $lockData = $this->getLockData(); $versionParser = new VersionParser(); $requirements = array(); if (!empty($lockData['platform'])) { $requirements = $versionParser->parseLinks( '__ROOT__', '1.0.0', 'requires', isset($lockData['platform']) ? $lockData['platform'] : array() ); } if ($withDevReqs && !empty($lockData['platform-dev'])) { $devRequirements = $versionParser->parseLinks( '__ROOT__', '1.0.0', 'requires', isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array() ); $requirements = array_merge($requirements, $devRequirements); } return $requirements; }
[ "public", "function", "getPlatformRequirements", "(", "$", "withDevReqs", "=", "false", ")", "{", "$", "lockData", "=", "$", "this", "->", "getLockData", "(", ")", ";", "$", "versionParser", "=", "new", "VersionParser", "(", ")", ";", "$", "requirements", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "lockData", "[", "'platform'", "]", ")", ")", "{", "$", "requirements", "=", "$", "versionParser", "->", "parseLinks", "(", "'__ROOT__'", ",", "'1.0.0'", ",", "'requires'", ",", "isset", "(", "$", "lockData", "[", "'platform'", "]", ")", "?", "$", "lockData", "[", "'platform'", "]", ":", "array", "(", ")", ")", ";", "}", "if", "(", "$", "withDevReqs", "&&", "!", "empty", "(", "$", "lockData", "[", "'platform-dev'", "]", ")", ")", "{", "$", "devRequirements", "=", "$", "versionParser", "->", "parseLinks", "(", "'__ROOT__'", ",", "'1.0.0'", ",", "'requires'", ",", "isset", "(", "$", "lockData", "[", "'platform-dev'", "]", ")", "?", "$", "lockData", "[", "'platform-dev'", "]", ":", "array", "(", ")", ")", ";", "$", "requirements", "=", "array_merge", "(", "$", "requirements", ",", "$", "devRequirements", ")", ";", "}", "return", "$", "requirements", ";", "}" ]
Returns the platform requirements stored in the lock file @param bool $withDevReqs if true, the platform requirements from the require-dev block are also returned @return \Composer\Package\Link[]
[ "Returns", "the", "platform", "requirements", "stored", "in", "the", "lock", "file" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Package/Locker.php#L133-L160
mothership-ec/composer
src/Composer/Package/Locker.php
Locker.setLockData
public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides) { $lock = array( '_readme' => array('This file locks the dependencies of your project to a known state', 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file', 'This file is @gener'.'ated automatically'), 'hash' => $this->hash, 'packages' => null, 'packages-dev' => null, 'aliases' => array(), 'minimum-stability' => $minimumStability, 'stability-flags' => $stabilityFlags, 'prefer-stable' => $preferStable, 'prefer-lowest' => $preferLowest, ); foreach ($aliases as $package => $versions) { foreach ($versions as $version => $alias) { $lock['aliases'][] = array( 'alias' => $alias['alias'], 'alias_normalized' => $alias['alias_normalized'], 'version' => $version, 'package' => $package, ); } } $lock['packages'] = $this->lockPackages($packages); if (null !== $devPackages) { $lock['packages-dev'] = $this->lockPackages($devPackages); } $lock['platform'] = $platformReqs; $lock['platform-dev'] = $platformDevReqs; if ($platformOverrides) { $lock['platform-overrides'] = $platformOverrides; } if (empty($lock['packages']) && empty($lock['packages-dev']) && empty($lock['platform']) && empty($lock['platform-dev'])) { if ($this->lockFile->exists()) { unlink($this->lockFile->getPath()); } return false; } if (!$this->isLocked() || $lock !== $this->getLockData()) { $this->lockFile->write($lock); $this->lockDataCache = null; return true; } return false; }
php
public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides) { $lock = array( '_readme' => array('This file locks the dependencies of your project to a known state', 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file', 'This file is @gener'.'ated automatically'), 'hash' => $this->hash, 'packages' => null, 'packages-dev' => null, 'aliases' => array(), 'minimum-stability' => $minimumStability, 'stability-flags' => $stabilityFlags, 'prefer-stable' => $preferStable, 'prefer-lowest' => $preferLowest, ); foreach ($aliases as $package => $versions) { foreach ($versions as $version => $alias) { $lock['aliases'][] = array( 'alias' => $alias['alias'], 'alias_normalized' => $alias['alias_normalized'], 'version' => $version, 'package' => $package, ); } } $lock['packages'] = $this->lockPackages($packages); if (null !== $devPackages) { $lock['packages-dev'] = $this->lockPackages($devPackages); } $lock['platform'] = $platformReqs; $lock['platform-dev'] = $platformDevReqs; if ($platformOverrides) { $lock['platform-overrides'] = $platformOverrides; } if (empty($lock['packages']) && empty($lock['packages-dev']) && empty($lock['platform']) && empty($lock['platform-dev'])) { if ($this->lockFile->exists()) { unlink($this->lockFile->getPath()); } return false; } if (!$this->isLocked() || $lock !== $this->getLockData()) { $this->lockFile->write($lock); $this->lockDataCache = null; return true; } return false; }
[ "public", "function", "setLockData", "(", "array", "$", "packages", ",", "$", "devPackages", ",", "array", "$", "platformReqs", ",", "$", "platformDevReqs", ",", "array", "$", "aliases", ",", "$", "minimumStability", ",", "array", "$", "stabilityFlags", ",", "$", "preferStable", ",", "$", "preferLowest", ",", "array", "$", "platformOverrides", ")", "{", "$", "lock", "=", "array", "(", "'_readme'", "=>", "array", "(", "'This file locks the dependencies of your project to a known state'", ",", "'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file'", ",", "'This file is @gener'", ".", "'ated automatically'", ")", ",", "'hash'", "=>", "$", "this", "->", "hash", ",", "'packages'", "=>", "null", ",", "'packages-dev'", "=>", "null", ",", "'aliases'", "=>", "array", "(", ")", ",", "'minimum-stability'", "=>", "$", "minimumStability", ",", "'stability-flags'", "=>", "$", "stabilityFlags", ",", "'prefer-stable'", "=>", "$", "preferStable", ",", "'prefer-lowest'", "=>", "$", "preferLowest", ",", ")", ";", "foreach", "(", "$", "aliases", "as", "$", "package", "=>", "$", "versions", ")", "{", "foreach", "(", "$", "versions", "as", "$", "version", "=>", "$", "alias", ")", "{", "$", "lock", "[", "'aliases'", "]", "[", "]", "=", "array", "(", "'alias'", "=>", "$", "alias", "[", "'alias'", "]", ",", "'alias_normalized'", "=>", "$", "alias", "[", "'alias_normalized'", "]", ",", "'version'", "=>", "$", "version", ",", "'package'", "=>", "$", "package", ",", ")", ";", "}", "}", "$", "lock", "[", "'packages'", "]", "=", "$", "this", "->", "lockPackages", "(", "$", "packages", ")", ";", "if", "(", "null", "!==", "$", "devPackages", ")", "{", "$", "lock", "[", "'packages-dev'", "]", "=", "$", "this", "->", "lockPackages", "(", "$", "devPackages", ")", ";", "}", "$", "lock", "[", "'platform'", "]", "=", "$", "platformReqs", ";", "$", "lock", "[", "'platform-dev'", "]", "=", "$", "platformDevReqs", ";", "if", "(", "$", "platformOverrides", ")", "{", "$", "lock", "[", "'platform-overrides'", "]", "=", "$", "platformOverrides", ";", "}", "if", "(", "empty", "(", "$", "lock", "[", "'packages'", "]", ")", "&&", "empty", "(", "$", "lock", "[", "'packages-dev'", "]", ")", "&&", "empty", "(", "$", "lock", "[", "'platform'", "]", ")", "&&", "empty", "(", "$", "lock", "[", "'platform-dev'", "]", ")", ")", "{", "if", "(", "$", "this", "->", "lockFile", "->", "exists", "(", ")", ")", "{", "unlink", "(", "$", "this", "->", "lockFile", "->", "getPath", "(", ")", ")", ";", "}", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "isLocked", "(", ")", "||", "$", "lock", "!==", "$", "this", "->", "getLockData", "(", ")", ")", "{", "$", "this", "->", "lockFile", "->", "write", "(", "$", "lock", ")", ";", "$", "this", "->", "lockDataCache", "=", "null", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Locks provided data into lockfile. @param array $packages array of packages @param mixed $devPackages array of dev packages or null if installed without --dev @param array $platformReqs array of package name => constraint for required platform packages @param mixed $platformDevReqs array of package name => constraint for dev-required platform packages @param array $aliases array of aliases @param string $minimumStability @param array $stabilityFlags @param bool $preferStable @param bool $preferLowest @param array $platformOverrides @return bool
[ "Locks", "provided", "data", "into", "lockfile", "." ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Package/Locker.php#L237-L291
Eresus/EresusCMS
src/core/CMS/Exception.php
Eresus_CMS_Exception.getHttpException
public function getHttpException() { if (null === $this->httpException) { $this->httpException = $this->createHttpException(); } return $this->httpException; }
php
public function getHttpException() { if (null === $this->httpException) { $this->httpException = $this->createHttpException(); } return $this->httpException; }
[ "public", "function", "getHttpException", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "httpException", ")", "{", "$", "this", "->", "httpException", "=", "$", "this", "->", "createHttpException", "(", ")", ";", "}", "return", "$", "this", "->", "httpException", ";", "}" ]
Возвращает исключение HTTP соответствующее этому исключению @return Eresus_HTTP_Exception
[ "Возвращает", "исключение", "HTTP", "соответствующее", "этому", "исключению" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS/Exception.php#L54-L61
crysalead/storage-stream
src/Stream.php
Stream._initResource
protected function _initResource($config) { if (!empty($config['data']) && !empty($config['filename'])) { throw new InvalidArgumentException("The `'data'` or `'filename'` option must be defined."); } if ($config['filename']) { $this->_filename = $config['filename']; if ($this->_filename === 'php://input') { $this->_mode = 'r'; } $this->_resource = fopen($this->_filename, $this->_mode); return; } if (is_resource($config['data'])) { $this->_resource = $config['data']; return; } elseif (is_scalar($config['data'])) { $this->_resource = fopen('php://temp', 'r+'); fwrite($this->_resource, (string) $config['data']); rewind($this->_resource); } }
php
protected function _initResource($config) { if (!empty($config['data']) && !empty($config['filename'])) { throw new InvalidArgumentException("The `'data'` or `'filename'` option must be defined."); } if ($config['filename']) { $this->_filename = $config['filename']; if ($this->_filename === 'php://input') { $this->_mode = 'r'; } $this->_resource = fopen($this->_filename, $this->_mode); return; } if (is_resource($config['data'])) { $this->_resource = $config['data']; return; } elseif (is_scalar($config['data'])) { $this->_resource = fopen('php://temp', 'r+'); fwrite($this->_resource, (string) $config['data']); rewind($this->_resource); } }
[ "protected", "function", "_initResource", "(", "$", "config", ")", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'data'", "]", ")", "&&", "!", "empty", "(", "$", "config", "[", "'filename'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"The `'data'` or `'filename'` option must be defined.\"", ")", ";", "}", "if", "(", "$", "config", "[", "'filename'", "]", ")", "{", "$", "this", "->", "_filename", "=", "$", "config", "[", "'filename'", "]", ";", "if", "(", "$", "this", "->", "_filename", "===", "'php://input'", ")", "{", "$", "this", "->", "_mode", "=", "'r'", ";", "}", "$", "this", "->", "_resource", "=", "fopen", "(", "$", "this", "->", "_filename", ",", "$", "this", "->", "_mode", ")", ";", "return", ";", "}", "if", "(", "is_resource", "(", "$", "config", "[", "'data'", "]", ")", ")", "{", "$", "this", "->", "_resource", "=", "$", "config", "[", "'data'", "]", ";", "return", ";", "}", "elseif", "(", "is_scalar", "(", "$", "config", "[", "'data'", "]", ")", ")", "{", "$", "this", "->", "_resource", "=", "fopen", "(", "'php://temp'", ",", "'r+'", ")", ";", "fwrite", "(", "$", "this", "->", "_resource", ",", "(", "string", ")", "$", "config", "[", "'data'", "]", ")", ";", "rewind", "(", "$", "this", "->", "_resource", ")", ";", "}", "}" ]
Init the stream resource. @param array $config The constructor configuration array.
[ "Init", "the", "stream", "resource", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L140-L161
crysalead/storage-stream
src/Stream.php
Stream.start
public function start($start = null, $autoseek = true) { if (!func_num_args()) { return $this->_start; } $this->_start = (int) $start; if ($autoseek) { $this->rewind(); } return $this; }
php
public function start($start = null, $autoseek = true) { if (!func_num_args()) { return $this->_start; } $this->_start = (int) $start; if ($autoseek) { $this->rewind(); } return $this; }
[ "public", "function", "start", "(", "$", "start", "=", "null", ",", "$", "autoseek", "=", "true", ")", "{", "if", "(", "!", "func_num_args", "(", ")", ")", "{", "return", "$", "this", "->", "_start", ";", "}", "$", "this", "->", "_start", "=", "(", "int", ")", "$", "start", ";", "if", "(", "$", "autoseek", ")", "{", "$", "this", "->", "rewind", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Get/set the starting offset. @param integer $start The offset to set. @return integer The setted offset.
[ "Get", "/", "set", "the", "starting", "offset", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L182-L193
crysalead/storage-stream
src/Stream.php
Stream.limit
public function limit($limit = null) { if (!func_num_args()) { return $this->_limit; } $this->_limit = $limit; return $this; }
php
public function limit($limit = null) { if (!func_num_args()) { return $this->_limit; } $this->_limit = $limit; return $this; }
[ "public", "function", "limit", "(", "$", "limit", "=", "null", ")", "{", "if", "(", "!", "func_num_args", "(", ")", ")", "{", "return", "$", "this", "->", "_limit", ";", "}", "$", "this", "->", "_limit", "=", "$", "limit", ";", "return", "$", "this", ";", "}" ]
Get/set the stream range limit. @param integer $limit The limit to set. @return integer|null The setted limit.
[ "Get", "/", "set", "the", "stream", "range", "limit", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L201-L208
crysalead/storage-stream
src/Stream.php
Stream.length
public function length() { if ($this->_limit !== null) { return $this->_limit; } if ($this->_length !== null) { return $this->_length; } if ($this->isSeekable()) { $old = $this->tell(); $begin = $this->rewind(); $end = $this->end(); $this->seek($old); return $end - $begin; } }
php
public function length() { if ($this->_limit !== null) { return $this->_limit; } if ($this->_length !== null) { return $this->_length; } if ($this->isSeekable()) { $old = $this->tell(); $begin = $this->rewind(); $end = $this->end(); $this->seek($old); return $end - $begin; } }
[ "public", "function", "length", "(", ")", "{", "if", "(", "$", "this", "->", "_limit", "!==", "null", ")", "{", "return", "$", "this", "->", "_limit", ";", "}", "if", "(", "$", "this", "->", "_length", "!==", "null", ")", "{", "return", "$", "this", "->", "_length", ";", "}", "if", "(", "$", "this", "->", "isSeekable", "(", ")", ")", "{", "$", "old", "=", "$", "this", "->", "tell", "(", ")", ";", "$", "begin", "=", "$", "this", "->", "rewind", "(", ")", ";", "$", "end", "=", "$", "this", "->", "end", "(", ")", ";", "$", "this", "->", "seek", "(", "$", "old", ")", ";", "return", "$", "end", "-", "$", "begin", ";", "}", "}" ]
Get the stream range length.
[ "Get", "the", "stream", "range", "length", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L213-L230
crysalead/storage-stream
src/Stream.php
Stream.range
public function range($range = null) { if (!func_num_args()) { return $this->_start . '-' . ($this->_limit ? $this->_start + $this->_limit : ''); } $values = explode('-', $range); $this->_start = (int) $values[0]; $this->_limit = $values[1] !== '' ? $values[1] - $values[0] : null; return $this; }
php
public function range($range = null) { if (!func_num_args()) { return $this->_start . '-' . ($this->_limit ? $this->_start + $this->_limit : ''); } $values = explode('-', $range); $this->_start = (int) $values[0]; $this->_limit = $values[1] !== '' ? $values[1] - $values[0] : null; return $this; }
[ "public", "function", "range", "(", "$", "range", "=", "null", ")", "{", "if", "(", "!", "func_num_args", "(", ")", ")", "{", "return", "$", "this", "->", "_start", ".", "'-'", ".", "(", "$", "this", "->", "_limit", "?", "$", "this", "->", "_start", "+", "$", "this", "->", "_limit", ":", "''", ")", ";", "}", "$", "values", "=", "explode", "(", "'-'", ",", "$", "range", ")", ";", "$", "this", "->", "_start", "=", "(", "int", ")", "$", "values", "[", "0", "]", ";", "$", "this", "->", "_limit", "=", "$", "values", "[", "1", "]", "!==", "''", "?", "$", "values", "[", "1", "]", "-", "$", "values", "[", "0", "]", ":", "null", ";", "return", "$", "this", ";", "}" ]
Get/set the range. @param integer $range The range to set. @return string The setted range.
[ "Get", "/", "set", "the", "range", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L238-L247
crysalead/storage-stream
src/Stream.php
Stream.mime
public function mime($mime = null) { if (!func_num_args()) { return $this->_mime; } return $this->_mime = static::getMime($this, $mime); }
php
public function mime($mime = null) { if (!func_num_args()) { return $this->_mime; } return $this->_mime = static::getMime($this, $mime); }
[ "public", "function", "mime", "(", "$", "mime", "=", "null", ")", "{", "if", "(", "!", "func_num_args", "(", ")", ")", "{", "return", "$", "this", "->", "_mime", ";", "}", "return", "$", "this", "->", "_mime", "=", "static", "::", "getMime", "(", "$", "this", ",", "$", "mime", ")", ";", "}" ]
Get/set the stream mime. @param mixed $mime The mime string to set or `true` to autodetect the mime. @return string The mime.
[ "Get", "/", "set", "the", "stream", "mime", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L255-L261
crysalead/storage-stream
src/Stream.php
Stream.charset
public function charset($charset = null) { if (!func_num_args()) { return $this->_charset; } $this->_charset = $charset ? strtoupper($charset) : null; return $this; }
php
public function charset($charset = null) { if (!func_num_args()) { return $this->_charset; } $this->_charset = $charset ? strtoupper($charset) : null; return $this; }
[ "public", "function", "charset", "(", "$", "charset", "=", "null", ")", "{", "if", "(", "!", "func_num_args", "(", ")", ")", "{", "return", "$", "this", "->", "_charset", ";", "}", "$", "this", "->", "_charset", "=", "$", "charset", "?", "strtoupper", "(", "$", "charset", ")", ":", "null", ";", "return", "$", "this", ";", "}" ]
Get/set the charset. @param string $charset @return string The charset.
[ "Get", "/", "set", "the", "charset", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L269-L276
crysalead/storage-stream
src/Stream.php
Stream.meta
public function meta($key = null) { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } if (!$this->valid()) { throw new RuntimeException('Invalid resource.'); } $meta = stream_get_meta_data($this->_resource); if ($key) { return isset($meta[$key]) ? $meta[$key] : null; } return $meta; }
php
public function meta($key = null) { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } if (!$this->valid()) { throw new RuntimeException('Invalid resource.'); } $meta = stream_get_meta_data($this->_resource); if ($key) { return isset($meta[$key]) ? $meta[$key] : null; } return $meta; }
[ "public", "function", "meta", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "this", "->", "_resource", "===", "null", "&&", "$", "this", "->", "_filename", ")", "{", "$", "this", "->", "_resource", "=", "fopen", "(", "$", "this", "->", "_filename", ",", "$", "this", "->", "_mode", ")", ";", "}", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Invalid resource.'", ")", ";", "}", "$", "meta", "=", "stream_get_meta_data", "(", "$", "this", "->", "_resource", ")", ";", "if", "(", "$", "key", ")", "{", "return", "isset", "(", "$", "meta", "[", "$", "key", "]", ")", "?", "$", "meta", "[", "$", "key", "]", ":", "null", ";", "}", "return", "$", "meta", ";", "}" ]
Get stream meta data. @param string $key A specific meta data or `null` to get all meta data. Possibles values are: `'uri'` _string_ : the URI/filename associated with this stream. `'mode'` _string_ : the type of access required for this stream. `'wrapper_type'` _string_ : the protocol wrapper implementation layered over the stream. `'stream_type'` _string_ : the underlying implementation of the stream. `'unread_bytes'` _integer_: the number of bytes contained in the PHP's own internal buffer. `'seekable'` _boolean_: `true` means the current stream can be seeked. `'eof'` _boolean_: `true` means the stream has reached end-of-file. `'blocked'` _boolean_: `true` means the stream is in blocking IO mode. `'timed_out'` _boolean_: `true` means stream timed out on the last read call. @return mixed
[ "Get", "stream", "meta", "data", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L309-L323
crysalead/storage-stream
src/Stream.php
Stream._ensureReadable
protected function _ensureReadable($bytePerByte = true) { if (!$this->valid()) { throw new RuntimeException('Cannot read from a closed stream.'); } if (!$this->isReadable()) { $mode = $this->meta('mode'); throw new RuntimeException("Cannot read on a non-readable stream (mode is `'{$mode}'`)."); } }
php
protected function _ensureReadable($bytePerByte = true) { if (!$this->valid()) { throw new RuntimeException('Cannot read from a closed stream.'); } if (!$this->isReadable()) { $mode = $this->meta('mode'); throw new RuntimeException("Cannot read on a non-readable stream (mode is `'{$mode}'`)."); } }
[ "protected", "function", "_ensureReadable", "(", "$", "bytePerByte", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Cannot read from a closed stream.'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isReadable", "(", ")", ")", "{", "$", "mode", "=", "$", "this", "->", "meta", "(", "'mode'", ")", ";", "throw", "new", "RuntimeException", "(", "\"Cannot read on a non-readable stream (mode is `'{$mode}'`).\"", ")", ";", "}", "}" ]
Throw an exception if a stream is not readable. @param boolean $bytePerByte Check if the stream is readable byte per byte.
[ "Throw", "an", "exception", "if", "a", "stream", "is", "not", "readable", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L351-L360
crysalead/storage-stream
src/Stream.php
Stream._ensureWritable
protected function _ensureWritable() { if (!$this->valid()) { throw new RuntimeException('Cannot write on a closed stream.'); } if (!$this->isWritable()) { $mode = $this->meta('mode'); throw new RuntimeException("Cannot write on a non-writable stream (mode is `'{$mode}'`)."); } }
php
protected function _ensureWritable() { if (!$this->valid()) { throw new RuntimeException('Cannot write on a closed stream.'); } if (!$this->isWritable()) { $mode = $this->meta('mode'); throw new RuntimeException("Cannot write on a non-writable stream (mode is `'{$mode}'`)."); } }
[ "protected", "function", "_ensureWritable", "(", ")", "{", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Cannot write on a closed stream.'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isWritable", "(", ")", ")", "{", "$", "mode", "=", "$", "this", "->", "meta", "(", "'mode'", ")", ";", "throw", "new", "RuntimeException", "(", "\"Cannot write on a non-writable stream (mode is `'{$mode}'`).\"", ")", ";", "}", "}" ]
Throw an exception if a stream is not writable.
[ "Throw", "an", "exception", "if", "a", "stream", "is", "not", "writable", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L376-L385
crysalead/storage-stream
src/Stream.php
Stream.bufferSize
public function bufferSize($bufferSize = null) { if (!func_num_args($bufferSize)) { return $this->_bufferSize; } return $this->_bufferSize = $bufferSize; }
php
public function bufferSize($bufferSize = null) { if (!func_num_args($bufferSize)) { return $this->_bufferSize; } return $this->_bufferSize = $bufferSize; }
[ "public", "function", "bufferSize", "(", "$", "bufferSize", "=", "null", ")", "{", "if", "(", "!", "func_num_args", "(", "$", "bufferSize", ")", ")", "{", "return", "$", "this", "->", "_bufferSize", ";", "}", "return", "$", "this", "->", "_bufferSize", "=", "$", "bufferSize", ";", "}" ]
Get/set the buffer size. @param integer $bufferSize The buffer size to set or `null` to get the current buffer size. @return integer The buffer size.
[ "Get", "/", "set", "the", "buffer", "size", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L416-L422
crysalead/storage-stream
src/Stream.php
Stream.read
public function read($length = null) { $this->_ensureReadable(); $length = $this->_bufferSize($length); if ($length <= 0) { return ''; } $result = fread($this->_resource, $length); return $result === false ? '' : $result; }
php
public function read($length = null) { $this->_ensureReadable(); $length = $this->_bufferSize($length); if ($length <= 0) { return ''; } $result = fread($this->_resource, $length); return $result === false ? '' : $result; }
[ "public", "function", "read", "(", "$", "length", "=", "null", ")", "{", "$", "this", "->", "_ensureReadable", "(", ")", ";", "$", "length", "=", "$", "this", "->", "_bufferSize", "(", "$", "length", ")", ";", "if", "(", "$", "length", "<=", "0", ")", "{", "return", "''", ";", "}", "$", "result", "=", "fread", "(", "$", "this", "->", "_resource", ",", "$", "length", ")", ";", "return", "$", "result", "===", "false", "?", "''", ":", "$", "result", ";", "}" ]
Read data from the stream. Binary-safe. @param integer $length Maximum number of bytes to read (default to buffer size). @return string The data.
[ "Read", "data", "from", "the", "stream", ".", "Binary", "-", "safe", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L431-L440
crysalead/storage-stream
src/Stream.php
Stream._bufferSize
protected function _bufferSize($length) { if ($this->_limit !== null) { $position = $this->tell(); $max = $this->_start + $this->_limit; $length = $max - $position; } if ($length === null) { $length = $this->_bufferSize; } return $length; }
php
protected function _bufferSize($length) { if ($this->_limit !== null) { $position = $this->tell(); $max = $this->_start + $this->_limit; $length = $max - $position; } if ($length === null) { $length = $this->_bufferSize; } return $length; }
[ "protected", "function", "_bufferSize", "(", "$", "length", ")", "{", "if", "(", "$", "this", "->", "_limit", "!==", "null", ")", "{", "$", "position", "=", "$", "this", "->", "tell", "(", ")", ";", "$", "max", "=", "$", "this", "->", "_start", "+", "$", "this", "->", "_limit", ";", "$", "length", "=", "$", "max", "-", "$", "position", ";", "}", "if", "(", "$", "length", "===", "null", ")", "{", "$", "length", "=", "$", "this", "->", "_bufferSize", ";", "}", "return", "$", "length", ";", "}" ]
Determine the buffer size to read. @param integer $length Maximum number of bytes to read (default to buffer size). @return integer The allowed size.
[ "Determine", "the", "buffer", "size", "to", "read", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L448-L459
crysalead/storage-stream
src/Stream.php
Stream.getLine
public function getLine($length = null, $ending = "\n") { $this->_ensureReadable(); $length = $this->_bufferSize($length); if ($length <= 0) { return ''; } $result = stream_get_line($this->_resource, $length, $ending); return $result === false ? '' : $result; }
php
public function getLine($length = null, $ending = "\n") { $this->_ensureReadable(); $length = $this->_bufferSize($length); if ($length <= 0) { return ''; } $result = stream_get_line($this->_resource, $length, $ending); return $result === false ? '' : $result; }
[ "public", "function", "getLine", "(", "$", "length", "=", "null", ",", "$", "ending", "=", "\"\\n\"", ")", "{", "$", "this", "->", "_ensureReadable", "(", ")", ";", "$", "length", "=", "$", "this", "->", "_bufferSize", "(", "$", "length", ")", ";", "if", "(", "$", "length", "<=", "0", ")", "{", "return", "''", ";", "}", "$", "result", "=", "stream_get_line", "(", "$", "this", "->", "_resource", ",", "$", "length", ",", "$", "ending", ")", ";", "return", "$", "result", "===", "false", "?", "''", ":", "$", "result", ";", "}" ]
Read one line from the stream. @param integer $length Maximum number of bytes to read (default to buffer size). @param string $ending Line ending to stop at (default to "\n"). @return string The data.
[ "Read", "one", "line", "from", "the", "stream", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L468-L477
crysalead/storage-stream
src/Stream.php
Stream.write
public function write($string, $length = null) { $this->_ensureWritable(); if (null === $length) { $result = fwrite($this->_resource, $string); } else { $result = fwrite($this->_resource, $string, $length); } return $result; }
php
public function write($string, $length = null) { $this->_ensureWritable(); if (null === $length) { $result = fwrite($this->_resource, $string); } else { $result = fwrite($this->_resource, $string, $length); } return $result; }
[ "public", "function", "write", "(", "$", "string", ",", "$", "length", "=", "null", ")", "{", "$", "this", "->", "_ensureWritable", "(", ")", ";", "if", "(", "null", "===", "$", "length", ")", "{", "$", "result", "=", "fwrite", "(", "$", "this", "->", "_resource", ",", "$", "string", ")", ";", "}", "else", "{", "$", "result", "=", "fwrite", "(", "$", "this", "->", "_resource", ",", "$", "string", ",", "$", "length", ")", ";", "}", "return", "$", "result", ";", "}" ]
Write data to the stream. @param string $string The string that is to be written. @param integer $length If the length argument is given, writing will stop after length bytes have been written or the end of string if reached, whichever comes first. @return integer Number of bytes written
[ "Write", "data", "to", "the", "stream", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L487-L496
crysalead/storage-stream
src/Stream.php
Stream.push
public function push($string, $length = null) { $this->_ensureWritable(); $offset = $this->tell(); if (null === $length) { $result = fwrite($this->_resource, $string); } else { $result = fwrite($this->_resource, $string, $length); } $this->seek($offset); return $result; }
php
public function push($string, $length = null) { $this->_ensureWritable(); $offset = $this->tell(); if (null === $length) { $result = fwrite($this->_resource, $string); } else { $result = fwrite($this->_resource, $string, $length); } $this->seek($offset); return $result; }
[ "public", "function", "push", "(", "$", "string", ",", "$", "length", "=", "null", ")", "{", "$", "this", "->", "_ensureWritable", "(", ")", ";", "$", "offset", "=", "$", "this", "->", "tell", "(", ")", ";", "if", "(", "null", "===", "$", "length", ")", "{", "$", "result", "=", "fwrite", "(", "$", "this", "->", "_resource", ",", "$", "string", ")", ";", "}", "else", "{", "$", "result", "=", "fwrite", "(", "$", "this", "->", "_resource", ",", "$", "string", ",", "$", "length", ")", ";", "}", "$", "this", "->", "seek", "(", "$", "offset", ")", ";", "return", "$", "result", ";", "}" ]
Push data to the stream. The difference with `write()` is that the position of the file pointer still unchanged. @param string $string The string that is to be written. @param integer $length If the length argument is given, writing will stop after length bytes have been written or the end of string if reached, whichever comes first. @return integer Number of bytes written
[ "Push", "data", "to", "the", "stream", ".", "The", "difference", "with", "write", "()", "is", "that", "the", "position", "of", "the", "file", "pointer", "still", "unchanged", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L520-L531
crysalead/storage-stream
src/Stream.php
Stream.pipe
public function pipe($stream) { $offset = $stream->tell(); $result = stream_copy_to_stream($this->resource(), $stream->resource()); if ($stream->isSeekable()) { $stream->seek($offset); } return $result; }
php
public function pipe($stream) { $offset = $stream->tell(); $result = stream_copy_to_stream($this->resource(), $stream->resource()); if ($stream->isSeekable()) { $stream->seek($offset); } return $result; }
[ "public", "function", "pipe", "(", "$", "stream", ")", "{", "$", "offset", "=", "$", "stream", "->", "tell", "(", ")", ";", "$", "result", "=", "stream_copy_to_stream", "(", "$", "this", "->", "resource", "(", ")", ",", "$", "stream", "->", "resource", "(", ")", ")", ";", "if", "(", "$", "stream", "->", "isSeekable", "(", ")", ")", "{", "$", "stream", "->", "seek", "(", "$", "offset", ")", ";", "}", "return", "$", "result", ";", "}" ]
Read the content of this stream and write it to another stream. @param instance $stream The destination stream to write to @return integer The number of copied bytes
[ "Read", "the", "content", "of", "this", "stream", "and", "write", "it", "to", "another", "stream", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L539-L547
crysalead/storage-stream
src/Stream.php
Stream.timeout
public function timeout($delay = null) { if ($delay === null) { return $this->_timeout; } if (!$this->valid()) { throw new RuntimeException("Invalid stream resource, unable to set a timeout on it."); } $this->_timeout = $delay; return stream_set_timeout($this->_resource, 0, $delay); }
php
public function timeout($delay = null) { if ($delay === null) { return $this->_timeout; } if (!$this->valid()) { throw new RuntimeException("Invalid stream resource, unable to set a timeout on it."); } $this->_timeout = $delay; return stream_set_timeout($this->_resource, 0, $delay); }
[ "public", "function", "timeout", "(", "$", "delay", "=", "null", ")", "{", "if", "(", "$", "delay", "===", "null", ")", "{", "return", "$", "this", "->", "_timeout", ";", "}", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Invalid stream resource, unable to set a timeout on it.\"", ")", ";", "}", "$", "this", "->", "_timeout", "=", "$", "delay", ";", "return", "stream_set_timeout", "(", "$", "this", "->", "_resource", ",", "0", ",", "$", "delay", ")", ";", "}" ]
Set timeout period on a stream. @param integer $delay The timeout delay in microseconds.
[ "Set", "timeout", "period", "on", "a", "stream", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L565-L574
crysalead/storage-stream
src/Stream.php
Stream.tell
public function tell() { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } return ftell($this->_resource); }
php
public function tell() { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } return ftell($this->_resource); }
[ "public", "function", "tell", "(", ")", "{", "if", "(", "$", "this", "->", "_resource", "===", "null", "&&", "$", "this", "->", "_filename", ")", "{", "$", "this", "->", "_resource", "=", "fopen", "(", "$", "this", "->", "_filename", ",", "$", "this", "->", "_mode", ")", ";", "}", "return", "ftell", "(", "$", "this", "->", "_resource", ")", ";", "}" ]
Get the position of the file pointer @return integer
[ "Get", "the", "position", "of", "the", "file", "pointer" ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L581-L587
crysalead/storage-stream
src/Stream.php
Stream.seek
public function seek($offset, $whence = SEEK_SET) { if ($this->_filename === 'php://input' && $this->eof() && !$offset && $whence === SEEK_SET) { $this->close(); $this->_resource = fopen($this->_filename, 'r'); } $this->_ensureSeekable(); fseek($this->_resource, $offset, $whence); return ftell($this->_resource); }
php
public function seek($offset, $whence = SEEK_SET) { if ($this->_filename === 'php://input' && $this->eof() && !$offset && $whence === SEEK_SET) { $this->close(); $this->_resource = fopen($this->_filename, 'r'); } $this->_ensureSeekable(); fseek($this->_resource, $offset, $whence); return ftell($this->_resource); }
[ "public", "function", "seek", "(", "$", "offset", ",", "$", "whence", "=", "SEEK_SET", ")", "{", "if", "(", "$", "this", "->", "_filename", "===", "'php://input'", "&&", "$", "this", "->", "eof", "(", ")", "&&", "!", "$", "offset", "&&", "$", "whence", "===", "SEEK_SET", ")", "{", "$", "this", "->", "close", "(", ")", ";", "$", "this", "->", "_resource", "=", "fopen", "(", "$", "this", "->", "_filename", ",", "'r'", ")", ";", "}", "$", "this", "->", "_ensureSeekable", "(", ")", ";", "fseek", "(", "$", "this", "->", "_resource", ",", "$", "offset", ",", "$", "whence", ")", ";", "return", "ftell", "(", "$", "this", "->", "_resource", ")", ";", "}" ]
Seek on the stream. @param integer $offset The offset. @param integer $whence Accepted values are: - SEEK_SET - Set position equal to $offset bytes. - SEEK_CUR - Set position to current location plus $offset. - SEEK_END - Set position to end-of-file plus $offset.
[ "Seek", "on", "the", "stream", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L598-L607
crysalead/storage-stream
src/Stream.php
Stream.end
public function end() { if ($this->_limit === null) { return $this->seek(0, SEEK_END); } else { return $this->seek($this->_start + $this->_limit); } }
php
public function end() { if ($this->_limit === null) { return $this->seek(0, SEEK_END); } else { return $this->seek($this->_start + $this->_limit); } }
[ "public", "function", "end", "(", ")", "{", "if", "(", "$", "this", "->", "_limit", "===", "null", ")", "{", "return", "$", "this", "->", "seek", "(", "0", ",", "SEEK_END", ")", ";", "}", "else", "{", "return", "$", "this", "->", "seek", "(", "$", "this", "->", "_start", "+", "$", "this", "->", "_limit", ")", ";", "}", "}" ]
Seek to the end of the stream. @return Boolean
[ "Seek", "to", "the", "end", "of", "the", "stream", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L634-L641
crysalead/storage-stream
src/Stream.php
Stream.valid
public function valid() { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } return !!$this->_resource && is_resource($this->_resource); }
php
public function valid() { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } return !!$this->_resource && is_resource($this->_resource); }
[ "public", "function", "valid", "(", ")", "{", "if", "(", "$", "this", "->", "_resource", "===", "null", "&&", "$", "this", "->", "_filename", ")", "{", "$", "this", "->", "_resource", "=", "fopen", "(", "$", "this", "->", "_filename", ",", "$", "this", "->", "_mode", ")", ";", "}", "return", "!", "!", "$", "this", "->", "_resource", "&&", "is_resource", "(", "$", "this", "->", "_resource", ")", ";", "}" ]
Check if the stream is valid. @return Boolean
[ "Check", "if", "the", "stream", "is", "valid", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L648-L654
crysalead/storage-stream
src/Stream.php
Stream.eof
public function eof() { $this->_ensureReadable(); if ($this->_limit === null) { return feof($this->_resource); } $position = $this->tell(); $max = $this->_start + $this->_limit; return $position >= $max; }
php
public function eof() { $this->_ensureReadable(); if ($this->_limit === null) { return feof($this->_resource); } $position = $this->tell(); $max = $this->_start + $this->_limit; return $position >= $max; }
[ "public", "function", "eof", "(", ")", "{", "$", "this", "->", "_ensureReadable", "(", ")", ";", "if", "(", "$", "this", "->", "_limit", "===", "null", ")", "{", "return", "feof", "(", "$", "this", "->", "_resource", ")", ";", "}", "$", "position", "=", "$", "this", "->", "tell", "(", ")", ";", "$", "max", "=", "$", "this", "->", "_start", "+", "$", "this", "->", "_limit", ";", "return", "$", "position", ">=", "$", "max", ";", "}" ]
Checks for EOF. @return boolean
[ "Checks", "for", "EOF", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L661-L670
crysalead/storage-stream
src/Stream.php
Stream.toString
public function toString() { if (!$this->isSeekable()) { return $this->flush(); } $old = $this->tell(); $this->rewind(); $result = $this->flush(); $this->seek($old); return $result; }
php
public function toString() { if (!$this->isSeekable()) { return $this->flush(); } $old = $this->tell(); $this->rewind(); $result = $this->flush(); $this->seek($old); return $result; }
[ "public", "function", "toString", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isSeekable", "(", ")", ")", "{", "return", "$", "this", "->", "flush", "(", ")", ";", "}", "$", "old", "=", "$", "this", "->", "tell", "(", ")", ";", "$", "this", "->", "rewind", "(", ")", ";", "$", "result", "=", "$", "this", "->", "flush", "(", ")", ";", "$", "this", "->", "seek", "(", "$", "old", ")", ";", "return", "$", "result", ";", "}" ]
Returns the remaining data from the stream (same as flush). @return string
[ "Returns", "the", "remaining", "data", "from", "the", "stream", "(", "same", "as", "flush", ")", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L677-L687
crysalead/storage-stream
src/Stream.php
Stream.getMime
public static function getMime($stream, $mime) { if (is_string($mime)) { return $mime; } if (!$mime || !$stream->isSeekable() || !$stream->isReadable()) { return; } $finfo = finfo_open(FILEINFO_MIME_TYPE); $old = $stream->tell(); $stream->rewind(); $end = $stream->end(); $size = min($end - 0, 4); if ($size === 0) { return; } $stream->seek($size, SEEK_SET); $signature = $stream->read($size, false); $size = min($end - 0, 1024); $stream->rewind(); $signature = $stream->read($size, false) . $signature; $stream->seek($old, SEEK_SET); return finfo_buffer($finfo, $signature); }
php
public static function getMime($stream, $mime) { if (is_string($mime)) { return $mime; } if (!$mime || !$stream->isSeekable() || !$stream->isReadable()) { return; } $finfo = finfo_open(FILEINFO_MIME_TYPE); $old = $stream->tell(); $stream->rewind(); $end = $stream->end(); $size = min($end - 0, 4); if ($size === 0) { return; } $stream->seek($size, SEEK_SET); $signature = $stream->read($size, false); $size = min($end - 0, 1024); $stream->rewind(); $signature = $stream->read($size, false) . $signature; $stream->seek($old, SEEK_SET); return finfo_buffer($finfo, $signature); }
[ "public", "static", "function", "getMime", "(", "$", "stream", ",", "$", "mime", ")", "{", "if", "(", "is_string", "(", "$", "mime", ")", ")", "{", "return", "$", "mime", ";", "}", "if", "(", "!", "$", "mime", "||", "!", "$", "stream", "->", "isSeekable", "(", ")", "||", "!", "$", "stream", "->", "isReadable", "(", ")", ")", "{", "return", ";", "}", "$", "finfo", "=", "finfo_open", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "old", "=", "$", "stream", "->", "tell", "(", ")", ";", "$", "stream", "->", "rewind", "(", ")", ";", "$", "end", "=", "$", "stream", "->", "end", "(", ")", ";", "$", "size", "=", "min", "(", "$", "end", "-", "0", ",", "4", ")", ";", "if", "(", "$", "size", "===", "0", ")", "{", "return", ";", "}", "$", "stream", "->", "seek", "(", "$", "size", ",", "SEEK_SET", ")", ";", "$", "signature", "=", "$", "stream", "->", "read", "(", "$", "size", ",", "false", ")", ";", "$", "size", "=", "min", "(", "$", "end", "-", "0", ",", "1024", ")", ";", "$", "stream", "->", "rewind", "(", ")", ";", "$", "signature", "=", "$", "stream", "->", "read", "(", "$", "size", ",", "false", ")", ".", "$", "signature", ";", "$", "stream", "->", "seek", "(", "$", "old", ",", "SEEK_SET", ")", ";", "return", "finfo_buffer", "(", "$", "finfo", ",", "$", "signature", ")", ";", "}" ]
Mime detector. Concat the first 1024 bytes + the last 4 bytes of readable & seekable streams to detext the mime info. @param string $stream The stream to extract mime value from. @param string $mime The mime type detection. Possible values are: -`true` : auto detect the mime. - a string : don't detect the mime and use the passed string instead. -`false` : don't detect the mime. @return string The detected mime.
[ "Mime", "detector", ".", "Concat", "the", "first", "1024", "bytes", "+", "the", "last", "4", "bytes", "of", "readable", "&", "seekable", "streams", "to", "detext", "the", "mime", "info", "." ]
train
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L750-L778
silvercommerce/geozones
src/Model/Zone.php
Zone.populateDefaults
public function populateDefaults() { parent::populateDefaults(); $current_region = Locale::getRegion(i18n::get_locale()); $this->Country = i18n::get_locale($current_region); }
php
public function populateDefaults() { parent::populateDefaults(); $current_region = Locale::getRegion(i18n::get_locale()); $this->Country = i18n::get_locale($current_region); }
[ "public", "function", "populateDefaults", "(", ")", "{", "parent", "::", "populateDefaults", "(", ")", ";", "$", "current_region", "=", "Locale", "::", "getRegion", "(", "i18n", "::", "get_locale", "(", ")", ")", ";", "$", "this", "->", "Country", "=", "i18n", "::", "get_locale", "(", "$", "current_region", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Model/Zone.php#L58-L64
silvercommerce/geozones
src/Model/Zone.php
Zone.getCountriesArray
public function getCountriesArray() { $return = json_decode($this->Country); if (empty($return) && isset($this->Country)) { $return = [$this->Country]; } return $return; }
php
public function getCountriesArray() { $return = json_decode($this->Country); if (empty($return) && isset($this->Country)) { $return = [$this->Country]; } return $return; }
[ "public", "function", "getCountriesArray", "(", ")", "{", "$", "return", "=", "json_decode", "(", "$", "this", "->", "Country", ")", ";", "if", "(", "empty", "(", "$", "return", ")", "&&", "isset", "(", "$", "this", "->", "Country", ")", ")", "{", "$", "return", "=", "[", "$", "this", "->", "Country", "]", ";", "}", "return", "$", "return", ";", "}" ]
Return an array of all associated countries @return array
[ "Return", "an", "array", "of", "all", "associated", "countries" ]
train
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Model/Zone.php#L71-L80
silvercommerce/geozones
src/Model/Zone.php
Zone.getCMSFields
public function getCMSFields() { $this->beforeUpdateCMSFields(function ($fields) { $fields->replaceField( "Country", ListboxField::create( 'Country', $this->fieldLabel("Country"), array_change_key_case( i18n::getData()->getCountries(), CASE_UPPER ) ) ); }); return parent::getCMSFields(); }
php
public function getCMSFields() { $this->beforeUpdateCMSFields(function ($fields) { $fields->replaceField( "Country", ListboxField::create( 'Country', $this->fieldLabel("Country"), array_change_key_case( i18n::getData()->getCountries(), CASE_UPPER ) ) ); }); return parent::getCMSFields(); }
[ "public", "function", "getCMSFields", "(", ")", "{", "$", "this", "->", "beforeUpdateCMSFields", "(", "function", "(", "$", "fields", ")", "{", "$", "fields", "->", "replaceField", "(", "\"Country\"", ",", "ListboxField", "::", "create", "(", "'Country'", ",", "$", "this", "->", "fieldLabel", "(", "\"Country\"", ")", ",", "array_change_key_case", "(", "i18n", "::", "getData", "(", ")", "->", "getCountries", "(", ")", ",", "CASE_UPPER", ")", ")", ")", ";", "}", ")", ";", "return", "parent", "::", "getCMSFields", "(", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Model/Zone.php#L95-L112
silvercommerce/geozones
src/Model/Zone.php
Zone.requireDefaultRecords
public function requireDefaultRecords() { parent::requireDefaultRecords(); if(ZoneMigrationTask::config()->run_during_dev_build) { $task = new ZoneMigrationTask(); $task->up(); } }
php
public function requireDefaultRecords() { parent::requireDefaultRecords(); if(ZoneMigrationTask::config()->run_during_dev_build) { $task = new ZoneMigrationTask(); $task->up(); } }
[ "public", "function", "requireDefaultRecords", "(", ")", "{", "parent", "::", "requireDefaultRecords", "(", ")", ";", "if", "(", "ZoneMigrationTask", "::", "config", "(", ")", "->", "run_during_dev_build", ")", "{", "$", "task", "=", "new", "ZoneMigrationTask", "(", ")", ";", "$", "task", "->", "up", "(", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Model/Zone.php#L117-L124
silvercommerce/geozones
src/Model/Zone.php
Zone.onAfterWrite
public function onAfterWrite() { parent::onAfterWrite(); // If this applies to all regions in the country, // then add them all on save if ($this->AllRegions && isset($this->Country)) { foreach ($this->getCountriesArray() as $country) { $regions = Region::get() ->filter("CountryCode", $country); foreach ($regions as $region) { $this ->Regions() ->add($region); } } } }
php
public function onAfterWrite() { parent::onAfterWrite(); // If this applies to all regions in the country, // then add them all on save if ($this->AllRegions && isset($this->Country)) { foreach ($this->getCountriesArray() as $country) { $regions = Region::get() ->filter("CountryCode", $country); foreach ($regions as $region) { $this ->Regions() ->add($region); } } } }
[ "public", "function", "onAfterWrite", "(", ")", "{", "parent", "::", "onAfterWrite", "(", ")", ";", "// If this applies to all regions in the country,", "// then add them all on save", "if", "(", "$", "this", "->", "AllRegions", "&&", "isset", "(", "$", "this", "->", "Country", ")", ")", "{", "foreach", "(", "$", "this", "->", "getCountriesArray", "(", ")", "as", "$", "country", ")", "{", "$", "regions", "=", "Region", "::", "get", "(", ")", "->", "filter", "(", "\"CountryCode\"", ",", "$", "country", ")", ";", "foreach", "(", "$", "regions", "as", "$", "region", ")", "{", "$", "this", "->", "Regions", "(", ")", "->", "add", "(", "$", "region", ")", ";", "}", "}", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Model/Zone.php#L129-L147
mothership-ec/composer
src/Composer/Command/Command.php
Command.initialize
protected function initialize(InputInterface $input, OutputInterface $output) { if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) { $input->setOption('no-progress', true); } parent::initialize($input, $output); }
php
protected function initialize(InputInterface $input, OutputInterface $output) { if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) { $input->setOption('no-progress', true); } parent::initialize($input, $output); }
[ "protected", "function", "initialize", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "true", "===", "$", "input", "->", "hasParameterOption", "(", "array", "(", "'--no-ansi'", ")", ")", "&&", "$", "input", "->", "hasOption", "(", "'no-progress'", ")", ")", "{", "$", "input", "->", "setOption", "(", "'no-progress'", ",", "true", ")", ";", "}", "parent", "::", "initialize", "(", "$", "input", ",", "$", "output", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/Command.php#L111-L118
ekuiter/feature-php
FeaturePhp/Generator/ChunkGenerator.php
ChunkGenerator.getSpecification
protected function getSpecification($file, $settings, $artifact) { return fphp\Specification\ChunkSpecification::fromArrayAndSettings($file, $settings); }
php
protected function getSpecification($file, $settings, $artifact) { return fphp\Specification\ChunkSpecification::fromArrayAndSettings($file, $settings); }
[ "protected", "function", "getSpecification", "(", "$", "file", ",", "$", "settings", ",", "$", "artifact", ")", "{", "return", "fphp", "\\", "Specification", "\\", "ChunkSpecification", "::", "fromArrayAndSettings", "(", "$", "file", ",", "$", "settings", ")", ";", "}" ]
Returns a chunk specification from a plain settings array. @param array $file a plain settings array @param Settings $settings the generator's settings @param \FeaturePhp\Artifact\Artifact $artifact the currently processed artifact @return \FeaturePhp\Specification\ChunkSpecification
[ "Returns", "a", "chunk", "specification", "from", "a", "plain", "settings", "array", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/ChunkGenerator.php#L33-L35
zhouyl/mellivora
Mellivora/Database/Query/Grammars/MySqlGrammar.php
MySqlGrammar.compileJsonUpdateColumn
protected function compileJsonUpdateColumn($key, JsonExpression $value) { $path = explode('->', $key); $field = $this->wrapValue(array_shift($path)); $accessor = '"$.' . implode('.', $path) . '"'; return "{$field} = json_set({$field}, {$accessor}, {$value->getValue()})"; }
php
protected function compileJsonUpdateColumn($key, JsonExpression $value) { $path = explode('->', $key); $field = $this->wrapValue(array_shift($path)); $accessor = '"$.' . implode('.', $path) . '"'; return "{$field} = json_set({$field}, {$accessor}, {$value->getValue()})"; }
[ "protected", "function", "compileJsonUpdateColumn", "(", "$", "key", ",", "JsonExpression", "$", "value", ")", "{", "$", "path", "=", "explode", "(", "'->'", ",", "$", "key", ")", ";", "$", "field", "=", "$", "this", "->", "wrapValue", "(", "array_shift", "(", "$", "path", ")", ")", ";", "$", "accessor", "=", "'\"$.'", ".", "implode", "(", "'.'", ",", "$", "path", ")", ".", "'\"'", ";", "return", "\"{$field} = json_set({$field}, {$accessor}, {$value->getValue()})\"", ";", "}" ]
Prepares a JSON column being updated using the JSON_SET function. @param string $key @param \Mellivora\Database\Query\JsonExpression $value @return string
[ "Prepares", "a", "JSON", "column", "being", "updated", "using", "the", "JSON_SET", "function", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Query/Grammars/MySqlGrammar.php#L167-L176
zhouyl/mellivora
Mellivora/Database/Query/Grammars/MySqlGrammar.php
MySqlGrammar.prepareBindingsForUpdate
public function prepareBindingsForUpdate(array $bindings, array $values) { $values = collect($values)->reject(function ($value, $column) { return $this->isJsonSelector($column) && in_array(gettype($value), ['boolean', 'integer', 'double']); })->all(); return parent::prepareBindingsForUpdate($bindings, $values); }
php
public function prepareBindingsForUpdate(array $bindings, array $values) { $values = collect($values)->reject(function ($value, $column) { return $this->isJsonSelector($column) && in_array(gettype($value), ['boolean', 'integer', 'double']); })->all(); return parent::prepareBindingsForUpdate($bindings, $values); }
[ "public", "function", "prepareBindingsForUpdate", "(", "array", "$", "bindings", ",", "array", "$", "values", ")", "{", "$", "values", "=", "collect", "(", "$", "values", ")", "->", "reject", "(", "function", "(", "$", "value", ",", "$", "column", ")", "{", "return", "$", "this", "->", "isJsonSelector", "(", "$", "column", ")", "&&", "in_array", "(", "gettype", "(", "$", "value", ")", ",", "[", "'boolean'", ",", "'integer'", ",", "'double'", "]", ")", ";", "}", ")", "->", "all", "(", ")", ";", "return", "parent", "::", "prepareBindingsForUpdate", "(", "$", "bindings", ",", "$", "values", ")", ";", "}" ]
Prepare the bindings for an update statement. Booleans, integers, and doubles are inserted into JSON updates as raw values. @param array $bindings @param array $values @return array
[ "Prepare", "the", "bindings", "for", "an", "update", "statement", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Query/Grammars/MySqlGrammar.php#L188-L196
zhouyl/mellivora
Mellivora/Database/Query/Grammars/MySqlGrammar.php
MySqlGrammar.compileDeleteWithJoins
protected function compileDeleteWithJoins($query, $table, $where) { $joins = ' ' . $this->compileJoins($query, $query->joins); return trim("delete {$table} from {$table}{$joins} {$where}"); }
php
protected function compileDeleteWithJoins($query, $table, $where) { $joins = ' ' . $this->compileJoins($query, $query->joins); return trim("delete {$table} from {$table}{$joins} {$where}"); }
[ "protected", "function", "compileDeleteWithJoins", "(", "$", "query", ",", "$", "table", ",", "$", "where", ")", "{", "$", "joins", "=", "' '", ".", "$", "this", "->", "compileJoins", "(", "$", "query", ",", "$", "query", "->", "joins", ")", ";", "return", "trim", "(", "\"delete {$table} from {$table}{$joins} {$where}\"", ")", ";", "}" ]
Compile a delete query that uses joins. @param \Mellivora\Database\Query\Builder $query @param string $table @param array $where @return string
[ "Compile", "a", "delete", "query", "that", "uses", "joins", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Query/Grammars/MySqlGrammar.php#L252-L257
zhouyl/mellivora
Mellivora/Database/Query/Grammars/MySqlGrammar.php
MySqlGrammar.wrapValue
protected function wrapValue($value) { if ($value === '*') { return $value; } // If the given value is a JSON selector we will wrap it differently than a // traditional value. We will need to split this path and wrap each part // wrapped, etc. Otherwise, we will simply wrap the value as a string. if ($this->isJsonSelector($value)) { return $this->wrapJsonSelector($value); } return '`' . str_replace('`', '``', $value) . '`'; }
php
protected function wrapValue($value) { if ($value === '*') { return $value; } // If the given value is a JSON selector we will wrap it differently than a // traditional value. We will need to split this path and wrap each part // wrapped, etc. Otherwise, we will simply wrap the value as a string. if ($this->isJsonSelector($value)) { return $this->wrapJsonSelector($value); } return '`' . str_replace('`', '``', $value) . '`'; }
[ "protected", "function", "wrapValue", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "'*'", ")", "{", "return", "$", "value", ";", "}", "// If the given value is a JSON selector we will wrap it differently than a", "// traditional value. We will need to split this path and wrap each part", "// wrapped, etc. Otherwise, we will simply wrap the value as a string.", "if", "(", "$", "this", "->", "isJsonSelector", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "wrapJsonSelector", "(", "$", "value", ")", ";", "}", "return", "'`'", ".", "str_replace", "(", "'`'", ",", "'``'", ",", "$", "value", ")", ".", "'`'", ";", "}" ]
Wrap a single string in keyword identifiers. @param string $value @return string
[ "Wrap", "a", "single", "string", "in", "keyword", "identifiers", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Query/Grammars/MySqlGrammar.php#L266-L280
zhouyl/mellivora
Mellivora/Database/Query/Grammars/MySqlGrammar.php
MySqlGrammar.wrapJsonSelector
protected function wrapJsonSelector($value) { $path = explode('->', $value); $field = $this->wrapValue(array_shift($path)); return sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) { return '"' . $part . '"'; })->implode('.')); }
php
protected function wrapJsonSelector($value) { $path = explode('->', $value); $field = $this->wrapValue(array_shift($path)); return sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) { return '"' . $part . '"'; })->implode('.')); }
[ "protected", "function", "wrapJsonSelector", "(", "$", "value", ")", "{", "$", "path", "=", "explode", "(", "'->'", ",", "$", "value", ")", ";", "$", "field", "=", "$", "this", "->", "wrapValue", "(", "array_shift", "(", "$", "path", ")", ")", ";", "return", "sprintf", "(", "'%s->\\'$.%s\\''", ",", "$", "field", ",", "collect", "(", "$", "path", ")", "->", "map", "(", "function", "(", "$", "part", ")", "{", "return", "'\"'", ".", "$", "part", ".", "'\"'", ";", "}", ")", "->", "implode", "(", "'.'", ")", ")", ";", "}" ]
Wrap the given JSON selector. @param string $value @return string
[ "Wrap", "the", "given", "JSON", "selector", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Query/Grammars/MySqlGrammar.php#L289-L298
inhere/php-librarys
src/Helpers/DateHelper.php
DateHelper.isTimestamp
public static function isTimestamp($timestamp) { if (!$timestamp || !is_numeric($timestamp) || 10 !== \strlen($timestamp)) { return false; } return date('Ymd', $timestamp) ? true : false; }
php
public static function isTimestamp($timestamp) { if (!$timestamp || !is_numeric($timestamp) || 10 !== \strlen($timestamp)) { return false; } return date('Ymd', $timestamp) ? true : false; }
[ "public", "static", "function", "isTimestamp", "(", "$", "timestamp", ")", "{", "if", "(", "!", "$", "timestamp", "||", "!", "is_numeric", "(", "$", "timestamp", ")", "||", "10", "!==", "\\", "strlen", "(", "$", "timestamp", ")", ")", "{", "return", "false", ";", "}", "return", "date", "(", "'Ymd'", ",", "$", "timestamp", ")", "?", "true", ":", "false", ";", "}" ]
判断给定的 字符串 是否是个 时间戳 @param int $timestamp 时间戳 @return bool|string datetime
[ "判断给定的", "字符串", "是否是个", "时间戳" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DateHelper.php#L23-L30
inhere/php-librarys
src/Helpers/DateHelper.php
DateHelper.isDateFormat
public static function isDateFormat($date, $format = 'Y-m-d') { if (!$unixTime = strtotime($date)) { return false; } // 校验日期的格式有效性 if (date($format, $unixTime) === $date) { return true; } return false; }
php
public static function isDateFormat($date, $format = 'Y-m-d') { if (!$unixTime = strtotime($date)) { return false; } // 校验日期的格式有效性 if (date($format, $unixTime) === $date) { return true; } return false; }
[ "public", "static", "function", "isDateFormat", "(", "$", "date", ",", "$", "format", "=", "'Y-m-d'", ")", "{", "if", "(", "!", "$", "unixTime", "=", "strtotime", "(", "$", "date", ")", ")", "{", "return", "false", ";", "}", "// 校验日期的格式有效性", "if", "(", "date", "(", "$", "format", ",", "$", "unixTime", ")", "===", "$", "date", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
校验值是否是日期并且是否满足设定格式 @param string $date 日期 @param string $format 需要检验的格式数组 @return boolean
[ "校验值是否是日期并且是否满足设定格式" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DateHelper.php#L49-L61
inhere/php-librarys
src/Helpers/DateHelper.php
DateHelper.getTheMonth
public static function getTheMonth($date) { $firstDay = date('Y-m-01', strtotime($date)); $lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day")); return array($firstDay, $lastDay); }
php
public static function getTheMonth($date) { $firstDay = date('Y-m-01', strtotime($date)); $lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day")); return array($firstDay, $lastDay); }
[ "public", "static", "function", "getTheMonth", "(", "$", "date", ")", "{", "$", "firstDay", "=", "date", "(", "'Y-m-01'", ",", "strtotime", "(", "$", "date", ")", ")", ";", "$", "lastDay", "=", "date", "(", "'Y-m-d'", ",", "strtotime", "(", "\"$firstDay +1 month -1 day\"", ")", ")", ";", "return", "array", "(", "$", "firstDay", ",", "$", "lastDay", ")", ";", "}" ]
获取指定日期所在月的第一天和最后一天
[ "获取指定日期所在月的第一天和最后一天" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DateHelper.php#L114-L120
inhere/php-librarys
src/Helpers/DateHelper.php
DateHelper.getPurMonth
public static function getPurMonth($date) { $time = strtotime($date); $firstDay = date('Y-m-01', strtotime(date('Y', $time) . '-' . (date('m', $time) - 1) . '-01')); $lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day")); return array($firstDay, $lastDay); }
php
public static function getPurMonth($date) { $time = strtotime($date); $firstDay = date('Y-m-01', strtotime(date('Y', $time) . '-' . (date('m', $time) - 1) . '-01')); $lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day")); return array($firstDay, $lastDay); }
[ "public", "static", "function", "getPurMonth", "(", "$", "date", ")", "{", "$", "time", "=", "strtotime", "(", "$", "date", ")", ";", "$", "firstDay", "=", "date", "(", "'Y-m-01'", ",", "strtotime", "(", "date", "(", "'Y'", ",", "$", "time", ")", ".", "'-'", ".", "(", "date", "(", "'m'", ",", "$", "time", ")", "-", "1", ")", ".", "'-01'", ")", ")", ";", "$", "lastDay", "=", "date", "(", "'Y-m-d'", ",", "strtotime", "(", "\"$firstDay +1 month -1 day\"", ")", ")", ";", "return", "array", "(", "$", "firstDay", ",", "$", "lastDay", ")", ";", "}" ]
获取指定日期上个月的第一天和最后一天
[ "获取指定日期上个月的第一天和最后一天" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DateHelper.php#L123-L130
inhere/php-librarys
src/Helpers/DateHelper.php
DateHelper.getNextMonth
public static function getNextMonth($date) { $arr = getdate(); if ($arr['mon'] === 12) { $year = $arr['year'] + 1; $month = $arr['mon'] - 11; $day = $arr['mday']; $mday = $day < 10 ? '0' . $day : $day; $firstDay = $year . '-0' . $month . '-01'; $lastDay = $year . '-0' . $month . '-' . $mday; } else { $time = strtotime($date); $firstDay = date('Y-m-01', strtotime(date('Y', $time) . '-' . (date('m', $time) + 1) . '-01')); $lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day")); } return [$firstDay, $lastDay]; }
php
public static function getNextMonth($date) { $arr = getdate(); if ($arr['mon'] === 12) { $year = $arr['year'] + 1; $month = $arr['mon'] - 11; $day = $arr['mday']; $mday = $day < 10 ? '0' . $day : $day; $firstDay = $year . '-0' . $month . '-01'; $lastDay = $year . '-0' . $month . '-' . $mday; } else { $time = strtotime($date); $firstDay = date('Y-m-01', strtotime(date('Y', $time) . '-' . (date('m', $time) + 1) . '-01')); $lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day")); } return [$firstDay, $lastDay]; }
[ "public", "static", "function", "getNextMonth", "(", "$", "date", ")", "{", "$", "arr", "=", "getdate", "(", ")", ";", "if", "(", "$", "arr", "[", "'mon'", "]", "===", "12", ")", "{", "$", "year", "=", "$", "arr", "[", "'year'", "]", "+", "1", ";", "$", "month", "=", "$", "arr", "[", "'mon'", "]", "-", "11", ";", "$", "day", "=", "$", "arr", "[", "'mday'", "]", ";", "$", "mday", "=", "$", "day", "<", "10", "?", "'0'", ".", "$", "day", ":", "$", "day", ";", "$", "firstDay", "=", "$", "year", ".", "'-0'", ".", "$", "month", ".", "'-01'", ";", "$", "lastDay", "=", "$", "year", ".", "'-0'", ".", "$", "month", ".", "'-'", ".", "$", "mday", ";", "}", "else", "{", "$", "time", "=", "strtotime", "(", "$", "date", ")", ";", "$", "firstDay", "=", "date", "(", "'Y-m-01'", ",", "strtotime", "(", "date", "(", "'Y'", ",", "$", "time", ")", ".", "'-'", ".", "(", "date", "(", "'m'", ",", "$", "time", ")", "+", "1", ")", ".", "'-01'", ")", ")", ";", "$", "lastDay", "=", "date", "(", "'Y-m-d'", ",", "strtotime", "(", "\"$firstDay +1 month -1 day\"", ")", ")", ";", "}", "return", "[", "$", "firstDay", ",", "$", "lastDay", "]", ";", "}" ]
获取指定日期下个月的第一天和最后一天
[ "获取指定日期下个月的第一天和最后一天" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DateHelper.php#L133-L153
inhere/php-librarys
src/Helpers/DateHelper.php
DateHelper.before
public static function before($time, $unit = null) { if (!\is_int($time)) { return false; } $unit = $unit ?: ['年', '月', '星期', '日', '小时', '分钟', '秒']; $nowTime = time(); $diffTime = $nowTime - $time; switch (true) { case $time < ($nowTime - 31536000): return floor($diffTime / 31536000) . $unit[0]; case $time < ($nowTime - 2592000): return floor($diffTime / 2592000) . $unit[1]; case $time < ($nowTime - 604800): return floor($diffTime / 604800) . $unit[2]; case $time < ($nowTime - 86400): return floor($diffTime / 86400) . $unit[3]; case $time < ($nowTime - 3600): return floor($diffTime / 3600) . $unit[4]; case $time < ($nowTime - 60): return floor($diffTime / 60) . $unit[5]; default: return floor($diffTime) . $unit[6]; } }
php
public static function before($time, $unit = null) { if (!\is_int($time)) { return false; } $unit = $unit ?: ['年', '月', '星期', '日', '小时', '分钟', '秒']; $nowTime = time(); $diffTime = $nowTime - $time; switch (true) { case $time < ($nowTime - 31536000): return floor($diffTime / 31536000) . $unit[0]; case $time < ($nowTime - 2592000): return floor($diffTime / 2592000) . $unit[1]; case $time < ($nowTime - 604800): return floor($diffTime / 604800) . $unit[2]; case $time < ($nowTime - 86400): return floor($diffTime / 86400) . $unit[3]; case $time < ($nowTime - 3600): return floor($diffTime / 3600) . $unit[4]; case $time < ($nowTime - 60): return floor($diffTime / 60) . $unit[5]; default: return floor($diffTime) . $unit[6]; } }
[ "public", "static", "function", "before", "(", "$", "time", ",", "$", "unit", "=", "null", ")", "{", "if", "(", "!", "\\", "is_int", "(", "$", "time", ")", ")", "{", "return", "false", ";", "}", "$", "unit", "=", "$", "unit", "?", ":", "[", "'年', ", "'", "', '星", "期", ", '日', '", "小", "', '分", "钟", ", '秒'];", "", "", "", "", "", "", "$", "nowTime", "=", "time", "(", ")", ";", "$", "diffTime", "=", "$", "nowTime", "-", "$", "time", ";", "switch", "(", "true", ")", "{", "case", "$", "time", "<", "(", "$", "nowTime", "-", "31536000", ")", ":", "return", "floor", "(", "$", "diffTime", "/", "31536000", ")", ".", "$", "unit", "[", "0", "]", ";", "case", "$", "time", "<", "(", "$", "nowTime", "-", "2592000", ")", ":", "return", "floor", "(", "$", "diffTime", "/", "2592000", ")", ".", "$", "unit", "[", "1", "]", ";", "case", "$", "time", "<", "(", "$", "nowTime", "-", "604800", ")", ":", "return", "floor", "(", "$", "diffTime", "/", "604800", ")", ".", "$", "unit", "[", "2", "]", ";", "case", "$", "time", "<", "(", "$", "nowTime", "-", "86400", ")", ":", "return", "floor", "(", "$", "diffTime", "/", "86400", ")", ".", "$", "unit", "[", "3", "]", ";", "case", "$", "time", "<", "(", "$", "nowTime", "-", "3600", ")", ":", "return", "floor", "(", "$", "diffTime", "/", "3600", ")", ".", "$", "unit", "[", "4", "]", ";", "case", "$", "time", "<", "(", "$", "nowTime", "-", "60", ")", ":", "return", "floor", "(", "$", "diffTime", "/", "60", ")", ".", "$", "unit", "[", "5", "]", ";", "default", ":", "return", "floor", "(", "$", "diffTime", ")", ".", "$", "unit", "[", "6", "]", ";", "}", "}" ]
获得几天前,几小时前,几月前 @param $time @param null|array $unit @return string
[ "获得几天前,几小时前,几月前" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DateHelper.php#L161-L187
expectation-php/expect
src/package/ReflectionIterator.php
ReflectionIterator.getClassFullNameFromFile
private function getClassFullNameFromFile(SplFileInfo $file) { $targets = [ realpath($this->namespaceDirectory).'/', '.php', ]; $replaceValues = ['', '']; $className = str_replace($targets, $replaceValues, realpath($file->getPathname())); $className = str_replace('/', "\\", $className); return $this->namespace."\\".$className; }
php
private function getClassFullNameFromFile(SplFileInfo $file) { $targets = [ realpath($this->namespaceDirectory).'/', '.php', ]; $replaceValues = ['', '']; $className = str_replace($targets, $replaceValues, realpath($file->getPathname())); $className = str_replace('/', "\\", $className); return $this->namespace."\\".$className; }
[ "private", "function", "getClassFullNameFromFile", "(", "SplFileInfo", "$", "file", ")", "{", "$", "targets", "=", "[", "realpath", "(", "$", "this", "->", "namespaceDirectory", ")", ".", "'/'", ",", "'.php'", ",", "]", ";", "$", "replaceValues", "=", "[", "''", ",", "''", "]", ";", "$", "className", "=", "str_replace", "(", "$", "targets", ",", "$", "replaceValues", ",", "realpath", "(", "$", "file", "->", "getPathname", "(", ")", ")", ")", ";", "$", "className", "=", "str_replace", "(", "'/'", ",", "\"\\\\\"", ",", "$", "className", ")", ";", "return", "$", "this", "->", "namespace", ".", "\"\\\\\"", ".", "$", "className", ";", "}" ]
@param SplFileInfo $file @return mixed
[ "@param", "SplFileInfo", "$file" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/package/ReflectionIterator.php#L73-L86
expectation-php/expect
src/package/ReflectionIterator.php
ReflectionIterator.createIterator
private function createIterator($directory) { $directoryIterator = new RecursiveDirectoryIterator($directory, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::SKIP_DOTS ); $filterIterator = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::LEAVES_ONLY); return $filterIterator; }
php
private function createIterator($directory) { $directoryIterator = new RecursiveDirectoryIterator($directory, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::SKIP_DOTS ); $filterIterator = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::LEAVES_ONLY); return $filterIterator; }
[ "private", "function", "createIterator", "(", "$", "directory", ")", "{", "$", "directoryIterator", "=", "new", "RecursiveDirectoryIterator", "(", "$", "directory", ",", "FilesystemIterator", "::", "CURRENT_AS_FILEINFO", "|", "FilesystemIterator", "::", "KEY_AS_PATHNAME", "|", "FilesystemIterator", "::", "SKIP_DOTS", ")", ";", "$", "filterIterator", "=", "new", "RecursiveIteratorIterator", "(", "$", "directoryIterator", ",", "RecursiveIteratorIterator", "::", "LEAVES_ONLY", ")", ";", "return", "$", "filterIterator", ";", "}" ]
@param string $directory @return RecursiveIteratorIterator
[ "@param", "string", "$directory" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/package/ReflectionIterator.php#L93-L105
fkooman/php-lib-http
src/fkooman/Http/Session.php
Session.startSession
private function startSession() { if ('' === session_id()) { // no session active session_set_cookie_params( $this->sessionOptions['lifetime'], $this->sessionOptions['path'], $this->sessionOptions['domain'], $this->sessionOptions['secure'], $this->sessionOptions['httponly'] ); session_start(); } }
php
private function startSession() { if ('' === session_id()) { // no session active session_set_cookie_params( $this->sessionOptions['lifetime'], $this->sessionOptions['path'], $this->sessionOptions['domain'], $this->sessionOptions['secure'], $this->sessionOptions['httponly'] ); session_start(); } }
[ "private", "function", "startSession", "(", ")", "{", "if", "(", "''", "===", "session_id", "(", ")", ")", "{", "// no session active", "session_set_cookie_params", "(", "$", "this", "->", "sessionOptions", "[", "'lifetime'", "]", ",", "$", "this", "->", "sessionOptions", "[", "'path'", "]", ",", "$", "this", "->", "sessionOptions", "[", "'domain'", "]", ",", "$", "this", "->", "sessionOptions", "[", "'secure'", "]", ",", "$", "this", "->", "sessionOptions", "[", "'httponly'", "]", ")", ";", "session_start", "(", ")", ";", "}", "}" ]
Start the session. We only start the session when it is actually being used by any of the session methods.
[ "Start", "the", "session", "." ]
train
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Session.php#L49-L62
mothership-ec/composer
src/Composer/Package/Archiver/GitExcludeFilter.php
GitExcludeFilter.parseGitAttributesLine
public function parseGitAttributesLine($line) { $parts = preg_split('#\s+#', $line); if (count($parts) != 2) { return null; } if ($parts[1] === 'export-ignore') { return $this->generatePattern($parts[0]); } }
php
public function parseGitAttributesLine($line) { $parts = preg_split('#\s+#', $line); if (count($parts) != 2) { return null; } if ($parts[1] === 'export-ignore') { return $this->generatePattern($parts[0]); } }
[ "public", "function", "parseGitAttributesLine", "(", "$", "line", ")", "{", "$", "parts", "=", "preg_split", "(", "'#\\s+#'", ",", "$", "line", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "!=", "2", ")", "{", "return", "null", ";", "}", "if", "(", "$", "parts", "[", "1", "]", "===", "'export-ignore'", ")", "{", "return", "$", "this", "->", "generatePattern", "(", "$", "parts", "[", "0", "]", ")", ";", "}", "}" ]
Callback parser which finds export-ignore rules in git attribute lines @param string $line A line from .gitattributes @return array An exclude pattern for filter()
[ "Callback", "parser", "which", "finds", "export", "-", "ignore", "rules", "in", "git", "attribute", "lines" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Package/Archiver/GitExcludeFilter.php#L68-L79