repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/Entity.php
Entity.setField
public function setField($fieldName, $value) { if ($value instanceof \DateTime) { $value = $this->convertDateTime($value); } $this->values[$fieldName] = $value; $this->modified[$fieldName] = true; return $this; }
php
public function setField($fieldName, $value) { if ($value instanceof \DateTime) { $value = $this->convertDateTime($value); } $this->values[$fieldName] = $value; $this->modified[$fieldName] = true; return $this; }
[ "public", "function", "setField", "(", "$", "fieldName", ",", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "\\", "DateTime", ")", "{", "$", "value", "=", "$", "this", "->", "convertDateTime", "(", "$", "value", ")", ";", "}", "$", "this", "->", "values", "[", "$", "fieldName", "]", "=", "$", "value", ";", "$", "this", "->", "modified", "[", "$", "fieldName", "]", "=", "true", ";", "return", "$", "this", ";", "}" ]
Sets this entity's field and adds it to the list of modified fields. Returns $this, which allows for chaining of setters. @param string $fieldName Name of the field to set, see {@link http://workspace.pipelinersales.com/community/api/data/Entities.html API documentation}. All standard fields are in upper-case, with underscore between the words (e.g. FORM_TYPE). Custom fields don't have this requirement. @param mixed $value Value to set the fields to. DateTime objects are automatically converted to strings according to the configured format (so calling a getter afterwards will only return this string). Other types of values are used directly. @return Entity
[ "Sets", "this", "entity", "s", "field", "and", "adds", "it", "to", "the", "list", "of", "modified", "fields", ".", "Returns", "$this", "which", "allows", "for", "chaining", "of", "setters", "." ]
train
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/Entity.php#L76-L85
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/Entity.php
Entity.setFields
public function setFields($values) { foreach ($values as $field => $value) { $this->setField($field, $value); } }
php
public function setFields($values) { foreach ($values as $field => $value) { $this->setField($field, $value); } }
[ "public", "function", "setFields", "(", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "this", "->", "setField", "(", "$", "field", ",", "$", "value", ")", ";", "}", "}" ]
Sets values of multiple fields at once. Fields not present in the array will not be changed in any way. @param array $values an associative array of fields to values
[ "Sets", "values", "of", "multiple", "fields", "at", "once", ".", "Fields", "not", "present", "in", "the", "array", "will", "not", "be", "changed", "in", "any", "way", "." ]
train
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/Entity.php#L92-L97
phpmob/twig-modify-bundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('phpmob_twig_modify'); $rootNode ->children() ->scalarNode('enabled')->defaultValue(true)->end() ->scalarNode('cache_adapter')->defaultValue(null)->end() ->end() ->children() ->arrayNode('modifiers') ->useAttributeAsKey('name') ->prototype('array') ->children() ->variableNode('class')->cannotBeEmpty()->end() ->variableNode('method')->cannotBeEmpty()->defaultValue('modify')->end() ->variableNode('options')->cannotBeEmpty()->defaultValue([])->end() ->variableNode('enabled')->cannotBeEmpty()->defaultValue(true)->end() ->end() ->end() ->end() ->end() ; return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('phpmob_twig_modify'); $rootNode ->children() ->scalarNode('enabled')->defaultValue(true)->end() ->scalarNode('cache_adapter')->defaultValue(null)->end() ->end() ->children() ->arrayNode('modifiers') ->useAttributeAsKey('name') ->prototype('array') ->children() ->variableNode('class')->cannotBeEmpty()->end() ->variableNode('method')->cannotBeEmpty()->defaultValue('modify')->end() ->variableNode('options')->cannotBeEmpty()->defaultValue([])->end() ->variableNode('enabled')->cannotBeEmpty()->defaultValue(true)->end() ->end() ->end() ->end() ->end() ; return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'phpmob_twig_modify'", ")", ";", "$", "rootNode", "->", "children", "(", ")", "->", "scalarNode", "(", "'enabled'", ")", "->", "defaultValue", "(", "true", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'cache_adapter'", ")", "->", "defaultValue", "(", "null", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "children", "(", ")", "->", "arrayNode", "(", "'modifiers'", ")", "->", "useAttributeAsKey", "(", "'name'", ")", "->", "prototype", "(", "'array'", ")", "->", "children", "(", ")", "->", "variableNode", "(", "'class'", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "variableNode", "(", "'method'", ")", "->", "cannotBeEmpty", "(", ")", "->", "defaultValue", "(", "'modify'", ")", "->", "end", "(", ")", "->", "variableNode", "(", "'options'", ")", "->", "cannotBeEmpty", "(", ")", "->", "defaultValue", "(", "[", "]", ")", "->", "end", "(", ")", "->", "variableNode", "(", "'enabled'", ")", "->", "cannotBeEmpty", "(", ")", "->", "defaultValue", "(", "true", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/twig-modify-bundle/blob/30b70ca3ea7b902f2f29c8457cd4f8da45b1d29e/DependencyInjection/Configuration.php#L25-L51
WindomZ/shmcache
src/shmop.php
shmop.exists
protected function exists(int $id = 0): bool { return (bool)@shmop_open($id ? $id : $this->id, 'a', 0, 0); }
php
protected function exists(int $id = 0): bool { return (bool)@shmop_open($id ? $id : $this->id, 'a', 0, 0); }
[ "protected", "function", "exists", "(", "int", "$", "id", "=", "0", ")", ":", "bool", "{", "return", "(", "bool", ")", "@", "shmop_open", "(", "$", "id", "?", "$", "id", ":", "$", "this", "->", "id", ",", "'a'", ",", "0", ",", "0", ")", ";", "}" ]
Whether there is a system's id @param int $id [optional] @return bool
[ "Whether", "there", "is", "a", "system", "s", "id" ]
train
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L65-L68
WindomZ/shmcache
src/shmop.php
shmop.pack
protected function pack($data, int $seconds = 0): string { return serialize( array( 'data' => $this->toPack($data), 'timeout' => $seconds ? $this->microtime($seconds * 1000) : 0, ) ); }
php
protected function pack($data, int $seconds = 0): string { return serialize( array( 'data' => $this->toPack($data), 'timeout' => $seconds ? $this->microtime($seconds * 1000) : 0, ) ); }
[ "protected", "function", "pack", "(", "$", "data", ",", "int", "$", "seconds", "=", "0", ")", ":", "string", "{", "return", "serialize", "(", "array", "(", "'data'", "=>", "$", "this", "->", "toPack", "(", "$", "data", ")", ",", "'timeout'", "=>", "$", "seconds", "?", "$", "this", "->", "microtime", "(", "$", "seconds", "*", "1000", ")", ":", "0", ",", ")", ")", ";", "}" ]
Package to an array and serialize to a string @param mixed $data @param int $seconds [optional] @return string
[ "Package", "to", "an", "array", "and", "serialize", "to", "a", "string" ]
train
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L93-L101
WindomZ/shmcache
src/shmop.php
shmop.unpack
protected function unpack(string $data) { if ($data) { $data = unserialize($data); if (is_array($data) && isset($data['data']) && isset($data['timeout'])) { $timeout = intval($data['timeout']); if (!$timeout || $timeout >= $this->microtime()) { return $this->toUnpack($data['data']); } } } return false; }
php
protected function unpack(string $data) { if ($data) { $data = unserialize($data); if (is_array($data) && isset($data['data']) && isset($data['timeout'])) { $timeout = intval($data['timeout']); if (!$timeout || $timeout >= $this->microtime()) { return $this->toUnpack($data['data']); } } } return false; }
[ "protected", "function", "unpack", "(", "string", "$", "data", ")", "{", "if", "(", "$", "data", ")", "{", "$", "data", "=", "unserialize", "(", "$", "data", ")", ";", "if", "(", "is_array", "(", "$", "data", ")", "&&", "isset", "(", "$", "data", "[", "'data'", "]", ")", "&&", "isset", "(", "$", "data", "[", "'timeout'", "]", ")", ")", "{", "$", "timeout", "=", "intval", "(", "$", "data", "[", "'timeout'", "]", ")", ";", "if", "(", "!", "$", "timeout", "||", "$", "timeout", ">=", "$", "this", "->", "microtime", "(", ")", ")", "{", "return", "$", "this", "->", "toUnpack", "(", "$", "data", "[", "'data'", "]", ")", ";", "}", "}", "}", "return", "false", ";", "}" ]
Unpacking a string and parse no timeout data from array @param string $data @return mixed|bool
[ "Unpacking", "a", "string", "and", "parse", "no", "timeout", "data", "from", "array" ]
train
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L115-L128
WindomZ/shmcache
src/shmop.php
shmop.write
protected function write($data, int $seconds = 0): bool { if (!$data) { return false; } $this->clean(); $data = $this->pack($data, $seconds); $id = shmop_open($this->id, "n", $this->mode, strlen($data)); if (!$id) { return false; } $size = shmop_write($id, $data, 0); return !empty($size); }
php
protected function write($data, int $seconds = 0): bool { if (!$data) { return false; } $this->clean(); $data = $this->pack($data, $seconds); $id = shmop_open($this->id, "n", $this->mode, strlen($data)); if (!$id) { return false; } $size = shmop_write($id, $data, 0); return !empty($size); }
[ "protected", "function", "write", "(", "$", "data", ",", "int", "$", "seconds", "=", "0", ")", ":", "bool", "{", "if", "(", "!", "$", "data", ")", "{", "return", "false", ";", "}", "$", "this", "->", "clean", "(", ")", ";", "$", "data", "=", "$", "this", "->", "pack", "(", "$", "data", ",", "$", "seconds", ")", ";", "$", "id", "=", "shmop_open", "(", "$", "this", "->", "id", ",", "\"n\"", ",", "$", "this", "->", "mode", ",", "strlen", "(", "$", "data", ")", ")", ";", "if", "(", "!", "$", "id", ")", "{", "return", "false", ";", "}", "$", "size", "=", "shmop_write", "(", "$", "id", ",", "$", "data", ",", "0", ")", ";", "return", "!", "empty", "(", "$", "size", ")", ";", "}" ]
Write data into shared memory block @param mixed $data @param int $seconds [optional] @return bool
[ "Write", "data", "into", "shared", "memory", "block" ]
train
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L136-L154
WindomZ/shmcache
src/shmop.php
shmop.read
protected function read() { if ($this->exists()) { $id = shmop_open($this->id, "a", 0, 0); if (!$id) { return false; } $data = shmop_read($id, 0, shmop_size($id)); if (!$data) { return false; } $data = $this->unpack($data); shmop_close($id); return $data; } return false; }
php
protected function read() { if ($this->exists()) { $id = shmop_open($this->id, "a", 0, 0); if (!$id) { return false; } $data = shmop_read($id, 0, shmop_size($id)); if (!$data) { return false; } $data = $this->unpack($data); shmop_close($id); return $data; } return false; }
[ "protected", "function", "read", "(", ")", "{", "if", "(", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "id", "=", "shmop_open", "(", "$", "this", "->", "id", ",", "\"a\"", ",", "0", ",", "0", ")", ";", "if", "(", "!", "$", "id", ")", "{", "return", "false", ";", "}", "$", "data", "=", "shmop_read", "(", "$", "id", ",", "0", ",", "shmop_size", "(", "$", "id", ")", ")", ";", "if", "(", "!", "$", "data", ")", "{", "return", "false", ";", "}", "$", "data", "=", "$", "this", "->", "unpack", "(", "$", "data", ")", ";", "shmop_close", "(", "$", "id", ")", ";", "return", "$", "data", ";", "}", "return", "false", ";", "}" ]
Read data from shared memory block @return bool|mixed
[ "Read", "data", "from", "shared", "memory", "block" ]
train
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L160-L180
WindomZ/shmcache
src/shmop.php
shmop.clean
protected function clean() { if ($this->exists()) { $id = shmop_open($this->id, "a", 0, 0); shmop_delete($id); shmop_close($id); } }
php
protected function clean() { if ($this->exists()) { $id = shmop_open($this->id, "a", 0, 0); shmop_delete($id); shmop_close($id); } }
[ "protected", "function", "clean", "(", ")", "{", "if", "(", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "id", "=", "shmop_open", "(", "$", "this", "->", "id", ",", "\"a\"", ",", "0", ",", "0", ")", ";", "shmop_delete", "(", "$", "id", ")", ";", "shmop_close", "(", "$", "id", ")", ";", "}", "}" ]
Clean data from shared memory block
[ "Clean", "data", "from", "shared", "memory", "block" ]
train
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L185-L192
stubbles/stubbles-webapp-core
src/main/php/routing/SupportedMimeTypes.php
SupportedMimeTypes.findMatch
public function findMatch(AcceptHeader $acceptedMimeTypes) { if (count($this->mimeTypes) === 0) { return 'text/html'; } if (count($acceptedMimeTypes) === 0) { reset($this->mimeTypes); return current($this->mimeTypes); } return $acceptedMimeTypes->findMatchWithGreatestPriority($this->mimeTypes); }
php
public function findMatch(AcceptHeader $acceptedMimeTypes) { if (count($this->mimeTypes) === 0) { return 'text/html'; } if (count($acceptedMimeTypes) === 0) { reset($this->mimeTypes); return current($this->mimeTypes); } return $acceptedMimeTypes->findMatchWithGreatestPriority($this->mimeTypes); }
[ "public", "function", "findMatch", "(", "AcceptHeader", "$", "acceptedMimeTypes", ")", "{", "if", "(", "count", "(", "$", "this", "->", "mimeTypes", ")", "===", "0", ")", "{", "return", "'text/html'", ";", "}", "if", "(", "count", "(", "$", "acceptedMimeTypes", ")", "===", "0", ")", "{", "reset", "(", "$", "this", "->", "mimeTypes", ")", ";", "return", "current", "(", "$", "this", "->", "mimeTypes", ")", ";", "}", "return", "$", "acceptedMimeTypes", "->", "findMatchWithGreatestPriority", "(", "$", "this", "->", "mimeTypes", ")", ";", "}" ]
finds best matching mime type based on accept header @param \stubbles\peer\http\AcceptHeader $acceptedMimeTypes @return string|null
[ "finds", "best", "matching", "mime", "type", "based", "on", "accept", "header" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/SupportedMimeTypes.php#L122-L134
stubbles/stubbles-webapp-core
src/main/php/routing/SupportedMimeTypes.php
SupportedMimeTypes.removeDefaultMimeTypeClass
public static function removeDefaultMimeTypeClass(string $mimeType) { if (isset(self::$supported[$mimeType])) { unset(self::$supported[$mimeType]); } }
php
public static function removeDefaultMimeTypeClass(string $mimeType) { if (isset(self::$supported[$mimeType])) { unset(self::$supported[$mimeType]); } }
[ "public", "static", "function", "removeDefaultMimeTypeClass", "(", "string", "$", "mimeType", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "supported", "[", "$", "mimeType", "]", ")", ")", "{", "unset", "(", "self", "::", "$", "supported", "[", "$", "mimeType", "]", ")", ";", "}", "}" ]
removes default mime type class for given mime type @param string $mimeType @since 5.1.1
[ "removes", "default", "mime", "type", "class", "for", "given", "mime", "type" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/SupportedMimeTypes.php#L154-L159
stubbles/stubbles-webapp-core
src/main/php/routing/SupportedMimeTypes.php
SupportedMimeTypes.provideDefaultClassFor
public static function provideDefaultClassFor(string $mimeType): bool { if (in_array($mimeType, array_keys(self::$supported))) { return true; } if (class_exists('stubbles\xml\serializer\XmlSerializerFacade') && in_array($mimeType, array_keys(self::$xml))) { return true; } if (class_exists('stubbles\img\Image') && in_array($mimeType, array_keys(self::$image))) { return true; } return false; }
php
public static function provideDefaultClassFor(string $mimeType): bool { if (in_array($mimeType, array_keys(self::$supported))) { return true; } if (class_exists('stubbles\xml\serializer\XmlSerializerFacade') && in_array($mimeType, array_keys(self::$xml))) { return true; } if (class_exists('stubbles\img\Image') && in_array($mimeType, array_keys(self::$image))) { return true; } return false; }
[ "public", "static", "function", "provideDefaultClassFor", "(", "string", "$", "mimeType", ")", ":", "bool", "{", "if", "(", "in_array", "(", "$", "mimeType", ",", "array_keys", "(", "self", "::", "$", "supported", ")", ")", ")", "{", "return", "true", ";", "}", "if", "(", "class_exists", "(", "'stubbles\\xml\\serializer\\XmlSerializerFacade'", ")", "&&", "in_array", "(", "$", "mimeType", ",", "array_keys", "(", "self", "::", "$", "xml", ")", ")", ")", "{", "return", "true", ";", "}", "if", "(", "class_exists", "(", "'stubbles\\img\\Image'", ")", "&&", "in_array", "(", "$", "mimeType", ",", "array_keys", "(", "self", "::", "$", "image", ")", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
checks if a default class is known for the given mime type @param string $mimeType @return bool @since 5.0.0
[ "checks", "if", "a", "default", "class", "is", "known", "for", "the", "given", "mime", "type" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/SupportedMimeTypes.php#L168-L183
stubbles/stubbles-webapp-core
src/main/php/routing/SupportedMimeTypes.php
SupportedMimeTypes.classFor
public function classFor(string $mimeType) { if ($this->provideClass($mimeType)) { return $this->mimeTypeClasses[$mimeType]; } return null; }
php
public function classFor(string $mimeType) { if ($this->provideClass($mimeType)) { return $this->mimeTypeClasses[$mimeType]; } return null; }
[ "public", "function", "classFor", "(", "string", "$", "mimeType", ")", "{", "if", "(", "$", "this", "->", "provideClass", "(", "$", "mimeType", ")", ")", "{", "return", "$", "this", "->", "mimeTypeClasses", "[", "$", "mimeType", "]", ";", "}", "return", "null", ";", "}" ]
returns special class which was defined for given mime type or null if none defined @param string $mimeType @return string|null @since 3.2.0
[ "returns", "special", "class", "which", "was", "defined", "for", "given", "mime", "type", "or", "null", "if", "none", "defined" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/SupportedMimeTypes.php#L204-L211
blast-project/CoreBundle
src/Generator/BlastGenerator.php
BlastGenerator.addResource
public function addResource($modelClass) { $code = ''; if (is_file($this->file)) { $code = rtrim(file_get_contents($this->file)); } $parts = explode('\\', $modelClass); $this->renderFile('Blast.yml.twig', $this->file, array( 'fqcn' => $modelClass, 'fields' => $this->modelManager->getExportFields($modelClass), 'entity' => array_pop($parts), 'oldCode' => $code, )); }
php
public function addResource($modelClass) { $code = ''; if (is_file($this->file)) { $code = rtrim(file_get_contents($this->file)); } $parts = explode('\\', $modelClass); $this->renderFile('Blast.yml.twig', $this->file, array( 'fqcn' => $modelClass, 'fields' => $this->modelManager->getExportFields($modelClass), 'entity' => array_pop($parts), 'oldCode' => $code, )); }
[ "public", "function", "addResource", "(", "$", "modelClass", ")", "{", "$", "code", "=", "''", ";", "if", "(", "is_file", "(", "$", "this", "->", "file", ")", ")", "{", "$", "code", "=", "rtrim", "(", "file_get_contents", "(", "$", "this", "->", "file", ")", ")", ";", "}", "$", "parts", "=", "explode", "(", "'\\\\'", ",", "$", "modelClass", ")", ";", "$", "this", "->", "renderFile", "(", "'Blast.yml.twig'", ",", "$", "this", "->", "file", ",", "array", "(", "'fqcn'", "=>", "$", "modelClass", ",", "'fields'", "=>", "$", "this", "->", "modelManager", "->", "getExportFields", "(", "$", "modelClass", ")", ",", "'entity'", "=>", "array_pop", "(", "$", "parts", ")", ",", "'oldCode'", "=>", "$", "code", ",", ")", ")", ";", "}" ]
@param string $modelClass @throws \RuntimeException
[ "@param", "string", "$modelClass" ]
train
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Generator/BlastGenerator.php#L42-L58
o2system/session
src/Abstracts/AbstractHandler.php
AbstractHandler.destroyCookie
protected function destroyCookie() { return setcookie( $this->config[ 'name' ], null, 1, $this->config[ 'cookie' ]->path, '.' . ltrim($this->config[ 'cookie' ]->domain, '.'), $this->config[ 'cookie' ]->secure, true ); }
php
protected function destroyCookie() { return setcookie( $this->config[ 'name' ], null, 1, $this->config[ 'cookie' ]->path, '.' . ltrim($this->config[ 'cookie' ]->domain, '.'), $this->config[ 'cookie' ]->secure, true ); }
[ "protected", "function", "destroyCookie", "(", ")", "{", "return", "setcookie", "(", "$", "this", "->", "config", "[", "'name'", "]", ",", "null", ",", "1", ",", "$", "this", "->", "config", "[", "'cookie'", "]", "->", "path", ",", "'.'", ".", "ltrim", "(", "$", "this", "->", "config", "[", "'cookie'", "]", "->", "domain", ",", "'.'", ")", ",", "$", "this", "->", "config", "[", "'cookie'", "]", "->", "secure", ",", "true", ")", ";", "}" ]
AbstractHandler::_destroyCookie Internal method to force removal of a cookie by the client when session_destroy() is called. @return bool
[ "AbstractHandler", "::", "_destroyCookie" ]
train
https://github.com/o2system/session/blob/49f2af67b876a58c0895ac80fc64a01b27ea6a6d/src/Abstracts/AbstractHandler.php#L313-L324
belgattitude/soluble-metadata
src/Soluble/Metadata/Reader/AbstractMetadataReader.php
AbstractMetadataReader.getColumnsMetadata
public function getColumnsMetadata(string $sql): ColumnsMetadata { if ($this->cache_active) { $cache_key = md5($sql); if (!array_key_exists($cache_key, static::$metadata_cache)) { $md = $this->readColumnsMetadata($sql); static::$metadata_cache[$cache_key] = $md; } return static::$metadata_cache[$cache_key]; } return $this->readColumnsMetadata($sql); }
php
public function getColumnsMetadata(string $sql): ColumnsMetadata { if ($this->cache_active) { $cache_key = md5($sql); if (!array_key_exists($cache_key, static::$metadata_cache)) { $md = $this->readColumnsMetadata($sql); static::$metadata_cache[$cache_key] = $md; } return static::$metadata_cache[$cache_key]; } return $this->readColumnsMetadata($sql); }
[ "public", "function", "getColumnsMetadata", "(", "string", "$", "sql", ")", ":", "ColumnsMetadata", "{", "if", "(", "$", "this", "->", "cache_active", ")", "{", "$", "cache_key", "=", "md5", "(", "$", "sql", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "cache_key", ",", "static", "::", "$", "metadata_cache", ")", ")", "{", "$", "md", "=", "$", "this", "->", "readColumnsMetadata", "(", "$", "sql", ")", ";", "static", "::", "$", "metadata_cache", "[", "$", "cache_key", "]", "=", "$", "md", ";", "}", "return", "static", "::", "$", "metadata_cache", "[", "$", "cache_key", "]", ";", "}", "return", "$", "this", "->", "readColumnsMetadata", "(", "$", "sql", ")", ";", "}" ]
Return columns metadata from query. @throws Exception\UnsupportedTypeException @throws Exception\AmbiguousColumnException @throws Exception\InvalidQueryException
[ "Return", "columns", "metadata", "from", "query", "." ]
train
https://github.com/belgattitude/soluble-metadata/blob/6285461c40a619070f601184d58e6c772b769d5c/src/Soluble/Metadata/Reader/AbstractMetadataReader.php#L48-L61
belgattitude/soluble-metadata
src/Soluble/Metadata/Reader/AbstractMetadataReader.php
AbstractMetadataReader.getTableMetadata
public function getTableMetadata(string $table): ColumnsMetadata { try { $metadata = $this->getColumnsMetadata(sprintf('select * from %s', $table)); } catch (Exception\InvalidQueryException $e) { throw new Exception\TableNotFoundException(sprintf( 'Table "%s" does not exists (%s).', $table, $e->getMessage() )); } return $metadata; }
php
public function getTableMetadata(string $table): ColumnsMetadata { try { $metadata = $this->getColumnsMetadata(sprintf('select * from %s', $table)); } catch (Exception\InvalidQueryException $e) { throw new Exception\TableNotFoundException(sprintf( 'Table "%s" does not exists (%s).', $table, $e->getMessage() )); } return $metadata; }
[ "public", "function", "getTableMetadata", "(", "string", "$", "table", ")", ":", "ColumnsMetadata", "{", "try", "{", "$", "metadata", "=", "$", "this", "->", "getColumnsMetadata", "(", "sprintf", "(", "'select * from %s'", ",", "$", "table", ")", ")", ";", "}", "catch", "(", "Exception", "\\", "InvalidQueryException", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "TableNotFoundException", "(", "sprintf", "(", "'Table \"%s\" does not exists (%s).'", ",", "$", "table", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "return", "$", "metadata", ";", "}" ]
Return columns metadata from a table. @throws Exception\UnsupportedTypeException @throws Exception\AmbiguousColumnException @throws Exception\TableNotFoundException
[ "Return", "columns", "metadata", "from", "a", "table", "." ]
train
https://github.com/belgattitude/soluble-metadata/blob/6285461c40a619070f601184d58e6c772b769d5c/src/Soluble/Metadata/Reader/AbstractMetadataReader.php#L70-L83
belgattitude/soluble-metadata
src/Soluble/Metadata/Reader/AbstractMetadataReader.php
AbstractMetadataReader.getEmptiedQuery
protected function getEmptiedQuery(string $sql): string { // see the reason why in Vision_Store_Adapter_ZendDbSelect::getMetaData //$sql = str_replace("('__innerselect'='__innerselect')", '(1=0)', $sql); $sql = preg_replace('/(\r\n|\r|\n|\t)+/', ' ', strtolower($sql)); $sql = trim($sql ?: ''); $sql = preg_replace('/\s+/', ' ', $sql) ?: ''; $replace_regexp = "LIMIT[\s]+[\d]+((\s*,\s*\d+)|(\s+OFFSET\s+\d+)){0,1}"; $search_regexp = "$replace_regexp"; if (preg_match("/$search_regexp/i", $sql) < 1) { // Limit is not already present $sql .= ' LIMIT 0'; } else { // replace first if offset exists, then if not //preg_match_all("/($search_regexp)/i", $sql, $matches, PREG_PATTERN_ORDER); //var_dump($matches); $sql = preg_replace("/($replace_regexp)/i", 'LIMIT 0', $sql) ?: ''; } return $sql; }
php
protected function getEmptiedQuery(string $sql): string { // see the reason why in Vision_Store_Adapter_ZendDbSelect::getMetaData //$sql = str_replace("('__innerselect'='__innerselect')", '(1=0)', $sql); $sql = preg_replace('/(\r\n|\r|\n|\t)+/', ' ', strtolower($sql)); $sql = trim($sql ?: ''); $sql = preg_replace('/\s+/', ' ', $sql) ?: ''; $replace_regexp = "LIMIT[\s]+[\d]+((\s*,\s*\d+)|(\s+OFFSET\s+\d+)){0,1}"; $search_regexp = "$replace_regexp"; if (preg_match("/$search_regexp/i", $sql) < 1) { // Limit is not already present $sql .= ' LIMIT 0'; } else { // replace first if offset exists, then if not //preg_match_all("/($search_regexp)/i", $sql, $matches, PREG_PATTERN_ORDER); //var_dump($matches); $sql = preg_replace("/($replace_regexp)/i", 'LIMIT 0', $sql) ?: ''; } return $sql; }
[ "protected", "function", "getEmptiedQuery", "(", "string", "$", "sql", ")", ":", "string", "{", "// see the reason why in Vision_Store_Adapter_ZendDbSelect::getMetaData", "//$sql = str_replace(\"('__innerselect'='__innerselect')\", '(1=0)', $sql);", "$", "sql", "=", "preg_replace", "(", "'/(\\r\\n|\\r|\\n|\\t)+/'", ",", "' '", ",", "strtolower", "(", "$", "sql", ")", ")", ";", "$", "sql", "=", "trim", "(", "$", "sql", "?", ":", "''", ")", ";", "$", "sql", "=", "preg_replace", "(", "'/\\s+/'", ",", "' '", ",", "$", "sql", ")", "?", ":", "''", ";", "$", "replace_regexp", "=", "\"LIMIT[\\s]+[\\d]+((\\s*,\\s*\\d+)|(\\s+OFFSET\\s+\\d+)){0,1}\"", ";", "$", "search_regexp", "=", "\"$replace_regexp\"", ";", "if", "(", "preg_match", "(", "\"/$search_regexp/i\"", ",", "$", "sql", ")", "<", "1", ")", "{", "// Limit is not already present", "$", "sql", ".=", "' LIMIT 0'", ";", "}", "else", "{", "// replace first if offset exists, then if not", "//preg_match_all(\"/($search_regexp)/i\", $sql, $matches, PREG_PATTERN_ORDER);", "//var_dump($matches);", "$", "sql", "=", "preg_replace", "(", "\"/($replace_regexp)/i\"", ",", "'LIMIT 0'", ",", "$", "sql", ")", "?", ":", "''", ";", "}", "return", "$", "sql", ";", "}" ]
Optimization, will add false condition to the query so the metadata loading will be faster.
[ "Optimization", "will", "add", "false", "condition", "to", "the", "query", "so", "the", "metadata", "loading", "will", "be", "faster", "." ]
train
https://github.com/belgattitude/soluble-metadata/blob/6285461c40a619070f601184d58e6c772b769d5c/src/Soluble/Metadata/Reader/AbstractMetadataReader.php#L98-L122
jan-dolata/crude-crud
src/Http/Requests/AutocompleteRequest.php
AutocompleteRequest.authorize
public function authorize() { $crude = CrudeInstance::get($this->crudeName); if ($crude == null) return false; return true; }
php
public function authorize() { $crude = CrudeInstance::get($this->crudeName); if ($crude == null) return false; return true; }
[ "public", "function", "authorize", "(", ")", "{", "$", "crude", "=", "CrudeInstance", "::", "get", "(", "$", "this", "->", "crudeName", ")", ";", "if", "(", "$", "crude", "==", "null", ")", "return", "false", ";", "return", "true", ";", "}" ]
Determine if the user is authorized to make this request. @return bool
[ "Determine", "if", "the", "user", "is", "authorized", "to", "make", "this", "request", "." ]
train
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Requests/AutocompleteRequest.php#L16-L24
cronario/cronario
src/Storage/Redis.php
Redis.save
public function save(AbstractJob $job) { $data = $job->getData(); if (!$job->isStored()) { $job->setId(uniqid()); } $this->redis->set($this->namespace . $job->getId(), json_encode($data)); return true; }
php
public function save(AbstractJob $job) { $data = $job->getData(); if (!$job->isStored()) { $job->setId(uniqid()); } $this->redis->set($this->namespace . $job->getId(), json_encode($data)); return true; }
[ "public", "function", "save", "(", "AbstractJob", "$", "job", ")", "{", "$", "data", "=", "$", "job", "->", "getData", "(", ")", ";", "if", "(", "!", "$", "job", "->", "isStored", "(", ")", ")", "{", "$", "job", "->", "setId", "(", "uniqid", "(", ")", ")", ";", "}", "$", "this", "->", "redis", "->", "set", "(", "$", "this", "->", "namespace", ".", "$", "job", "->", "getId", "(", ")", ",", "json_encode", "(", "$", "data", ")", ")", ";", "return", "true", ";", "}" ]
@param AbstractJob $job @return bool @throws \Cronario\Exception\JobException
[ "@param", "AbstractJob", "$job" ]
train
https://github.com/cronario/cronario/blob/954df60e95efd3085269331d435e8ce6f4980441/src/Storage/Redis.php#L40-L51
cronario/cronario
src/Storage/Redis.php
Redis.find
public function find($jobId) { $data = $this->redis->get($this->namespace . $jobId); $data = json_decode($data, true); $jobClass = $data[AbstractJob::P_JOB_CLASS]; /** @var AbstractJob $job */ $job = new $jobClass($data); return $job; }
php
public function find($jobId) { $data = $this->redis->get($this->namespace . $jobId); $data = json_decode($data, true); $jobClass = $data[AbstractJob::P_JOB_CLASS]; /** @var AbstractJob $job */ $job = new $jobClass($data); return $job; }
[ "public", "function", "find", "(", "$", "jobId", ")", "{", "$", "data", "=", "$", "this", "->", "redis", "->", "get", "(", "$", "this", "->", "namespace", ".", "$", "jobId", ")", ";", "$", "data", "=", "json_decode", "(", "$", "data", ",", "true", ")", ";", "$", "jobClass", "=", "$", "data", "[", "AbstractJob", "::", "P_JOB_CLASS", "]", ";", "/** @var AbstractJob $job */", "$", "job", "=", "new", "$", "jobClass", "(", "$", "data", ")", ";", "return", "$", "job", ";", "}" ]
@param $jobId @return AbstractJob
[ "@param", "$jobId" ]
train
https://github.com/cronario/cronario/blob/954df60e95efd3085269331d435e8ce6f4980441/src/Storage/Redis.php#L58-L69
andyvenus/form
src/Type/CollectionType.php
CollectionType.processFieldsCollection
protected function processFieldsCollection($fieldCollection, $data, FormHandler $formHandler) { $fields = array(); foreach ($fieldCollection as $field) { // Unnamed array fields if ($field['name'] === null) { if (!isset($i)) $i = 0; $field['name'] = $i; $field = $this->typeHandler->makeView($field, $data, $formHandler); $fields[] = $field; $i++; } // Named array fields else { $fieldName = $field['name']; $field = $this->typeHandler->makeView($field, $data, $formHandler); $field['has_error'] = false; if ($formHandler->fieldHasError($field['name'])) { $field['has_error'] = true; } $fields[$fieldName] = $field; } } return $fields; }
php
protected function processFieldsCollection($fieldCollection, $data, FormHandler $formHandler) { $fields = array(); foreach ($fieldCollection as $field) { // Unnamed array fields if ($field['name'] === null) { if (!isset($i)) $i = 0; $field['name'] = $i; $field = $this->typeHandler->makeView($field, $data, $formHandler); $fields[] = $field; $i++; } // Named array fields else { $fieldName = $field['name']; $field = $this->typeHandler->makeView($field, $data, $formHandler); $field['has_error'] = false; if ($formHandler->fieldHasError($field['name'])) { $field['has_error'] = true; } $fields[$fieldName] = $field; } } return $fields; }
[ "protected", "function", "processFieldsCollection", "(", "$", "fieldCollection", ",", "$", "data", ",", "FormHandler", "$", "formHandler", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "foreach", "(", "$", "fieldCollection", "as", "$", "field", ")", "{", "// Unnamed array fields", "if", "(", "$", "field", "[", "'name'", "]", "===", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "i", ")", ")", "$", "i", "=", "0", ";", "$", "field", "[", "'name'", "]", "=", "$", "i", ";", "$", "field", "=", "$", "this", "->", "typeHandler", "->", "makeView", "(", "$", "field", ",", "$", "data", ",", "$", "formHandler", ")", ";", "$", "fields", "[", "]", "=", "$", "field", ";", "$", "i", "++", ";", "}", "// Named array fields", "else", "{", "$", "fieldName", "=", "$", "field", "[", "'name'", "]", ";", "$", "field", "=", "$", "this", "->", "typeHandler", "->", "makeView", "(", "$", "field", ",", "$", "data", ",", "$", "formHandler", ")", ";", "$", "field", "[", "'has_error'", "]", "=", "false", ";", "if", "(", "$", "formHandler", "->", "fieldHasError", "(", "$", "field", "[", "'name'", "]", ")", ")", "{", "$", "field", "[", "'has_error'", "]", "=", "true", ";", "}", "$", "fields", "[", "$", "fieldName", "]", "=", "$", "field", ";", "}", "}", "return", "$", "fields", ";", "}" ]
Process a collection of fields @param $fieldCollection @param $data @param \AV\Form\FormHandler $formHandler @return array
[ "Process", "a", "collection", "of", "fields" ]
train
https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/Type/CollectionType.php#L72-L101
tjbp/laravel-verify-emails
src/Auth/VerifyEmails/VerifyEmailServiceProvider.php
VerifyEmailServiceProvider.registerVerifyEmailBroker
protected function registerVerifyEmailBroker() { $this->app->singleton('auth.verify_emails', function ($app) { return new VerifyEmailBrokerManager($app); }); $this->app->bind('auth.verify_emails.broker', function ($app) { return $app->make('auth.verify_emails')->broker(); }); }
php
protected function registerVerifyEmailBroker() { $this->app->singleton('auth.verify_emails', function ($app) { return new VerifyEmailBrokerManager($app); }); $this->app->bind('auth.verify_emails.broker', function ($app) { return $app->make('auth.verify_emails')->broker(); }); }
[ "protected", "function", "registerVerifyEmailBroker", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'auth.verify_emails'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "VerifyEmailBrokerManager", "(", "$", "app", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "'auth.verify_emails.broker'", ",", "function", "(", "$", "app", ")", "{", "return", "$", "app", "->", "make", "(", "'auth.verify_emails'", ")", "->", "broker", "(", ")", ";", "}", ")", ";", "}" ]
Register the verify email broker instance. @return void
[ "Register", "the", "verify", "email", "broker", "instance", "." ]
train
https://github.com/tjbp/laravel-verify-emails/blob/1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6/src/Auth/VerifyEmails/VerifyEmailServiceProvider.php#L34-L43
phramework/validate
src/BooleanValidator.php
BooleanValidator.validate
public function validate($value) { $return = new ValidateResult($value, false); $filterValue = filter_var($value, FILTER_VALIDATE_BOOLEAN, [ 'flags' => FILTER_NULL_ON_FAILURE ]); if ($filterValue === null) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'type' ] ]); } else { $return->errorObject = null; //Set status to success $return->status = true; //Type cast $return->value = $filterValue; } return $this->validateCommon($value, $return); }
php
public function validate($value) { $return = new ValidateResult($value, false); $filterValue = filter_var($value, FILTER_VALIDATE_BOOLEAN, [ 'flags' => FILTER_NULL_ON_FAILURE ]); if ($filterValue === null) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'type' ] ]); } else { $return->errorObject = null; //Set status to success $return->status = true; //Type cast $return->value = $filterValue; } return $this->validateCommon($value, $return); }
[ "public", "function", "validate", "(", "$", "value", ")", "{", "$", "return", "=", "new", "ValidateResult", "(", "$", "value", ",", "false", ")", ";", "$", "filterValue", "=", "filter_var", "(", "$", "value", ",", "FILTER_VALIDATE_BOOLEAN", ",", "[", "'flags'", "=>", "FILTER_NULL_ON_FAILURE", "]", ")", ";", "if", "(", "$", "filterValue", "===", "null", ")", "{", "//error", "$", "return", "->", "errorObject", "=", "new", "IncorrectParametersException", "(", "[", "[", "'type'", "=>", "static", "::", "getType", "(", ")", ",", "'failure'", "=>", "'type'", "]", "]", ")", ";", "}", "else", "{", "$", "return", "->", "errorObject", "=", "null", ";", "//Set status to success", "$", "return", "->", "status", "=", "true", ";", "//Type cast", "$", "return", "->", "value", "=", "$", "filterValue", ";", "}", "return", "$", "this", "->", "validateCommon", "(", "$", "value", ",", "$", "return", ")", ";", "}" ]
Validate value @see \Phramework\Validate\ValidateResult for ValidateResult object @param mixed $value Value to validate @return ValidateResult @uses filter_var with filter FILTER_VALIDATE_BOOLEAN @see https://secure.php.net/manual/en/filter.filters.validate.php
[ "Validate", "value" ]
train
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/BooleanValidator.php#L52-L78
movoin/one-swoole
src/Support/Helpers/Assert.php
Assert.datetime
public static function datetime($value): bool { if ($value instanceof \DateTime) { return true; } elseif (strtotime($value) !== false) { return true; } return false; }
php
public static function datetime($value): bool { if ($value instanceof \DateTime) { return true; } elseif (strtotime($value) !== false) { return true; } return false; }
[ "public", "static", "function", "datetime", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "$", "value", "instanceof", "\\", "DateTime", ")", "{", "return", "true", ";", "}", "elseif", "(", "strtotime", "(", "$", "value", ")", "!==", "false", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
判断是否日期类型 @param mixed $value @return bool
[ "判断是否日期类型" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Support/Helpers/Assert.php#L124-L133
movoin/one-swoole
src/Support/Helpers/Assert.php
Assert.resource
public static function resource($value, $type = null): bool { if ($type !== null) { return is_resource($value) && $type === get_resource_type($value); } return is_resource($value); }
php
public static function resource($value, $type = null): bool { if ($type !== null) { return is_resource($value) && $type === get_resource_type($value); } return is_resource($value); }
[ "public", "static", "function", "resource", "(", "$", "value", ",", "$", "type", "=", "null", ")", ":", "bool", "{", "if", "(", "$", "type", "!==", "null", ")", "{", "return", "is_resource", "(", "$", "value", ")", "&&", "$", "type", "===", "get_resource_type", "(", "$", "value", ")", ";", "}", "return", "is_resource", "(", "$", "value", ")", ";", "}" ]
判断是否资源类型 @param mixed $value @param string $type @return bool
[ "判断是否资源类型" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Support/Helpers/Assert.php#L143-L150
movoin/one-swoole
src/Support/Helpers/Assert.php
Assert.email
public static function email($value, $domains = null): bool { $isEmail = (bool) filter_var($value, FILTER_VALIDATE_EMAIL); if ($isEmail && $domains !== null) { list(, $host) = explode('@', $value); $domains = (array) $domains; if (in_array($host, $domains)) { return true; } return false; } return $isEmail; }
php
public static function email($value, $domains = null): bool { $isEmail = (bool) filter_var($value, FILTER_VALIDATE_EMAIL); if ($isEmail && $domains !== null) { list(, $host) = explode('@', $value); $domains = (array) $domains; if (in_array($host, $domains)) { return true; } return false; } return $isEmail; }
[ "public", "static", "function", "email", "(", "$", "value", ",", "$", "domains", "=", "null", ")", ":", "bool", "{", "$", "isEmail", "=", "(", "bool", ")", "filter_var", "(", "$", "value", ",", "FILTER_VALIDATE_EMAIL", ")", ";", "if", "(", "$", "isEmail", "&&", "$", "domains", "!==", "null", ")", "{", "list", "(", ",", "$", "host", ")", "=", "explode", "(", "'@'", ",", "$", "value", ")", ";", "$", "domains", "=", "(", "array", ")", "$", "domains", ";", "if", "(", "in_array", "(", "$", "host", ",", "$", "domains", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "return", "$", "isEmail", ";", "}" ]
判断是否 E-Mail @param mixed $value @param mixed $domains @return bool
[ "判断是否", "E", "-", "Mail" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Support/Helpers/Assert.php#L323-L339
baleen/cli
src/CommandBus/Repository/AbstractRepositoryListHandler.php
AbstractRepositoryListHandler.getCollection
protected function getCollection(RepositoryInterface $repository, callable $comparator = null) { $versions = $repository->fetchAll(); if ($comparator) { $versions->sortWith($comparator); } return $versions; }
php
protected function getCollection(RepositoryInterface $repository, callable $comparator = null) { $versions = $repository->fetchAll(); if ($comparator) { $versions->sortWith($comparator); } return $versions; }
[ "protected", "function", "getCollection", "(", "RepositoryInterface", "$", "repository", ",", "callable", "$", "comparator", "=", "null", ")", "{", "$", "versions", "=", "$", "repository", "->", "fetchAll", "(", ")", ";", "if", "(", "$", "comparator", ")", "{", "$", "versions", "->", "sortWith", "(", "$", "comparator", ")", ";", "}", "return", "$", "versions", ";", "}" ]
getCollection. @param RepositoryInterface $repository @param callable|null $comparator @return LinkedVersions
[ "getCollection", "." ]
train
https://github.com/baleen/cli/blob/2ecbc7179c5800c9075fd93204ef25da375536ed/src/CommandBus/Repository/AbstractRepositoryListHandler.php#L51-L59
ubirak/symfony-json-rest-api
src/Weblink.php
Weblink.fromWeblinkWithHost
public static function fromWeblinkWithHost(Weblink $weblink, $host) { $urlParts = parse_url($weblink->getUrl()); unset($urlParts['host']); unset($urlParts['scheme']); $urlWithHost = http_build_url($host, $urlParts); return new static($urlWithHost, $weblink->getRel(), $weblink->getAttributes()); }
php
public static function fromWeblinkWithHost(Weblink $weblink, $host) { $urlParts = parse_url($weblink->getUrl()); unset($urlParts['host']); unset($urlParts['scheme']); $urlWithHost = http_build_url($host, $urlParts); return new static($urlWithHost, $weblink->getRel(), $weblink->getAttributes()); }
[ "public", "static", "function", "fromWeblinkWithHost", "(", "Weblink", "$", "weblink", ",", "$", "host", ")", "{", "$", "urlParts", "=", "parse_url", "(", "$", "weblink", "->", "getUrl", "(", ")", ")", ";", "unset", "(", "$", "urlParts", "[", "'host'", "]", ")", ";", "unset", "(", "$", "urlParts", "[", "'scheme'", "]", ")", ";", "$", "urlWithHost", "=", "http_build_url", "(", "$", "host", ",", "$", "urlParts", ")", ";", "return", "new", "static", "(", "$", "urlWithHost", ",", "$", "weblink", "->", "getRel", "(", ")", ",", "$", "weblink", "->", "getAttributes", "(", ")", ")", ";", "}" ]
@param Weblink $weblink @param string $host complete base url (scheme+host) eg http://sub.domain.tld
[ "@param", "Weblink", "$weblink", "@param", "string", "$host", "complete", "base", "url", "(", "scheme", "+", "host", ")", "eg", "http", ":", "//", "sub", ".", "domain", ".", "tld" ]
train
https://github.com/ubirak/symfony-json-rest-api/blob/f34b58feebf7908897bc47403bd8859d4e26a069/src/Weblink.php#L48-L57
FrenchFrogs/framework
src/Form/Form/Form.php
Form.render
public function render() { $render = ''; try { $render = $this->getRenderer()->render('form', $this); } catch(\Exception $e){ dd($e->getMessage());//@todo find a good way to warn the developper } return $render; }
php
public function render() { $render = ''; try { $render = $this->getRenderer()->render('form', $this); } catch(\Exception $e){ dd($e->getMessage());//@todo find a good way to warn the developper } return $render; }
[ "public", "function", "render", "(", ")", "{", "$", "render", "=", "''", ";", "try", "{", "$", "render", "=", "$", "this", "->", "getRenderer", "(", ")", "->", "render", "(", "'form'", ",", "$", "this", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "dd", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "//@todo find a good way to warn the developper", "}", "return", "$", "render", ";", "}" ]
Render the polliwog @return mixed|string
[ "Render", "the", "polliwog" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L268-L278
FrenchFrogs/framework
src/Form/Form/Form.php
Form.getValues
public function getValues() { $values = []; foreach($this->getElements() as $name => $e) { /** @var $e \FrenchFrogs\Form\Element\Element */ if ($e->isDiscreet()) {continue;} $values[$name] = $e->getValue(); } return $values; }
php
public function getValues() { $values = []; foreach($this->getElements() as $name => $e) { /** @var $e \FrenchFrogs\Form\Element\Element */ if ($e->isDiscreet()) {continue;} $values[$name] = $e->getValue(); } return $values; }
[ "public", "function", "getValues", "(", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getElements", "(", ")", "as", "$", "name", "=>", "$", "e", ")", "{", "/** @var $e \\FrenchFrogs\\Form\\Element\\Element */", "if", "(", "$", "e", "->", "isDiscreet", "(", ")", ")", "{", "continue", ";", "}", "$", "values", "[", "$", "name", "]", "=", "$", "e", "->", "getValue", "(", ")", ";", "}", "return", "$", "values", ";", "}" ]
Return all values from all elements @return array
[ "Return", "all", "values", "from", "all", "elements" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L333-L344
FrenchFrogs/framework
src/Form/Form/Form.php
Form.getFilteredValues
public function getFilteredValues() { $values = []; foreach($this->getElements() as $name => $e){ /** @var \FrenchFrogs\Form\Element\Element $e */ if ($e->isDiscreet()) {continue;} $values[$name] = $e->getFilteredValue(); } return $values; }
php
public function getFilteredValues() { $values = []; foreach($this->getElements() as $name => $e){ /** @var \FrenchFrogs\Form\Element\Element $e */ if ($e->isDiscreet()) {continue;} $values[$name] = $e->getFilteredValue(); } return $values; }
[ "public", "function", "getFilteredValues", "(", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getElements", "(", ")", "as", "$", "name", "=>", "$", "e", ")", "{", "/** @var \\FrenchFrogs\\Form\\Element\\Element $e */", "if", "(", "$", "e", "->", "isDiscreet", "(", ")", ")", "{", "continue", ";", "}", "$", "values", "[", "$", "name", "]", "=", "$", "e", "->", "getFilteredValue", "(", ")", ";", "}", "return", "$", "values", ";", "}" ]
Return all filtered values from all elements @return array
[ "Return", "all", "filtered", "values", "from", "all", "elements" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L364-L374
FrenchFrogs/framework
src/Form/Form/Form.php
Form.valid
public function valid(array $values, $populate = true) { foreach($this->getElements() as $index => &$element) { if(!array_key_exists($index, $values)) { if(is_a($element, 'FrenchFrogs\Form\Element\Boolean')){ $values[$index] = 0; } else { $values[$index] = ''; } } $element->valid($values[$index]); if (!$element->isValid()) { $this->getValidator()->addError($index, $element->getErrorAsString()); } } return $this; }
php
public function valid(array $values, $populate = true) { foreach($this->getElements() as $index => &$element) { if(!array_key_exists($index, $values)) { if(is_a($element, 'FrenchFrogs\Form\Element\Boolean')){ $values[$index] = 0; } else { $values[$index] = ''; } } $element->valid($values[$index]); if (!$element->isValid()) { $this->getValidator()->addError($index, $element->getErrorAsString()); } } return $this; }
[ "public", "function", "valid", "(", "array", "$", "values", ",", "$", "populate", "=", "true", ")", "{", "foreach", "(", "$", "this", "->", "getElements", "(", ")", "as", "$", "index", "=>", "&", "$", "element", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "index", ",", "$", "values", ")", ")", "{", "if", "(", "is_a", "(", "$", "element", ",", "'FrenchFrogs\\Form\\Element\\Boolean'", ")", ")", "{", "$", "values", "[", "$", "index", "]", "=", "0", ";", "}", "else", "{", "$", "values", "[", "$", "index", "]", "=", "''", ";", "}", "}", "$", "element", "->", "valid", "(", "$", "values", "[", "$", "index", "]", ")", ";", "if", "(", "!", "$", "element", "->", "isValid", "(", ")", ")", "{", "$", "this", "->", "getValidator", "(", ")", "->", "addError", "(", "$", "index", ",", "$", "element", "->", "getErrorAsString", "(", ")", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Valid all the form elements @param array $values @param bool|true $populate @return $this
[ "Valid", "all", "the", "form", "elements" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L416-L436
FrenchFrogs/framework
src/Form/Form/Form.php
Form.getErrorAsString
public function getErrorAsString() { $errors = []; foreach($this->getValidator()->getErrors() as $index => $message){ $errors[] = sprintf('%s:%s %s', $index, PHP_EOL, $message); } return implode(PHP_EOL, $errors); }
php
public function getErrorAsString() { $errors = []; foreach($this->getValidator()->getErrors() as $index => $message){ $errors[] = sprintf('%s:%s %s', $index, PHP_EOL, $message); } return implode(PHP_EOL, $errors); }
[ "public", "function", "getErrorAsString", "(", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getValidator", "(", ")", "->", "getErrors", "(", ")", "as", "$", "index", "=>", "$", "message", ")", "{", "$", "errors", "[", "]", "=", "sprintf", "(", "'%s:%s %s'", ",", "$", "index", ",", "PHP_EOL", ",", "$", "message", ")", ";", "}", "return", "implode", "(", "PHP_EOL", ",", "$", "errors", ")", ";", "}" ]
Return string formated error from the form validation @return string
[ "Return", "string", "formated", "error", "from", "the", "form", "validation" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L445-L452
okvpn/fixture-bundle
src/Fixture/AbstractEntityReferenceFixture.php
AbstractEntityReferenceFixture.getObjectReferences
protected function getObjectReferences(ObjectManager $objectManager, $className) { $identifier = $objectManager->getClassMetadata($className)->getIdentifier(); $idField = reset($identifier); /** @var EntityRepository $objectRepository */ $objectRepository = $objectManager->getRepository($className); $idsResult = $objectRepository ->createQueryBuilder('t') ->select('t.' . $idField) ->getQuery() ->getArrayResult(); $ids = []; foreach ($idsResult as $result) { $ids[] = $result[$idField]; } return $this->getObjectReferencesByIds($objectManager, $className, $ids); }
php
protected function getObjectReferences(ObjectManager $objectManager, $className) { $identifier = $objectManager->getClassMetadata($className)->getIdentifier(); $idField = reset($identifier); /** @var EntityRepository $objectRepository */ $objectRepository = $objectManager->getRepository($className); $idsResult = $objectRepository ->createQueryBuilder('t') ->select('t.' . $idField) ->getQuery() ->getArrayResult(); $ids = []; foreach ($idsResult as $result) { $ids[] = $result[$idField]; } return $this->getObjectReferencesByIds($objectManager, $className, $ids); }
[ "protected", "function", "getObjectReferences", "(", "ObjectManager", "$", "objectManager", ",", "$", "className", ")", "{", "$", "identifier", "=", "$", "objectManager", "->", "getClassMetadata", "(", "$", "className", ")", "->", "getIdentifier", "(", ")", ";", "$", "idField", "=", "reset", "(", "$", "identifier", ")", ";", "/** @var EntityRepository $objectRepository */", "$", "objectRepository", "=", "$", "objectManager", "->", "getRepository", "(", "$", "className", ")", ";", "$", "idsResult", "=", "$", "objectRepository", "->", "createQueryBuilder", "(", "'t'", ")", "->", "select", "(", "'t.'", ".", "$", "idField", ")", "->", "getQuery", "(", ")", "->", "getArrayResult", "(", ")", ";", "$", "ids", "=", "[", "]", ";", "foreach", "(", "$", "idsResult", "as", "$", "result", ")", "{", "$", "ids", "[", "]", "=", "$", "result", "[", "$", "idField", "]", ";", "}", "return", "$", "this", "->", "getObjectReferencesByIds", "(", "$", "objectManager", ",", "$", "className", ",", "$", "ids", ")", ";", "}" ]
Returns array of object references. @param ObjectManager $objectManager @param string $className @return array @see getObjectReferencesByIds
[ "Returns", "array", "of", "object", "references", "." ]
train
https://github.com/okvpn/fixture-bundle/blob/243b5e4dff9773e97fa447280e929c936a5d66ae/src/Fixture/AbstractEntityReferenceFixture.php#L21-L41
okvpn/fixture-bundle
src/Fixture/AbstractEntityReferenceFixture.php
AbstractEntityReferenceFixture.getObjectReferencesByIds
protected function getObjectReferencesByIds(ObjectManager $objectManager, $className, array $ids) { $entities = []; foreach ($ids as $id) { /** @var EntityManager $objectManager */ $entities[] = $objectManager->getReference($className, $id); } return $entities; }
php
protected function getObjectReferencesByIds(ObjectManager $objectManager, $className, array $ids) { $entities = []; foreach ($ids as $id) { /** @var EntityManager $objectManager */ $entities[] = $objectManager->getReference($className, $id); } return $entities; }
[ "protected", "function", "getObjectReferencesByIds", "(", "ObjectManager", "$", "objectManager", ",", "$", "className", ",", "array", "$", "ids", ")", "{", "$", "entities", "=", "[", "]", ";", "foreach", "(", "$", "ids", "as", "$", "id", ")", "{", "/** @var EntityManager $objectManager */", "$", "entities", "[", "]", "=", "$", "objectManager", "->", "getReference", "(", "$", "className", ",", "$", "id", ")", ";", "}", "return", "$", "entities", ";", "}" ]
Returns array of object references by their ids. It's useful when ids are known and objects are used as other entities' relation. @param ObjectManager $objectManager @param string $className @param array $ids @return array
[ "Returns", "array", "of", "object", "references", "by", "their", "ids", ".", "It", "s", "useful", "when", "ids", "are", "known", "and", "objects", "are", "used", "as", "other", "entities", "relation", "." ]
train
https://github.com/okvpn/fixture-bundle/blob/243b5e4dff9773e97fa447280e929c936a5d66ae/src/Fixture/AbstractEntityReferenceFixture.php#L52-L62
ejsmont-artur/phpProxyBuilder
src/PhpProxyBuilder/Aop/Advice/CachingAdvice.php
CachingAdvice.interceptMethodCall
public function interceptMethodCall(ProceedingJoinPointInterface $jointPoint) { $key = md5(serialize(array( get_class($jointPoint->getTarget()), $jointPoint->getMethodName(), $jointPoint->getArguments() ))); $value = $this->cache->get($key); if ($value === null) { $value = $jointPoint->proceed(); $this->cache->set($key, $value, $this->ttl); } return $value; }
php
public function interceptMethodCall(ProceedingJoinPointInterface $jointPoint) { $key = md5(serialize(array( get_class($jointPoint->getTarget()), $jointPoint->getMethodName(), $jointPoint->getArguments() ))); $value = $this->cache->get($key); if ($value === null) { $value = $jointPoint->proceed(); $this->cache->set($key, $value, $this->ttl); } return $value; }
[ "public", "function", "interceptMethodCall", "(", "ProceedingJoinPointInterface", "$", "jointPoint", ")", "{", "$", "key", "=", "md5", "(", "serialize", "(", "array", "(", "get_class", "(", "$", "jointPoint", "->", "getTarget", "(", ")", ")", ",", "$", "jointPoint", "->", "getMethodName", "(", ")", ",", "$", "jointPoint", "->", "getArguments", "(", ")", ")", ")", ")", ";", "$", "value", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "key", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "$", "value", "=", "$", "jointPoint", "->", "proceed", "(", ")", ";", "$", "this", "->", "cache", "->", "set", "(", "$", "key", ",", "$", "value", ",", "$", "this", "->", "ttl", ")", ";", "}", "return", "$", "value", ";", "}" ]
Method called instead of the target object. You have a chance to do whatever you need: For example reject the call, change results etc @param ProceedingJoinPointInterface $jointPoint @return mixed
[ "Method", "called", "instead", "of", "the", "target", "object", ".", "You", "have", "a", "chance", "to", "do", "whatever", "you", "need", ":", "For", "example", "reject", "the", "call", "change", "results", "etc" ]
train
https://github.com/ejsmont-artur/phpProxyBuilder/blob/ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480/src/PhpProxyBuilder/Aop/Advice/CachingAdvice.php#L59-L72
link0/profiler
src/Link0/Profiler/PersistenceHandler/MongoDbHandler.php
MongoDbHandler.retrieve
public function retrieve($identifier) { $profileData = $this->collection->findOne([ 'identifier' => $identifier, ]); if($profileData !== null) { return $this->createProfileFromProfileData($profileData['profile']); } return null; }
php
public function retrieve($identifier) { $profileData = $this->collection->findOne([ 'identifier' => $identifier, ]); if($profileData !== null) { return $this->createProfileFromProfileData($profileData['profile']); } return null; }
[ "public", "function", "retrieve", "(", "$", "identifier", ")", "{", "$", "profileData", "=", "$", "this", "->", "collection", "->", "findOne", "(", "[", "'identifier'", "=>", "$", "identifier", ",", "]", ")", ";", "if", "(", "$", "profileData", "!==", "null", ")", "{", "return", "$", "this", "->", "createProfileFromProfileData", "(", "$", "profileData", "[", "'profile'", "]", ")", ";", "}", "return", "null", ";", "}" ]
@param string $identifier @return ProfileInterface|null $profile
[ "@param", "string", "$identifier" ]
train
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceHandler/MongoDbHandler.php#L72-L83
link0/profiler
src/Link0/Profiler/PersistenceHandler/MongoDbHandler.php
MongoDbHandler.persist
public function persist(ProfileInterface $profile) { // This is messed up, but this is finally compatible with XHGui, which is more important to me now. // Find a way to abstract this nicely! BUT FIRST! Release time! YEAH! (I am _SO_ gonna regret this...) $profileArray = $profile->toArray(); $serverData = $profileArray['serverData']; $requestTime = isset($serverData['REQUEST_TIME']) ? $serverData['REQUEST_TIME'] : time(); $requestTimeFloat = isset($serverData['REQUEST_TIME_FLOAT']) ? $serverData['REQUEST_TIME_FLOAT'] : microtime(true); $timeParts = explode('.', $requestTimeFloat); if(!isset($timeParts[1])) { $timeParts[1] = 0; } $scriptName = isset($serverData['SCRIPT_NAME']) ? $serverData['SCRIPT_NAME'] : '__unknown__'; $uri = isset($serverData['REQUEST_URI']) ? $serverData['REQUEST_URI'] : $scriptName; $mongoData = array( 'identifier' => $profile->getIdentifier(), 'profile' => $profileArray['profileData'], 'meta' => array( 'url' => $uri, 'SERVER' => $profileArray['serverData'], 'get' => array(), 'env' => array(), 'simple_url' => $uri, 'request_ts' => new MongoDate($requestTime), 'request_ts_micro' => new MongoDate($timeParts[0], $timeParts[1]), 'request_date' => date('Y-m-d', $requestTime), ) ); $this->collection->insert($mongoData); return $this; }
php
public function persist(ProfileInterface $profile) { // This is messed up, but this is finally compatible with XHGui, which is more important to me now. // Find a way to abstract this nicely! BUT FIRST! Release time! YEAH! (I am _SO_ gonna regret this...) $profileArray = $profile->toArray(); $serverData = $profileArray['serverData']; $requestTime = isset($serverData['REQUEST_TIME']) ? $serverData['REQUEST_TIME'] : time(); $requestTimeFloat = isset($serverData['REQUEST_TIME_FLOAT']) ? $serverData['REQUEST_TIME_FLOAT'] : microtime(true); $timeParts = explode('.', $requestTimeFloat); if(!isset($timeParts[1])) { $timeParts[1] = 0; } $scriptName = isset($serverData['SCRIPT_NAME']) ? $serverData['SCRIPT_NAME'] : '__unknown__'; $uri = isset($serverData['REQUEST_URI']) ? $serverData['REQUEST_URI'] : $scriptName; $mongoData = array( 'identifier' => $profile->getIdentifier(), 'profile' => $profileArray['profileData'], 'meta' => array( 'url' => $uri, 'SERVER' => $profileArray['serverData'], 'get' => array(), 'env' => array(), 'simple_url' => $uri, 'request_ts' => new MongoDate($requestTime), 'request_ts_micro' => new MongoDate($timeParts[0], $timeParts[1]), 'request_date' => date('Y-m-d', $requestTime), ) ); $this->collection->insert($mongoData); return $this; }
[ "public", "function", "persist", "(", "ProfileInterface", "$", "profile", ")", "{", "// This is messed up, but this is finally compatible with XHGui, which is more important to me now.", "// Find a way to abstract this nicely! BUT FIRST! Release time! YEAH! (I am _SO_ gonna regret this...)", "$", "profileArray", "=", "$", "profile", "->", "toArray", "(", ")", ";", "$", "serverData", "=", "$", "profileArray", "[", "'serverData'", "]", ";", "$", "requestTime", "=", "isset", "(", "$", "serverData", "[", "'REQUEST_TIME'", "]", ")", "?", "$", "serverData", "[", "'REQUEST_TIME'", "]", ":", "time", "(", ")", ";", "$", "requestTimeFloat", "=", "isset", "(", "$", "serverData", "[", "'REQUEST_TIME_FLOAT'", "]", ")", "?", "$", "serverData", "[", "'REQUEST_TIME_FLOAT'", "]", ":", "microtime", "(", "true", ")", ";", "$", "timeParts", "=", "explode", "(", "'.'", ",", "$", "requestTimeFloat", ")", ";", "if", "(", "!", "isset", "(", "$", "timeParts", "[", "1", "]", ")", ")", "{", "$", "timeParts", "[", "1", "]", "=", "0", ";", "}", "$", "scriptName", "=", "isset", "(", "$", "serverData", "[", "'SCRIPT_NAME'", "]", ")", "?", "$", "serverData", "[", "'SCRIPT_NAME'", "]", ":", "'__unknown__'", ";", "$", "uri", "=", "isset", "(", "$", "serverData", "[", "'REQUEST_URI'", "]", ")", "?", "$", "serverData", "[", "'REQUEST_URI'", "]", ":", "$", "scriptName", ";", "$", "mongoData", "=", "array", "(", "'identifier'", "=>", "$", "profile", "->", "getIdentifier", "(", ")", ",", "'profile'", "=>", "$", "profileArray", "[", "'profileData'", "]", ",", "'meta'", "=>", "array", "(", "'url'", "=>", "$", "uri", ",", "'SERVER'", "=>", "$", "profileArray", "[", "'serverData'", "]", ",", "'get'", "=>", "array", "(", ")", ",", "'env'", "=>", "array", "(", ")", ",", "'simple_url'", "=>", "$", "uri", ",", "'request_ts'", "=>", "new", "MongoDate", "(", "$", "requestTime", ")", ",", "'request_ts_micro'", "=>", "new", "MongoDate", "(", "$", "timeParts", "[", "0", "]", ",", "$", "timeParts", "[", "1", "]", ")", ",", "'request_date'", "=>", "date", "(", "'Y-m-d'", ",", "$", "requestTime", ")", ",", ")", ")", ";", "$", "this", "->", "collection", "->", "insert", "(", "$", "mongoData", ")", ";", "return", "$", "this", ";", "}" ]
@param ProfileInterface $profile @return PersistenceHandlerInterface $this
[ "@param", "ProfileInterface", "$profile" ]
train
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceHandler/MongoDbHandler.php#L90-L125
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.applyFieldFilter
private function applyFieldFilter(Builder $query, $field, $value) { $query = $this->resolveOrLinks($query, $field, $value); return $query; }
php
private function applyFieldFilter(Builder $query, $field, $value) { $query = $this->resolveOrLinks($query, $field, $value); return $query; }
[ "private", "function", "applyFieldFilter", "(", "Builder", "$", "query", ",", "$", "field", ",", "$", "value", ")", "{", "$", "query", "=", "$", "this", "->", "resolveOrLinks", "(", "$", "query", ",", "$", "field", ",", "$", "value", ")", ";", "return", "$", "query", ";", "}" ]
Resolves :or: and then :and: links @param Builder $query @param $field @param $value @return Builder
[ "Resolves", ":", "or", ":", "and", "then", ":", "and", ":", "links" ]
train
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L86-L91
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.resolveOrLinks
private function resolveOrLinks(Builder $query, $field, $value) { $filters = explode(':or:', $value); if (count($filters) > 1) { $that = $this; $query->where(function ($query) use ($filters, $field, $that) { $first = true; foreach ($filters as $filter) { $verb = $first ? 'where' : 'orWhere'; $query->$verb(function ($query) use ($field, $filter, $that) { $query = $that->resolveAndLinks($query, $field, $filter); }); $first = false; } }); } else { $query = $this->resolveAndLinks($query, $field, $value); } return $query; }
php
private function resolveOrLinks(Builder $query, $field, $value) { $filters = explode(':or:', $value); if (count($filters) > 1) { $that = $this; $query->where(function ($query) use ($filters, $field, $that) { $first = true; foreach ($filters as $filter) { $verb = $first ? 'where' : 'orWhere'; $query->$verb(function ($query) use ($field, $filter, $that) { $query = $that->resolveAndLinks($query, $field, $filter); }); $first = false; } }); } else { $query = $this->resolveAndLinks($query, $field, $value); } return $query; }
[ "private", "function", "resolveOrLinks", "(", "Builder", "$", "query", ",", "$", "field", ",", "$", "value", ")", "{", "$", "filters", "=", "explode", "(", "':or:'", ",", "$", "value", ")", ";", "if", "(", "count", "(", "$", "filters", ")", ">", "1", ")", "{", "$", "that", "=", "$", "this", ";", "$", "query", "->", "where", "(", "function", "(", "$", "query", ")", "use", "(", "$", "filters", ",", "$", "field", ",", "$", "that", ")", "{", "$", "first", "=", "true", ";", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "$", "verb", "=", "$", "first", "?", "'where'", ":", "'orWhere'", ";", "$", "query", "->", "$", "verb", "(", "function", "(", "$", "query", ")", "use", "(", "$", "field", ",", "$", "filter", ",", "$", "that", ")", "{", "$", "query", "=", "$", "that", "->", "resolveAndLinks", "(", "$", "query", ",", "$", "field", ",", "$", "filter", ")", ";", "}", ")", ";", "$", "first", "=", "false", ";", "}", "}", ")", ";", "}", "else", "{", "$", "query", "=", "$", "this", "->", "resolveAndLinks", "(", "$", "query", ",", "$", "field", ",", "$", "value", ")", ";", "}", "return", "$", "query", ";", "}" ]
Resolves :or: links and then resolves the :and: links in the resulting sections @param Builder $query @param $field @param $value @return Builder
[ "Resolves", ":", "or", ":", "links", "and", "then", "resolves", "the", ":", "and", ":", "links", "in", "the", "resulting", "sections" ]
train
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L101-L125
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.applyFilter
private function applyFilter(Builder $query, $field, $filter, $or = false) { $filter = explode(':', $filter); if (count($filter) > 1) { $operator = $this->getFilterOperator($filter[0]); $value = $this->replaceWildcards($filter[1]); } else { $operator = '='; $value = $this->replaceWildcards($filter[0]); } $fields = explode('.', $field); if (count($fields) > 1) { return $this->applyNestedFilter($query, $fields, $operator, $value, $or); } else { return $this->applyWhereClause($query, $field, $operator, $value, $or); } }
php
private function applyFilter(Builder $query, $field, $filter, $or = false) { $filter = explode(':', $filter); if (count($filter) > 1) { $operator = $this->getFilterOperator($filter[0]); $value = $this->replaceWildcards($filter[1]); } else { $operator = '='; $value = $this->replaceWildcards($filter[0]); } $fields = explode('.', $field); if (count($fields) > 1) { return $this->applyNestedFilter($query, $fields, $operator, $value, $or); } else { return $this->applyWhereClause($query, $field, $operator, $value, $or); } }
[ "private", "function", "applyFilter", "(", "Builder", "$", "query", ",", "$", "field", ",", "$", "filter", ",", "$", "or", "=", "false", ")", "{", "$", "filter", "=", "explode", "(", "':'", ",", "$", "filter", ")", ";", "if", "(", "count", "(", "$", "filter", ")", ">", "1", ")", "{", "$", "operator", "=", "$", "this", "->", "getFilterOperator", "(", "$", "filter", "[", "0", "]", ")", ";", "$", "value", "=", "$", "this", "->", "replaceWildcards", "(", "$", "filter", "[", "1", "]", ")", ";", "}", "else", "{", "$", "operator", "=", "'='", ";", "$", "value", "=", "$", "this", "->", "replaceWildcards", "(", "$", "filter", "[", "0", "]", ")", ";", "}", "$", "fields", "=", "explode", "(", "'.'", ",", "$", "field", ")", ";", "if", "(", "count", "(", "$", "fields", ")", ">", "1", ")", "{", "return", "$", "this", "->", "applyNestedFilter", "(", "$", "query", ",", "$", "fields", ",", "$", "operator", ",", "$", "value", ",", "$", "or", ")", ";", "}", "else", "{", "return", "$", "this", "->", "applyWhereClause", "(", "$", "query", ",", "$", "field", ",", "$", "operator", ",", "$", "value", ",", "$", "or", ")", ";", "}", "}" ]
Applies a single filter to the query @param Builder $query @param $field @param $filter @param $or = false @return Builder
[ "Applies", "a", "single", "filter", "to", "the", "query" ]
train
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L152-L171
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.applyNestedFilter
private function applyNestedFilter(Builder $query, array $fields, $operator, $value, $or = false) { $relation_name = implode('.', array_slice($fields, 0, count($fields) - 1)); $relation_field = end($fields); if ($relation_name[0] == '!') { $relation_name = substr($relation_name, 1, strlen($relation_name)); $that = $this; return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) { $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or); }, '=', 0); } $that = $this; return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) { $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or); }); }
php
private function applyNestedFilter(Builder $query, array $fields, $operator, $value, $or = false) { $relation_name = implode('.', array_slice($fields, 0, count($fields) - 1)); $relation_field = end($fields); if ($relation_name[0] == '!') { $relation_name = substr($relation_name, 1, strlen($relation_name)); $that = $this; return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) { $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or); }, '=', 0); } $that = $this; return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) { $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or); }); }
[ "private", "function", "applyNestedFilter", "(", "Builder", "$", "query", ",", "array", "$", "fields", ",", "$", "operator", ",", "$", "value", ",", "$", "or", "=", "false", ")", "{", "$", "relation_name", "=", "implode", "(", "'.'", ",", "array_slice", "(", "$", "fields", ",", "0", ",", "count", "(", "$", "fields", ")", "-", "1", ")", ")", ";", "$", "relation_field", "=", "end", "(", "$", "fields", ")", ";", "if", "(", "$", "relation_name", "[", "0", "]", "==", "'!'", ")", "{", "$", "relation_name", "=", "substr", "(", "$", "relation_name", ",", "1", ",", "strlen", "(", "$", "relation_name", ")", ")", ";", "$", "that", "=", "$", "this", ";", "return", "$", "query", "->", "whereHas", "(", "$", "relation_name", ",", "function", "(", "$", "query", ")", "use", "(", "$", "relation_field", ",", "$", "operator", ",", "$", "value", ",", "$", "that", ",", "$", "or", ")", "{", "$", "query", "=", "$", "that", "->", "applyWhereClause", "(", "$", "query", ",", "$", "relation_field", ",", "$", "operator", ",", "$", "value", ",", "$", "or", ")", ";", "}", ",", "'='", ",", "0", ")", ";", "}", "$", "that", "=", "$", "this", ";", "return", "$", "query", "->", "whereHas", "(", "$", "relation_name", ",", "function", "(", "$", "query", ")", "use", "(", "$", "relation_field", ",", "$", "operator", ",", "$", "value", ",", "$", "that", ",", "$", "or", ")", "{", "$", "query", "=", "$", "that", "->", "applyWhereClause", "(", "$", "query", ",", "$", "relation_field", ",", "$", "operator", ",", "$", "value", ",", "$", "or", ")", ";", "}", ")", ";", "}" ]
Applies a nested filter. Nested filters are filters on field on related models. @param Builder $query @param array $fields @param $operator @param $value @param $or = false @return Builder
[ "Applies", "a", "nested", "filter", ".", "Nested", "filters", "are", "filters", "on", "field", "on", "related", "models", "." ]
train
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L184-L203
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.applyWhereClause
private function applyWhereClause(Builder $query, $field, $operator, $value, $or = false) { $verb = $or ? 'orWhere' : 'where'; $null_verb = $or ? 'orWhereNull' : 'whereNull'; $not_null_verb = $or ? 'orWhereNotNull' : 'whereNotNull'; $value = $this->base64decodeIfNecessary($value); switch ($value) { case 'today': return $query->$verb($field, 'like', Carbon::now()->format('Y-m-d') . '%'); case 'nottoday': return $query->$verb(function ($q) use ($field) { $q->where($field, 'not like', Carbon::now()->format('Y-m-d') . '%') ->orWhereNull($field); }); case 'null': return $query->$null_verb($field); case 'notnull': return $query->$not_null_verb($field); default: return $query->$verb($field, $operator, $value); } }
php
private function applyWhereClause(Builder $query, $field, $operator, $value, $or = false) { $verb = $or ? 'orWhere' : 'where'; $null_verb = $or ? 'orWhereNull' : 'whereNull'; $not_null_verb = $or ? 'orWhereNotNull' : 'whereNotNull'; $value = $this->base64decodeIfNecessary($value); switch ($value) { case 'today': return $query->$verb($field, 'like', Carbon::now()->format('Y-m-d') . '%'); case 'nottoday': return $query->$verb(function ($q) use ($field) { $q->where($field, 'not like', Carbon::now()->format('Y-m-d') . '%') ->orWhereNull($field); }); case 'null': return $query->$null_verb($field); case 'notnull': return $query->$not_null_verb($field); default: return $query->$verb($field, $operator, $value); } }
[ "private", "function", "applyWhereClause", "(", "Builder", "$", "query", ",", "$", "field", ",", "$", "operator", ",", "$", "value", ",", "$", "or", "=", "false", ")", "{", "$", "verb", "=", "$", "or", "?", "'orWhere'", ":", "'where'", ";", "$", "null_verb", "=", "$", "or", "?", "'orWhereNull'", ":", "'whereNull'", ";", "$", "not_null_verb", "=", "$", "or", "?", "'orWhereNotNull'", ":", "'whereNotNull'", ";", "$", "value", "=", "$", "this", "->", "base64decodeIfNecessary", "(", "$", "value", ")", ";", "switch", "(", "$", "value", ")", "{", "case", "'today'", ":", "return", "$", "query", "->", "$", "verb", "(", "$", "field", ",", "'like'", ",", "Carbon", "::", "now", "(", ")", "->", "format", "(", "'Y-m-d'", ")", ".", "'%'", ")", ";", "case", "'nottoday'", ":", "return", "$", "query", "->", "$", "verb", "(", "function", "(", "$", "q", ")", "use", "(", "$", "field", ")", "{", "$", "q", "->", "where", "(", "$", "field", ",", "'not like'", ",", "Carbon", "::", "now", "(", ")", "->", "format", "(", "'Y-m-d'", ")", ".", "'%'", ")", "->", "orWhereNull", "(", "$", "field", ")", ";", "}", ")", ";", "case", "'null'", ":", "return", "$", "query", "->", "$", "null_verb", "(", "$", "field", ")", ";", "case", "'notnull'", ":", "return", "$", "query", "->", "$", "not_null_verb", "(", "$", "field", ")", ";", "default", ":", "return", "$", "query", "->", "$", "verb", "(", "$", "field", ",", "$", "operator", ",", "$", "value", ")", ";", "}", "}" ]
Applies a where clause. Is used by applyFilter and applyNestedFilter to apply the clause to the query. @param Builder $query @param $field @param $operator @param $value @param $or = false @return Builder
[ "Applies", "a", "where", "clause", ".", "Is", "used", "by", "applyFilter", "and", "applyNestedFilter", "to", "apply", "the", "clause", "to", "the", "query", "." ]
train
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L216-L238
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.applyNestedOrder
private function applyNestedOrder($relation_name, Builder $query, $relation_field, $value) { $that = $this; return $query->orderBy($relation_name, function ($query) use ($relation_field, $value, $that) { $query = $that->applyOrderByClause($query, $relation_field, $value); }); }
php
private function applyNestedOrder($relation_name, Builder $query, $relation_field, $value) { $that = $this; return $query->orderBy($relation_name, function ($query) use ($relation_field, $value, $that) { $query = $that->applyOrderByClause($query, $relation_field, $value); }); }
[ "private", "function", "applyNestedOrder", "(", "$", "relation_name", ",", "Builder", "$", "query", ",", "$", "relation_field", ",", "$", "value", ")", "{", "$", "that", "=", "$", "this", ";", "return", "$", "query", "->", "orderBy", "(", "$", "relation_name", ",", "function", "(", "$", "query", ")", "use", "(", "$", "relation_field", ",", "$", "value", ",", "$", "that", ")", "{", "$", "query", "=", "$", "that", "->", "applyOrderByClause", "(", "$", "query", ",", "$", "relation_field", ",", "$", "value", ")", ";", "}", ")", ";", "}" ]
@TODO: This does not work yet. Order by doesn't seem to support this the same way whereHas does @param $relation_name @param Builder $query @param $relation_field @param $value @return mixed
[ "@TODO", ":", "This", "does", "not", "work", "yet", ".", "Order", "by", "doesn", "t", "seem", "to", "support", "this", "the", "same", "way", "whereHas", "does" ]
train
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L266-L272
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.getFilterOperator
private function getFilterOperator($filter) { $operator = str_replace('notlike', 'not like', $filter); $operator = str_replace('gt', '>', $operator); $operator = str_replace('ge', '>=', $operator); $operator = str_replace('lt', '<', $operator); $operator = str_replace('le', '<=', $operator); $operator = str_replace('eq', '=', $operator); $operator = str_replace('ne', '!=', $operator); return $operator; }
php
private function getFilterOperator($filter) { $operator = str_replace('notlike', 'not like', $filter); $operator = str_replace('gt', '>', $operator); $operator = str_replace('ge', '>=', $operator); $operator = str_replace('lt', '<', $operator); $operator = str_replace('le', '<=', $operator); $operator = str_replace('eq', '=', $operator); $operator = str_replace('ne', '!=', $operator); return $operator; }
[ "private", "function", "getFilterOperator", "(", "$", "filter", ")", "{", "$", "operator", "=", "str_replace", "(", "'notlike'", ",", "'not like'", ",", "$", "filter", ")", ";", "$", "operator", "=", "str_replace", "(", "'gt'", ",", "'>'", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'ge'", ",", "'>='", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'lt'", ",", "'<'", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'le'", ",", "'<='", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'eq'", ",", "'='", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'ne'", ",", "'!='", ",", "$", "operator", ")", ";", "return", "$", "operator", ";", "}" ]
Translates operators to SQL @param $filter @return mixed
[ "Translates", "operators", "to", "SQL" ]
train
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L304-L315
roshangara/statusable
migrations/2017_11_01_085755_create_statuses_table.php
CreateStatusesTable.up
public function up() { Schema::create('statuses', function (Blueprint $table) { $table->tinyIncrements('id'); $table->json('title'); $table->json('description')->nullable(); $table->string('color', 20)->nullable(); $table->timestamps(); }); $status = new \Roshangara\Statusable\Models\Status(); $status->setTranslation('title', 'fa', 'جدید'); $status->setTranslation('title', 'en', 'new'); $status->save(); }
php
public function up() { Schema::create('statuses', function (Blueprint $table) { $table->tinyIncrements('id'); $table->json('title'); $table->json('description')->nullable(); $table->string('color', 20)->nullable(); $table->timestamps(); }); $status = new \Roshangara\Statusable\Models\Status(); $status->setTranslation('title', 'fa', 'جدید'); $status->setTranslation('title', 'en', 'new'); $status->save(); }
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "create", "(", "'statuses'", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$", "table", "->", "tinyIncrements", "(", "'id'", ")", ";", "$", "table", "->", "json", "(", "'title'", ")", ";", "$", "table", "->", "json", "(", "'description'", ")", "->", "nullable", "(", ")", ";", "$", "table", "->", "string", "(", "'color'", ",", "20", ")", "->", "nullable", "(", ")", ";", "$", "table", "->", "timestamps", "(", ")", ";", "}", ")", ";", "$", "status", "=", "new", "\\", "Roshangara", "\\", "Statusable", "\\", "Models", "\\", "Status", "(", ")", ";", "$", "status", "->", "setTranslation", "(", "'title'", ",", "'fa'", ",", "'جدید');", "", "", "$", "status", "->", "setTranslation", "(", "'title'", ",", "'en'", ",", "'new'", ")", ";", "$", "status", "->", "save", "(", ")", ";", "}" ]
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/roshangara/statusable/blob/657658ee6bd5d4fa9e5b67fe8094ff69dc30a45d/migrations/2017_11_01_085755_create_statuses_table.php#L14-L28
codeburnerframework/router
src/Collectors/ResourceCollectorTrait.php
ResourceCollectorTrait.resource
public function resource($controller, array $options = array()) { $name = isset($options["prefix"]) ? $options["prefix"] : ""; $name .= $this->getResourceName($controller, $options); $actions = $this->getResourceActions($options); $resource = new RouteResource; foreach ($actions as $action => $map) { $resource->set( $this->set( $map[0], $this->getResourcePath($action, $map[1], $name, $options), [$controller, $action] ) ->setName("$name.$action") ); } return $resource; }
php
public function resource($controller, array $options = array()) { $name = isset($options["prefix"]) ? $options["prefix"] : ""; $name .= $this->getResourceName($controller, $options); $actions = $this->getResourceActions($options); $resource = new RouteResource; foreach ($actions as $action => $map) { $resource->set( $this->set( $map[0], $this->getResourcePath($action, $map[1], $name, $options), [$controller, $action] ) ->setName("$name.$action") ); } return $resource; }
[ "public", "function", "resource", "(", "$", "controller", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "name", "=", "isset", "(", "$", "options", "[", "\"prefix\"", "]", ")", "?", "$", "options", "[", "\"prefix\"", "]", ":", "\"\"", ";", "$", "name", ".=", "$", "this", "->", "getResourceName", "(", "$", "controller", ",", "$", "options", ")", ";", "$", "actions", "=", "$", "this", "->", "getResourceActions", "(", "$", "options", ")", ";", "$", "resource", "=", "new", "RouteResource", ";", "foreach", "(", "$", "actions", "as", "$", "action", "=>", "$", "map", ")", "{", "$", "resource", "->", "set", "(", "$", "this", "->", "set", "(", "$", "map", "[", "0", "]", ",", "$", "this", "->", "getResourcePath", "(", "$", "action", ",", "$", "map", "[", "1", "]", ",", "$", "name", ",", "$", "options", ")", ",", "[", "$", "controller", ",", "$", "action", "]", ")", "->", "setName", "(", "\"$name.$action\"", ")", ")", ";", "}", "return", "$", "resource", ";", "}" ]
Resource routing allows you to quickly declare all of the common routes for a given resourceful controller. Instead of declaring separate routes for your index, show, new, edit, create, update and destroy actions, a resourceful route declares them in a single line of code. @param string $controller The controller name. @param array $options Some options like, "as" to name the route pattern, "only" to explicit say that only this routes will be registered, and "except" that register all the routes except the indicates. @return RouteResource
[ "Resource", "routing", "allows", "you", "to", "quickly", "declare", "all", "of", "the", "common", "routes", "for", "a", "given", "resourceful", "controller", ".", "Instead", "of", "declaring", "separate", "routes", "for", "your", "index", "show", "new", "edit", "create", "update", "and", "destroy", "actions", "a", "resourceful", "route", "declares", "them", "in", "a", "single", "line", "of", "code", "." ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Collectors/ResourceCollectorTrait.php#L68-L87
codeburnerframework/router
src/Collectors/ResourceCollectorTrait.php
ResourceCollectorTrait.resources
public function resources(array $controllers) { $resource = new RouteResource; foreach ($controllers as $controller) $resource->set($this->resource($controller)); return $resource; }
php
public function resources(array $controllers) { $resource = new RouteResource; foreach ($controllers as $controller) $resource->set($this->resource($controller)); return $resource; }
[ "public", "function", "resources", "(", "array", "$", "controllers", ")", "{", "$", "resource", "=", "new", "RouteResource", ";", "foreach", "(", "$", "controllers", "as", "$", "controller", ")", "$", "resource", "->", "set", "(", "$", "this", "->", "resource", "(", "$", "controller", ")", ")", ";", "return", "$", "resource", ";", "}" ]
Collect several resources at same time. @param array $controllers Several controller names as parameters or an array with all controller names. @return RouteResource
[ "Collect", "several", "resources", "at", "same", "time", "." ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Collectors/ResourceCollectorTrait.php#L96-L102
codeburnerframework/router
src/Collectors/ResourceCollectorTrait.php
ResourceCollectorTrait.getResourcePath
protected function getResourcePath($action, $path, $name, array $options) { return str_replace("{name}", $name, $action === "make" && isset($options["translate"]["make"]) ? str_replace("make", $options["translate"]["make"], $path) : ($action === "edit" && isset($options["translate"]["edit"]) ? str_replace("edit", $options["translate"]["edit"], $path) : $path)); }
php
protected function getResourcePath($action, $path, $name, array $options) { return str_replace("{name}", $name, $action === "make" && isset($options["translate"]["make"]) ? str_replace("make", $options["translate"]["make"], $path) : ($action === "edit" && isset($options["translate"]["edit"]) ? str_replace("edit", $options["translate"]["edit"], $path) : $path)); }
[ "protected", "function", "getResourcePath", "(", "$", "action", ",", "$", "path", ",", "$", "name", ",", "array", "$", "options", ")", "{", "return", "str_replace", "(", "\"{name}\"", ",", "$", "name", ",", "$", "action", "===", "\"make\"", "&&", "isset", "(", "$", "options", "[", "\"translate\"", "]", "[", "\"make\"", "]", ")", "?", "str_replace", "(", "\"make\"", ",", "$", "options", "[", "\"translate\"", "]", "[", "\"make\"", "]", ",", "$", "path", ")", ":", "(", "$", "action", "===", "\"edit\"", "&&", "isset", "(", "$", "options", "[", "\"translate\"", "]", "[", "\"edit\"", "]", ")", "?", "str_replace", "(", "\"edit\"", ",", "$", "options", "[", "\"translate\"", "]", "[", "\"edit\"", "]", ",", "$", "path", ")", ":", "$", "path", ")", ")", ";", "}" ]
@param string $action @param string $path @param string $name @param string[] $options @return string
[ "@param", "string", "$action", "@param", "string", "$path", "@param", "string", "$name", "@param", "string", "[]", "$options" ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Collectors/ResourceCollectorTrait.php#L136-L141
phossa2/middleware
src/Middleware/Utility.php
Utility.setCookie
public static function setCookie( ResponseInterface $response, /*# string */ $name, /*# string */ $value = null, /*# int */ $ttl = null, /*# string */ $path = null, /*# string */ $domain = null, /*# bool */ $secure = false, /*# bool */ $httponly = true )/*# : ResponseInterface */ { $cookie = urlencode($name) . '=' . urlencode($value); self::addExpire($cookie, $ttl); self::addDomain($cookie, $domain); self::addPath($cookie, $path); self::addSecure($cookie, $secure); self::addHttpOnly($cookie, $httponly); return $response->withAddedHeader('Set-Cookie', $cookie); }
php
public static function setCookie( ResponseInterface $response, /*# string */ $name, /*# string */ $value = null, /*# int */ $ttl = null, /*# string */ $path = null, /*# string */ $domain = null, /*# bool */ $secure = false, /*# bool */ $httponly = true )/*# : ResponseInterface */ { $cookie = urlencode($name) . '=' . urlencode($value); self::addExpire($cookie, $ttl); self::addDomain($cookie, $domain); self::addPath($cookie, $path); self::addSecure($cookie, $secure); self::addHttpOnly($cookie, $httponly); return $response->withAddedHeader('Set-Cookie', $cookie); }
[ "public", "static", "function", "setCookie", "(", "ResponseInterface", "$", "response", ",", "/*# string */", "$", "name", ",", "/*# string */", "$", "value", "=", "null", ",", "/*# int */", "$", "ttl", "=", "null", ",", "/*# string */", "$", "path", "=", "null", ",", "/*# string */", "$", "domain", "=", "null", ",", "/*# bool */", "$", "secure", "=", "false", ",", "/*# bool */", "$", "httponly", "=", "true", ")", "/*# : ResponseInterface */", "{", "$", "cookie", "=", "urlencode", "(", "$", "name", ")", ".", "'='", ".", "urlencode", "(", "$", "value", ")", ";", "self", "::", "addExpire", "(", "$", "cookie", ",", "$", "ttl", ")", ";", "self", "::", "addDomain", "(", "$", "cookie", ",", "$", "domain", ")", ";", "self", "::", "addPath", "(", "$", "cookie", ",", "$", "path", ")", ";", "self", "::", "addSecure", "(", "$", "cookie", ",", "$", "secure", ")", ";", "self", "::", "addHttpOnly", "(", "$", "cookie", ",", "$", "httponly", ")", ";", "return", "$", "response", "->", "withAddedHeader", "(", "'Set-Cookie'", ",", "$", "cookie", ")", ";", "}" ]
Set a cookie in the response @param ResponseInterface $response @param string $name @param string $value @param int $ttl @param string $path @param string $domain @param bool $secure @param bool $httponly @return ResponseInterface @access public
[ "Set", "a", "cookie", "in", "the", "response" ]
train
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Utility.php#L47-L70
phossa2/middleware
src/Middleware/Utility.php
Utility.unsetCookie
public static function unsetCookie( ResponseInterface $response, /*# string */ $name, /*# string */ $path = null )/*# : ResponseInterface */ { return self::setCookie($response, $name, '', time() - 86400, $path); }
php
public static function unsetCookie( ResponseInterface $response, /*# string */ $name, /*# string */ $path = null )/*# : ResponseInterface */ { return self::setCookie($response, $name, '', time() - 86400, $path); }
[ "public", "static", "function", "unsetCookie", "(", "ResponseInterface", "$", "response", ",", "/*# string */", "$", "name", ",", "/*# string */", "$", "path", "=", "null", ")", "/*# : ResponseInterface */", "{", "return", "self", "::", "setCookie", "(", "$", "response", ",", "$", "name", ",", "''", ",", "time", "(", ")", "-", "86400", ",", "$", "path", ")", ";", "}" ]
Unset a cookie @param ResponseInterface $response @param string $name @param string $path @return ResponseInterface @access public
[ "Unset", "a", "cookie" ]
train
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Utility.php#L81-L87
phossa2/middleware
src/Middleware/Utility.php
Utility.publicCache
public static function publicCache( ResponseInterface $response, /*# int */ $cacheTime = 120 )/*# : ResponseInterface */ { $maxAge = $cacheTime * 60; return $response ->withAddedHeader('Expires', self::timeStamp($maxAge)) ->withAddedHeader('Cache-Control', "public, max-age={$maxAge}") ->withAddedHeader('Last-Modified', self::timeStamp()); }
php
public static function publicCache( ResponseInterface $response, /*# int */ $cacheTime = 120 )/*# : ResponseInterface */ { $maxAge = $cacheTime * 60; return $response ->withAddedHeader('Expires', self::timeStamp($maxAge)) ->withAddedHeader('Cache-Control', "public, max-age={$maxAge}") ->withAddedHeader('Last-Modified', self::timeStamp()); }
[ "public", "static", "function", "publicCache", "(", "ResponseInterface", "$", "response", ",", "/*# int */", "$", "cacheTime", "=", "120", ")", "/*# : ResponseInterface */", "{", "$", "maxAge", "=", "$", "cacheTime", "*", "60", ";", "return", "$", "response", "->", "withAddedHeader", "(", "'Expires'", ",", "self", "::", "timeStamp", "(", "$", "maxAge", ")", ")", "->", "withAddedHeader", "(", "'Cache-Control'", ",", "\"public, max-age={$maxAge}\"", ")", "->", "withAddedHeader", "(", "'Last-Modified'", ",", "self", "::", "timeStamp", "(", ")", ")", ";", "}" ]
Set public cache header @param ResponseInterface $response @param int $cacheTime cache time in minutes @return ResponseInterface @access public
[ "Set", "public", "cache", "header" ]
train
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Utility.php#L97-L106
phossa2/middleware
src/Middleware/Utility.php
Utility.privateNoExpireCache
public static function privateNoExpireCache( ResponseInterface $response, /*# int */ $cacheTime = 120 )/*# : ResponseInterface */ { $maxAge = $cacheTime * 60; return $response ->withAddedHeader('Cache-Control', "private, max-age={$maxAge}, pre-check={$maxAge}") ->withAddedHeader('Last-Modified', self::timeStamp()); }
php
public static function privateNoExpireCache( ResponseInterface $response, /*# int */ $cacheTime = 120 )/*# : ResponseInterface */ { $maxAge = $cacheTime * 60; return $response ->withAddedHeader('Cache-Control', "private, max-age={$maxAge}, pre-check={$maxAge}") ->withAddedHeader('Last-Modified', self::timeStamp()); }
[ "public", "static", "function", "privateNoExpireCache", "(", "ResponseInterface", "$", "response", ",", "/*# int */", "$", "cacheTime", "=", "120", ")", "/*# : ResponseInterface */", "{", "$", "maxAge", "=", "$", "cacheTime", "*", "60", ";", "return", "$", "response", "->", "withAddedHeader", "(", "'Cache-Control'", ",", "\"private, max-age={$maxAge}, pre-check={$maxAge}\"", ")", "->", "withAddedHeader", "(", "'Last-Modified'", ",", "self", "::", "timeStamp", "(", ")", ")", ";", "}" ]
Set private_no_expire cache header @param ResponseInterface $response @param int $cacheTime cache time in minutes @return ResponseInterface @access public
[ "Set", "private_no_expire", "cache", "header" ]
train
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Utility.php#L116-L124
activecollab/databasestructure
src/Field/Composite/StringField.php
StringField.onAddedToType
public function onAddedToType(TypeInterface &$type) { parent::onAddedToType($type); if ($this->getAddIndex()) { $index_fields = [$this->name]; if (count($this->getAddIndexContext())) { $index_fields = array_merge($index_fields, $this->getAddIndexContext()); } $type->addIndex(new Index($this->name, $index_fields, $this->getAddIndexType())); } }
php
public function onAddedToType(TypeInterface &$type) { parent::onAddedToType($type); if ($this->getAddIndex()) { $index_fields = [$this->name]; if (count($this->getAddIndexContext())) { $index_fields = array_merge($index_fields, $this->getAddIndexContext()); } $type->addIndex(new Index($this->name, $index_fields, $this->getAddIndexType())); } }
[ "public", "function", "onAddedToType", "(", "TypeInterface", "&", "$", "type", ")", "{", "parent", "::", "onAddedToType", "(", "$", "type", ")", ";", "if", "(", "$", "this", "->", "getAddIndex", "(", ")", ")", "{", "$", "index_fields", "=", "[", "$", "this", "->", "name", "]", ";", "if", "(", "count", "(", "$", "this", "->", "getAddIndexContext", "(", ")", ")", ")", "{", "$", "index_fields", "=", "array_merge", "(", "$", "index_fields", ",", "$", "this", "->", "getAddIndexContext", "(", ")", ")", ";", "}", "$", "type", "->", "addIndex", "(", "new", "Index", "(", "$", "this", "->", "name", ",", "$", "index_fields", ",", "$", "this", "->", "getAddIndexType", "(", ")", ")", ")", ";", "}", "}" ]
Method that is called when field is added to a type. @param TypeInterface $type
[ "Method", "that", "is", "called", "when", "field", "is", "added", "to", "a", "type", "." ]
train
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Composite/StringField.php#L105-L118
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/Http/PipelinerHttpException.php
PipelinerHttpException.getErrorMessage
public function getErrorMessage() { if (is_string($this->jsonError)) { return $this->jsonError; } elseif (isset($this->jsonError['message'])) { return $this->jsonError['message']; } return ''; }
php
public function getErrorMessage() { if (is_string($this->jsonError)) { return $this->jsonError; } elseif (isset($this->jsonError['message'])) { return $this->jsonError['message']; } return ''; }
[ "public", "function", "getErrorMessage", "(", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "jsonError", ")", ")", "{", "return", "$", "this", "->", "jsonError", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "jsonError", "[", "'message'", "]", ")", ")", "{", "return", "$", "this", "->", "jsonError", "[", "'message'", "]", ";", "}", "return", "''", ";", "}" ]
The error message specified in the API, or an empty string if not available. @return string
[ "The", "error", "message", "specified", "in", "the", "API", "or", "an", "empty", "string", "if", "not", "available", "." ]
train
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/Http/PipelinerHttpException.php#L67-L75
puli/discovery
src/Binding/ClassBinding.php
ClassBinding.equals
public function equals(Binding $other) { if (!parent::equals($other)) { return false; } /* @var ClassBinding $other */ return $this->className === $other->className; }
php
public function equals(Binding $other) { if (!parent::equals($other)) { return false; } /* @var ClassBinding $other */ return $this->className === $other->className; }
[ "public", "function", "equals", "(", "Binding", "$", "other", ")", "{", "if", "(", "!", "parent", "::", "equals", "(", "$", "other", ")", ")", "{", "return", "false", ";", "}", "/* @var ClassBinding $other */", "return", "$", "this", "->", "className", "===", "$", "other", "->", "className", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/puli/discovery/blob/975f5e099563f1096bfabc17fbe4d1816408ad98/src/Binding/ClassBinding.php#L64-L72
activecollab/databasemigrations
src/Finder/MigrationsInChangesetsFinder.php
MigrationsInChangesetsFinder.getMigrationClassFilePathMap
public function getMigrationClassFilePathMap() { $migrations_by_changeset = []; $total_migrations_found = 0; foreach ($this->migrations_dirs as $migrations_dir) { $file_system = new FileSystem(new LocalAdapter($migrations_dir)); foreach ($file_system->subdirs() as $changeset_dir) { if ($this->isValidChangesetName($changeset_dir)) { $migrations_found = 0; foreach ($file_system->files($changeset_dir, false) as $migration_file_path) { if (empty($migrations_by_changeset[$changeset_dir])) { $migrations_by_changeset[$changeset_dir] = []; } $migrations_by_changeset[$changeset_dir][$this->getMigrationClassName($migration_file_path)] = $file_system->getFullPath($migration_file_path); ++$migrations_found; } if (empty($migrations_found)) { $this->log->debug('No migrations found in {migrations_dir}/{changeset}', ['migrations_dir' => $migrations_dir, 'changeset' => $changeset_dir]); } else { $total_migrations_found += $migrations_found; } } else { throw new RuntimeException("Value '$changeset_dir' is not a valid changeset name"); } } } $this->log->debug('{total_migrations} migrations found {total_changesets} changesets', ['total_migrations' => $total_migrations_found, 'total_changesets' => count($migrations_by_changeset), 'changesets' => array_keys($migrations_by_changeset)]); ksort($migrations_by_changeset); $result = []; foreach ($migrations_by_changeset as $migrations) { $result = array_merge($result, $migrations); } return $result; }
php
public function getMigrationClassFilePathMap() { $migrations_by_changeset = []; $total_migrations_found = 0; foreach ($this->migrations_dirs as $migrations_dir) { $file_system = new FileSystem(new LocalAdapter($migrations_dir)); foreach ($file_system->subdirs() as $changeset_dir) { if ($this->isValidChangesetName($changeset_dir)) { $migrations_found = 0; foreach ($file_system->files($changeset_dir, false) as $migration_file_path) { if (empty($migrations_by_changeset[$changeset_dir])) { $migrations_by_changeset[$changeset_dir] = []; } $migrations_by_changeset[$changeset_dir][$this->getMigrationClassName($migration_file_path)] = $file_system->getFullPath($migration_file_path); ++$migrations_found; } if (empty($migrations_found)) { $this->log->debug('No migrations found in {migrations_dir}/{changeset}', ['migrations_dir' => $migrations_dir, 'changeset' => $changeset_dir]); } else { $total_migrations_found += $migrations_found; } } else { throw new RuntimeException("Value '$changeset_dir' is not a valid changeset name"); } } } $this->log->debug('{total_migrations} migrations found {total_changesets} changesets', ['total_migrations' => $total_migrations_found, 'total_changesets' => count($migrations_by_changeset), 'changesets' => array_keys($migrations_by_changeset)]); ksort($migrations_by_changeset); $result = []; foreach ($migrations_by_changeset as $migrations) { $result = array_merge($result, $migrations); } return $result; }
[ "public", "function", "getMigrationClassFilePathMap", "(", ")", "{", "$", "migrations_by_changeset", "=", "[", "]", ";", "$", "total_migrations_found", "=", "0", ";", "foreach", "(", "$", "this", "->", "migrations_dirs", "as", "$", "migrations_dir", ")", "{", "$", "file_system", "=", "new", "FileSystem", "(", "new", "LocalAdapter", "(", "$", "migrations_dir", ")", ")", ";", "foreach", "(", "$", "file_system", "->", "subdirs", "(", ")", "as", "$", "changeset_dir", ")", "{", "if", "(", "$", "this", "->", "isValidChangesetName", "(", "$", "changeset_dir", ")", ")", "{", "$", "migrations_found", "=", "0", ";", "foreach", "(", "$", "file_system", "->", "files", "(", "$", "changeset_dir", ",", "false", ")", "as", "$", "migration_file_path", ")", "{", "if", "(", "empty", "(", "$", "migrations_by_changeset", "[", "$", "changeset_dir", "]", ")", ")", "{", "$", "migrations_by_changeset", "[", "$", "changeset_dir", "]", "=", "[", "]", ";", "}", "$", "migrations_by_changeset", "[", "$", "changeset_dir", "]", "[", "$", "this", "->", "getMigrationClassName", "(", "$", "migration_file_path", ")", "]", "=", "$", "file_system", "->", "getFullPath", "(", "$", "migration_file_path", ")", ";", "++", "$", "migrations_found", ";", "}", "if", "(", "empty", "(", "$", "migrations_found", ")", ")", "{", "$", "this", "->", "log", "->", "debug", "(", "'No migrations found in {migrations_dir}/{changeset}'", ",", "[", "'migrations_dir'", "=>", "$", "migrations_dir", ",", "'changeset'", "=>", "$", "changeset_dir", "]", ")", ";", "}", "else", "{", "$", "total_migrations_found", "+=", "$", "migrations_found", ";", "}", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Value '$changeset_dir' is not a valid changeset name\"", ")", ";", "}", "}", "}", "$", "this", "->", "log", "->", "debug", "(", "'{total_migrations} migrations found {total_changesets} changesets'", ",", "[", "'total_migrations'", "=>", "$", "total_migrations_found", ",", "'total_changesets'", "=>", "count", "(", "$", "migrations_by_changeset", ")", ",", "'changesets'", "=>", "array_keys", "(", "$", "migrations_by_changeset", ")", "]", ")", ";", "ksort", "(", "$", "migrations_by_changeset", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "migrations_by_changeset", "as", "$", "migrations", ")", "{", "$", "result", "=", "array_merge", "(", "$", "result", ",", "$", "migrations", ")", ";", "}", "return", "$", "result", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/activecollab/databasemigrations/blob/ef91d5b5f74d79b4a75695393eb25c7c47dad093/src/Finder/MigrationsInChangesetsFinder.php#L65-L108
activecollab/databasemigrations
src/Finder/MigrationsInChangesetsFinder.php
MigrationsInChangesetsFinder.prepareMigrationPath
public function prepareMigrationPath($classified_name, $migrations_dir = null, ...$extra_arguments) { if ($migrations_dir === null) { $migrations_dir = $this->migrations_dirs[0]; } elseif (empty($migrations_dir)) { throw new InvalidArgumentException("Migrations dir is optional, but it can't be empty when specified"); } if (!in_array($migrations_dir, $this->migrations_dirs)) { throw new InvalidArgumentException("Directory '$migrations_dir' is not managed by this finder"); } $underscore_name = Inflector::tableize($classified_name); if (array_key_exists(0, $extra_arguments)) { if (trim($extra_arguments[0])) { $changeset = trim($extra_arguments[0]); } else { throw new InvalidArgumentException("Changeset argument is optional, but it can't be empty when specified"); } } else { $changeset = $underscore_name; } $changeset = strtolower(str_replace([' ', '_'], ['-', '-'], $changeset)); if (!$this->isValidChangesetName($changeset)) { $changeset = (new DateTimeValue())->format('Y-m-d') . '-' . $changeset; } return "$migrations_dir/$changeset/$classified_name.php"; }
php
public function prepareMigrationPath($classified_name, $migrations_dir = null, ...$extra_arguments) { if ($migrations_dir === null) { $migrations_dir = $this->migrations_dirs[0]; } elseif (empty($migrations_dir)) { throw new InvalidArgumentException("Migrations dir is optional, but it can't be empty when specified"); } if (!in_array($migrations_dir, $this->migrations_dirs)) { throw new InvalidArgumentException("Directory '$migrations_dir' is not managed by this finder"); } $underscore_name = Inflector::tableize($classified_name); if (array_key_exists(0, $extra_arguments)) { if (trim($extra_arguments[0])) { $changeset = trim($extra_arguments[0]); } else { throw new InvalidArgumentException("Changeset argument is optional, but it can't be empty when specified"); } } else { $changeset = $underscore_name; } $changeset = strtolower(str_replace([' ', '_'], ['-', '-'], $changeset)); if (!$this->isValidChangesetName($changeset)) { $changeset = (new DateTimeValue())->format('Y-m-d') . '-' . $changeset; } return "$migrations_dir/$changeset/$classified_name.php"; }
[ "public", "function", "prepareMigrationPath", "(", "$", "classified_name", ",", "$", "migrations_dir", "=", "null", ",", "...", "$", "extra_arguments", ")", "{", "if", "(", "$", "migrations_dir", "===", "null", ")", "{", "$", "migrations_dir", "=", "$", "this", "->", "migrations_dirs", "[", "0", "]", ";", "}", "elseif", "(", "empty", "(", "$", "migrations_dir", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Migrations dir is optional, but it can't be empty when specified\"", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "migrations_dir", ",", "$", "this", "->", "migrations_dirs", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Directory '$migrations_dir' is not managed by this finder\"", ")", ";", "}", "$", "underscore_name", "=", "Inflector", "::", "tableize", "(", "$", "classified_name", ")", ";", "if", "(", "array_key_exists", "(", "0", ",", "$", "extra_arguments", ")", ")", "{", "if", "(", "trim", "(", "$", "extra_arguments", "[", "0", "]", ")", ")", "{", "$", "changeset", "=", "trim", "(", "$", "extra_arguments", "[", "0", "]", ")", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "\"Changeset argument is optional, but it can't be empty when specified\"", ")", ";", "}", "}", "else", "{", "$", "changeset", "=", "$", "underscore_name", ";", "}", "$", "changeset", "=", "strtolower", "(", "str_replace", "(", "[", "' '", ",", "'_'", "]", ",", "[", "'-'", ",", "'-'", "]", ",", "$", "changeset", ")", ")", ";", "if", "(", "!", "$", "this", "->", "isValidChangesetName", "(", "$", "changeset", ")", ")", "{", "$", "changeset", "=", "(", "new", "DateTimeValue", "(", ")", ")", "->", "format", "(", "'Y-m-d'", ")", ".", "'-'", ".", "$", "changeset", ";", "}", "return", "\"$migrations_dir/$changeset/$classified_name.php\"", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/activecollab/databasemigrations/blob/ef91d5b5f74d79b4a75695393eb25c7c47dad093/src/Finder/MigrationsInChangesetsFinder.php#L137-L168
codeburnerframework/router
src/Route.php
Route.reset
public function reset() { return $this->collector->set($this->method, $this->pattern, $this->action)->nth(0) ->setStrategy($this->strategy)->setParams($this->params) ->setDefaults($this->defaults)->setMetadataArray($this->metadata); }
php
public function reset() { return $this->collector->set($this->method, $this->pattern, $this->action)->nth(0) ->setStrategy($this->strategy)->setParams($this->params) ->setDefaults($this->defaults)->setMetadataArray($this->metadata); }
[ "public", "function", "reset", "(", ")", "{", "return", "$", "this", "->", "collector", "->", "set", "(", "$", "this", "->", "method", ",", "$", "this", "->", "pattern", ",", "$", "this", "->", "action", ")", "->", "nth", "(", "0", ")", "->", "setStrategy", "(", "$", "this", "->", "strategy", ")", "->", "setParams", "(", "$", "this", "->", "params", ")", "->", "setDefaults", "(", "$", "this", "->", "defaults", ")", "->", "setMetadataArray", "(", "$", "this", "->", "metadata", ")", ";", "}" ]
Clone this route and set it into the collector. @return Route
[ "Clone", "this", "route", "and", "set", "it", "into", "the", "collector", "." ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L139-L144
codeburnerframework/router
src/Route.php
Route.call
public function call(callable $container = null) { $this->action = $this->buildCallable($this->action, $container); if ($this->strategy === null) { return call_user_func_array($this->action, array_merge($this->defaults, $this->params)); } if (!is_object($this->strategy)) { if ($container === null) { $this->strategy = new $this->strategy; } else $this->strategy = $container($this->strategy); } return $this->callWithStrategy(); }
php
public function call(callable $container = null) { $this->action = $this->buildCallable($this->action, $container); if ($this->strategy === null) { return call_user_func_array($this->action, array_merge($this->defaults, $this->params)); } if (!is_object($this->strategy)) { if ($container === null) { $this->strategy = new $this->strategy; } else $this->strategy = $container($this->strategy); } return $this->callWithStrategy(); }
[ "public", "function", "call", "(", "callable", "$", "container", "=", "null", ")", "{", "$", "this", "->", "action", "=", "$", "this", "->", "buildCallable", "(", "$", "this", "->", "action", ",", "$", "container", ")", ";", "if", "(", "$", "this", "->", "strategy", "===", "null", ")", "{", "return", "call_user_func_array", "(", "$", "this", "->", "action", ",", "array_merge", "(", "$", "this", "->", "defaults", ",", "$", "this", "->", "params", ")", ")", ";", "}", "if", "(", "!", "is_object", "(", "$", "this", "->", "strategy", ")", ")", "{", "if", "(", "$", "container", "===", "null", ")", "{", "$", "this", "->", "strategy", "=", "new", "$", "this", "->", "strategy", ";", "}", "else", "$", "this", "->", "strategy", "=", "$", "container", "(", "$", "this", "->", "strategy", ")", ";", "}", "return", "$", "this", "->", "callWithStrategy", "(", ")", ";", "}" ]
Execute the route action, if no strategy was provided the action will be executed by the call_user_func PHP function. @param callable $container @throws BadRouteException @return mixed
[ "Execute", "the", "route", "action", "if", "no", "strategy", "was", "provided", "the", "action", "will", "be", "executed", "by", "the", "call_user_func", "PHP", "function", "." ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L167-L182
codeburnerframework/router
src/Route.php
Route.buildCallable
private function buildCallable($callable, $container = null) { if (is_string($callable) && strpos($callable, "::")) { $callable = explode("::", $callable); } if (is_array($callable)) { if (is_string($callable[0])) { $callable[0] = $this->parseCallableController($callable[0], $container); } $callable[1] = $this->parseCallablePlaceholders($callable[1]); } return $callable; }
php
private function buildCallable($callable, $container = null) { if (is_string($callable) && strpos($callable, "::")) { $callable = explode("::", $callable); } if (is_array($callable)) { if (is_string($callable[0])) { $callable[0] = $this->parseCallableController($callable[0], $container); } $callable[1] = $this->parseCallablePlaceholders($callable[1]); } return $callable; }
[ "private", "function", "buildCallable", "(", "$", "callable", ",", "$", "container", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "callable", ")", "&&", "strpos", "(", "$", "callable", ",", "\"::\"", ")", ")", "{", "$", "callable", "=", "explode", "(", "\"::\"", ",", "$", "callable", ")", ";", "}", "if", "(", "is_array", "(", "$", "callable", ")", ")", "{", "if", "(", "is_string", "(", "$", "callable", "[", "0", "]", ")", ")", "{", "$", "callable", "[", "0", "]", "=", "$", "this", "->", "parseCallableController", "(", "$", "callable", "[", "0", "]", ",", "$", "container", ")", ";", "}", "$", "callable", "[", "1", "]", "=", "$", "this", "->", "parseCallablePlaceholders", "(", "$", "callable", "[", "1", "]", ")", ";", "}", "return", "$", "callable", ";", "}" ]
Seek for dynamic content in one callable. This allow to use parameters defined on pattern on callable definition, eg. "get" "/{resource:string+}/{slug:slug+}" "{resource}::find". This will snakecase the resource parameter and deal with as a controller, then call the find method. A request for "/articles/my-first-article" will execute find method of Articles controller with only "my-first-article" as parameter. @param callable $callable @param callable $container @return callable
[ "Seek", "for", "dynamic", "content", "in", "one", "callable", ".", "This", "allow", "to", "use", "parameters", "defined", "on", "pattern", "on", "callable", "definition", "eg", ".", "get", "/", "{", "resource", ":", "string", "+", "}", "/", "{", "slug", ":", "slug", "+", "}", "{", "resource", "}", "::", "find", "." ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L198-L213
codeburnerframework/router
src/Route.php
Route.parseCallableController
private function parseCallableController($controller, $container) { $controller = rtrim($this->namespace, "\\") . "\\" . $this->parseCallablePlaceholders($controller); if ($container === null) { return new $controller; } else return $container($controller); }
php
private function parseCallableController($controller, $container) { $controller = rtrim($this->namespace, "\\") . "\\" . $this->parseCallablePlaceholders($controller); if ($container === null) { return new $controller; } else return $container($controller); }
[ "private", "function", "parseCallableController", "(", "$", "controller", ",", "$", "container", ")", "{", "$", "controller", "=", "rtrim", "(", "$", "this", "->", "namespace", ",", "\"\\\\\"", ")", ".", "\"\\\\\"", ".", "$", "this", "->", "parseCallablePlaceholders", "(", "$", "controller", ")", ";", "if", "(", "$", "container", "===", "null", ")", "{", "return", "new", "$", "controller", ";", "}", "else", "return", "$", "container", "(", "$", "controller", ")", ";", "}" ]
Get the controller object. @param string $controller @param callable $container @return Object
[ "Get", "the", "controller", "object", "." ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L224-L231
codeburnerframework/router
src/Route.php
Route.parseCallablePlaceholders
private function parseCallablePlaceholders($fragment) { if (strpos($fragment, "{") !== false) { foreach ($this->params as $placeholder => $value) { if (strpos($fragment, "{" . $placeholder . "}") !== false) { $fragment = str_replace("{" . $placeholder . "}", ucwords(str_replace("-", " ", $value)), $fragment); } } } return $fragment; }
php
private function parseCallablePlaceholders($fragment) { if (strpos($fragment, "{") !== false) { foreach ($this->params as $placeholder => $value) { if (strpos($fragment, "{" . $placeholder . "}") !== false) { $fragment = str_replace("{" . $placeholder . "}", ucwords(str_replace("-", " ", $value)), $fragment); } } } return $fragment; }
[ "private", "function", "parseCallablePlaceholders", "(", "$", "fragment", ")", "{", "if", "(", "strpos", "(", "$", "fragment", ",", "\"{\"", ")", "!==", "false", ")", "{", "foreach", "(", "$", "this", "->", "params", "as", "$", "placeholder", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "fragment", ",", "\"{\"", ".", "$", "placeholder", ".", "\"}\"", ")", "!==", "false", ")", "{", "$", "fragment", "=", "str_replace", "(", "\"{\"", ".", "$", "placeholder", ".", "\"}\"", ",", "ucwords", "(", "str_replace", "(", "\"-\"", ",", "\" \"", ",", "$", "value", ")", ")", ",", "$", "fragment", ")", ";", "}", "}", "}", "return", "$", "fragment", ";", "}" ]
Parse and replace dynamic content on route action. @param string $fragment Part of callable @return string
[ "Parse", "and", "replace", "dynamic", "content", "on", "route", "action", "." ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L240-L251
codeburnerframework/router
src/Route.php
Route.callWithStrategy
private function callWithStrategy() { if ($this->strategy instanceof StrategyInterface) { if ($this->strategy instanceof MatcherAwareInterface) { $this->strategy->setMatcher($this->matcher); } return $this->strategy->call($this); } throw new BadRouteException(str_replace("%s", get_class($this->strategy), BadRouteException::BAD_STRATEGY)); }
php
private function callWithStrategy() { if ($this->strategy instanceof StrategyInterface) { if ($this->strategy instanceof MatcherAwareInterface) { $this->strategy->setMatcher($this->matcher); } return $this->strategy->call($this); } throw new BadRouteException(str_replace("%s", get_class($this->strategy), BadRouteException::BAD_STRATEGY)); }
[ "private", "function", "callWithStrategy", "(", ")", "{", "if", "(", "$", "this", "->", "strategy", "instanceof", "StrategyInterface", ")", "{", "if", "(", "$", "this", "->", "strategy", "instanceof", "MatcherAwareInterface", ")", "{", "$", "this", "->", "strategy", "->", "setMatcher", "(", "$", "this", "->", "matcher", ")", ";", "}", "return", "$", "this", "->", "strategy", "->", "call", "(", "$", "this", ")", ";", "}", "throw", "new", "BadRouteException", "(", "str_replace", "(", "\"%s\"", ",", "get_class", "(", "$", "this", "->", "strategy", ")", ",", "BadRouteException", "::", "BAD_STRATEGY", ")", ")", ";", "}" ]
Execute the route action with the given strategy. @throws BadRouteException @return mixed
[ "Execute", "the", "route", "action", "with", "the", "given", "strategy", "." ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L260-L271
codeburnerframework/router
src/Route.php
Route.setConstraint
public function setConstraint($token, $regex) { $initPos = strpos($this->pattern, "{" . $token); if ($initPos !== false) { $endPos = strpos($this->pattern, "}", $initPos); $newPattern = substr_replace($this->pattern, "{" . "$token:$regex" . "}", $initPos, $endPos - $initPos + 1); $wildcards = $this->collector->getParser()->getWildcardTokens(); $newPattern = str_replace(array_keys($wildcards), $wildcards, $newPattern); $this->setPatternWithoutReset($newPattern); } return $this; }
php
public function setConstraint($token, $regex) { $initPos = strpos($this->pattern, "{" . $token); if ($initPos !== false) { $endPos = strpos($this->pattern, "}", $initPos); $newPattern = substr_replace($this->pattern, "{" . "$token:$regex" . "}", $initPos, $endPos - $initPos + 1); $wildcards = $this->collector->getParser()->getWildcardTokens(); $newPattern = str_replace(array_keys($wildcards), $wildcards, $newPattern); $this->setPatternWithoutReset($newPattern); } return $this; }
[ "public", "function", "setConstraint", "(", "$", "token", ",", "$", "regex", ")", "{", "$", "initPos", "=", "strpos", "(", "$", "this", "->", "pattern", ",", "\"{\"", ".", "$", "token", ")", ";", "if", "(", "$", "initPos", "!==", "false", ")", "{", "$", "endPos", "=", "strpos", "(", "$", "this", "->", "pattern", ",", "\"}\"", ",", "$", "initPos", ")", ";", "$", "newPattern", "=", "substr_replace", "(", "$", "this", "->", "pattern", ",", "\"{\"", ".", "\"$token:$regex\"", ".", "\"}\"", ",", "$", "initPos", ",", "$", "endPos", "-", "$", "initPos", "+", "1", ")", ";", "$", "wildcards", "=", "$", "this", "->", "collector", "->", "getParser", "(", ")", "->", "getWildcardTokens", "(", ")", ";", "$", "newPattern", "=", "str_replace", "(", "array_keys", "(", "$", "wildcards", ")", ",", "$", "wildcards", ",", "$", "newPattern", ")", ";", "$", "this", "->", "setPatternWithoutReset", "(", "$", "newPattern", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set a constraint to a token in the route pattern. @param string $token @param string $regex @return self
[ "Set", "a", "constraint", "to", "a", "token", "in", "the", "route", "pattern", "." ]
train
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L627-L640
prooph/link-app-core
src/SharedKernel/ApplicationDataTypeLocation.php
ApplicationDataTypeLocation.addDataTypeClass
public function addDataTypeClass($dataTypeFQCN, $classContent, $replace = false) { if (strpos($dataTypeFQCN, "Prooph\\Link\\Application\\DataType\\") !== 0) { throw new \InvalidArgumentException("Namespace of data type should start with Prooph\\Link\\Application\\DataType\\. Got " . $dataTypeFQCN); } $nsDirs = explode("\\", str_replace("Prooph\\Link\\Application\\DataType\\", "", $dataTypeFQCN)); $className = array_pop($nsDirs); if (empty($className)) { throw new \InvalidArgumentException("Provided data type FQCN contains no class name: " . $dataTypeFQCN); } $currentPath = $this->toString(); if (! empty($nsDirs)) { foreach ($nsDirs as $nsDir) { $currentPath .= DIRECTORY_SEPARATOR . $nsDir; if (! is_dir($currentPath)) mkdir($currentPath); } } $filename = $currentPath . DIRECTORY_SEPARATOR . $className . ".php"; if (!$replace && file_exists($filename)) return; file_put_contents($filename, $classContent); }
php
public function addDataTypeClass($dataTypeFQCN, $classContent, $replace = false) { if (strpos($dataTypeFQCN, "Prooph\\Link\\Application\\DataType\\") !== 0) { throw new \InvalidArgumentException("Namespace of data type should start with Prooph\\Link\\Application\\DataType\\. Got " . $dataTypeFQCN); } $nsDirs = explode("\\", str_replace("Prooph\\Link\\Application\\DataType\\", "", $dataTypeFQCN)); $className = array_pop($nsDirs); if (empty($className)) { throw new \InvalidArgumentException("Provided data type FQCN contains no class name: " . $dataTypeFQCN); } $currentPath = $this->toString(); if (! empty($nsDirs)) { foreach ($nsDirs as $nsDir) { $currentPath .= DIRECTORY_SEPARATOR . $nsDir; if (! is_dir($currentPath)) mkdir($currentPath); } } $filename = $currentPath . DIRECTORY_SEPARATOR . $className . ".php"; if (!$replace && file_exists($filename)) return; file_put_contents($filename, $classContent); }
[ "public", "function", "addDataTypeClass", "(", "$", "dataTypeFQCN", ",", "$", "classContent", ",", "$", "replace", "=", "false", ")", "{", "if", "(", "strpos", "(", "$", "dataTypeFQCN", ",", "\"Prooph\\\\Link\\\\Application\\\\DataType\\\\\"", ")", "!==", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Namespace of data type should start with Prooph\\\\Link\\\\Application\\\\DataType\\\\. Got \"", ".", "$", "dataTypeFQCN", ")", ";", "}", "$", "nsDirs", "=", "explode", "(", "\"\\\\\"", ",", "str_replace", "(", "\"Prooph\\\\Link\\\\Application\\\\DataType\\\\\"", ",", "\"\"", ",", "$", "dataTypeFQCN", ")", ")", ";", "$", "className", "=", "array_pop", "(", "$", "nsDirs", ")", ";", "if", "(", "empty", "(", "$", "className", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Provided data type FQCN contains no class name: \"", ".", "$", "dataTypeFQCN", ")", ";", "}", "$", "currentPath", "=", "$", "this", "->", "toString", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "nsDirs", ")", ")", "{", "foreach", "(", "$", "nsDirs", "as", "$", "nsDir", ")", "{", "$", "currentPath", ".=", "DIRECTORY_SEPARATOR", ".", "$", "nsDir", ";", "if", "(", "!", "is_dir", "(", "$", "currentPath", ")", ")", "mkdir", "(", "$", "currentPath", ")", ";", "}", "}", "$", "filename", "=", "$", "currentPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "className", ".", "\".php\"", ";", "if", "(", "!", "$", "replace", "&&", "file_exists", "(", "$", "filename", ")", ")", "return", ";", "file_put_contents", "(", "$", "filename", ",", "$", "classContent", ")", ";", "}" ]
Writes the given class content to a class file named after the class. The root directory is defined by the path of ApplicationDataTypeLocation. The namespace of the class should start with Application\DataType\ If more sub namespaces are defined, the method creates a directory for each namespace part if not already exists. By default a new class is only generated if it does not exist already. You can force an override by setting the replace flag to true. @param $dataTypeFQCN @param $classContent @param bool $replace @throws \InvalidArgumentException
[ "Writes", "the", "given", "class", "content", "to", "a", "class", "file", "named", "after", "the", "class", ".", "The", "root", "directory", "is", "defined", "by", "the", "path", "of", "ApplicationDataTypeLocation", ".", "The", "namespace", "of", "the", "class", "should", "start", "with", "Application", "\\", "DataType", "\\", "If", "more", "sub", "namespaces", "are", "defined", "the", "method", "creates", "a", "directory", "for", "each", "namespace", "part", "if", "not", "already", "exists", "." ]
train
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/SharedKernel/ApplicationDataTypeLocation.php#L43-L70
phossa2/middleware
src/Middleware/Condition/HttpMethodCondition.php
HttpMethodCondition.evaluate
public function evaluate( RequestInterface $request, ResponseInterface $response )/*# : bool */ { return in_array($request->getMethod(), $this->methods); }
php
public function evaluate( RequestInterface $request, ResponseInterface $response )/*# : bool */ { return in_array($request->getMethod(), $this->methods); }
[ "public", "function", "evaluate", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "/*# : bool */", "{", "return", "in_array", "(", "$", "request", "->", "getMethod", "(", ")", ",", "$", "this", "->", "methods", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Condition/HttpMethodCondition.php#L52-L57
phramework/jsonapi
src/Controller/POST.php
POST.handlePOSTResource
private static function handlePOSTResource( $params, $method, $headers, $modelClass, $primaryDataParameters, $relationshipParameters, $requestAttributes, $validationCallbacks, $requestRelationships ) { $validationModel = $modelClass::getValidationModel(); $attributesValidator = ( isset($validationModel->attributes) && $validationModel->attributes ? $validationModel->attributes : new ObjectValidator() ); //Parse request attributes using $validationModel to validate the data $attributes = $attributesValidator->parse($requestAttributes); if (empty((array) $attributes)) { $attributes = new \stdClass(); } $parsedRelationshipAttributes = self::getParsedRelationshipAttributes( $modelClass, $attributes, $requestRelationships, $relationshipParameters, $validationModel ); //Call Validation callbacks foreach ($validationCallbacks as $callback) { call_user_func( $callback, $requestAttributes, $requestRelationships, $attributes, $parsedRelationshipAttributes ); } $queueRelationships = new \stdClass(); /** * Call POST_RELATIONSHIP_BY_PREFIX handler for TO_MANY relationships * This handler should post into database these relationships */ foreach ($requestRelationships as $relationshipKey => $relationshipValue) { $relationship = $modelClass::getRelationship($relationshipKey); if ($relationship->type == Relationship::TYPE_TO_MANY) { $parsedRelationshipValue = $parsedRelationshipAttributes->{$relationshipKey}; $relationship = $modelClass::getRelationship($relationshipKey); if (!isset($relationship->callbacks->{Phramework::METHOD_POST})) { throw new ServerException(sprintf( 'POST callback is not implemented for relationship "%s"', $relationshipKey )); } //Push to queueRelationships $queueRelationships->{$relationshipKey} = (object) [ 'callback' => $relationship->callbacks->{Phramework::METHOD_POST}, //callable 'resources' => $parsedRelationshipValue //array ]; } } return new \Phramework\JSONAPI\Controller\POST\QueueItem( $attributes, $queueRelationships ); }
php
private static function handlePOSTResource( $params, $method, $headers, $modelClass, $primaryDataParameters, $relationshipParameters, $requestAttributes, $validationCallbacks, $requestRelationships ) { $validationModel = $modelClass::getValidationModel(); $attributesValidator = ( isset($validationModel->attributes) && $validationModel->attributes ? $validationModel->attributes : new ObjectValidator() ); //Parse request attributes using $validationModel to validate the data $attributes = $attributesValidator->parse($requestAttributes); if (empty((array) $attributes)) { $attributes = new \stdClass(); } $parsedRelationshipAttributes = self::getParsedRelationshipAttributes( $modelClass, $attributes, $requestRelationships, $relationshipParameters, $validationModel ); //Call Validation callbacks foreach ($validationCallbacks as $callback) { call_user_func( $callback, $requestAttributes, $requestRelationships, $attributes, $parsedRelationshipAttributes ); } $queueRelationships = new \stdClass(); /** * Call POST_RELATIONSHIP_BY_PREFIX handler for TO_MANY relationships * This handler should post into database these relationships */ foreach ($requestRelationships as $relationshipKey => $relationshipValue) { $relationship = $modelClass::getRelationship($relationshipKey); if ($relationship->type == Relationship::TYPE_TO_MANY) { $parsedRelationshipValue = $parsedRelationshipAttributes->{$relationshipKey}; $relationship = $modelClass::getRelationship($relationshipKey); if (!isset($relationship->callbacks->{Phramework::METHOD_POST})) { throw new ServerException(sprintf( 'POST callback is not implemented for relationship "%s"', $relationshipKey )); } //Push to queueRelationships $queueRelationships->{$relationshipKey} = (object) [ 'callback' => $relationship->callbacks->{Phramework::METHOD_POST}, //callable 'resources' => $parsedRelationshipValue //array ]; } } return new \Phramework\JSONAPI\Controller\POST\QueueItem( $attributes, $queueRelationships ); }
[ "private", "static", "function", "handlePOSTResource", "(", "$", "params", ",", "$", "method", ",", "$", "headers", ",", "$", "modelClass", ",", "$", "primaryDataParameters", ",", "$", "relationshipParameters", ",", "$", "requestAttributes", ",", "$", "validationCallbacks", ",", "$", "requestRelationships", ")", "{", "$", "validationModel", "=", "$", "modelClass", "::", "getValidationModel", "(", ")", ";", "$", "attributesValidator", "=", "(", "isset", "(", "$", "validationModel", "->", "attributes", ")", "&&", "$", "validationModel", "->", "attributes", "?", "$", "validationModel", "->", "attributes", ":", "new", "ObjectValidator", "(", ")", ")", ";", "//Parse request attributes using $validationModel to validate the data", "$", "attributes", "=", "$", "attributesValidator", "->", "parse", "(", "$", "requestAttributes", ")", ";", "if", "(", "empty", "(", "(", "array", ")", "$", "attributes", ")", ")", "{", "$", "attributes", "=", "new", "\\", "stdClass", "(", ")", ";", "}", "$", "parsedRelationshipAttributes", "=", "self", "::", "getParsedRelationshipAttributes", "(", "$", "modelClass", ",", "$", "attributes", ",", "$", "requestRelationships", ",", "$", "relationshipParameters", ",", "$", "validationModel", ")", ";", "//Call Validation callbacks", "foreach", "(", "$", "validationCallbacks", "as", "$", "callback", ")", "{", "call_user_func", "(", "$", "callback", ",", "$", "requestAttributes", ",", "$", "requestRelationships", ",", "$", "attributes", ",", "$", "parsedRelationshipAttributes", ")", ";", "}", "$", "queueRelationships", "=", "new", "\\", "stdClass", "(", ")", ";", "/**\n * Call POST_RELATIONSHIP_BY_PREFIX handler for TO_MANY relationships\n * This handler should post into database these relationships\n */", "foreach", "(", "$", "requestRelationships", "as", "$", "relationshipKey", "=>", "$", "relationshipValue", ")", "{", "$", "relationship", "=", "$", "modelClass", "::", "getRelationship", "(", "$", "relationshipKey", ")", ";", "if", "(", "$", "relationship", "->", "type", "==", "Relationship", "::", "TYPE_TO_MANY", ")", "{", "$", "parsedRelationshipValue", "=", "$", "parsedRelationshipAttributes", "->", "{", "$", "relationshipKey", "}", ";", "$", "relationship", "=", "$", "modelClass", "::", "getRelationship", "(", "$", "relationshipKey", ")", ";", "if", "(", "!", "isset", "(", "$", "relationship", "->", "callbacks", "->", "{", "Phramework", "::", "METHOD_POST", "}", ")", ")", "{", "throw", "new", "ServerException", "(", "sprintf", "(", "'POST callback is not implemented for relationship \"%s\"'", ",", "$", "relationshipKey", ")", ")", ";", "}", "//Push to queueRelationships", "$", "queueRelationships", "->", "{", "$", "relationshipKey", "}", "=", "(", "object", ")", "[", "'callback'", "=>", "$", "relationship", "->", "callbacks", "->", "{", "Phramework", "::", "METHOD_POST", "}", ",", "//callable", "'resources'", "=>", "$", "parsedRelationshipValue", "//array", "]", ";", "}", "}", "return", "new", "\\", "Phramework", "\\", "JSONAPI", "\\", "Controller", "\\", "POST", "\\", "QueueItem", "(", "$", "attributes", ",", "$", "queueRelationships", ")", ";", "}" ]
Helper method @param object $params @param $method @param $headers @param string $modelClass @param object $primaryDataParameters @param object $relationshipParameters @param object $requestAttributes @param $validationCallbacks @param $requestRelationships @return POST\QueueItem @throws RequestException @throws \Exception @throws \Phramework\Exceptions\NotFoundException @throws \Phramework\Exceptions\ServerException
[ "Helper", "method" ]
train
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/POST.php#L240-L319
o2system/html
src/Element/Nodes.php
Nodes.createNode
public function createNode($tagName, $entityName = null) { if ($tagName instanceof Element) { $this->push($tagName); } else { $this->push(new Element($tagName, $entityName)); } return $this->last(); }
php
public function createNode($tagName, $entityName = null) { if ($tagName instanceof Element) { $this->push($tagName); } else { $this->push(new Element($tagName, $entityName)); } return $this->last(); }
[ "public", "function", "createNode", "(", "$", "tagName", ",", "$", "entityName", "=", "null", ")", "{", "if", "(", "$", "tagName", "instanceof", "Element", ")", "{", "$", "this", "->", "push", "(", "$", "tagName", ")", ";", "}", "else", "{", "$", "this", "->", "push", "(", "new", "Element", "(", "$", "tagName", ",", "$", "entityName", ")", ")", ";", "}", "return", "$", "this", "->", "last", "(", ")", ";", "}" ]
Nodes::createNode @param string $tagName @param string|null $entityName @return mixed
[ "Nodes", "::", "createNode" ]
train
https://github.com/o2system/html/blob/b7336fb45d42603ce1064b25572a05d495887670/src/Element/Nodes.php#L45-L54
o2system/html
src/Element/Nodes.php
Nodes.push
public function push($value) { parent::push($value); $this->nodesEntities[] = $this->last()->entity->getEntityName(); }
php
public function push($value) { parent::push($value); $this->nodesEntities[] = $this->last()->entity->getEntityName(); }
[ "public", "function", "push", "(", "$", "value", ")", "{", "parent", "::", "push", "(", "$", "value", ")", ";", "$", "this", "->", "nodesEntities", "[", "]", "=", "$", "this", "->", "last", "(", ")", "->", "entity", "->", "getEntityName", "(", ")", ";", "}" ]
Nodes::push @param mixed $value
[ "Nodes", "::", "push" ]
train
https://github.com/o2system/html/blob/b7336fb45d42603ce1064b25572a05d495887670/src/Element/Nodes.php#L63-L67
o2system/html
src/Element/Nodes.php
Nodes.hasNode
public function hasNode($index) { if (is_string($index) and in_array($index, $this->nodesEntities)) { if (false !== ($key = array_search($index, $this->nodesEntities))) { if ($this->offsetExists($key)) { return true; } } } return false; }
php
public function hasNode($index) { if (is_string($index) and in_array($index, $this->nodesEntities)) { if (false !== ($key = array_search($index, $this->nodesEntities))) { if ($this->offsetExists($key)) { return true; } } } return false; }
[ "public", "function", "hasNode", "(", "$", "index", ")", "{", "if", "(", "is_string", "(", "$", "index", ")", "and", "in_array", "(", "$", "index", ",", "$", "this", "->", "nodesEntities", ")", ")", "{", "if", "(", "false", "!==", "(", "$", "key", "=", "array_search", "(", "$", "index", ",", "$", "this", "->", "nodesEntities", ")", ")", ")", "{", "if", "(", "$", "this", "->", "offsetExists", "(", "$", "key", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Nodes::hasNode @param string $index @return bool
[ "Nodes", "::", "hasNode" ]
train
https://github.com/o2system/html/blob/b7336fb45d42603ce1064b25572a05d495887670/src/Element/Nodes.php#L78-L89
o2system/html
src/Element/Nodes.php
Nodes.getNode
public function getNode($index) { if (is_string($index) and in_array($index, $this->nodesEntities)) { if (false !== ($key = array_search($index, $this->nodesEntities))) { if ($this->offsetExists($key)) { return $this->offsetGet($index); } } } return false; }
php
public function getNode($index) { if (is_string($index) and in_array($index, $this->nodesEntities)) { if (false !== ($key = array_search($index, $this->nodesEntities))) { if ($this->offsetExists($key)) { return $this->offsetGet($index); } } } return false; }
[ "public", "function", "getNode", "(", "$", "index", ")", "{", "if", "(", "is_string", "(", "$", "index", ")", "and", "in_array", "(", "$", "index", ",", "$", "this", "->", "nodesEntities", ")", ")", "{", "if", "(", "false", "!==", "(", "$", "key", "=", "array_search", "(", "$", "index", ",", "$", "this", "->", "nodesEntities", ")", ")", ")", "{", "if", "(", "$", "this", "->", "offsetExists", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "offsetGet", "(", "$", "index", ")", ";", "}", "}", "}", "return", "false", ";", "}" ]
Nodes::getNode @param string $index @return bool|mixed
[ "Nodes", "::", "getNode" ]
train
https://github.com/o2system/html/blob/b7336fb45d42603ce1064b25572a05d495887670/src/Element/Nodes.php#L100-L111
o2system/html
src/Element/Nodes.php
Nodes.getNodeByTagName
public function getNodeByTagName($tagName) { $result = []; foreach ($this as $node) { if ($node->tagName === $tagName) { $result[] = $node; } } return $result; }
php
public function getNodeByTagName($tagName) { $result = []; foreach ($this as $node) { if ($node->tagName === $tagName) { $result[] = $node; } } return $result; }
[ "public", "function", "getNodeByTagName", "(", "$", "tagName", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "tagName", "===", "$", "tagName", ")", "{", "$", "result", "[", "]", "=", "$", "node", ";", "}", "}", "return", "$", "result", ";", "}" ]
Nodes::getNodeByTagName @param string $tagName @return array
[ "Nodes", "::", "getNodeByTagName" ]
train
https://github.com/o2system/html/blob/b7336fb45d42603ce1064b25572a05d495887670/src/Element/Nodes.php#L148-L159
o2system/html
src/Element/Nodes.php
Nodes.getNodeByEntityName
public function getNodeByEntityName($entityName) { if (false !== ($index = array_search($entityName, $this->nodesEntities))) { if ($this->offsetExists($index)) { return $this->offsetGet($index); } } return false; }
php
public function getNodeByEntityName($entityName) { if (false !== ($index = array_search($entityName, $this->nodesEntities))) { if ($this->offsetExists($index)) { return $this->offsetGet($index); } } return false; }
[ "public", "function", "getNodeByEntityName", "(", "$", "entityName", ")", "{", "if", "(", "false", "!==", "(", "$", "index", "=", "array_search", "(", "$", "entityName", ",", "$", "this", "->", "nodesEntities", ")", ")", ")", "{", "if", "(", "$", "this", "->", "offsetExists", "(", "$", "index", ")", ")", "{", "return", "$", "this", "->", "offsetGet", "(", "$", "index", ")", ";", "}", "}", "return", "false", ";", "}" ]
Nodes::getNodeByEntityName @param string $entityName @return bool|mixed
[ "Nodes", "::", "getNodeByEntityName" ]
train
https://github.com/o2system/html/blob/b7336fb45d42603ce1064b25572a05d495887670/src/Element/Nodes.php#L170-L179
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.checkForDuplicateNames
protected function checkForDuplicateNames() { $normalized = []; foreach ($this->data->rawData['modules'] as $moduleId => $module) { $normalized[ $moduleId ] = $this->normalizeName( array_get($module, 'prefixed_name') ?: $module['name'] ); } return $this->getKeysForDuplicates($normalized); }
php
protected function checkForDuplicateNames() { $normalized = []; foreach ($this->data->rawData['modules'] as $moduleId => $module) { $normalized[ $moduleId ] = $this->normalizeName( array_get($module, 'prefixed_name') ?: $module['name'] ); } return $this->getKeysForDuplicates($normalized); }
[ "protected", "function", "checkForDuplicateNames", "(", ")", "{", "$", "normalized", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "as", "$", "moduleId", "=>", "$", "module", ")", "{", "$", "normalized", "[", "$", "moduleId", "]", "=", "$", "this", "->", "normalizeName", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ")", ";", "}", "return", "$", "this", "->", "getKeysForDuplicates", "(", "$", "normalized", ")", ";", "}" ]
Checks all modules for conflicting module names, and returns modules per duplicate set. @return array
[ "Checks", "all", "modules", "for", "conflicting", "module", "names", "and", "returns", "modules", "per", "duplicate", "set", "." ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L102-L113
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.attemptToResolveDuplicates
protected function attemptToResolveDuplicates(array $duplicates) { foreach ($duplicates as $set) { foreach ($set as $moduleId) { // change the module id by doing what's left to do // 1. prefix section if ( ! $this->prefixSection && ! array_key_exists($moduleId, $this->modulePrefixedSection)) { $this->addOrInjectSectionNamePrefix($moduleId); continue; } // 2. prefix group if ( ! $this->prefixGroup && ! array_key_exists($moduleId, $this->modulePrefixedGroup)) { $this->addOrInjectGroupNamePrefix($moduleId); continue; } // 3. prefix menu if ( ! $this->prefixMenu && ! array_key_exists($moduleId, $this->modulePrefixedMenu)) { $this->addOrInjectMenuNamePrefix($moduleId); continue; } // 4. append module id (last resort) $this->addModuleIdPostFix($moduleId); } } }
php
protected function attemptToResolveDuplicates(array $duplicates) { foreach ($duplicates as $set) { foreach ($set as $moduleId) { // change the module id by doing what's left to do // 1. prefix section if ( ! $this->prefixSection && ! array_key_exists($moduleId, $this->modulePrefixedSection)) { $this->addOrInjectSectionNamePrefix($moduleId); continue; } // 2. prefix group if ( ! $this->prefixGroup && ! array_key_exists($moduleId, $this->modulePrefixedGroup)) { $this->addOrInjectGroupNamePrefix($moduleId); continue; } // 3. prefix menu if ( ! $this->prefixMenu && ! array_key_exists($moduleId, $this->modulePrefixedMenu)) { $this->addOrInjectMenuNamePrefix($moduleId); continue; } // 4. append module id (last resort) $this->addModuleIdPostFix($moduleId); } } }
[ "protected", "function", "attemptToResolveDuplicates", "(", "array", "$", "duplicates", ")", "{", "foreach", "(", "$", "duplicates", "as", "$", "set", ")", "{", "foreach", "(", "$", "set", "as", "$", "moduleId", ")", "{", "// change the module id by doing what's left to do", "// 1. prefix section", "if", "(", "!", "$", "this", "->", "prefixSection", "&&", "!", "array_key_exists", "(", "$", "moduleId", ",", "$", "this", "->", "modulePrefixedSection", ")", ")", "{", "$", "this", "->", "addOrInjectSectionNamePrefix", "(", "$", "moduleId", ")", ";", "continue", ";", "}", "// 2. prefix group", "if", "(", "!", "$", "this", "->", "prefixGroup", "&&", "!", "array_key_exists", "(", "$", "moduleId", ",", "$", "this", "->", "modulePrefixedGroup", ")", ")", "{", "$", "this", "->", "addOrInjectGroupNamePrefix", "(", "$", "moduleId", ")", ";", "continue", ";", "}", "// 3. prefix menu", "if", "(", "!", "$", "this", "->", "prefixMenu", "&&", "!", "array_key_exists", "(", "$", "moduleId", ",", "$", "this", "->", "modulePrefixedMenu", ")", ")", "{", "$", "this", "->", "addOrInjectMenuNamePrefix", "(", "$", "moduleId", ")", ";", "continue", ";", "}", "// 4. append module id (last resort)", "$", "this", "->", "addModuleIdPostFix", "(", "$", "moduleId", ")", ";", "}", "}", "}" ]
Attempts to remove duplicates by changing (prefixed) module names @param array $duplicates an array with arrays of keys that are duplicates of one another
[ "Attempts", "to", "remove", "duplicates", "by", "changing", "(", "prefixed", ")", "module", "names" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L120-L153
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.addOrInjectSectionNamePrefix
protected function addOrInjectSectionNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['section']; // mark so we don't prefix it twice $this->modulePrefixedSection[$moduleId] = true; // simple prefix if nothing else was prefixed yet if ( ! $this->prefixGroup && ! $this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); } // simple prefix won't work, we'll need to rebuild the name, prefixing the section first $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); if ($this->prefixGroup) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); } if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
php
protected function addOrInjectSectionNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['section']; // mark so we don't prefix it twice $this->modulePrefixedSection[$moduleId] = true; // simple prefix if nothing else was prefixed yet if ( ! $this->prefixGroup && ! $this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); } // simple prefix won't work, we'll need to rebuild the name, prefixing the section first $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); if ($this->prefixGroup) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); } if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
[ "protected", "function", "addOrInjectSectionNamePrefix", "(", "$", "moduleId", ")", "{", "$", "module", "=", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", ";", "$", "prefix", "=", "$", "module", "[", "'parent_names'", "]", "[", "'section'", "]", ";", "// mark so we don't prefix it twice", "$", "this", "->", "modulePrefixedSection", "[", "$", "moduleId", "]", "=", "true", ";", "// simple prefix if nothing else was prefixed yet", "if", "(", "!", "$", "this", "->", "prefixGroup", "&&", "!", "$", "this", "->", "prefixMenu", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "prefix", ")", ";", "}", "// simple prefix won't work, we'll need to rebuild the name, prefixing the section first", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'section'", "]", ")", ";", "if", "(", "$", "this", "->", "prefixGroup", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'group'", "]", ")", ";", "}", "if", "(", "$", "this", "->", "prefixMenu", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'menu'", "]", ")", ";", "}", "}" ]
Prefixes module name with section name, keeping into account whether other, higher-level prefixes have been applied @param int $moduleId
[ "Prefixes", "module", "name", "with", "section", "name", "keeping", "into", "account", "whether", "other", "higher", "-", "level", "prefixes", "have", "been", "applied" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L161-L200
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.addOrInjectGroupNamePrefix
protected function addOrInjectGroupNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['group']; // mark so we don't prefix it twice $this->modulePrefixedGroup[$moduleId] = true; // simple prefix if nothing else was prefixed yet if ( ! $this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); } // simple prefix won't work, we'll need to rebuild the name, prefixing the section and group first // note that the section will always have been prefixed, one way or the other, at this point! $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
php
protected function addOrInjectGroupNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['group']; // mark so we don't prefix it twice $this->modulePrefixedGroup[$moduleId] = true; // simple prefix if nothing else was prefixed yet if ( ! $this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); } // simple prefix won't work, we'll need to rebuild the name, prefixing the section and group first // note that the section will always have been prefixed, one way or the other, at this point! $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
[ "protected", "function", "addOrInjectGroupNamePrefix", "(", "$", "moduleId", ")", "{", "$", "module", "=", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", ";", "$", "prefix", "=", "$", "module", "[", "'parent_names'", "]", "[", "'group'", "]", ";", "// mark so we don't prefix it twice", "$", "this", "->", "modulePrefixedGroup", "[", "$", "moduleId", "]", "=", "true", ";", "// simple prefix if nothing else was prefixed yet", "if", "(", "!", "$", "this", "->", "prefixMenu", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "prefix", ")", ";", "}", "// simple prefix won't work, we'll need to rebuild the name, prefixing the section and group first", "// note that the section will always have been prefixed, one way or the other, at this point!", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'section'", "]", ")", ";", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'group'", "]", ")", ";", "if", "(", "$", "this", "->", "prefixMenu", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'menu'", "]", ")", ";", "}", "}" ]
Prefixes module name with group name, keeping into account whether other, higher-level prefixes have been applied @param int $moduleId
[ "Prefixes", "module", "name", "with", "group", "name", "keeping", "into", "account", "whether", "other", "higher", "-", "level", "prefixes", "have", "been", "applied" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L208-L246
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.addOrInjectMenuNamePrefix
protected function addOrInjectMenuNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['menu']; // mark so we don't prefix it twice $this->modulePrefixedMenu[$moduleId] = true; // this is always a simple prefix $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); }
php
protected function addOrInjectMenuNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['menu']; // mark so we don't prefix it twice $this->modulePrefixedMenu[$moduleId] = true; // this is always a simple prefix $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); }
[ "protected", "function", "addOrInjectMenuNamePrefix", "(", "$", "moduleId", ")", "{", "$", "module", "=", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", ";", "$", "prefix", "=", "$", "module", "[", "'parent_names'", "]", "[", "'menu'", "]", ";", "// mark so we don't prefix it twice", "$", "this", "->", "modulePrefixedMenu", "[", "$", "moduleId", "]", "=", "true", ";", "// this is always a simple prefix", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "prefix", ")", ";", "}" ]
Prefixes module name with menu name, keeping into account whether other, higher-level prefixes have been applied @param int $moduleId
[ "Prefixes", "module", "name", "with", "menu", "name", "keeping", "into", "account", "whether", "other", "higher", "-", "level", "prefixes", "have", "been", "applied" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L254-L268
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.addModuleIdPostFix
protected function addModuleIdPostFix($moduleId) { // undo previously applied prefixes (if any) $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = null; $this->prefixModuleName($moduleId); // postfix the module ID $module = $this->data->rawData['modules'][ $moduleId ]; $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = trim(array_get($module, 'prefixed_name') ?: $module['name']) . ' ' . $moduleId; }
php
protected function addModuleIdPostFix($moduleId) { // undo previously applied prefixes (if any) $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = null; $this->prefixModuleName($moduleId); // postfix the module ID $module = $this->data->rawData['modules'][ $moduleId ]; $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = trim(array_get($module, 'prefixed_name') ?: $module['name']) . ' ' . $moduleId; }
[ "protected", "function", "addModuleIdPostFix", "(", "$", "moduleId", ")", "{", "// undo previously applied prefixes (if any)", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "null", ";", "$", "this", "->", "prefixModuleName", "(", "$", "moduleId", ")", ";", "// postfix the module ID", "$", "module", "=", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", ";", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "trim", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ")", ".", "' '", ".", "$", "moduleId", ";", "}" ]
Postfixes the module name with the module ID, as a last resort to making a unique module name. Ideally this should undo any other attempts by prefixes, since they are useless anyway.. but this might be tricky in edge cases. You'd have to recheck for duplicates or trust the module IDs. We'll do the latter for now. @param $moduleId
[ "Postfixes", "the", "module", "name", "with", "the", "module", "ID", "as", "a", "last", "resort", "to", "making", "a", "unique", "module", "name", "." ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L281-L292
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.getKeysForDuplicates
function getKeysForDuplicates(array $array) { $duplicates = $newArray = []; foreach ($array as $key => $value) { if ( ! isset($newArray[ $value ])) { $newArray[ $value ] = $key; continue; } if (isset($duplicates[ $value ])) { $duplicates[ $value ][] = $key; } else { $duplicates[ $value ] = [ $newArray[ $value ], $key ]; } } return $duplicates; }
php
function getKeysForDuplicates(array $array) { $duplicates = $newArray = []; foreach ($array as $key => $value) { if ( ! isset($newArray[ $value ])) { $newArray[ $value ] = $key; continue; } if (isset($duplicates[ $value ])) { $duplicates[ $value ][] = $key; } else { $duplicates[ $value ] = [ $newArray[ $value ], $key ]; } } return $duplicates; }
[ "function", "getKeysForDuplicates", "(", "array", "$", "array", ")", "{", "$", "duplicates", "=", "$", "newArray", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "newArray", "[", "$", "value", "]", ")", ")", "{", "$", "newArray", "[", "$", "value", "]", "=", "$", "key", ";", "continue", ";", "}", "if", "(", "isset", "(", "$", "duplicates", "[", "$", "value", "]", ")", ")", "{", "$", "duplicates", "[", "$", "value", "]", "[", "]", "=", "$", "key", ";", "}", "else", "{", "$", "duplicates", "[", "$", "value", "]", "=", "[", "$", "newArray", "[", "$", "value", "]", ",", "$", "key", "]", ";", "}", "}", "return", "$", "duplicates", ";", "}" ]
Returns the keys for values that occur more than once in an array @param array $array @return array
[ "Returns", "the", "keys", "for", "values", "that", "occur", "more", "than", "once", "in", "an", "array" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L314-L336
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.prefixAllModuleNames
protected function prefixAllModuleNames() { foreach ($this->data->rawData['modules'] as $moduleId => $module) { $this->prefixModuleName($moduleId); } }
php
protected function prefixAllModuleNames() { foreach ($this->data->rawData['modules'] as $moduleId => $module) { $this->prefixModuleName($moduleId); } }
[ "protected", "function", "prefixAllModuleNames", "(", ")", "{", "foreach", "(", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "as", "$", "moduleId", "=>", "$", "module", ")", "{", "$", "this", "->", "prefixModuleName", "(", "$", "moduleId", ")", ";", "}", "}" ]
Prefixes all modules with section, group and/or menu names to module names
[ "Prefixes", "all", "modules", "with", "section", "group", "and", "/", "or", "menu", "names", "to", "module", "names" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L343-L349
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.prefixModuleName
protected function prefixModuleName($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; if ($this->prefixSection) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); } if ($this->prefixGroup) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); } if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
php
protected function prefixModuleName($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; if ($this->prefixSection) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); } if ($this->prefixGroup) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); } if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
[ "protected", "function", "prefixModuleName", "(", "$", "moduleId", ")", "{", "$", "module", "=", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", ";", "if", "(", "$", "this", "->", "prefixSection", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'section'", "]", ")", ";", "}", "if", "(", "$", "this", "->", "prefixGroup", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'group'", "]", ")", ";", "}", "if", "(", "$", "this", "->", "prefixMenu", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'menu'", "]", ")", ";", "}", "}" ]
Prefixes section, group and/or menu names to module names, if configured to @param int $moduleId
[ "Prefixes", "section", "group", "and", "/", "or", "menu", "names", "to", "module", "names", "if", "configured", "to" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L356-L386
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.reportModuleNamePrefixing
protected function reportModuleNamePrefixing() { foreach ($this->data->rawData['modules'] as $moduleId => $module) { if ( ! array_get($module, 'prefixed_name')) continue; $this->context->log( "Prefixed or altered module name to avoid duplicates: #{$moduleId} (" . "{$module['name']}) is now known as {$module['prefixed_name']}", Generator::LOG_LEVEL_WARNING ); } }
php
protected function reportModuleNamePrefixing() { foreach ($this->data->rawData['modules'] as $moduleId => $module) { if ( ! array_get($module, 'prefixed_name')) continue; $this->context->log( "Prefixed or altered module name to avoid duplicates: #{$moduleId} (" . "{$module['name']}) is now known as {$module['prefixed_name']}", Generator::LOG_LEVEL_WARNING ); } }
[ "protected", "function", "reportModuleNamePrefixing", "(", ")", "{", "foreach", "(", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "as", "$", "moduleId", "=>", "$", "module", ")", "{", "if", "(", "!", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", ")", "continue", ";", "$", "this", "->", "context", "->", "log", "(", "\"Prefixed or altered module name to avoid duplicates: #{$moduleId} (\"", ".", "\"{$module['name']}) is now known as {$module['prefixed_name']}\"", ",", "Generator", "::", "LOG_LEVEL_WARNING", ")", ";", "}", "}" ]
Fire log events for any module name that was prefixed / altered
[ "Fire", "log", "events", "for", "any", "module", "name", "that", "was", "prefixed", "/", "altered" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L404-L415
vespolina/VespolinaCommerceBundle
Form/Type/Cart/CreditCardDateFormType.php
CreditCardDateFormType.buildForm
public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('month', 'choice', array( 'choices' => $this->getMonthChoices(), 'required' => true, )) ->add('year', 'choice', array( 'choices' => $this->getYearChoices(), 'required' => true, )) ; }
php
public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('month', 'choice', array( 'choices' => $this->getMonthChoices(), 'required' => true, )) ->add('year', 'choice', array( 'choices' => $this->getYearChoices(), 'required' => true, )) ; }
[ "public", "function", "buildForm", "(", "FormBuilderInterface", "$", "builder", ",", "array", "$", "options", ")", "{", "$", "builder", "->", "add", "(", "'month'", ",", "'choice'", ",", "array", "(", "'choices'", "=>", "$", "this", "->", "getMonthChoices", "(", ")", ",", "'required'", "=>", "true", ",", ")", ")", "->", "add", "(", "'year'", ",", "'choice'", ",", "array", "(", "'choices'", "=>", "$", "this", "->", "getYearChoices", "(", ")", ",", "'required'", "=>", "true", ",", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Form/Type/Cart/CreditCardDateFormType.php#L25-L37
avoo/SerializerTranslation
Serializer/JsonSerializer.php
JsonSerializer.trans
public function trans(ClassMetadataInterface $metadataClass, JsonSerializationVisitor $visitor, SerializationContext $context, $data) { /** @var VirtualPropertyMetadata $propertyMetadata */ foreach ($metadataClass->getPropertiesToTranslate() as $propertyMetadata) { $value = $propertyMetadata->getValue($data); if (!empty($value)) { $locale = $propertyMetadata->locale; if (is_null($locale)) { $locale = $context->getLocale(); } $parameters = $this->expressionEvaluator->evaluateArray($propertyMetadata->parameters, $data); $value = $this->translator->trans($value, $parameters, $propertyMetadata->domain, $locale); $propertyMetadata->setValue($data, $this->expressionEvaluator->evaluate($value, $data)); } } }
php
public function trans(ClassMetadataInterface $metadataClass, JsonSerializationVisitor $visitor, SerializationContext $context, $data) { /** @var VirtualPropertyMetadata $propertyMetadata */ foreach ($metadataClass->getPropertiesToTranslate() as $propertyMetadata) { $value = $propertyMetadata->getValue($data); if (!empty($value)) { $locale = $propertyMetadata->locale; if (is_null($locale)) { $locale = $context->getLocale(); } $parameters = $this->expressionEvaluator->evaluateArray($propertyMetadata->parameters, $data); $value = $this->translator->trans($value, $parameters, $propertyMetadata->domain, $locale); $propertyMetadata->setValue($data, $this->expressionEvaluator->evaluate($value, $data)); } } }
[ "public", "function", "trans", "(", "ClassMetadataInterface", "$", "metadataClass", ",", "JsonSerializationVisitor", "$", "visitor", ",", "SerializationContext", "$", "context", ",", "$", "data", ")", "{", "/** @var VirtualPropertyMetadata $propertyMetadata */", "foreach", "(", "$", "metadataClass", "->", "getPropertiesToTranslate", "(", ")", "as", "$", "propertyMetadata", ")", "{", "$", "value", "=", "$", "propertyMetadata", "->", "getValue", "(", "$", "data", ")", ";", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "locale", "=", "$", "propertyMetadata", "->", "locale", ";", "if", "(", "is_null", "(", "$", "locale", ")", ")", "{", "$", "locale", "=", "$", "context", "->", "getLocale", "(", ")", ";", "}", "$", "parameters", "=", "$", "this", "->", "expressionEvaluator", "->", "evaluateArray", "(", "$", "propertyMetadata", "->", "parameters", ",", "$", "data", ")", ";", "$", "value", "=", "$", "this", "->", "translator", "->", "trans", "(", "$", "value", ",", "$", "parameters", ",", "$", "propertyMetadata", "->", "domain", ",", "$", "locale", ")", ";", "$", "propertyMetadata", "->", "setValue", "(", "$", "data", ",", "$", "this", "->", "expressionEvaluator", "->", "evaluate", "(", "$", "value", ",", "$", "data", ")", ")", ";", "}", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/avoo/SerializerTranslation/blob/e66de5482adb944197a36874465ef144b293a157/Serializer/JsonSerializer.php#L65-L84
discophp/framework
core/classes/Paginate.class.php
Paginate.getPageUrl
public function getPageUrl($page){ $qs = ''; if($_SERVER['QUERY_STRING']){ $qs = '?' . $_SERVER['QUERY_STRING']; }//if return str_replace($this->fromFormat($this->currentPage),$this->fromFormat($page),$this->uri) . $qs; }
php
public function getPageUrl($page){ $qs = ''; if($_SERVER['QUERY_STRING']){ $qs = '?' . $_SERVER['QUERY_STRING']; }//if return str_replace($this->fromFormat($this->currentPage),$this->fromFormat($page),$this->uri) . $qs; }
[ "public", "function", "getPageUrl", "(", "$", "page", ")", "{", "$", "qs", "=", "''", ";", "if", "(", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ")", "{", "$", "qs", "=", "'?'", ".", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ";", "}", "//if", "return", "str_replace", "(", "$", "this", "->", "fromFormat", "(", "$", "this", "->", "currentPage", ")", ",", "$", "this", "->", "fromFormat", "(", "$", "page", ")", ",", "$", "this", "->", "uri", ")", ".", "$", "qs", ";", "}" ]
Get the url for a specified page number. @param int $page The page number to build a link to. @return string
[ "Get", "the", "url", "for", "a", "specified", "page", "number", "." ]
train
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Paginate.class.php#L240-L246
discophp/framework
core/classes/Paginate.class.php
Paginate.getPrevUrls
public function getPrevUrls($floor = null){ if($floor){ $floor = $this->currentPage - $floor; } else { $floor = 1; }//el return $this->getRangeUrls($floor,$this->currentPage - 1); }
php
public function getPrevUrls($floor = null){ if($floor){ $floor = $this->currentPage - $floor; } else { $floor = 1; }//el return $this->getRangeUrls($floor,$this->currentPage - 1); }
[ "public", "function", "getPrevUrls", "(", "$", "floor", "=", "null", ")", "{", "if", "(", "$", "floor", ")", "{", "$", "floor", "=", "$", "this", "->", "currentPage", "-", "$", "floor", ";", "}", "else", "{", "$", "floor", "=", "1", ";", "}", "//el", "return", "$", "this", "->", "getRangeUrls", "(", "$", "floor", ",", "$", "this", "->", "currentPage", "-", "1", ")", ";", "}" ]
Get paginated urls that come before the current page. @param null|int $floor The max number of links to generate. @return string[]
[ "Get", "paginated", "urls", "that", "come", "before", "the", "current", "page", "." ]
train
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Paginate.class.php#L258-L268
discophp/framework
core/classes/Paginate.class.php
Paginate.getNextUrls
public function getNextUrls($max = null){ if($max){ $max = $this->currentPage + $max; } else { $max = $this->totalPages; }//el return $this->getRangeUrls($this->currentPage + 1,$max); }
php
public function getNextUrls($max = null){ if($max){ $max = $this->currentPage + $max; } else { $max = $this->totalPages; }//el return $this->getRangeUrls($this->currentPage + 1,$max); }
[ "public", "function", "getNextUrls", "(", "$", "max", "=", "null", ")", "{", "if", "(", "$", "max", ")", "{", "$", "max", "=", "$", "this", "->", "currentPage", "+", "$", "max", ";", "}", "else", "{", "$", "max", "=", "$", "this", "->", "totalPages", ";", "}", "//el", "return", "$", "this", "->", "getRangeUrls", "(", "$", "this", "->", "currentPage", "+", "1", ",", "$", "max", ")", ";", "}" ]
Get paginated urls that come after the current page. @param null|int $max The max number of links to generate. @return string[]
[ "Get", "paginated", "urls", "that", "come", "after", "the", "current", "page", "." ]
train
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Paginate.class.php#L280-L290
discophp/framework
core/classes/Paginate.class.php
Paginate.getRangeUrls
public function getRangeUrls($start,$end){ $urls = Array(); if($end > $this->totalPages){ $end = $this->totalPages; }//if if($start < 1){ $start = 1; }//if for($i = $start; $i <= $end; $i++){ $urls[] = $this->getPageUrl($i); }//for return $urls; }
php
public function getRangeUrls($start,$end){ $urls = Array(); if($end > $this->totalPages){ $end = $this->totalPages; }//if if($start < 1){ $start = 1; }//if for($i = $start; $i <= $end; $i++){ $urls[] = $this->getPageUrl($i); }//for return $urls; }
[ "public", "function", "getRangeUrls", "(", "$", "start", ",", "$", "end", ")", "{", "$", "urls", "=", "Array", "(", ")", ";", "if", "(", "$", "end", ">", "$", "this", "->", "totalPages", ")", "{", "$", "end", "=", "$", "this", "->", "totalPages", ";", "}", "//if", "if", "(", "$", "start", "<", "1", ")", "{", "$", "start", "=", "1", ";", "}", "//if", "for", "(", "$", "i", "=", "$", "start", ";", "$", "i", "<=", "$", "end", ";", "$", "i", "++", ")", "{", "$", "urls", "[", "]", "=", "$", "this", "->", "getPageUrl", "(", "$", "i", ")", ";", "}", "//for", "return", "$", "urls", ";", "}" ]
Return the urls for the pages between `$start` and `$end`. @param int $start The page to start from. @param int $end The page to end on. @return string[]
[ "Return", "the", "urls", "for", "the", "pages", "between", "$start", "and", "$end", "." ]
train
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Paginate.class.php#L317-L335
discophp/framework
core/classes/Paginate.class.php
Paginate.getEasyMarkup
public function getEasyMarkup(){ $markup = ''; if($this->prevUrl){ $markup .= "<li class='pagination-previous' title='View previous page'><a href='{$this->prevUrl}'>prev</a></li>"; }//if $pages = $this->getPrevUrls(5); foreach($pages as $i => $page){ $markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>"; }//foreach if($this->totalPages){ $markup .= "<li class='current' title='Your viewing page {$this->currentPage} of {$this->totalPages}'><a>{$this->currentPage}</a></li>"; }//if $pages = $this->getNextUrls(5); foreach($pages as $i => $page){ $markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>"; }//foreach if($this->nextUrl){ $markup .= "<li class='pagination-next' title='View next page'><a href='{$this->nextUrl}'>next</a></li>"; }//if return "<ul class='pagination'>{$markup}</ul>"; }
php
public function getEasyMarkup(){ $markup = ''; if($this->prevUrl){ $markup .= "<li class='pagination-previous' title='View previous page'><a href='{$this->prevUrl}'>prev</a></li>"; }//if $pages = $this->getPrevUrls(5); foreach($pages as $i => $page){ $markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>"; }//foreach if($this->totalPages){ $markup .= "<li class='current' title='Your viewing page {$this->currentPage} of {$this->totalPages}'><a>{$this->currentPage}</a></li>"; }//if $pages = $this->getNextUrls(5); foreach($pages as $i => $page){ $markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>"; }//foreach if($this->nextUrl){ $markup .= "<li class='pagination-next' title='View next page'><a href='{$this->nextUrl}'>next</a></li>"; }//if return "<ul class='pagination'>{$markup}</ul>"; }
[ "public", "function", "getEasyMarkup", "(", ")", "{", "$", "markup", "=", "''", ";", "if", "(", "$", "this", "->", "prevUrl", ")", "{", "$", "markup", ".=", "\"<li class='pagination-previous' title='View previous page'><a href='{$this->prevUrl}'>prev</a></li>\"", ";", "}", "//if", "$", "pages", "=", "$", "this", "->", "getPrevUrls", "(", "5", ")", ";", "foreach", "(", "$", "pages", "as", "$", "i", "=>", "$", "page", ")", "{", "$", "markup", ".=", "\"<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>\"", ";", "}", "//foreach", "if", "(", "$", "this", "->", "totalPages", ")", "{", "$", "markup", ".=", "\"<li class='current' title='Your viewing page {$this->currentPage} of {$this->totalPages}'><a>{$this->currentPage}</a></li>\"", ";", "}", "//if", "$", "pages", "=", "$", "this", "->", "getNextUrls", "(", "5", ")", ";", "foreach", "(", "$", "pages", "as", "$", "i", "=>", "$", "page", ")", "{", "$", "markup", ".=", "\"<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>\"", ";", "}", "//foreach", "if", "(", "$", "this", "->", "nextUrl", ")", "{", "$", "markup", ".=", "\"<li class='pagination-next' title='View next page'><a href='{$this->nextUrl}'>next</a></li>\"", ";", "}", "//if", "return", "\"<ul class='pagination'>{$markup}</ul>\"", ";", "}" ]
Get a simple markup for a pagination feed. @return string The pagination markup.
[ "Get", "a", "simple", "markup", "for", "a", "pagination", "feed", "." ]
train
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Paginate.class.php#L344-L374
heyday/heystack
src/Output/Handler.php
Handler.process
public function process($identifier, \Controller $controller, $result = null) { if ($this->hasProcessor($identifier)) { return $this->processors[$identifier]->process($controller, $result); } else { return false; } }
php
public function process($identifier, \Controller $controller, $result = null) { if ($this->hasProcessor($identifier)) { return $this->processors[$identifier]->process($controller, $result); } else { return false; } }
[ "public", "function", "process", "(", "$", "identifier", ",", "\\", "Controller", "$", "controller", ",", "$", "result", "=", "null", ")", "{", "if", "(", "$", "this", "->", "hasProcessor", "(", "$", "identifier", ")", ")", "{", "return", "$", "this", "->", "processors", "[", "$", "identifier", "]", "->", "process", "(", "$", "controller", ",", "$", "result", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Process an output processor by identifier if it exists @param string $identifier The identifier of the processor to run @param \Controller $controller The controller that handled the request @param mixed $result The result from the run input processor @return mixed|null
[ "Process", "an", "output", "processor", "by", "identifier", "if", "it", "exists" ]
train
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/Output/Handler.php#L42-L49
vespolina/VespolinaCommerceBundle
Resolver/AbstractFulfillmentMethodResolver.php
AbstractFulfillmentMethodResolver.getFulfillmentMethodsByType
protected function getFulfillmentMethodsByType($type) { if (!$this->fulfillmentMethodsByType) { $this->loadFulfillmentMethods(); } return $this->fulfillmentMethodsByType->get($type); }
php
protected function getFulfillmentMethodsByType($type) { if (!$this->fulfillmentMethodsByType) { $this->loadFulfillmentMethods(); } return $this->fulfillmentMethodsByType->get($type); }
[ "protected", "function", "getFulfillmentMethodsByType", "(", "$", "type", ")", "{", "if", "(", "!", "$", "this", "->", "fulfillmentMethodsByType", ")", "{", "$", "this", "->", "loadFulfillmentMethods", "(", ")", ";", "}", "return", "$", "this", "->", "fulfillmentMethodsByType", "->", "get", "(", "$", "type", ")", ";", "}" ]
Retrieve a collection of fulfillment methods by type eg. give back all fulfillment methods for type 'shipment' @param $type @return ArrayCollection
[ "Retrieve", "a", "collection", "of", "fulfillment", "methods", "by", "type", "eg", ".", "give", "back", "all", "fulfillment", "methods", "for", "type", "shipment" ]
train
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Resolver/AbstractFulfillmentMethodResolver.php#L37-L44
vespolina/VespolinaCommerceBundle
Resolver/AbstractFulfillmentMethodResolver.php
AbstractFulfillmentMethodResolver.loadFulfillmentMethods
protected function loadFulfillmentMethods() { $this->fulfillmentMethodsByType = new ArrayCollection(); foreach ($this->configuration as $type => $configurationFulfillmentMethods) { foreach ($configurationFulfillmentMethods as $configurationFulfillmentMethod) { if (array_key_exists('class', $configurationFulfillmentMethod)) { $class = $configurationFulfillmentMethod['class']; $fulfillmentMethod = new $class(); $fulfillmentMethodsInType = $this->fulfillmentMethodsByType->get($type); if (!$fulfillmentMethodsInType) { $fulfillmentMethodsInType = new ArrayCollection(); $this->fulfillmentMethodsByType->set($type, $fulfillmentMethodsInType); } $fulfillmentMethodsInType->add($fulfillmentMethod); } } } }
php
protected function loadFulfillmentMethods() { $this->fulfillmentMethodsByType = new ArrayCollection(); foreach ($this->configuration as $type => $configurationFulfillmentMethods) { foreach ($configurationFulfillmentMethods as $configurationFulfillmentMethod) { if (array_key_exists('class', $configurationFulfillmentMethod)) { $class = $configurationFulfillmentMethod['class']; $fulfillmentMethod = new $class(); $fulfillmentMethodsInType = $this->fulfillmentMethodsByType->get($type); if (!$fulfillmentMethodsInType) { $fulfillmentMethodsInType = new ArrayCollection(); $this->fulfillmentMethodsByType->set($type, $fulfillmentMethodsInType); } $fulfillmentMethodsInType->add($fulfillmentMethod); } } } }
[ "protected", "function", "loadFulfillmentMethods", "(", ")", "{", "$", "this", "->", "fulfillmentMethodsByType", "=", "new", "ArrayCollection", "(", ")", ";", "foreach", "(", "$", "this", "->", "configuration", "as", "$", "type", "=>", "$", "configurationFulfillmentMethods", ")", "{", "foreach", "(", "$", "configurationFulfillmentMethods", "as", "$", "configurationFulfillmentMethod", ")", "{", "if", "(", "array_key_exists", "(", "'class'", ",", "$", "configurationFulfillmentMethod", ")", ")", "{", "$", "class", "=", "$", "configurationFulfillmentMethod", "[", "'class'", "]", ";", "$", "fulfillmentMethod", "=", "new", "$", "class", "(", ")", ";", "$", "fulfillmentMethodsInType", "=", "$", "this", "->", "fulfillmentMethodsByType", "->", "get", "(", "$", "type", ")", ";", "if", "(", "!", "$", "fulfillmentMethodsInType", ")", "{", "$", "fulfillmentMethodsInType", "=", "new", "ArrayCollection", "(", ")", ";", "$", "this", "->", "fulfillmentMethodsByType", "->", "set", "(", "$", "type", ",", "$", "fulfillmentMethodsInType", ")", ";", "}", "$", "fulfillmentMethodsInType", "->", "add", "(", "$", "fulfillmentMethod", ")", ";", "}", "}", "}", "}" ]
Load fulfillment methods from the configuration
[ "Load", "fulfillment", "methods", "from", "the", "configuration" ]
train
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Resolver/AbstractFulfillmentMethodResolver.php#L49-L70
activecollab/databasestructure
src/Field/Composite/ActionByField.php
ActionByField.getFields
public function getFields() { $id_field = (new IntegerField($this->getName(), 0))->unsigned(); if ($this->isRequired()) { $id_field->required(); } return [ $id_field, new ScalarStringField($this->getActionName() . '_by_name'), new EmailField($this->getActionName() . '_by_email'), ]; }
php
public function getFields() { $id_field = (new IntegerField($this->getName(), 0))->unsigned(); if ($this->isRequired()) { $id_field->required(); } return [ $id_field, new ScalarStringField($this->getActionName() . '_by_name'), new EmailField($this->getActionName() . '_by_email'), ]; }
[ "public", "function", "getFields", "(", ")", "{", "$", "id_field", "=", "(", "new", "IntegerField", "(", "$", "this", "->", "getName", "(", ")", ",", "0", ")", ")", "->", "unsigned", "(", ")", ";", "if", "(", "$", "this", "->", "isRequired", "(", ")", ")", "{", "$", "id_field", "->", "required", "(", ")", ";", "}", "return", "[", "$", "id_field", ",", "new", "ScalarStringField", "(", "$", "this", "->", "getActionName", "(", ")", ".", "'_by_name'", ")", ",", "new", "EmailField", "(", "$", "this", "->", "getActionName", "(", ")", ".", "'_by_email'", ")", ",", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Composite/ActionByField.php#L105-L118
activecollab/databasestructure
src/Field/Composite/ActionByField.php
ActionByField.getBaseClassMethods
public function getBaseClassMethods($indent, array &$result) { $id_getter_name = 'get' . Inflector::classify($this->name); $id_setter_name = 'set' . Inflector::classify($this->name); $email_getter_name = 'get' . Inflector::classify($this->getActionName() . '_by_email'); $email_setter_name = 'set' . Inflector::classify($this->getActionName() . '_by_email'); $name_getter_name = 'get' . Inflector::classify($this->getActionName() . '_by_name'); $name_setter_name = 'set' . Inflector::classify($this->getActionName() . '_by_name'); $instance_getter_name = 'get' . Inflector::classify(substr($this->name, 0, strlen($this->name) - 3)); $instance_setter_name = 'set' . Inflector::classify(substr($this->name, 0, strlen($this->name) - 3)); $type_hint = '\\' . UserInterface::class . '|' . $this->identified_visitor_class_name . '|' . $this->user_class_name . '|null'; $methods = []; $methods[] = '/**'; $methods[] = ' * @param bool' . str_pad('$use_cache', strlen($type_hint) + 7, ' ', STR_PAD_LEFT); $methods[] = ' * @return ' . $type_hint; $methods[] = ' */'; $methods[] = 'public function ' . $instance_getter_name . '($use_cache = true)'; $methods[] = '{'; $methods[] = ' if ($id = $this->' . $id_getter_name . '()) {'; $methods[] = ' return $this->pool->getById(' . var_export($this->user_class_name, true). ', $id, $use_cache);'; $methods[] = ' } elseif ($email = $this->' . $email_getter_name . '()) {'; $methods[] = ' return new ' . $this->identified_visitor_class_name . '($this->' . $name_getter_name . '(), $email);'; $methods[] = ' } else {'; $methods[] = ' return null;'; $methods[] = ' }'; $methods[] = '}'; $methods[] = ''; if ($this->isRequired()) { $methods[] = '/**'; $methods[] = ' * Set ' . $this->action_name . '.'; $methods[] = ' *'; $methods[] = ' * @param \\' . UserInterface::class . '|' . $this->user_class_name .' $value'; $methods[] = ' * @return $this'; $methods[] = ' */'; $methods[] = 'public function &' . $instance_setter_name . '(\\' . UserInterface::class . ' $value)'; $methods[] = '{'; $methods[] = ' if ($value instanceof ' . $this->user_class_name . ' && $value->isLoaded()) {'; $methods[] = ' $this->' . $id_setter_name . '($value->getId());'; $methods[] = ' $this->' . $name_setter_name . '($value->getFullName());'; $methods[] = ' $this->' . $email_setter_name . '($value->getEmail());'; $methods[] = ' } else {'; $methods[] = ' throw new \InvalidArgumentException(' . var_export("Instance of '$this->user_class_name' expected", true) . ');'; $methods[] = ' }'; $methods[] = ''; $methods[] = ' return $this;'; $methods[] = '}'; } else { $methods[] = '/**'; $methods[] = ' * Set ' . $this->action_name . '.'; $methods[] = ' *'; $methods[] = ' * @param ' . $type_hint . ' $value'; $methods[] = ' * @return $this'; $methods[] = ' */'; $methods[] = 'public function &' . $instance_setter_name . '(\\' . UserInterface::class . ' $value = null)'; $methods[] = '{'; $methods[] = ' if ($value instanceof ' . $this->user_class_name . ') {'; $methods[] = ' if ($value->isLoaded()) {'; $methods[] = ' $this->' . $id_setter_name . '($value->getId());'; $methods[] = ' $this->' . $name_setter_name . '($value->getFullName());'; $methods[] = ' $this->' . $email_setter_name . '($value->getEmail());'; $methods[] = ' } else {'; $methods[] = ' throw new \InvalidArgumentException(' . var_export("Instance of '$this->user_class_name' expected") . ');'; $methods[] = ' }'; $methods[] = ' } elseif ($value instanceof ' . $this->identified_visitor_class_name . ') {'; $methods[] = ' $this->' . $id_setter_name . '(0);'; $methods[] = ' $this->' . $name_setter_name . '($value->getFullName());'; $methods[] = ' $this->' . $email_setter_name . '($value->getEmail());'; $methods[] = ' } else {'; $methods[] = ' $this->' . $id_setter_name . '(0);'; $methods[] = ' $this->' . $name_setter_name . '(null);'; $methods[] = ' $this->' . $email_setter_name . '(null);'; $methods[] = ' }'; $methods[] = ''; $methods[] = ' return $this;'; $methods[] = '}'; } foreach ($methods as $line) { if ($line) { $result[] = "$indent$line"; } else { $result[] = ''; } } }
php
public function getBaseClassMethods($indent, array &$result) { $id_getter_name = 'get' . Inflector::classify($this->name); $id_setter_name = 'set' . Inflector::classify($this->name); $email_getter_name = 'get' . Inflector::classify($this->getActionName() . '_by_email'); $email_setter_name = 'set' . Inflector::classify($this->getActionName() . '_by_email'); $name_getter_name = 'get' . Inflector::classify($this->getActionName() . '_by_name'); $name_setter_name = 'set' . Inflector::classify($this->getActionName() . '_by_name'); $instance_getter_name = 'get' . Inflector::classify(substr($this->name, 0, strlen($this->name) - 3)); $instance_setter_name = 'set' . Inflector::classify(substr($this->name, 0, strlen($this->name) - 3)); $type_hint = '\\' . UserInterface::class . '|' . $this->identified_visitor_class_name . '|' . $this->user_class_name . '|null'; $methods = []; $methods[] = '/**'; $methods[] = ' * @param bool' . str_pad('$use_cache', strlen($type_hint) + 7, ' ', STR_PAD_LEFT); $methods[] = ' * @return ' . $type_hint; $methods[] = ' */'; $methods[] = 'public function ' . $instance_getter_name . '($use_cache = true)'; $methods[] = '{'; $methods[] = ' if ($id = $this->' . $id_getter_name . '()) {'; $methods[] = ' return $this->pool->getById(' . var_export($this->user_class_name, true). ', $id, $use_cache);'; $methods[] = ' } elseif ($email = $this->' . $email_getter_name . '()) {'; $methods[] = ' return new ' . $this->identified_visitor_class_name . '($this->' . $name_getter_name . '(), $email);'; $methods[] = ' } else {'; $methods[] = ' return null;'; $methods[] = ' }'; $methods[] = '}'; $methods[] = ''; if ($this->isRequired()) { $methods[] = '/**'; $methods[] = ' * Set ' . $this->action_name . '.'; $methods[] = ' *'; $methods[] = ' * @param \\' . UserInterface::class . '|' . $this->user_class_name .' $value'; $methods[] = ' * @return $this'; $methods[] = ' */'; $methods[] = 'public function &' . $instance_setter_name . '(\\' . UserInterface::class . ' $value)'; $methods[] = '{'; $methods[] = ' if ($value instanceof ' . $this->user_class_name . ' && $value->isLoaded()) {'; $methods[] = ' $this->' . $id_setter_name . '($value->getId());'; $methods[] = ' $this->' . $name_setter_name . '($value->getFullName());'; $methods[] = ' $this->' . $email_setter_name . '($value->getEmail());'; $methods[] = ' } else {'; $methods[] = ' throw new \InvalidArgumentException(' . var_export("Instance of '$this->user_class_name' expected", true) . ');'; $methods[] = ' }'; $methods[] = ''; $methods[] = ' return $this;'; $methods[] = '}'; } else { $methods[] = '/**'; $methods[] = ' * Set ' . $this->action_name . '.'; $methods[] = ' *'; $methods[] = ' * @param ' . $type_hint . ' $value'; $methods[] = ' * @return $this'; $methods[] = ' */'; $methods[] = 'public function &' . $instance_setter_name . '(\\' . UserInterface::class . ' $value = null)'; $methods[] = '{'; $methods[] = ' if ($value instanceof ' . $this->user_class_name . ') {'; $methods[] = ' if ($value->isLoaded()) {'; $methods[] = ' $this->' . $id_setter_name . '($value->getId());'; $methods[] = ' $this->' . $name_setter_name . '($value->getFullName());'; $methods[] = ' $this->' . $email_setter_name . '($value->getEmail());'; $methods[] = ' } else {'; $methods[] = ' throw new \InvalidArgumentException(' . var_export("Instance of '$this->user_class_name' expected") . ');'; $methods[] = ' }'; $methods[] = ' } elseif ($value instanceof ' . $this->identified_visitor_class_name . ') {'; $methods[] = ' $this->' . $id_setter_name . '(0);'; $methods[] = ' $this->' . $name_setter_name . '($value->getFullName());'; $methods[] = ' $this->' . $email_setter_name . '($value->getEmail());'; $methods[] = ' } else {'; $methods[] = ' $this->' . $id_setter_name . '(0);'; $methods[] = ' $this->' . $name_setter_name . '(null);'; $methods[] = ' $this->' . $email_setter_name . '(null);'; $methods[] = ' }'; $methods[] = ''; $methods[] = ' return $this;'; $methods[] = '}'; } foreach ($methods as $line) { if ($line) { $result[] = "$indent$line"; } else { $result[] = ''; } } }
[ "public", "function", "getBaseClassMethods", "(", "$", "indent", ",", "array", "&", "$", "result", ")", "{", "$", "id_getter_name", "=", "'get'", ".", "Inflector", "::", "classify", "(", "$", "this", "->", "name", ")", ";", "$", "id_setter_name", "=", "'set'", ".", "Inflector", "::", "classify", "(", "$", "this", "->", "name", ")", ";", "$", "email_getter_name", "=", "'get'", ".", "Inflector", "::", "classify", "(", "$", "this", "->", "getActionName", "(", ")", ".", "'_by_email'", ")", ";", "$", "email_setter_name", "=", "'set'", ".", "Inflector", "::", "classify", "(", "$", "this", "->", "getActionName", "(", ")", ".", "'_by_email'", ")", ";", "$", "name_getter_name", "=", "'get'", ".", "Inflector", "::", "classify", "(", "$", "this", "->", "getActionName", "(", ")", ".", "'_by_name'", ")", ";", "$", "name_setter_name", "=", "'set'", ".", "Inflector", "::", "classify", "(", "$", "this", "->", "getActionName", "(", ")", ".", "'_by_name'", ")", ";", "$", "instance_getter_name", "=", "'get'", ".", "Inflector", "::", "classify", "(", "substr", "(", "$", "this", "->", "name", ",", "0", ",", "strlen", "(", "$", "this", "->", "name", ")", "-", "3", ")", ")", ";", "$", "instance_setter_name", "=", "'set'", ".", "Inflector", "::", "classify", "(", "substr", "(", "$", "this", "->", "name", ",", "0", ",", "strlen", "(", "$", "this", "->", "name", ")", "-", "3", ")", ")", ";", "$", "type_hint", "=", "'\\\\'", ".", "UserInterface", "::", "class", ".", "'|'", ".", "$", "this", "->", "identified_visitor_class_name", ".", "'|'", ".", "$", "this", "->", "user_class_name", ".", "'|null'", ";", "$", "methods", "=", "[", "]", ";", "$", "methods", "[", "]", "=", "'/**'", ";", "$", "methods", "[", "]", "=", "' * @param bool'", ".", "str_pad", "(", "'$use_cache'", ",", "strlen", "(", "$", "type_hint", ")", "+", "7", ",", "' '", ",", "STR_PAD_LEFT", ")", ";", "$", "methods", "[", "]", "=", "' * @return '", ".", "$", "type_hint", ";", "$", "methods", "[", "]", "=", "' */'", ";", "$", "methods", "[", "]", "=", "'public function '", ".", "$", "instance_getter_name", ".", "'($use_cache = true)'", ";", "$", "methods", "[", "]", "=", "'{'", ";", "$", "methods", "[", "]", "=", "' if ($id = $this->'", ".", "$", "id_getter_name", ".", "'()) {'", ";", "$", "methods", "[", "]", "=", "' return $this->pool->getById('", ".", "var_export", "(", "$", "this", "->", "user_class_name", ",", "true", ")", ".", "', $id, $use_cache);'", ";", "$", "methods", "[", "]", "=", "' } elseif ($email = $this->'", ".", "$", "email_getter_name", ".", "'()) {'", ";", "$", "methods", "[", "]", "=", "' return new '", ".", "$", "this", "->", "identified_visitor_class_name", ".", "'($this->'", ".", "$", "name_getter_name", ".", "'(), $email);'", ";", "$", "methods", "[", "]", "=", "' } else {'", ";", "$", "methods", "[", "]", "=", "' return null;'", ";", "$", "methods", "[", "]", "=", "' }'", ";", "$", "methods", "[", "]", "=", "'}'", ";", "$", "methods", "[", "]", "=", "''", ";", "if", "(", "$", "this", "->", "isRequired", "(", ")", ")", "{", "$", "methods", "[", "]", "=", "'/**'", ";", "$", "methods", "[", "]", "=", "' * Set '", ".", "$", "this", "->", "action_name", ".", "'.'", ";", "$", "methods", "[", "]", "=", "' *'", ";", "$", "methods", "[", "]", "=", "' * @param \\\\'", ".", "UserInterface", "::", "class", ".", "'|'", ".", "$", "this", "->", "user_class_name", ".", "' $value'", ";", "$", "methods", "[", "]", "=", "' * @return $this'", ";", "$", "methods", "[", "]", "=", "' */'", ";", "$", "methods", "[", "]", "=", "'public function &'", ".", "$", "instance_setter_name", ".", "'(\\\\'", ".", "UserInterface", "::", "class", ".", "' $value)'", ";", "$", "methods", "[", "]", "=", "'{'", ";", "$", "methods", "[", "]", "=", "' if ($value instanceof '", ".", "$", "this", "->", "user_class_name", ".", "' && $value->isLoaded()) {'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "id_setter_name", ".", "'($value->getId());'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "name_setter_name", ".", "'($value->getFullName());'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "email_setter_name", ".", "'($value->getEmail());'", ";", "$", "methods", "[", "]", "=", "' } else {'", ";", "$", "methods", "[", "]", "=", "' throw new \\InvalidArgumentException('", ".", "var_export", "(", "\"Instance of '$this->user_class_name' expected\"", ",", "true", ")", ".", "');'", ";", "$", "methods", "[", "]", "=", "' }'", ";", "$", "methods", "[", "]", "=", "''", ";", "$", "methods", "[", "]", "=", "' return $this;'", ";", "$", "methods", "[", "]", "=", "'}'", ";", "}", "else", "{", "$", "methods", "[", "]", "=", "'/**'", ";", "$", "methods", "[", "]", "=", "' * Set '", ".", "$", "this", "->", "action_name", ".", "'.'", ";", "$", "methods", "[", "]", "=", "' *'", ";", "$", "methods", "[", "]", "=", "' * @param '", ".", "$", "type_hint", ".", "' $value'", ";", "$", "methods", "[", "]", "=", "' * @return $this'", ";", "$", "methods", "[", "]", "=", "' */'", ";", "$", "methods", "[", "]", "=", "'public function &'", ".", "$", "instance_setter_name", ".", "'(\\\\'", ".", "UserInterface", "::", "class", ".", "' $value = null)'", ";", "$", "methods", "[", "]", "=", "'{'", ";", "$", "methods", "[", "]", "=", "' if ($value instanceof '", ".", "$", "this", "->", "user_class_name", ".", "') {'", ";", "$", "methods", "[", "]", "=", "' if ($value->isLoaded()) {'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "id_setter_name", ".", "'($value->getId());'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "name_setter_name", ".", "'($value->getFullName());'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "email_setter_name", ".", "'($value->getEmail());'", ";", "$", "methods", "[", "]", "=", "' } else {'", ";", "$", "methods", "[", "]", "=", "' throw new \\InvalidArgumentException('", ".", "var_export", "(", "\"Instance of '$this->user_class_name' expected\"", ")", ".", "');'", ";", "$", "methods", "[", "]", "=", "' }'", ";", "$", "methods", "[", "]", "=", "' } elseif ($value instanceof '", ".", "$", "this", "->", "identified_visitor_class_name", ".", "') {'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "id_setter_name", ".", "'(0);'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "name_setter_name", ".", "'($value->getFullName());'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "email_setter_name", ".", "'($value->getEmail());'", ";", "$", "methods", "[", "]", "=", "' } else {'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "id_setter_name", ".", "'(0);'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "name_setter_name", ".", "'(null);'", ";", "$", "methods", "[", "]", "=", "' $this->'", ".", "$", "email_setter_name", ".", "'(null);'", ";", "$", "methods", "[", "]", "=", "' }'", ";", "$", "methods", "[", "]", "=", "''", ";", "$", "methods", "[", "]", "=", "' return $this;'", ";", "$", "methods", "[", "]", "=", "'}'", ";", "}", "foreach", "(", "$", "methods", "as", "$", "line", ")", "{", "if", "(", "$", "line", ")", "{", "$", "result", "[", "]", "=", "\"$indent$line\"", ";", "}", "else", "{", "$", "result", "[", "]", "=", "''", ";", "}", "}", "}" ]
Return methods that this field needs to inject in base class. @param string $indent @param array $result
[ "Return", "methods", "that", "this", "field", "needs", "to", "inject", "in", "base", "class", "." ]
train
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Composite/ActionByField.php#L126-L217
activecollab/databasestructure
src/Field/Composite/ActionByField.php
ActionByField.getActionName
private function getActionName() { if (empty($this->action_name)) { $this->action_name = substr($this->name, 0, strlen($this->name) - 6); } return $this->action_name; }
php
private function getActionName() { if (empty($this->action_name)) { $this->action_name = substr($this->name, 0, strlen($this->name) - 6); } return $this->action_name; }
[ "private", "function", "getActionName", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "action_name", ")", ")", "{", "$", "this", "->", "action_name", "=", "substr", "(", "$", "this", "->", "name", ",", "0", ",", "strlen", "(", "$", "this", "->", "name", ")", "-", "6", ")", ";", "}", "return", "$", "this", "->", "action_name", ";", "}" ]
Return action name (name without _by_id). @return string
[ "Return", "action", "name", "(", "name", "without", "_by_id", ")", "." ]
train
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Composite/ActionByField.php#L229-L236
activecollab/databasestructure
src/Field/Composite/ActionByField.php
ActionByField.onAddedToType
public function onAddedToType(TypeInterface &$type) { parent::onAddedToType($type); if ($this->getAddIndex()) { $type->addIndex(new Index($this->name)); } $type->serialize($this->name); }
php
public function onAddedToType(TypeInterface &$type) { parent::onAddedToType($type); if ($this->getAddIndex()) { $type->addIndex(new Index($this->name)); } $type->serialize($this->name); }
[ "public", "function", "onAddedToType", "(", "TypeInterface", "&", "$", "type", ")", "{", "parent", "::", "onAddedToType", "(", "$", "type", ")", ";", "if", "(", "$", "this", "->", "getAddIndex", "(", ")", ")", "{", "$", "type", "->", "addIndex", "(", "new", "Index", "(", "$", "this", "->", "name", ")", ")", ";", "}", "$", "type", "->", "serialize", "(", "$", "this", "->", "name", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Composite/ActionByField.php#L241-L250
heyday/heystack
src/Input/GroupedProcessor.php
GroupedProcessor.process
public function process(\SS_HTTPRequest $request) { $results = []; foreach ($this->processors as $identifier => $processor) { $results[$identifier] = $processor->process($request); } return $results; }
php
public function process(\SS_HTTPRequest $request) { $results = []; foreach ($this->processors as $identifier => $processor) { $results[$identifier] = $processor->process($request); } return $results; }
[ "public", "function", "process", "(", "\\", "SS_HTTPRequest", "$", "request", ")", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "processors", "as", "$", "identifier", "=>", "$", "processor", ")", "{", "$", "results", "[", "$", "identifier", "]", "=", "$", "processor", "->", "process", "(", "$", "request", ")", ";", "}", "return", "$", "results", ";", "}" ]
Runs over the list of processors running them all in turn @param \SS_HTTPRequest $request The request object to pass into processors @return array
[ "Runs", "over", "the", "list", "of", "processors", "running", "them", "all", "in", "turn" ]
train
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/Input/GroupedProcessor.php#L66-L77