repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
litert/annotation
lib/Extractor.php
Extractor.fromMethod
public static function fromMethod( string $method, string $class = null, bool $withParents = false ): array { if ($class) { try { $refMethod = new \ReflectionMethod($class, $method); } catch (\ReflectionException $e) { throw new Exception( "Method '{$class}::{$method}' not found.", Exception::METHOD_NOT_FOUND ); } } else { try { $refMethod = new \ReflectionMethod($method); } catch (\ReflectionException $e) { throw new Exception( "Method '{$method}' not found.", Exception::METHOD_NOT_FOUND ); } } $docComment = $refMethod->getDocComment(); if ($withParents) { $refClass = $refMethod->getDeclaringClass(); while (1) { if ($refClass = $refClass->getParentClass()) { try { $refMethod = $refClass->getMethod($method); } catch (\ReflectionException $e) { break; } if (!$refMethod) { continue; } if ($parentDoc = $refMethod->getDocComment()) { $docComment = $docComment === false ? $parentDoc : "{$parentDoc}{$docComment}"; } } else { break; } } } unset($refMethod, $refClass); if ($docComment === false) { return []; } return Parser::parseDocComment($docComment); }
php
public static function fromMethod( string $method, string $class = null, bool $withParents = false ): array { if ($class) { try { $refMethod = new \ReflectionMethod($class, $method); } catch (\ReflectionException $e) { throw new Exception( "Method '{$class}::{$method}' not found.", Exception::METHOD_NOT_FOUND ); } } else { try { $refMethod = new \ReflectionMethod($method); } catch (\ReflectionException $e) { throw new Exception( "Method '{$method}' not found.", Exception::METHOD_NOT_FOUND ); } } $docComment = $refMethod->getDocComment(); if ($withParents) { $refClass = $refMethod->getDeclaringClass(); while (1) { if ($refClass = $refClass->getParentClass()) { try { $refMethod = $refClass->getMethod($method); } catch (\ReflectionException $e) { break; } if (!$refMethod) { continue; } if ($parentDoc = $refMethod->getDocComment()) { $docComment = $docComment === false ? $parentDoc : "{$parentDoc}{$docComment}"; } } else { break; } } } unset($refMethod, $refClass); if ($docComment === false) { return []; } return Parser::parseDocComment($docComment); }
[ "public", "static", "function", "fromMethod", "(", "string", "$", "method", ",", "string", "$", "class", "=", "null", ",", "bool", "$", "withParents", "=", "false", ")", ":", "array", "{", "if", "(", "$", "class", ")", "{", "try", "{", "$", "refMetho...
Extract the annotations from a method. @param string $method @param string|null $class @param bool $withParents @throws \L\Annotation\Exception @return array
[ "Extract", "the", "annotations", "from", "a", "method", "." ]
0a0fd01ad88eac887cb2cde2dc89017632b8d47e
https://github.com/litert/annotation/blob/0a0fd01ad88eac887cb2cde2dc89017632b8d47e/lib/Extractor.php#L40-L121
train
litert/annotation
lib/Extractor.php
Extractor.fromProperty
public static function fromProperty( string $class, string $property ): array { try { $property = new \ReflectionProperty($class, $property); } catch (\ReflectionException $e) { throw new Exception( "Property '{$class}::{$property}' not found.", Exception::PROPERTY_NOT_FOUND ); } $docComment = $property->getDocComment(); unset($property); if ($docComment === false) { return []; } return Parser::parseDocComment($docComment); }
php
public static function fromProperty( string $class, string $property ): array { try { $property = new \ReflectionProperty($class, $property); } catch (\ReflectionException $e) { throw new Exception( "Property '{$class}::{$property}' not found.", Exception::PROPERTY_NOT_FOUND ); } $docComment = $property->getDocComment(); unset($property); if ($docComment === false) { return []; } return Parser::parseDocComment($docComment); }
[ "public", "static", "function", "fromProperty", "(", "string", "$", "class", ",", "string", "$", "property", ")", ":", "array", "{", "try", "{", "$", "property", "=", "new", "\\", "ReflectionProperty", "(", "$", "class", ",", "$", "property", ")", ";", ...
Extract the annotations from a property. @param string $class @param string $property @throws \L\Annotation\Exception @return array
[ "Extract", "the", "annotations", "from", "a", "property", "." ]
0a0fd01ad88eac887cb2cde2dc89017632b8d47e
https://github.com/litert/annotation/blob/0a0fd01ad88eac887cb2cde2dc89017632b8d47e/lib/Extractor.php#L133-L160
train
litert/annotation
lib/Extractor.php
Extractor.fromClass
public static function fromClass( string $class, bool $withParents = false ): array { try { $class = new \ReflectionClass($class); } catch (\ReflectionException $e) { throw new Exception( "Class '{$class}' not found.", Exception::CLASS_NOT_FOUND ); } $docComment = $class->getDocComment(); if ($withParents) { while (1) { if ($class = $class->getParentClass()) { if ($parentDoc = $class->getDocComment()) { $docComment = $docComment === false ? $parentDoc : "{$parentDoc}{$docComment}"; } } else { break; } } } unset($class); if ($docComment === false) { return []; } return Parser::parseDocComment($docComment); }
php
public static function fromClass( string $class, bool $withParents = false ): array { try { $class = new \ReflectionClass($class); } catch (\ReflectionException $e) { throw new Exception( "Class '{$class}' not found.", Exception::CLASS_NOT_FOUND ); } $docComment = $class->getDocComment(); if ($withParents) { while (1) { if ($class = $class->getParentClass()) { if ($parentDoc = $class->getDocComment()) { $docComment = $docComment === false ? $parentDoc : "{$parentDoc}{$docComment}"; } } else { break; } } } unset($class); if ($docComment === false) { return []; } return Parser::parseDocComment($docComment); }
[ "public", "static", "function", "fromClass", "(", "string", "$", "class", ",", "bool", "$", "withParents", "=", "false", ")", ":", "array", "{", "try", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "}", "catch", ...
Extract the annotations from a class. @param string $class @param bool $withParents @throws \L\Annotation\Exception @return array
[ "Extract", "the", "annotations", "from", "a", "class", "." ]
0a0fd01ad88eac887cb2cde2dc89017632b8d47e
https://github.com/litert/annotation/blob/0a0fd01ad88eac887cb2cde2dc89017632b8d47e/lib/Extractor.php#L172-L219
train
litert/annotation
lib/Extractor.php
Extractor.fromFunction
public static function fromFunction( string $fn ): array { try { $fn = new \ReflectionFunction($fn); } catch (\ReflectionException $e) { throw new Exception( "Function {$fn} not found.", Exception::FUNCTION_NOT_FOUND ); } $docComment = $fn->getDocComment(); unset($fn); if ($docComment === false) { return []; } return Parser::parseDocComment($docComment); }
php
public static function fromFunction( string $fn ): array { try { $fn = new \ReflectionFunction($fn); } catch (\ReflectionException $e) { throw new Exception( "Function {$fn} not found.", Exception::FUNCTION_NOT_FOUND ); } $docComment = $fn->getDocComment(); unset($fn); if ($docComment === false) { return []; } return Parser::parseDocComment($docComment); }
[ "public", "static", "function", "fromFunction", "(", "string", "$", "fn", ")", ":", "array", "{", "try", "{", "$", "fn", "=", "new", "\\", "ReflectionFunction", "(", "$", "fn", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", ...
Extract the annotations from a function. @param string $fn @throws \L\Annotation\Exception @return array
[ "Extract", "the", "annotations", "from", "a", "function", "." ]
0a0fd01ad88eac887cb2cde2dc89017632b8d47e
https://github.com/litert/annotation/blob/0a0fd01ad88eac887cb2cde2dc89017632b8d47e/lib/Extractor.php#L230-L256
train
tekkla/core-security
Core/Security/Group/Group.php
Group.getGroups
public function getGroups($byid = false, $skip_guest = false) { if ($byid) { $data = $this->byid; if ($skip_guest) { unset($data[- 1]); } } else { $data = $this->groups; if ($skip_guest) { unset($data['Core'][- 1]); } } return $data; }
php
public function getGroups($byid = false, $skip_guest = false) { if ($byid) { $data = $this->byid; if ($skip_guest) { unset($data[- 1]); } } else { $data = $this->groups; if ($skip_guest) { unset($data['Core'][- 1]); } } return $data; }
[ "public", "function", "getGroups", "(", "$", "byid", "=", "false", ",", "$", "skip_guest", "=", "false", ")", "{", "if", "(", "$", "byid", ")", "{", "$", "data", "=", "$", "this", "->", "byid", ";", "if", "(", "$", "skip_guest", ")", "{", "unset"...
Returns all groups @return array
[ "Returns", "all", "groups" ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Group/Group.php#L222-L241
train
tekkla/core-security
Core/Security/Group/Group.php
Group.getGroupById
public function getGroupById($id_group) { if (array_key_exists($id_group, $this->byid)) { return $this->byid[$id_group]; } return false; }
php
public function getGroupById($id_group) { if (array_key_exists($id_group, $this->byid)) { return $this->byid[$id_group]; } return false; }
[ "public", "function", "getGroupById", "(", "$", "id_group", ")", "{", "if", "(", "array_key_exists", "(", "$", "id_group", ",", "$", "this", "->", "byid", ")", ")", "{", "return", "$", "this", "->", "byid", "[", "$", "id_group", "]", ";", "}", "retur...
Returns a group by it's id @param int $id_group Internal id of group @return mixed|boolean
[ "Returns", "a", "group", "by", "it", "s", "id" ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Group/Group.php#L251-L258
train
tekkla/core-security
Core/Security/Group/Group.php
Group.getGroupByAppAndName
public function getGroupByAppAndName($app, $name) { if (array_key_exists($app, $this->groups) && array_key_exists($name, $this->groups[$app])) { return $this->groups[$app][$name]; } return false; }
php
public function getGroupByAppAndName($app, $name) { if (array_key_exists($app, $this->groups) && array_key_exists($name, $this->groups[$app])) { return $this->groups[$app][$name]; } return false; }
[ "public", "function", "getGroupByAppAndName", "(", "$", "app", ",", "$", "name", ")", "{", "if", "(", "array_key_exists", "(", "$", "app", ",", "$", "this", "->", "groups", ")", "&&", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "group...
Returns a group by app and name @param string $app Name of related app @param string $name Name of group @return mixed|boolean
[ "Returns", "a", "group", "by", "app", "and", "name" ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Group/Group.php#L270-L277
train
zepi/turbo-base
Zepi/Web/General/src/FilterHandler/VerifyEventName.php
VerifyEventName.execute
public function execute(Framework $framework, RequestAbstract $request, Response $response, $value = null) { if (!($request instanceof WebRequest)) { return $value; } $fullUrl = $request->getRequestedUrl(); $urlParts = parse_url($fullUrl); if ($urlParts == false) { return $value; } $urlParts = $this->verifyPath($urlParts); $completeUrl = $response->buildUrl($urlParts); if ($completeUrl !== $request->getRequestedUrl()) { $response->redirectTo($completeUrl); return null; } return $value; }
php
public function execute(Framework $framework, RequestAbstract $request, Response $response, $value = null) { if (!($request instanceof WebRequest)) { return $value; } $fullUrl = $request->getRequestedUrl(); $urlParts = parse_url($fullUrl); if ($urlParts == false) { return $value; } $urlParts = $this->verifyPath($urlParts); $completeUrl = $response->buildUrl($urlParts); if ($completeUrl !== $request->getRequestedUrl()) { $response->redirectTo($completeUrl); return null; } return $value; }
[ "public", "function", "execute", "(", "Framework", "$", "framework", ",", "RequestAbstract", "$", "request", ",", "Response", "$", "response", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "(", "$", "request", "instanceof", "WebRequest", ")", ...
Replaces the event name with a redirect event if the url hasn't a slash at the end of the url. @access public @param \Zepi\Turbo\Framework $framework @param \Zepi\Turbo\Request\RequestAbstract $request @param \Zepi\Turbo\Response\Response $response @param mixed $value @return mixed
[ "Replaces", "the", "event", "name", "with", "a", "redirect", "event", "if", "the", "url", "hasn", "t", "a", "slash", "at", "the", "end", "of", "the", "url", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/FilterHandler/VerifyEventName.php#L65-L88
train
zepi/turbo-base
Zepi/Web/General/src/FilterHandler/VerifyEventName.php
VerifyEventName.verifyPath
protected function verifyPath($urlParts) { if (isset($urlParts['path'])) { $path = $urlParts['path']; if (substr($path, -1) !== '/' && (strrpos($path, '.') === false || strrpos($path, '.') < strrpos($path, '/'))) { $path .= '/'; } $urlParts['path'] = $path; } return $urlParts; }
php
protected function verifyPath($urlParts) { if (isset($urlParts['path'])) { $path = $urlParts['path']; if (substr($path, -1) !== '/' && (strrpos($path, '.') === false || strrpos($path, '.') < strrpos($path, '/'))) { $path .= '/'; } $urlParts['path'] = $path; } return $urlParts; }
[ "protected", "function", "verifyPath", "(", "$", "urlParts", ")", "{", "if", "(", "isset", "(", "$", "urlParts", "[", "'path'", "]", ")", ")", "{", "$", "path", "=", "$", "urlParts", "[", "'path'", "]", ";", "if", "(", "substr", "(", "$", "path", ...
Verifies the path of the url and adds a slash at the end if there is no slash. @param array $urlParts @return string
[ "Verifies", "the", "path", "of", "the", "url", "and", "adds", "a", "slash", "at", "the", "end", "if", "there", "is", "no", "slash", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/FilterHandler/VerifyEventName.php#L97-L110
train
jarrettbarnett/RockPaperScissorsSpockLizard
src/Game.php
Game.generateMovesForBots
private function generateMovesForBots() { foreach ($this->getPlayers() as &$player) { $last_move = $player->getLastMoveIndex(); // generate move for bots if ($player->isBot() && empty($last_move)) { $move = $this->generateMove(); $player->move($move); } } return $this; }
php
private function generateMovesForBots() { foreach ($this->getPlayers() as &$player) { $last_move = $player->getLastMoveIndex(); // generate move for bots if ($player->isBot() && empty($last_move)) { $move = $this->generateMove(); $player->move($move); } } return $this; }
[ "private", "function", "generateMovesForBots", "(", ")", "{", "foreach", "(", "$", "this", "->", "getPlayers", "(", ")", "as", "&", "$", "player", ")", "{", "$", "last_move", "=", "$", "player", "->", "getLastMoveIndex", "(", ")", ";", "// generate move fo...
Generate Moves For Bots @return $this
[ "Generate", "Moves", "For", "Bots" ]
c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b
https://github.com/jarrettbarnett/RockPaperScissorsSpockLizard/blob/c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b/src/Game.php#L204-L218
train
jarrettbarnett/RockPaperScissorsSpockLizard
src/Game.php
Game.getWinners
public function getWinners() { $outcomes = $this->getOutcomes(); foreach ($outcomes as $outcome) { $winners[] = $outcome['winners']; } return $winners; }
php
public function getWinners() { $outcomes = $this->getOutcomes(); foreach ($outcomes as $outcome) { $winners[] = $outcome['winners']; } return $winners; }
[ "public", "function", "getWinners", "(", ")", "{", "$", "outcomes", "=", "$", "this", "->", "getOutcomes", "(", ")", ";", "foreach", "(", "$", "outcomes", "as", "$", "outcome", ")", "{", "$", "winners", "[", "]", "=", "$", "outcome", "[", "'winners'"...
Get Game Winners @return array
[ "Get", "Game", "Winners" ]
c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b
https://github.com/jarrettbarnett/RockPaperScissorsSpockLizard/blob/c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b/src/Game.php#L405-L415
train
Thuata/FrameworkBundle
Repository/Registry/MongoDBRegistry.php
MongoDBRegistry.findByKey
public function findByKey($key) { $document = $this->collection->findOne(['_id' => $key]); return $this->hydrateEntity($document); }
php
public function findByKey($key) { $document = $this->collection->findOne(['_id' => $key]); return $this->hydrateEntity($document); }
[ "public", "function", "findByKey", "(", "$", "key", ")", "{", "$", "document", "=", "$", "this", "->", "collection", "->", "findOne", "(", "[", "'_id'", "=>", "$", "key", "]", ")", ";", "return", "$", "this", "->", "hydrateEntity", "(", "$", "documen...
Finds an item by key @param mixed $key @return mixed
[ "Finds", "an", "item", "by", "key" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/MongoDBRegistry.php#L55-L60
train
Thuata/FrameworkBundle
Repository/Registry/MongoDBRegistry.php
MongoDBRegistry.findByKeys
public function findByKeys(array $keys) { $result = []; /** @var Cursor $list */ $list = $this->collection->find(['_id' => ['$in' => $keys]]); foreach ($list as $document) { $result[] = $this->hydrateEntity($document); } return $result; }
php
public function findByKeys(array $keys) { $result = []; /** @var Cursor $list */ $list = $this->collection->find(['_id' => ['$in' => $keys]]); foreach ($list as $document) { $result[] = $this->hydrateEntity($document); } return $result; }
[ "public", "function", "findByKeys", "(", "array", "$", "keys", ")", "{", "$", "result", "=", "[", "]", ";", "/** @var Cursor $list */", "$", "list", "=", "$", "this", "->", "collection", "->", "find", "(", "[", "'_id'", "=>", "[", "'$in'", "=>", "$", ...
Finds a list of items by keys @param array $keys @return array
[ "Finds", "a", "list", "of", "items", "by", "keys" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/MongoDBRegistry.php#L69-L80
train
Thuata/FrameworkBundle
Repository/Registry/MongoDBRegistry.php
MongoDBRegistry.add
public function add($key, $data) { $toInsert = $this->getDocumentData($data); $result = $this->collection->insertOne($toInsert); $data->_id = $result->getInsertedId(); }
php
public function add($key, $data) { $toInsert = $this->getDocumentData($data); $result = $this->collection->insertOne($toInsert); $data->_id = $result->getInsertedId(); }
[ "public", "function", "add", "(", "$", "key", ",", "$", "data", ")", "{", "$", "toInsert", "=", "$", "this", "->", "getDocumentData", "(", "$", "data", ")", ";", "$", "result", "=", "$", "this", "->", "collection", "->", "insertOne", "(", "$", "toI...
adds an item to the registry @param mixed $key @param mixed $data @throws \Exception
[ "adds", "an", "item", "to", "the", "registry" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/MongoDBRegistry.php#L91-L98
train
Thuata/FrameworkBundle
Repository/Registry/MongoDBRegistry.php
MongoDBRegistry.getDocumentData
protected function getDocumentData($document) { if (is_array($document)) { $data = $document; } elseif ($document instanceof AbstractDocument) { $reflectionClass = new \ReflectionClass($document); $documentProperty = $reflectionClass->getParentClass()->getProperty('document'); $documentProperty->setAccessible(true); $data = $documentProperty->getValue($document); foreach ($data as $key => &$value) { if ($value instanceof DocumentSerializableInterface) { $value = $value->documentSerialize()->jsonSerialize(); } } } else { throw new \Exception('Invalid data type, array or AbstractDocument expected'); } return $data; }
php
protected function getDocumentData($document) { if (is_array($document)) { $data = $document; } elseif ($document instanceof AbstractDocument) { $reflectionClass = new \ReflectionClass($document); $documentProperty = $reflectionClass->getParentClass()->getProperty('document'); $documentProperty->setAccessible(true); $data = $documentProperty->getValue($document); foreach ($data as $key => &$value) { if ($value instanceof DocumentSerializableInterface) { $value = $value->documentSerialize()->jsonSerialize(); } } } else { throw new \Exception('Invalid data type, array or AbstractDocument expected'); } return $data; }
[ "protected", "function", "getDocumentData", "(", "$", "document", ")", "{", "if", "(", "is_array", "(", "$", "document", ")", ")", "{", "$", "data", "=", "$", "document", ";", "}", "elseif", "(", "$", "document", "instanceof", "AbstractDocument", ")", "{...
Gets document data @param $document @return mixed @throws \Exception
[ "Gets", "document", "data" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/MongoDBRegistry.php#L109-L128
train
Thuata/FrameworkBundle
Repository/Registry/MongoDBRegistry.php
MongoDBRegistry.hydrateEntity
private function hydrateEntity($document) { $class = $this->entityClass; $reflectionClass = new \ReflectionClass(AbstractDocument::class); $entity = new $class(); if (!($entity instanceof AbstractDocument)) { throw new \Exception(sprintf('"%s" is not a subclass of "%s"', $this->entityClass, AbstractDocument::class)); } $documentProperty = $reflectionClass->getProperty('document'); $documentProperty->setAccessible(true); $documentProperty->setValue($entity, $document); return $entity; }
php
private function hydrateEntity($document) { $class = $this->entityClass; $reflectionClass = new \ReflectionClass(AbstractDocument::class); $entity = new $class(); if (!($entity instanceof AbstractDocument)) { throw new \Exception(sprintf('"%s" is not a subclass of "%s"', $this->entityClass, AbstractDocument::class)); } $documentProperty = $reflectionClass->getProperty('document'); $documentProperty->setAccessible(true); $documentProperty->setValue($entity, $document); return $entity; }
[ "private", "function", "hydrateEntity", "(", "$", "document", ")", "{", "$", "class", "=", "$", "this", "->", "entityClass", ";", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "AbstractDocument", "::", "class", ")", ";", "$", "entity", ...
Hydrates a document entity with a mongo document @param mixed $document @return AbstractDocument @throws \Exception
[ "Hydrates", "a", "document", "entity", "with", "a", "mongo", "document" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/MongoDBRegistry.php#L184-L199
train
jnjxp/html
src/Helper/Breadcrumb.php
Breadcrumb.buildItem
protected function buildItem($position, array $item) { $position +=1; list($title, $aAttr, $liAttr) = $item; $base = $this->baseAttr; $esc = $this->escaper->attr; $meta = $base['meta']; $meta['content'] = $position; $liAttr = $esc(array_merge_recursive($liAttr, $base['li'])); $aAttr = $esc(array_merge_recursive($aAttr, $base['a'])); $spanAttr = $esc($base['span']); $title = "<span $spanAttr>$title</span>"; $anchor = "<a $aAttr>$title</a>"; $meta = $this->void('meta', $meta); $this->html .= $this->indent(2, "<li {$liAttr}>"); $this->html .= $this->indent(3, $anchor); $this->html .= $this->indent(3, $meta); $this->html .= $this->indent(2, '</li>'); }
php
protected function buildItem($position, array $item) { $position +=1; list($title, $aAttr, $liAttr) = $item; $base = $this->baseAttr; $esc = $this->escaper->attr; $meta = $base['meta']; $meta['content'] = $position; $liAttr = $esc(array_merge_recursive($liAttr, $base['li'])); $aAttr = $esc(array_merge_recursive($aAttr, $base['a'])); $spanAttr = $esc($base['span']); $title = "<span $spanAttr>$title</span>"; $anchor = "<a $aAttr>$title</a>"; $meta = $this->void('meta', $meta); $this->html .= $this->indent(2, "<li {$liAttr}>"); $this->html .= $this->indent(3, $anchor); $this->html .= $this->indent(3, $meta); $this->html .= $this->indent(2, '</li>'); }
[ "protected", "function", "buildItem", "(", "$", "position", ",", "array", "$", "item", ")", "{", "$", "position", "+=", "1", ";", "list", "(", "$", "title", ",", "$", "aAttr", ",", "$", "liAttr", ")", "=", "$", "item", ";", "$", "base", "=", "$",...
build an item @param int $position numeric position @param array $item array representation of item @return void @access protected
[ "build", "an", "item" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Breadcrumb.php#L176-L201
train
jnjxp/html
src/Helper/Breadcrumb.php
Breadcrumb.buildActive
protected function buildActive(array $active) { $active[2] = array_merge_recursive( $active[2], ['class' => 'active'] ); $this->buildItem(count($this->stack), $active); }
php
protected function buildActive(array $active) { $active[2] = array_merge_recursive( $active[2], ['class' => 'active'] ); $this->buildItem(count($this->stack), $active); }
[ "protected", "function", "buildActive", "(", "array", "$", "active", ")", "{", "$", "active", "[", "2", "]", "=", "array_merge_recursive", "(", "$", "active", "[", "2", "]", ",", "[", "'class'", "=>", "'active'", "]", ")", ";", "$", "this", "->", "bu...
build the active item @param array $active array representation of item @return void @access protected
[ "build", "the", "active", "item" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Breadcrumb.php#L212-L219
train
jnjxp/html
src/Helper/Breadcrumb.php
Breadcrumb.item
public function item($title, $uri = '#', $liAttr = []) { $this->stack[] = [ $this->escaper->html($title), ['href' => $uri], $liAttr, ]; return $this; }
php
public function item($title, $uri = '#', $liAttr = []) { $this->stack[] = [ $this->escaper->html($title), ['href' => $uri], $liAttr, ]; return $this; }
[ "public", "function", "item", "(", "$", "title", ",", "$", "uri", "=", "'#'", ",", "$", "liAttr", "=", "[", "]", ")", "{", "$", "this", "->", "stack", "[", "]", "=", "[", "$", "this", "->", "escaper", "->", "html", "(", "$", "title", ")", ","...
add an item @param string $title text for item @param string $uri uri for item @param array $liAttr attributes for li element @return Breadcrumb @access public
[ "add", "an", "item" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Breadcrumb.php#L233-L241
train
jnjxp/html
src/Helper/Breadcrumb.php
Breadcrumb.rawItem
public function rawItem($title, $uri = '#', $liAttr = []) { $this->stack[] = [$title, ['href' => $uri], $liAttr]; return $this; }
php
public function rawItem($title, $uri = '#', $liAttr = []) { $this->stack[] = [$title, ['href' => $uri], $liAttr]; return $this; }
[ "public", "function", "rawItem", "(", "$", "title", ",", "$", "uri", "=", "'#'", ",", "$", "liAttr", "=", "[", "]", ")", "{", "$", "this", "->", "stack", "[", "]", "=", "[", "$", "title", ",", "[", "'href'", "=>", "$", "uri", "]", ",", "$", ...
add a raw item @param string $title title of item @param string $uri uri of item @param mixed $liAttr attributes for li element @return Breadcrumb @access public
[ "add", "a", "raw", "item" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Breadcrumb.php#L254-L258
train
jnjxp/html
src/Helper/Breadcrumb.php
Breadcrumb.items
public function items(array $items) { foreach ($items as $uri => $title) { list($title, $uri, $liAttr) = $this->fixData($uri, $title); $this->item($title, $uri, $liAttr); } return $this; }
php
public function items(array $items) { foreach ($items as $uri => $title) { list($title, $uri, $liAttr) = $this->fixData($uri, $title); $this->item($title, $uri, $liAttr); } return $this; }
[ "public", "function", "items", "(", "array", "$", "items", ")", "{", "foreach", "(", "$", "items", "as", "$", "uri", "=>", "$", "title", ")", "{", "list", "(", "$", "title", ",", "$", "uri", ",", "$", "liAttr", ")", "=", "$", "this", "->", "fix...
add an array of items @param array $items array of items @return Breadcrumb @access public
[ "add", "an", "array", "of", "items" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Breadcrumb.php#L269-L276
train
jnjxp/html
src/Helper/Breadcrumb.php
Breadcrumb.rawItems
public function rawItems(array $items) { foreach ($items as $uri => $title) { list($title, $uri, $liAttr) = $this->fixData($uri, $title); $this->rawItem($title, $uri, $liAttr); } return $this; }
php
public function rawItems(array $items) { foreach ($items as $uri => $title) { list($title, $uri, $liAttr) = $this->fixData($uri, $title); $this->rawItem($title, $uri, $liAttr); } return $this; }
[ "public", "function", "rawItems", "(", "array", "$", "items", ")", "{", "foreach", "(", "$", "items", "as", "$", "uri", "=>", "$", "title", ")", "{", "list", "(", "$", "title", ",", "$", "uri", ",", "$", "liAttr", ")", "=", "$", "this", "->", "...
add an array of raw items @param array $items array of raw items to add @return Breadcrumb @access public
[ "add", "an", "array", "of", "raw", "items" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Breadcrumb.php#L287-L294
train
jnjxp/html
src/Helper/Breadcrumb.php
Breadcrumb.fixData
protected function fixData($uri, $title) { $liAttr = []; if (is_int($uri)) { $uri = '#'; } if (is_array($title)) { $liAttr = $title; $title = array_shift($liAttr); } return [$title, $uri, $liAttr]; }
php
protected function fixData($uri, $title) { $liAttr = []; if (is_int($uri)) { $uri = '#'; } if (is_array($title)) { $liAttr = $title; $title = array_shift($liAttr); } return [$title, $uri, $liAttr]; }
[ "protected", "function", "fixData", "(", "$", "uri", ",", "$", "title", ")", "{", "$", "liAttr", "=", "[", "]", ";", "if", "(", "is_int", "(", "$", "uri", ")", ")", "{", "$", "uri", "=", "'#'", ";", "}", "if", "(", "is_array", "(", "$", "titl...
fixes item data @param mixed $uri uri of item or numeric key @param mixed $title title of item or array of title and li attrs @return array @access protected
[ "fixes", "item", "data" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Breadcrumb.php#L306-L317
train
jabernardo/saddle
src/Saddle/Container.php
Container.raw
public function raw($key) { if (!is_string($key)) { throw new \Calf\Exception\InvalidArgument('Key must be string.'); } if (!isset($this->_keys[$key])) { throw new \Calf\Exception\Runtime('Key doesn\'t exists: ' . $key); } return $this->_values[$key]; }
php
public function raw($key) { if (!is_string($key)) { throw new \Calf\Exception\InvalidArgument('Key must be string.'); } if (!isset($this->_keys[$key])) { throw new \Calf\Exception\Runtime('Key doesn\'t exists: ' . $key); } return $this->_values[$key]; }
[ "public", "function", "raw", "(", "$", "key", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "\\", "Calf", "\\", "Exception", "\\", "InvalidArgument", "(", "'Key must be string.'", ")", ";", "}", "if", "(", "!"...
Get raw value @access public @return void @throws \Calf\Exception\InvalidArgument Key must be string @throws \Calf\Exception\Runtime Key doesn't exists
[ "Get", "raw", "value" ]
07dbccda2491904940afd7b9ffd6cfd8fe4dcec1
https://github.com/jabernardo/saddle/blob/07dbccda2491904940afd7b9ffd6cfd8fe4dcec1/src/Saddle/Container.php#L148-L158
train
kiler129/CherryHttp
src/Http/Response/AutogeneratedResponseTrait.php
AutogeneratedResponseTrait.generateAutomaticResponseContent
public function generateAutomaticResponseContent($code, $reasonPhrase, $title = null, $description = null) { if ($title === null) { $title = $code . ' ' . $reasonPhrase; } return sprintf($this->template, $title, $code, $reasonPhrase, $description); }
php
public function generateAutomaticResponseContent($code, $reasonPhrase, $title = null, $description = null) { if ($title === null) { $title = $code . ' ' . $reasonPhrase; } return sprintf($this->template, $title, $code, $reasonPhrase, $description); }
[ "public", "function", "generateAutomaticResponseContent", "(", "$", "code", ",", "$", "reasonPhrase", ",", "$", "title", "=", "null", ",", "$", "description", "=", "null", ")", "{", "if", "(", "$", "title", "===", "null", ")", "{", "$", "title", "=", "...
Generates response with built-in template. @param int|string $code Response code which will be presented to the user. @param string $reasonPhrase Response code reason phrase displayed under the code. @param string|null $title HTML <title> tag contents. If null it will be generated from code & reason phrase. @param string|null $description Additional description/explanation of situation. @return string HTML content
[ "Generates", "response", "with", "built", "-", "in", "template", "." ]
05927f26183cbd6fd5ccb0853befecdea279308d
https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/Http/Response/AutogeneratedResponseTrait.php#L31-L38
train
rybakdigital/fapi
Component/Routing/Route/Route.php
Route.addMethod
public function addMethod($method) { // Capitalise method $method = strtoupper($method); if (!in_array($method, self::$availableMethods)) { throw new InvalidArgumentException(sprintf('Invalid method for route with path "%s". Method must be one of: ' . implode(', ', self::$availableMethods) . '. Got "%s" instead.', $this->getPath(), $method)); } if (!in_array($method, $this->methods)) { $this->methods[] = $method; } // Add HEAD method if GET has been allowed for this Route if ($method == 'GET') { $this->addMethod('HEAD'); } return $this; }
php
public function addMethod($method) { // Capitalise method $method = strtoupper($method); if (!in_array($method, self::$availableMethods)) { throw new InvalidArgumentException(sprintf('Invalid method for route with path "%s". Method must be one of: ' . implode(', ', self::$availableMethods) . '. Got "%s" instead.', $this->getPath(), $method)); } if (!in_array($method, $this->methods)) { $this->methods[] = $method; } // Add HEAD method if GET has been allowed for this Route if ($method == 'GET') { $this->addMethod('HEAD'); } return $this; }
[ "public", "function", "addMethod", "(", "$", "method", ")", "{", "// Capitalise method", "$", "method", "=", "strtoupper", "(", "$", "method", ")", ";", "if", "(", "!", "in_array", "(", "$", "method", ",", "self", "::", "$", "availableMethods", ")", ")",...
Adds method to array of methods accepted by Route @param string $method Name of HTTP method to add @return Route @throws InvalidArgumentException
[ "Adds", "method", "to", "array", "of", "methods", "accepted", "by", "Route" ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/Routing/Route/Route.php#L127-L146
train
ipalaus/redisqueue
src/Ipalaus/RedisQueue/Repository.php
Repository.getAll
public function getAll() { $collection = new Collection; $keys = $this->database->keys($this->namespace.':*'); foreach ($keys as $key) { list($namespace, $name) = explode(':', $key); if ( ! $collection->has($name)) { $collection->put($name, $this->get($name)); } } return $collection; }
php
public function getAll() { $collection = new Collection; $keys = $this->database->keys($this->namespace.':*'); foreach ($keys as $key) { list($namespace, $name) = explode(':', $key); if ( ! $collection->has($name)) { $collection->put($name, $this->get($name)); } } return $collection; }
[ "public", "function", "getAll", "(", ")", "{", "$", "collection", "=", "new", "Collection", ";", "$", "keys", "=", "$", "this", "->", "database", "->", "keys", "(", "$", "this", "->", "namespace", ".", "':*'", ")", ";", "foreach", "(", "$", "keys", ...
Fetch all the queues inside the 'queues' namespace with the delayed and reserved. @return \Illuminate\Support\Collection
[ "Fetch", "all", "the", "queues", "inside", "the", "queues", "namespace", "with", "the", "delayed", "and", "reserved", "." ]
0a6c675e9918122263adfb4e0f6207bb3c5fd1f6
https://github.com/ipalaus/redisqueue/blob/0a6c675e9918122263adfb4e0f6207bb3c5fd1f6/src/Ipalaus/RedisQueue/Repository.php#L41-L58
train
ipalaus/redisqueue
src/Ipalaus/RedisQueue/Repository.php
Repository.get
public function get($name) { $namespaced = $this->namespace.':'.$name; $queued = $this->length($namespaced, 'list'); $delayed = $this->length($namespaced.':delayed', 'zset'); $reserved = $this->length($namespaced.':reserved', 'zset'); return array('queued' => $queued, 'delayed' => $delayed, 'reserved' => $reserved); }
php
public function get($name) { $namespaced = $this->namespace.':'.$name; $queued = $this->length($namespaced, 'list'); $delayed = $this->length($namespaced.':delayed', 'zset'); $reserved = $this->length($namespaced.':reserved', 'zset'); return array('queued' => $queued, 'delayed' => $delayed, 'reserved' => $reserved); }
[ "public", "function", "get", "(", "$", "name", ")", "{", "$", "namespaced", "=", "$", "this", "->", "namespace", ".", "':'", ".", "$", "name", ";", "$", "queued", "=", "$", "this", "->", "length", "(", "$", "namespaced", ",", "'list'", ")", ";", ...
Get the items that a concrete queue contain. @param string $name @return array
[ "Get", "the", "items", "that", "a", "concrete", "queue", "contain", "." ]
0a6c675e9918122263adfb4e0f6207bb3c5fd1f6
https://github.com/ipalaus/redisqueue/blob/0a6c675e9918122263adfb4e0f6207bb3c5fd1f6/src/Ipalaus/RedisQueue/Repository.php#L66-L75
train
ipalaus/redisqueue
src/Ipalaus/RedisQueue/Repository.php
Repository.getItems
public function getItems($name, $type) { $namespaced = $this->namespace.':'.$name; $key = ($type === 'queued') ? $namespaced : $namespaced.':'.$type; if ( ! $this->exists($key)) throw new QueueNotFoundException($key); $type = $this->type($key); $length = $this->length($key, $type); $method = 'get'.ucwords($type).'Items'; $items = $this->{$method}($key, $length); return Collection::make($items); }
php
public function getItems($name, $type) { $namespaced = $this->namespace.':'.$name; $key = ($type === 'queued') ? $namespaced : $namespaced.':'.$type; if ( ! $this->exists($key)) throw new QueueNotFoundException($key); $type = $this->type($key); $length = $this->length($key, $type); $method = 'get'.ucwords($type).'Items'; $items = $this->{$method}($key, $length); return Collection::make($items); }
[ "public", "function", "getItems", "(", "$", "name", ",", "$", "type", ")", "{", "$", "namespaced", "=", "$", "this", "->", "namespace", ".", "':'", ".", "$", "name", ";", "$", "key", "=", "(", "$", "type", "===", "'queued'", ")", "?", "$", "names...
Retruns a list of items for a given key. @param string $name @param string $type @return \Illuminate\Support\Collection
[ "Retruns", "a", "list", "of", "items", "for", "a", "given", "key", "." ]
0a6c675e9918122263adfb4e0f6207bb3c5fd1f6
https://github.com/ipalaus/redisqueue/blob/0a6c675e9918122263adfb4e0f6207bb3c5fd1f6/src/Ipalaus/RedisQueue/Repository.php#L84-L99
train
ipalaus/redisqueue
src/Ipalaus/RedisQueue/Repository.php
Repository.getListItems
protected function getListItems($key, $total, $offset = 0) { $items = array(); for ($i = $offset; $i < $total; $i++) { $items[$i] = $this->database->lindex($key, $i); } return $items; }
php
protected function getListItems($key, $total, $offset = 0) { $items = array(); for ($i = $offset; $i < $total; $i++) { $items[$i] = $this->database->lindex($key, $i); } return $items; }
[ "protected", "function", "getListItems", "(", "$", "key", ",", "$", "total", ",", "$", "offset", "=", "0", ")", "{", "$", "items", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "$", "offset", ";", "$", "i", "<", "$", "total", ";", "...
Returns a list of items inside a list. @param string $key @param integer $total @param integer $offset @return array
[ "Returns", "a", "list", "of", "items", "inside", "a", "list", "." ]
0a6c675e9918122263adfb4e0f6207bb3c5fd1f6
https://github.com/ipalaus/redisqueue/blob/0a6c675e9918122263adfb4e0f6207bb3c5fd1f6/src/Ipalaus/RedisQueue/Repository.php#L109-L118
train
ipalaus/redisqueue
src/Ipalaus/RedisQueue/Repository.php
Repository.type
public function type($key) { if (Str::endsWith($key, ':queued')) { $key = str_replace(':queued', '', $key); } return $this->database->type($key); }
php
public function type($key) { if (Str::endsWith($key, ':queued')) { $key = str_replace(':queued', '', $key); } return $this->database->type($key); }
[ "public", "function", "type", "(", "$", "key", ")", "{", "if", "(", "Str", "::", "endsWith", "(", "$", "key", ",", "':queued'", ")", ")", "{", "$", "key", "=", "str_replace", "(", "':queued'", ",", "''", ",", "$", "key", ")", ";", "}", "return", ...
Returns the type of a Redis key. @param string $key @return string
[ "Returns", "the", "type", "of", "a", "Redis", "key", "." ]
0a6c675e9918122263adfb4e0f6207bb3c5fd1f6
https://github.com/ipalaus/redisqueue/blob/0a6c675e9918122263adfb4e0f6207bb3c5fd1f6/src/Ipalaus/RedisQueue/Repository.php#L149-L156
train
ipalaus/redisqueue
src/Ipalaus/RedisQueue/Repository.php
Repository.length
public function length($key, $type = null) { if (is_null($type)) $type = $this->type($key); switch ($type) { case 'list': return $this->database->llen($key); case 'zset': return $this->database->zcard($key); default: throw new UnexpectedValueException("List type '{$type}' not supported."); } }
php
public function length($key, $type = null) { if (is_null($type)) $type = $this->type($key); switch ($type) { case 'list': return $this->database->llen($key); case 'zset': return $this->database->zcard($key); default: throw new UnexpectedValueException("List type '{$type}' not supported."); } }
[ "public", "function", "length", "(", "$", "key", ",", "$", "type", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "type", ")", ")", "$", "type", "=", "$", "this", "->", "type", "(", "$", "key", ")", ";", "switch", "(", "$", "type", ")...
Return the length of a given list or set. @param string $key @param string $type @return integer|\UnexpectedValueException
[ "Return", "the", "length", "of", "a", "given", "list", "or", "set", "." ]
0a6c675e9918122263adfb4e0f6207bb3c5fd1f6
https://github.com/ipalaus/redisqueue/blob/0a6c675e9918122263adfb4e0f6207bb3c5fd1f6/src/Ipalaus/RedisQueue/Repository.php#L165-L180
train
ipalaus/redisqueue
src/Ipalaus/RedisQueue/Repository.php
Repository.remove
public function remove($key, $value, $type = null) { if (is_null($type)) $type = $this->type($key); switch ($type) { case 'list': $key = str_replace(':queued', '', $key); $random = Str::quickRandom(64); $this->database->lset($key, $value, $random); return $this->database->lrem($key, 1, $random); case 'zset': return $this->database->zrem($key, $value); default: throw new UnexpectedValueException("Unable to delete {$value} from {$key}. List type {$type} not supported."); } }
php
public function remove($key, $value, $type = null) { if (is_null($type)) $type = $this->type($key); switch ($type) { case 'list': $key = str_replace(':queued', '', $key); $random = Str::quickRandom(64); $this->database->lset($key, $value, $random); return $this->database->lrem($key, 1, $random); case 'zset': return $this->database->zrem($key, $value); default: throw new UnexpectedValueException("Unable to delete {$value} from {$key}. List type {$type} not supported."); } }
[ "public", "function", "remove", "(", "$", "key", ",", "$", "value", ",", "$", "type", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "type", ")", ")", "$", "type", "=", "$", "this", "->", "type", "(", "$", "key", ")", ";", "switch", "...
Remove an item with a given key, index or value. @param string $key @param string $value @param string $type @return bool
[ "Remove", "an", "item", "with", "a", "given", "key", "index", "or", "value", "." ]
0a6c675e9918122263adfb4e0f6207bb3c5fd1f6
https://github.com/ipalaus/redisqueue/blob/0a6c675e9918122263adfb4e0f6207bb3c5fd1f6/src/Ipalaus/RedisQueue/Repository.php#L190-L210
train
dzegarra/jsonrpcsmd
src/Greplab/Jsonrpcsmd/Smd/Service.php
Service.read
static public function read(Smd $smd, $classname) { $reflectedclass = new \ReflectionClass($classname); return self::isValid($smd, $reflectedclass) ? new Service($smd, $reflectedclass) : false; }
php
static public function read(Smd $smd, $classname) { $reflectedclass = new \ReflectionClass($classname); return self::isValid($smd, $reflectedclass) ? new Service($smd, $reflectedclass) : false; }
[ "static", "public", "function", "read", "(", "Smd", "$", "smd", ",", "$", "classname", ")", "{", "$", "reflectedclass", "=", "new", "\\", "ReflectionClass", "(", "$", "classname", ")", ";", "return", "self", "::", "isValid", "(", "$", "smd", ",", "$", ...
Read the content of one class and return the result of the analysis. Return FALSE if the cass found is not a valid service. @param Smd $smd @param string $classname @return Service
[ "Read", "the", "content", "of", "one", "class", "and", "return", "the", "result", "of", "the", "analysis", ".", "Return", "FALSE", "if", "the", "cass", "found", "is", "not", "a", "valid", "service", "." ]
2f423b575d34d9ef2370495b89b9efd96f0cd30b
https://github.com/dzegarra/jsonrpcsmd/blob/2f423b575d34d9ef2370495b89b9efd96f0cd30b/src/Greplab/Jsonrpcsmd/Smd/Service.php#L50-L54
train
dzegarra/jsonrpcsmd
src/Greplab/Jsonrpcsmd/Smd/Service.php
Service.isValid
static protected function isValid(Smd $smd, \ReflectionClass $reflectedclass) { $validator = $smd->getServiceValidator(); if ($validator && is_callable($validator)) { if ( call_user_func_array($validator, [$reflectedclass]) === false ) { return false; } } return true; }
php
static protected function isValid(Smd $smd, \ReflectionClass $reflectedclass) { $validator = $smd->getServiceValidator(); if ($validator && is_callable($validator)) { if ( call_user_func_array($validator, [$reflectedclass]) === false ) { return false; } } return true; }
[ "static", "protected", "function", "isValid", "(", "Smd", "$", "smd", ",", "\\", "ReflectionClass", "$", "reflectedclass", ")", "{", "$", "validator", "=", "$", "smd", "->", "getServiceValidator", "(", ")", ";", "if", "(", "$", "validator", "&&", "is_calla...
Validate a class using the custom validation closure. @param Smd $smd @param \ReflectionClass $reflectedclass @return bool
[ "Validate", "a", "class", "using", "the", "custom", "validation", "closure", "." ]
2f423b575d34d9ef2370495b89b9efd96f0cd30b
https://github.com/dzegarra/jsonrpcsmd/blob/2f423b575d34d9ef2370495b89b9efd96f0cd30b/src/Greplab/Jsonrpcsmd/Smd/Service.php#L63-L72
train
dzegarra/jsonrpcsmd
src/Greplab/Jsonrpcsmd/Smd/Service.php
Service.toArrayPlain
protected function toArrayPlain() { $classname = $this->resolveClassname(); $methods = array(); foreach ($this->getMethods() as $method) { $method_fullname = $classname . '.' . $method->getName(); $methods[$method_fullname] = $method->toArray(); } return $methods; }
php
protected function toArrayPlain() { $classname = $this->resolveClassname(); $methods = array(); foreach ($this->getMethods() as $method) { $method_fullname = $classname . '.' . $method->getName(); $methods[$method_fullname] = $method->toArray(); } return $methods; }
[ "protected", "function", "toArrayPlain", "(", ")", "{", "$", "classname", "=", "$", "this", "->", "resolveClassname", "(", ")", ";", "$", "methods", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getMethods", "(", ")", "as", "$", "m...
Return a plain representation of the class methods. @return array
[ "Return", "a", "plain", "representation", "of", "the", "class", "methods", "." ]
2f423b575d34d9ef2370495b89b9efd96f0cd30b
https://github.com/dzegarra/jsonrpcsmd/blob/2f423b575d34d9ef2370495b89b9efd96f0cd30b/src/Greplab/Jsonrpcsmd/Smd/Service.php#L146-L155
train
dzegarra/jsonrpcsmd
src/Greplab/Jsonrpcsmd/Smd/Service.php
Service.buildLevel
protected function buildLevel($classname) { $parts = explode('.', $classname); $lastLevel = &$this->methods; foreach ($parts as $part) { $lastLevel[$part] = array(); $lastLevel = &$lastLevel[$part]; } return $lastLevel; }
php
protected function buildLevel($classname) { $parts = explode('.', $classname); $lastLevel = &$this->methods; foreach ($parts as $part) { $lastLevel[$part] = array(); $lastLevel = &$lastLevel[$part]; } return $lastLevel; }
[ "protected", "function", "buildLevel", "(", "$", "classname", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "classname", ")", ";", "$", "lastLevel", "=", "&", "$", "this", "->", "methods", ";", "foreach", "(", "$", "parts", "as", "$",...
This method is still in development. @todo implement the method toArrayTree() @param string $classname @return string
[ "This", "method", "is", "still", "in", "development", "." ]
2f423b575d34d9ef2370495b89b9efd96f0cd30b
https://github.com/dzegarra/jsonrpcsmd/blob/2f423b575d34d9ef2370495b89b9efd96f0cd30b/src/Greplab/Jsonrpcsmd/Smd/Service.php#L164-L175
train
dzegarra/jsonrpcsmd
src/Greplab/Jsonrpcsmd/Smd/Service.php
Service.toArrayTree
protected function toArrayTree() { $classname = $this->getDottedClassname(); $lastLevel = $this->buildLevel($classname); foreach ($this->getMethods() as $method) { $lastLevel[$method->getName()] = $method->toArray(); } return $this->methods; }
php
protected function toArrayTree() { $classname = $this->getDottedClassname(); $lastLevel = $this->buildLevel($classname); foreach ($this->getMethods() as $method) { $lastLevel[$method->getName()] = $method->toArray(); } return $this->methods; }
[ "protected", "function", "toArrayTree", "(", ")", "{", "$", "classname", "=", "$", "this", "->", "getDottedClassname", "(", ")", ";", "$", "lastLevel", "=", "$", "this", "->", "buildLevel", "(", "$", "classname", ")", ";", "foreach", "(", "$", "this", ...
Return a tree representation of the methods of the reflected class. @todo This method is still in development. @return array
[ "Return", "a", "tree", "representation", "of", "the", "methods", "of", "the", "reflected", "class", "." ]
2f423b575d34d9ef2370495b89b9efd96f0cd30b
https://github.com/dzegarra/jsonrpcsmd/blob/2f423b575d34d9ef2370495b89b9efd96f0cd30b/src/Greplab/Jsonrpcsmd/Smd/Service.php#L183-L193
train
dzegarra/jsonrpcsmd
src/Greplab/Jsonrpcsmd/Smd/Service.php
Service.toArray
public function toArray() { $fn = 'toArray' . ucfirst($this->presentation); if (!method_exists($this, $fn)) { throw new \Exception('There is no method ' . $fn . '.'); } return $this->$fn(); }
php
public function toArray() { $fn = 'toArray' . ucfirst($this->presentation); if (!method_exists($this, $fn)) { throw new \Exception('There is no method ' . $fn . '.'); } return $this->$fn(); }
[ "public", "function", "toArray", "(", ")", "{", "$", "fn", "=", "'toArray'", ".", "ucfirst", "(", "$", "this", "->", "presentation", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "fn", ")", ")", "{", "throw", "new", "\\", ...
Build and return the class representation as an array. @return array @throws \Exception If the current representation mode cannot be used
[ "Build", "and", "return", "the", "class", "representation", "as", "an", "array", "." ]
2f423b575d34d9ef2370495b89b9efd96f0cd30b
https://github.com/dzegarra/jsonrpcsmd/blob/2f423b575d34d9ef2370495b89b9efd96f0cd30b/src/Greplab/Jsonrpcsmd/Smd/Service.php#L201-L208
train
phossa2/libs
src/Phossa2/Logger/Handler/StreamHandler.php
StreamHandler.openStream
protected function openStream(/*# string */ $path) { if (is_string($path)) { if (false !== strpos($path, '://')) { $path = 'file://' . $path; } return fopen($path, 'a'); } return $path; }
php
protected function openStream(/*# string */ $path) { if (is_string($path)) { if (false !== strpos($path, '://')) { $path = 'file://' . $path; } return fopen($path, 'a'); } return $path; }
[ "protected", "function", "openStream", "(", "/*# string */", "$", "path", ")", "{", "if", "(", "is_string", "(", "$", "path", ")", ")", "{", "if", "(", "false", "!==", "strpos", "(", "$", "path", ",", "'://'", ")", ")", "{", "$", "path", "=", "'fil...
Open stream for writing @param string|resource $path @return resource|false @access protected
[ "Open", "stream", "for", "writing" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Handler/StreamHandler.php#L91-L100
train
cityware/city-components
src/File.php
File.prepare
public static function prepare($data, $forceWindows = false) { $lineBreak = "\n"; if (DS === '\\' || $forceWindows === true) { $lineBreak = "\r\n"; } return strtr($data, array("\r\n" => $lineBreak, "\n" => $lineBreak, "\r" => $lineBreak)); }
php
public static function prepare($data, $forceWindows = false) { $lineBreak = "\n"; if (DS === '\\' || $forceWindows === true) { $lineBreak = "\r\n"; } return strtr($data, array("\r\n" => $lineBreak, "\n" => $lineBreak, "\r" => $lineBreak)); }
[ "public", "static", "function", "prepare", "(", "$", "data", ",", "$", "forceWindows", "=", "false", ")", "{", "$", "lineBreak", "=", "\"\\n\"", ";", "if", "(", "DS", "===", "'\\\\'", "||", "$", "forceWindows", "===", "true", ")", "{", "$", "lineBreak"...
Prepares a ASCII string for writing. Converts line endings to the correct terminator for the current platform. If Windows, "\r\n" will be used, all other platforms will use "\n" @param string $data Data to prepare for writing. @param boolean $forceWindows @return string The with converted line endings.
[ "Prepares", "a", "ASCII", "string", "for", "writing", ".", "Converts", "line", "endings", "to", "the", "correct", "terminator", "for", "the", "current", "platform", ".", "If", "Windows", "\\", "r", "\\", "n", "will", "be", "used", "all", "other", "platform...
103211a4896f7e9ecdccec2ee9bf26239d52faa0
https://github.com/cityware/city-components/blob/103211a4896f7e9ecdccec2ee9bf26239d52faa0/src/File.php#L202-L210
train
cityware/city-components
src/File.php
File.mime
public function mime() { if (!$this->exists()) { return false; } if (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME); $finfo = finfo_file($finfo, $this->pwd()); if (!$finfo) { return false; } list($type) = explode(';', $finfo); return $type; } if (function_exists('mime_content_type')) { return mime_content_type($this->pwd()); } return false; }
php
public function mime() { if (!$this->exists()) { return false; } if (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME); $finfo = finfo_file($finfo, $this->pwd()); if (!$finfo) { return false; } list($type) = explode(';', $finfo); return $type; } if (function_exists('mime_content_type')) { return mime_content_type($this->pwd()); } return false; }
[ "public", "function", "mime", "(", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "function_exists", "(", "'finfo_open'", ")", ")", "{", "$", "finfo", "=", "finfo_open", "(", "FILE...
Get the mime type of the file. Uses the finfo extension if its available, otherwise falls back to mime_content_type @return false|string The mimetype of the file, or false if reading fails.
[ "Get", "the", "mime", "type", "of", "the", "file", ".", "Uses", "the", "finfo", "extension", "if", "its", "available", "otherwise", "falls", "back", "to", "mime_content_type" ]
103211a4896f7e9ecdccec2ee9bf26239d52faa0
https://github.com/cityware/city-components/blob/103211a4896f7e9ecdccec2ee9bf26239d52faa0/src/File.php#L562-L582
train
Flowpack/Flowpack.SingleSignOn.DemoInstance
Classes/Flowpack/SingleSignOn/DemoInstance/Command/DemoCommandController.php
DemoCommandController.setupCommand
public function setupCommand() { $serverPublicKeyString = Files::getFileContents('resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoServer.pub', FILE_TEXT); if ($serverPublicKeyString === FALSE) { $this->outputLine('Could not open resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoServer.pub, exiting.'); $this->quit(1); } $serverPublicKeyFingerprint = $this->rsaWalletService->registerPublicKeyFromString($serverPublicKeyString); $this->outputLine('Registered sso demo server public key'); $clientPrivateKeyString = Files::getFileContents('resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoClient.key', FILE_TEXT); if ($clientPrivateKeyString === FALSE) { $this->outputLine('Could not open resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoClient.key, exiting.'); $this->quit(2); } $clientPublicKeyFingerprint = $this->rsaWalletService->registerKeyPairFromPrivateKeyString($clientPrivateKeyString); $this->outputLine('Registered demo client key pair'); $globalSettings = $this->yamlSource->load(FLOW_PATH_CONFIGURATION . '/Settings'); $globalSettings['Flowpack']['SingleSignOn']['Client']['client']['publicKeyFingerprint'] = $clientPublicKeyFingerprint; $globalSettings['Flowpack']['SingleSignOn']['Client']['server']['DemoServer']['publicKeyFingerprint'] = $serverPublicKeyFingerprint; $this->yamlSource->save(FLOW_PATH_CONFIGURATION . '/Settings', $globalSettings); $this->outputLine('Updated settings'); }
php
public function setupCommand() { $serverPublicKeyString = Files::getFileContents('resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoServer.pub', FILE_TEXT); if ($serverPublicKeyString === FALSE) { $this->outputLine('Could not open resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoServer.pub, exiting.'); $this->quit(1); } $serverPublicKeyFingerprint = $this->rsaWalletService->registerPublicKeyFromString($serverPublicKeyString); $this->outputLine('Registered sso demo server public key'); $clientPrivateKeyString = Files::getFileContents('resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoClient.key', FILE_TEXT); if ($clientPrivateKeyString === FALSE) { $this->outputLine('Could not open resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoClient.key, exiting.'); $this->quit(2); } $clientPublicKeyFingerprint = $this->rsaWalletService->registerKeyPairFromPrivateKeyString($clientPrivateKeyString); $this->outputLine('Registered demo client key pair'); $globalSettings = $this->yamlSource->load(FLOW_PATH_CONFIGURATION . '/Settings'); $globalSettings['Flowpack']['SingleSignOn']['Client']['client']['publicKeyFingerprint'] = $clientPublicKeyFingerprint; $globalSettings['Flowpack']['SingleSignOn']['Client']['server']['DemoServer']['publicKeyFingerprint'] = $serverPublicKeyFingerprint; $this->yamlSource->save(FLOW_PATH_CONFIGURATION . '/Settings', $globalSettings); $this->outputLine('Updated settings'); }
[ "public", "function", "setupCommand", "(", ")", "{", "$", "serverPublicKeyString", "=", "Files", "::", "getFileContents", "(", "'resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoServer.pub'", ",", "FILE_TEXT", ")", ";", "if", "(", "$", "serverPublicKeyStri...
Set up the SSO demo instance This commands sets a up a single sign-on demo instance with some initial fixture data. It overwrites existing data in the database. ONLY FOR DEMO PURPOSES - DO NOT USE IN PRODUCTION!
[ "Set", "up", "the", "SSO", "demo", "instance" ]
a3de8fef092cec34e2577832576e32b37ca507c5
https://github.com/Flowpack/Flowpack.SingleSignOn.DemoInstance/blob/a3de8fef092cec34e2577832576e32b37ca507c5/Classes/Flowpack/SingleSignOn/DemoInstance/Command/DemoCommandController.php#L39-L63
train
dronemill/eventsocket-client-php
src/Client.php
Client.recv
public function recv() { // receive a message from the socket $message = $this->ws->receive(); // is the message is empty? if (empty($message)) { return; } // decode the message (json_decode + error checking) $message = $this->decodeMessage($message); // injest and route the message $this->injest($message); }
php
public function recv() { // receive a message from the socket $message = $this->ws->receive(); // is the message is empty? if (empty($message)) { return; } // decode the message (json_decode + error checking) $message = $this->decodeMessage($message); // injest and route the message $this->injest($message); }
[ "public", "function", "recv", "(", ")", "{", "// receive a message from the socket", "$", "message", "=", "$", "this", "->", "ws", "->", "receive", "(", ")", ";", "// is the message is empty?", "if", "(", "empty", "(", "$", "message", ")", ")", "{", "return"...
Receive a message from the socket @return void
[ "Receive", "a", "message", "from", "the", "socket" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L118-L134
train
dronemill/eventsocket-client-php
src/Client.php
Client.suscribe
public function suscribe($events, Closure $handler) { if (is_string($events)) $events = [$events]; // store the handler for each of the events it represents foreach ($events as $event) { // check that we have a place to store the handler if (! array_key_exists($event, $this->handlers[static::MESSAGE_TYPE_STANDARD])) { $this->handlers[static::MESSAGE_TYPE_STANDARD][$event] = []; } $this->handlers[static::MESSAGE_TYPE_STANDARD][$event][] = $handler; } // create a new bare message, and store the events $m = $this->bareMessage(static::MESSAGE_TYPE_SUSCRIBE); $m->Payload['Events'] = $events; // finally, send the message $this->send($m); }
php
public function suscribe($events, Closure $handler) { if (is_string($events)) $events = [$events]; // store the handler for each of the events it represents foreach ($events as $event) { // check that we have a place to store the handler if (! array_key_exists($event, $this->handlers[static::MESSAGE_TYPE_STANDARD])) { $this->handlers[static::MESSAGE_TYPE_STANDARD][$event] = []; } $this->handlers[static::MESSAGE_TYPE_STANDARD][$event][] = $handler; } // create a new bare message, and store the events $m = $this->bareMessage(static::MESSAGE_TYPE_SUSCRIBE); $m->Payload['Events'] = $events; // finally, send the message $this->send($m); }
[ "public", "function", "suscribe", "(", "$", "events", ",", "Closure", "$", "handler", ")", "{", "if", "(", "is_string", "(", "$", "events", ")", ")", "$", "events", "=", "[", "$", "events", "]", ";", "// store the handler for each of the events it represents",...
Suscribe to a given event @param string|[] $event the event to suscribe to @param Closure $handler the event handler to be called upon receiving of the event @return void
[ "Suscribe", "to", "a", "given", "event" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L144-L166
train
dronemill/eventsocket-client-php
src/Client.php
Client.reply
public function reply($requestId, $replyClientId, Array $payload) { $m = $this->bareMessage(static::MESSAGE_TYPE_REPLY); $m->ReplyClientId = $replyClientId; $m->RequestId = $requestId; $m->Payload = $payload; $this->send($m); }
php
public function reply($requestId, $replyClientId, Array $payload) { $m = $this->bareMessage(static::MESSAGE_TYPE_REPLY); $m->ReplyClientId = $replyClientId; $m->RequestId = $requestId; $m->Payload = $payload; $this->send($m); }
[ "public", "function", "reply", "(", "$", "requestId", ",", "$", "replyClientId", ",", "Array", "$", "payload", ")", "{", "$", "m", "=", "$", "this", "->", "bareMessage", "(", "static", "::", "MESSAGE_TYPE_REPLY", ")", ";", "$", "m", "->", "ReplyClientId"...
Reply to a given request @param $string $requestId the id of the request to reply to @param $string $replyClientId the client to reply to @param Array $payload the payload to send @return void
[ "Reply", "to", "a", "given", "request" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L176-L184
train
dronemill/eventsocket-client-php
src/Client.php
Client.request
public function request($requestClientId, Array $payload, Closure $handler) { // generate a new requestId $requestId = $this->uuid(); // store the handler $this->handlers[static::MESSAGE_TYPE_REPLY][$requestId] = $handler; $m = $this->bareMessage(static::MESSAGE_TYPE_REQUEST); $m->RequestClientId = $requestClientId; $m->RequestId = $requestId; $m->Payload = $payload; $this->send($m); }
php
public function request($requestClientId, Array $payload, Closure $handler) { // generate a new requestId $requestId = $this->uuid(); // store the handler $this->handlers[static::MESSAGE_TYPE_REPLY][$requestId] = $handler; $m = $this->bareMessage(static::MESSAGE_TYPE_REQUEST); $m->RequestClientId = $requestClientId; $m->RequestId = $requestId; $m->Payload = $payload; $this->send($m); }
[ "public", "function", "request", "(", "$", "requestClientId", ",", "Array", "$", "payload", ",", "Closure", "$", "handler", ")", "{", "// generate a new requestId", "$", "requestId", "=", "$", "this", "->", "uuid", "(", ")", ";", "// store the handler", "$", ...
Make a request to a client @param string $requestClientId the client to send the request to @param Array $payload the payload to send to the client @param Closure $handler the reply handler @return void
[ "Make", "a", "request", "to", "a", "client" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L194-L208
train
dronemill/eventsocket-client-php
src/Client.php
Client.emit
public function emit($event, Array $payload) { $m = $this->bareMessage(static::MESSAGE_TYPE_STANDARD); $m->Event = $event; $m->Payload = $payload; $this->send($m); }
php
public function emit($event, Array $payload) { $m = $this->bareMessage(static::MESSAGE_TYPE_STANDARD); $m->Event = $event; $m->Payload = $payload; $this->send($m); }
[ "public", "function", "emit", "(", "$", "event", ",", "Array", "$", "payload", ")", "{", "$", "m", "=", "$", "this", "->", "bareMessage", "(", "static", "::", "MESSAGE_TYPE_STANDARD", ")", ";", "$", "m", "->", "Event", "=", "$", "event", ";", "$", ...
Emit a given event @param string $event the event to event to @param Array $payload the payload to send @return void
[ "Emit", "a", "given", "event" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L217-L224
train
dronemill/eventsocket-client-php
src/Client.php
Client.serverRequest
protected function serverRequest($path, $context) { if (strpos($path, '/') === 0) { $path = substr($path, 1); } $url = sprintf('http://%s/%s', $this->serverUrl, $path); $context = stream_context_create($context); $result = @file_get_contents($url, false, $context); if ($result === false) { throw new ClientException('Failed connecting to ' . $url); } if (($result = json_decode($result)) === false) { throw new ClientException("Failed decoding json response from server"); } if (empty($result)) { throw new ClientException("Did not receive a valid client instance"); } return $result; }
php
protected function serverRequest($path, $context) { if (strpos($path, '/') === 0) { $path = substr($path, 1); } $url = sprintf('http://%s/%s', $this->serverUrl, $path); $context = stream_context_create($context); $result = @file_get_contents($url, false, $context); if ($result === false) { throw new ClientException('Failed connecting to ' . $url); } if (($result = json_decode($result)) === false) { throw new ClientException("Failed decoding json response from server"); } if (empty($result)) { throw new ClientException("Did not receive a valid client instance"); } return $result; }
[ "protected", "function", "serverRequest", "(", "$", "path", ",", "$", "context", ")", "{", "if", "(", "strpos", "(", "$", "path", ",", "'/'", ")", "===", "0", ")", "{", "$", "path", "=", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "$",...
Execute a request against the server @param string $path the server path @param array $context contextual array for stream_context_create @return stdClass the decoded json body
[ "Execute", "a", "request", "against", "the", "server" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L286-L314
train
dronemill/eventsocket-client-php
src/Client.php
Client.connectWs
protected function connectWs() { $wsUrl = sprintf('ws://%s/v1/clients/%s/ws', $this->serverUrl, $this->getId()); $this->ws = new WebsocketClient($wsUrl, ['timeout' => 30]); $this->ws->setTimeout(30); }
php
protected function connectWs() { $wsUrl = sprintf('ws://%s/v1/clients/%s/ws', $this->serverUrl, $this->getId()); $this->ws = new WebsocketClient($wsUrl, ['timeout' => 30]); $this->ws->setTimeout(30); }
[ "protected", "function", "connectWs", "(", ")", "{", "$", "wsUrl", "=", "sprintf", "(", "'ws://%s/v1/clients/%s/ws'", ",", "$", "this", "->", "serverUrl", ",", "$", "this", "->", "getId", "(", ")", ")", ";", "$", "this", "->", "ws", "=", "new", "Websoc...
Open the websocket connection to the eventsocket server @return void
[ "Open", "the", "websocket", "connection", "to", "the", "eventsocket", "server" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L321-L327
train
dronemill/eventsocket-client-php
src/Client.php
Client.bareMessage
protected function bareMessage($type) { $m = [ 'MessageType' => $type, 'Event' => null, 'RequestId' => null, 'ReplyClientId' => null, 'RequestClientId' => null, 'Payload' => [], 'Error' => null, ]; return (object) $m; }
php
protected function bareMessage($type) { $m = [ 'MessageType' => $type, 'Event' => null, 'RequestId' => null, 'ReplyClientId' => null, 'RequestClientId' => null, 'Payload' => [], 'Error' => null, ]; return (object) $m; }
[ "protected", "function", "bareMessage", "(", "$", "type", ")", "{", "$", "m", "=", "[", "'MessageType'", "=>", "$", "type", ",", "'Event'", "=>", "null", ",", "'RequestId'", "=>", "null", ",", "'ReplyClientId'", "=>", "null", ",", "'RequestClientId'", "=>"...
Instantiate a new message @param int $type the message tyoe @return stdClass the new instance
[ "Instantiate", "a", "new", "message" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L367-L380
train
dronemill/eventsocket-client-php
src/Client.php
Client.send
protected function send($message) { $message = $this->encodeMessage($message); $this->ws->send($message); }
php
protected function send($message) { $message = $this->encodeMessage($message); $this->ws->send($message); }
[ "protected", "function", "send", "(", "$", "message", ")", "{", "$", "message", "=", "$", "this", "->", "encodeMessage", "(", "$", "message", ")", ";", "$", "this", "->", "ws", "->", "send", "(", "$", "message", ")", ";", "}" ]
Send a Message @param string $message the message to send @return void
[ "Send", "a", "Message" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L388-L392
train
dronemill/eventsocket-client-php
src/Client.php
Client.injest
protected function injest($message) { switch($message->MessageType) { case static::MESSAGE_TYPE_BROADCAST: $this->handleBroadcast($message); break; case static::MESSAGE_TYPE_STANDARD: $this->handleStandard($message); break; case static::MESSAGE_TYPE_REQUEST: $this->handleRequest($message); break; case static::MESSAGE_TYPE_REPLY: $this->handleReply($message); break; default: throw new ClientException('Unknown MessageType: ' . var_export($message->MessageType, true)); } }
php
protected function injest($message) { switch($message->MessageType) { case static::MESSAGE_TYPE_BROADCAST: $this->handleBroadcast($message); break; case static::MESSAGE_TYPE_STANDARD: $this->handleStandard($message); break; case static::MESSAGE_TYPE_REQUEST: $this->handleRequest($message); break; case static::MESSAGE_TYPE_REPLY: $this->handleReply($message); break; default: throw new ClientException('Unknown MessageType: ' . var_export($message->MessageType, true)); } }
[ "protected", "function", "injest", "(", "$", "message", ")", "{", "switch", "(", "$", "message", "->", "MessageType", ")", "{", "case", "static", "::", "MESSAGE_TYPE_BROADCAST", ":", "$", "this", "->", "handleBroadcast", "(", "$", "message", ")", ";", "bre...
Injest, and route an incomming message @param stdClass $message the incomming message @return void
[ "Injest", "and", "route", "an", "incomming", "message" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L400-L419
train
dronemill/eventsocket-client-php
src/Client.php
Client.handleReply
protected function handleReply($message) { // if we dont have a handler for this request, then something is wrong if (!array_key_exists($message->RequestId, $this->handlers[static::MESSAGE_TYPE_REPLY])) { throw new ClientException("Request handler not found"); } // handle the event $this->handlers[static::MESSAGE_TYPE_REPLY][$message->RequestId]($message); // cleanup the handler, as it is no longer needed unset($this->handlers[static::MESSAGE_TYPE_REPLY][$message->RequestId]); }
php
protected function handleReply($message) { // if we dont have a handler for this request, then something is wrong if (!array_key_exists($message->RequestId, $this->handlers[static::MESSAGE_TYPE_REPLY])) { throw new ClientException("Request handler not found"); } // handle the event $this->handlers[static::MESSAGE_TYPE_REPLY][$message->RequestId]($message); // cleanup the handler, as it is no longer needed unset($this->handlers[static::MESSAGE_TYPE_REPLY][$message->RequestId]); }
[ "protected", "function", "handleReply", "(", "$", "message", ")", "{", "// if we dont have a handler for this request, then something is wrong", "if", "(", "!", "array_key_exists", "(", "$", "message", "->", "RequestId", ",", "$", "this", "->", "handlers", "[", "stati...
Handle an incomming reply @param stdClass $message the request message @return void
[ "Handle", "an", "incomming", "reply" ]
3e10af53e732432f7974eea5168e8b34817defc1
https://github.com/dronemill/eventsocket-client-php/blob/3e10af53e732432f7974eea5168e8b34817defc1/src/Client.php#L478-L491
train
lasallecrm/lasallecrm-l5-lasallecrmapi-pkg
src/Repositories/BaseRepository.php
BaseRepository.getFirstWorkEmail
public function getFirstWorkEmail($id) { $people = $this->model->findOrfail($id); // The first email that is type "work" foreach ($people->email as $email) { if ($email->email_type_id == 3) { return $email->title; } } return "there is no email address"; }
php
public function getFirstWorkEmail($id) { $people = $this->model->findOrfail($id); // The first email that is type "work" foreach ($people->email as $email) { if ($email->email_type_id == 3) { return $email->title; } } return "there is no email address"; }
[ "public", "function", "getFirstWorkEmail", "(", "$", "id", ")", "{", "$", "people", "=", "$", "this", "->", "model", "->", "findOrfail", "(", "$", "id", ")", ";", "// The first email that is type \"work\"", "foreach", "(", "$", "people", "->", "email", "as",...
Get the first work email found for a specific People ID @param int $id PeopleID @return text
[ "Get", "the", "first", "work", "email", "found", "for", "a", "specific", "People", "ID" ]
6ef0eb3a9158fd2bc31b0aa570d94eddb96e10cb
https://github.com/lasallecrm/lasallecrm-l5-lasallecrmapi-pkg/blob/6ef0eb3a9158fd2bc31b0aa570d94eddb96e10cb/src/Repositories/BaseRepository.php#L118-L131
train
lasallecrm/lasallecrm-l5-lasallecrmapi-pkg
src/Repositories/BaseRepository.php
BaseRepository.getFirstWorkTelephone
public function getFirstWorkTelephone($id) { $people = $this->model->findOrfail($id); // The first telephone number that is they type "work" foreach ($people->telephone as $telephone) { if ($telephone->telephone_type_id == 1) { return $telephone->title; } } return "there is no telephone number"; }
php
public function getFirstWorkTelephone($id) { $people = $this->model->findOrfail($id); // The first telephone number that is they type "work" foreach ($people->telephone as $telephone) { if ($telephone->telephone_type_id == 1) { return $telephone->title; } } return "there is no telephone number"; }
[ "public", "function", "getFirstWorkTelephone", "(", "$", "id", ")", "{", "$", "people", "=", "$", "this", "->", "model", "->", "findOrfail", "(", "$", "id", ")", ";", "// The first telephone number that is they type \"work\"", "foreach", "(", "$", "people", "->"...
Get the first work telephone number found for a specific People ID @param int $id PeopleID @return text
[ "Get", "the", "first", "work", "telephone", "number", "found", "for", "a", "specific", "People", "ID" ]
6ef0eb3a9158fd2bc31b0aa570d94eddb96e10cb
https://github.com/lasallecrm/lasallecrm-l5-lasallecrmapi-pkg/blob/6ef0eb3a9158fd2bc31b0aa570d94eddb96e10cb/src/Repositories/BaseRepository.php#L140-L153
train
xinc-develop/xinc-core
src/Engine/Base.php
Base.setupBuildProperties
protected function setupBuildProperties(BuildInterface $build) { $project = $build->getProject(); $build->setProperty('project.name', $project->getName()); $build->setProperty('build.number', $build->getNumber()); $build->setProperty('build.label', $build->getLabel()); }
php
protected function setupBuildProperties(BuildInterface $build) { $project = $build->getProject(); $build->setProperty('project.name', $project->getName()); $build->setProperty('build.number', $build->getNumber()); $build->setProperty('build.label', $build->getLabel()); }
[ "protected", "function", "setupBuildProperties", "(", "BuildInterface", "$", "build", ")", "{", "$", "project", "=", "$", "build", "->", "getProject", "(", ")", ";", "$", "build", "->", "setProperty", "(", "'project.name'", ",", "$", "project", "->", "getNam...
copies some basic informations to the build object. @param Xinc::Core::Build::BuildInterface
[ "copies", "some", "basic", "informations", "to", "the", "build", "object", "." ]
4bb69a6afe19e1186950a3122cbfe0989823e0d6
https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Engine/Base.php#L81-L87
train
xinc-develop/xinc-core
src/Engine/Base.php
Base.validateTask
protected function validateTask($taskObject) { try { if (!$taskObject->validate($msg)) { $this->log->warn("Task {$taskObject->getName()} is invalid.". ($msg ? "\nError message: $msg" : '') ); return false; } return true; } catch (MalformedConfigException $e) { $this->log->error("Error in task {$taskObject->getName()} configuration: ". $e->getMessage() ); return false; } }
php
protected function validateTask($taskObject) { try { if (!$taskObject->validate($msg)) { $this->log->warn("Task {$taskObject->getName()} is invalid.". ($msg ? "\nError message: $msg" : '') ); return false; } return true; } catch (MalformedConfigException $e) { $this->log->error("Error in task {$taskObject->getName()} configuration: ". $e->getMessage() ); return false; } }
[ "protected", "function", "validateTask", "(", "$", "taskObject", ")", "{", "try", "{", "if", "(", "!", "$", "taskObject", "->", "validate", "(", "$", "msg", ")", ")", "{", "$", "this", "->", "log", "->", "warn", "(", "\"Task {$taskObject->getName()} is inv...
Calls the validate method of a task.
[ "Calls", "the", "validate", "method", "of", "a", "task", "." ]
4bb69a6afe19e1186950a3122cbfe0989823e0d6
https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Engine/Base.php#L138-L157
train
aedart/model
src/Traits/Strings/NicknameTrait.php
NickNameTrait.getNickName
public function getNickName() : ?string { if ( ! $this->hasNickName()) { $this->setNickName($this->getDefaultNickName()); } return $this->nickName; }
php
public function getNickName() : ?string { if ( ! $this->hasNickName()) { $this->setNickName($this->getDefaultNickName()); } return $this->nickName; }
[ "public", "function", "getNickName", "(", ")", ":", "?", "string", "{", "if", "(", "!", "$", "this", "->", "hasNickName", "(", ")", ")", "{", "$", "this", "->", "setNickName", "(", "$", "this", "->", "getDefaultNickName", "(", ")", ")", ";", "}", "...
Get nick name If no "nick name" value has been set, this method will set and return a default "nick name" value, if any such value is available @see getDefaultNickName() @return string|null nick name or null if no nick name has been set
[ "Get", "nick", "name" ]
9a562c1c53a276d01ace0ab71f5305458bea542f
https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/NicknameTrait.php#L48-L54
train
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/ongletObject.class.php
OngletObject.init
function init($idBuilder="0", $tabOnglets=array()) { $this->ongletsArray=$tabOnglets; $this->typeOngletsArray=array(); $this->optionsOngletParType = array(); $this->idOngletBuilder=$idBuilder; $this->largeurTotale=680; $this->largeurEtiquette=150; $this->numOngletSelected=0; $this->champHiddenCourant=""; $this->isContours = true; $this->isAncreOnglet = true; $this->isSpaceInLibelle = true; $this->styleContenu = ""; }
php
function init($idBuilder="0", $tabOnglets=array()) { $this->ongletsArray=$tabOnglets; $this->typeOngletsArray=array(); $this->optionsOngletParType = array(); $this->idOngletBuilder=$idBuilder; $this->largeurTotale=680; $this->largeurEtiquette=150; $this->numOngletSelected=0; $this->champHiddenCourant=""; $this->isContours = true; $this->isAncreOnglet = true; $this->isSpaceInLibelle = true; $this->styleContenu = ""; }
[ "function", "init", "(", "$", "idBuilder", "=", "\"0\"", ",", "$", "tabOnglets", "=", "array", "(", ")", ")", "{", "$", "this", "->", "ongletsArray", "=", "$", "tabOnglets", ";", "$", "this", "->", "typeOngletsArray", "=", "array", "(", ")", ";", "$"...
Pour PHP 4 @param string $idBuilder ? @param array $tabOnglets ? @return void
[ "Pour", "PHP", "4" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/ongletObject.class.php#L81-L95
train
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/ongletObject.class.php
OngletObject.addContent
function addContent( $ongletName="default", $content="", $isSelected=false, $type="default", $optionsParType="" ) { $this->ongletsArray[$ongletName]=$content; $this->typeOngletsArray[$ongletName]=$type; $this->optionsOngletParType[$ongletName]=$optionsParType; $this->listeOngletJSNameArray[]=$this->convertIntituleOnglet($ongletName). (count($this->ongletsArray)-1).$this->idOngletBuilder; if ($isSelected && count($this->ongletsArray)>0) { $this->numOngletSelected=count($this->ongletsArray)-1; } }
php
function addContent( $ongletName="default", $content="", $isSelected=false, $type="default", $optionsParType="" ) { $this->ongletsArray[$ongletName]=$content; $this->typeOngletsArray[$ongletName]=$type; $this->optionsOngletParType[$ongletName]=$optionsParType; $this->listeOngletJSNameArray[]=$this->convertIntituleOnglet($ongletName). (count($this->ongletsArray)-1).$this->idOngletBuilder; if ($isSelected && count($this->ongletsArray)>0) { $this->numOngletSelected=count($this->ongletsArray)-1; } }
[ "function", "addContent", "(", "$", "ongletName", "=", "\"default\"", ",", "$", "content", "=", "\"\"", ",", "$", "isSelected", "=", "false", ",", "$", "type", "=", "\"default\"", ",", "$", "optionsParType", "=", "\"\"", ")", "{", "$", "this", "->", "o...
Ajoute du contenu @param string $ongletName Nom de l'onglet @param string $content Contenu @param bool $isSelected L'onglet est-il sélectionné ? @param string $type Type @param string $optionsParType ? @return void
[ "Ajoute", "du", "contenu" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/ongletObject.class.php#L108-L121
train
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/ongletObject.class.php
OngletObject.getHTMLNoDiv
function getHTMLNoDiv() { $html=""; if ($this->getCountOnglets()>0) { /* * Assignation des styles en dur : a changer à terme, * les styles sont les memes que pour le site en ligne * => a ajouter dans la feuille de style * */ if (isset($this->stylesOnglets) && $this->stylesOnglets!='') { $html=$this->stylesOnglets; } $html.="<table width='".$this->largeurTotale. "' cellspacing=0 cellpadding=0 border=0><tr><td>"; $html.="<a name='onglet'></a>"; $html.="<table cellspacing=0 cellpadding=0 border=0><tr>"; // construction du tableau contenant les intitules $i=0; foreach ($this->ongletsArray as $fieldName => $fieldValue) { $className='OngletOff'; if ($i==$this->numOngletSelected) { $className='OngletOn'; } $html.="<td height='25' width='".$this->largeurEtiquette. "' class='".$className. "' style='border-left:1px solid #000000;'>&nbsp;&nbsp;&nbsp;"; /* * Lien le champs hiddenCourant est un champs cache du formulaire * permettant de stocker l'onglet actif courant * */ /*if ($this->champHiddenCourant<>"") { $html.="document.getElementById('".$this->champHiddenCourant."'). * value='".$i."';"; } */ $html.=$fieldName."&nbsp;&nbsp;&nbsp;</td><td width='4' ". "style='border-bottom:1px solid #000000;'>&nbsp</td>"; $i++; } $styleContenu = ""; if (isset($this->styleContenu)) { $styleContenu = $this->styleContenu; } $html.="<td width='". ( $this->largeurTotale - ($i * ($this->largeurEtiquette+4))). "' style='border-bottom:1px solid #000000;'>&nbsp;</td>"; $html.="</tr></table></td></tr><tr><td ". "style='border-left:1px solid #000000;border-right:1px solid #000000;". "border-bottom:1px solid #000000;padding:5px;".$styleContenu."'>"; // construction des contenus $i=0; foreach ($this->ongletsArray as $fieldName => $fieldValue) { if ($i==$this->numOngletSelected) { // cas ou il n'y a pas de photo dans la liste $html.=$fieldValue; } $i++; } $html.="</td></tr></table>"; } return $html; }
php
function getHTMLNoDiv() { $html=""; if ($this->getCountOnglets()>0) { /* * Assignation des styles en dur : a changer à terme, * les styles sont les memes que pour le site en ligne * => a ajouter dans la feuille de style * */ if (isset($this->stylesOnglets) && $this->stylesOnglets!='') { $html=$this->stylesOnglets; } $html.="<table width='".$this->largeurTotale. "' cellspacing=0 cellpadding=0 border=0><tr><td>"; $html.="<a name='onglet'></a>"; $html.="<table cellspacing=0 cellpadding=0 border=0><tr>"; // construction du tableau contenant les intitules $i=0; foreach ($this->ongletsArray as $fieldName => $fieldValue) { $className='OngletOff'; if ($i==$this->numOngletSelected) { $className='OngletOn'; } $html.="<td height='25' width='".$this->largeurEtiquette. "' class='".$className. "' style='border-left:1px solid #000000;'>&nbsp;&nbsp;&nbsp;"; /* * Lien le champs hiddenCourant est un champs cache du formulaire * permettant de stocker l'onglet actif courant * */ /*if ($this->champHiddenCourant<>"") { $html.="document.getElementById('".$this->champHiddenCourant."'). * value='".$i."';"; } */ $html.=$fieldName."&nbsp;&nbsp;&nbsp;</td><td width='4' ". "style='border-bottom:1px solid #000000;'>&nbsp</td>"; $i++; } $styleContenu = ""; if (isset($this->styleContenu)) { $styleContenu = $this->styleContenu; } $html.="<td width='". ( $this->largeurTotale - ($i * ($this->largeurEtiquette+4))). "' style='border-bottom:1px solid #000000;'>&nbsp;</td>"; $html.="</tr></table></td></tr><tr><td ". "style='border-left:1px solid #000000;border-right:1px solid #000000;". "border-bottom:1px solid #000000;padding:5px;".$styleContenu."'>"; // construction des contenus $i=0; foreach ($this->ongletsArray as $fieldName => $fieldValue) { if ($i==$this->numOngletSelected) { // cas ou il n'y a pas de photo dans la liste $html.=$fieldValue; } $i++; } $html.="</td></tr></table>"; } return $html; }
[ "function", "getHTMLNoDiv", "(", ")", "{", "$", "html", "=", "\"\"", ";", "if", "(", "$", "this", "->", "getCountOnglets", "(", ")", ">", "0", ")", "{", "/*\n * Assignation des styles en dur : a changer à terme,\n * les styles sont les memes que po...
Si on affiche les onglets avec cette fonction, c'est un fonctionnement different, le contenu n'est pas dans les divs, et les liens sur les onglets sont des url initialisation : init(0) addContent("onglet1", "texte onglet1", true) Ddans le contenu de l'onglet selectionné on ne va mettre que le code de l'onglet addContent("onglet2", "<a href='onglet2'>onglet2</a>", false) Dans l'onglet qui n'est pas selectionné, on met un lien vers la page contenant le code html de l'onglet @return string HTML
[ "Si", "on", "affiche", "les", "onglets", "avec", "cette", "fonction", "c", "est", "un", "fonctionnement", "different", "le", "contenu", "n", "est", "pas", "dans", "les", "divs", "et", "les", "liens", "sur", "les", "onglets", "sont", "des", "url" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/ongletObject.class.php#L213-L284
train
jetwaves/edit-array-in-file
src/EditArrayInFileEditor.php
Editor.find
public function find($keyword, $comp = null, $type = self::FIND_TYPE_KEY_ONLY){ $this->_targetLineNumber = null; $items = $this->getTargetLines(); foreach ($items as $lineNumber => $line){ $line = trim(trim($line),','); $arr = explode('=>', $line); foreach ($arr as $idx => $item){ $arr[$idx] = trim($item); } $key = $arr[0]; if(count($arr)>1){ $val = $arr[1]; } else{ $val = $arr[0]; } $key = str_replace("'","", $key); $val = str_replace("'","", $val); // echo ' '.__method__.'() line:'.__line__.' $key = '.print_r($key, true).PHP_EOL; // echo ' '.__method__.'() line:'.__line__.' $val = '.print_r($val, true).PHP_EOL; $ret = null; switch ($type){ case self::FIND_TYPE_ALL: if($key == $keyword || $val == $comp ){ $this->_targetLineNumber = $lineNumber; return $val; } break; case self::FIND_TYPE_KEY_ONLY: if($key == $keyword){ $this->_targetLineNumber = $lineNumber; return $val; } break; case self::FIND_TYPE_VALUE_ONLY: if($val == $keyword){ $this->_targetLineNumber = $lineNumber; return $val; } break; } } return null; }
php
public function find($keyword, $comp = null, $type = self::FIND_TYPE_KEY_ONLY){ $this->_targetLineNumber = null; $items = $this->getTargetLines(); foreach ($items as $lineNumber => $line){ $line = trim(trim($line),','); $arr = explode('=>', $line); foreach ($arr as $idx => $item){ $arr[$idx] = trim($item); } $key = $arr[0]; if(count($arr)>1){ $val = $arr[1]; } else{ $val = $arr[0]; } $key = str_replace("'","", $key); $val = str_replace("'","", $val); // echo ' '.__method__.'() line:'.__line__.' $key = '.print_r($key, true).PHP_EOL; // echo ' '.__method__.'() line:'.__line__.' $val = '.print_r($val, true).PHP_EOL; $ret = null; switch ($type){ case self::FIND_TYPE_ALL: if($key == $keyword || $val == $comp ){ $this->_targetLineNumber = $lineNumber; return $val; } break; case self::FIND_TYPE_KEY_ONLY: if($key == $keyword){ $this->_targetLineNumber = $lineNumber; return $val; } break; case self::FIND_TYPE_VALUE_ONLY: if($val == $keyword){ $this->_targetLineNumber = $lineNumber; return $val; } break; } } return null; }
[ "public", "function", "find", "(", "$", "keyword", ",", "$", "comp", "=", "null", ",", "$", "type", "=", "self", "::", "FIND_TYPE_KEY_ONLY", ")", "{", "$", "this", "->", "_targetLineNumber", "=", "null", ";", "$", "items", "=", "$", "this", "->", "ge...
if the target array contains a key or value
[ "if", "the", "target", "array", "contains", "a", "key", "or", "value" ]
37bd60a7559c3c83e5d2f1fb080571b8cd0319dc
https://github.com/jetwaves/edit-array-in-file/blob/37bd60a7559c3c83e5d2f1fb080571b8cd0319dc/src/EditArrayInFileEditor.php#L139-L182
train
jetwaves/edit-array-in-file
src/EditArrayInFileEditor.php
Editor.save
public function save(){ $this->_contentArray = array_merge($this->_codesBeforeEditArea, $this->_editArea, $this->_codesAfterEditArea); return $this; }
php
public function save(){ $this->_contentArray = array_merge($this->_codesBeforeEditArea, $this->_editArea, $this->_codesAfterEditArea); return $this; }
[ "public", "function", "save", "(", ")", "{", "$", "this", "->", "_contentArray", "=", "array_merge", "(", "$", "this", "->", "_codesBeforeEditArea", ",", "$", "this", "->", "_editArea", ",", "$", "this", "->", "_codesAfterEditArea", ")", ";", "return", "$"...
reconstruct the complete file in the memory
[ "reconstruct", "the", "complete", "file", "in", "the", "memory" ]
37bd60a7559c3c83e5d2f1fb080571b8cd0319dc
https://github.com/jetwaves/edit-array-in-file/blob/37bd60a7559c3c83e5d2f1fb080571b8cd0319dc/src/EditArrayInFileEditor.php#L301-L304
train
webriq/core
module/Tag/src/Grid/Tag/Form/View/Helper/FormTagList.php
FormTagList.getName
protected static function getName( ElementInterface $element ) { $name = $element->getName(); if ( $name === null || $name === '' ) { throw new Exception\DomainException( sprintf( '%s requires that the element has an assigned name; none discovered', __METHOD__ ) ); } return $name . '[]'; }
php
protected static function getName( ElementInterface $element ) { $name = $element->getName(); if ( $name === null || $name === '' ) { throw new Exception\DomainException( sprintf( '%s requires that the element has an assigned name; none discovered', __METHOD__ ) ); } return $name . '[]'; }
[ "protected", "static", "function", "getName", "(", "ElementInterface", "$", "element", ")", "{", "$", "name", "=", "$", "element", "->", "getName", "(", ")", ";", "if", "(", "$", "name", "===", "null", "||", "$", "name", "===", "''", ")", "{", "throw...
Get element name @param ElementInterface $element @throws Exception\DomainException @return string
[ "Get", "element", "name" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Tag/src/Grid/Tag/Form/View/Helper/FormTagList.php#L106-L119
train
laradic/service-provider
src/Plugins/Commands.php
Commands.startCommandsPlugin
protected function startCommandsPlugin($app) { $this->onRegister('commands', function ($app) { /** @var \Illuminate\Foundation\Application $app */ // Commands if ($app->runningInConsole()) { foreach ($this->findCommands as $path) { $dir = path_get_directory((new ReflectionClass(get_called_class()))->getFileName()); $classes = $this->findCommandsIn(path_join($dir, $path), $this->findCommandsRecursive); $this->commands = array_merge($this->commands, $classes); } if (is_array($this->commands) && count($this->commands) > 0) { $commands = []; foreach ($this->commands as $k => $v) { if (is_string($k)) { $app[ $this->commandPrefix.$k ] = $app->share(function ($app) use ($k, $v) { return $app->build($v); }); $commands[] = $this->commandPrefix.$k; } else { $commands[] = $v; } } $this->commands($commands); } } }); }
php
protected function startCommandsPlugin($app) { $this->onRegister('commands', function ($app) { /** @var \Illuminate\Foundation\Application $app */ // Commands if ($app->runningInConsole()) { foreach ($this->findCommands as $path) { $dir = path_get_directory((new ReflectionClass(get_called_class()))->getFileName()); $classes = $this->findCommandsIn(path_join($dir, $path), $this->findCommandsRecursive); $this->commands = array_merge($this->commands, $classes); } if (is_array($this->commands) && count($this->commands) > 0) { $commands = []; foreach ($this->commands as $k => $v) { if (is_string($k)) { $app[ $this->commandPrefix.$k ] = $app->share(function ($app) use ($k, $v) { return $app->build($v); }); $commands[] = $this->commandPrefix.$k; } else { $commands[] = $v; } } $this->commands($commands); } } }); }
[ "protected", "function", "startCommandsPlugin", "(", "$", "app", ")", "{", "$", "this", "->", "onRegister", "(", "'commands'", ",", "function", "(", "$", "app", ")", "{", "/** @var \\Illuminate\\Foundation\\Application $app */", "// Commands", "if", "(", "$", "app...
startCommandsPlugin method. @param \Illuminate\Foundation\Application $app
[ "startCommandsPlugin", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Commands.php#L76-L105
train
laradic/service-provider
src/Plugins/Commands.php
Commands.findCommandsIn
protected function findCommandsIn($path, $recursive = false) { $classes = []; foreach ($this->findCommandsFiles($path) as $filePath) { //$class = $classFinder->findClass($filePath); $class = Util::getClassNameFromFile($filePath); if ($class !== null) { $namespace = Util::getNamespaceFromFile($filePath); if ($namespace !== null) { $class = "$namespace\\$class"; } $class = Str::removeLeft($class, '\\'); $parents = class_parents($class); if ($this->findCommandsExtending !== null && in_array($this->findCommandsExtending, $parents, true) === false) { continue; } $ref = new \ReflectionClass($class); if ($ref->isAbstract()) { continue; } $classes[] = Str::removeLeft($class, '\\'); } } return $classes; }
php
protected function findCommandsIn($path, $recursive = false) { $classes = []; foreach ($this->findCommandsFiles($path) as $filePath) { //$class = $classFinder->findClass($filePath); $class = Util::getClassNameFromFile($filePath); if ($class !== null) { $namespace = Util::getNamespaceFromFile($filePath); if ($namespace !== null) { $class = "$namespace\\$class"; } $class = Str::removeLeft($class, '\\'); $parents = class_parents($class); if ($this->findCommandsExtending !== null && in_array($this->findCommandsExtending, $parents, true) === false) { continue; } $ref = new \ReflectionClass($class); if ($ref->isAbstract()) { continue; } $classes[] = Str::removeLeft($class, '\\'); } } return $classes; }
[ "protected", "function", "findCommandsIn", "(", "$", "path", ",", "$", "recursive", "=", "false", ")", "{", "$", "classes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "findCommandsFiles", "(", "$", "path", ")", "as", "$", "filePath", ")", ...
findCommandsIn method. @param $path @param bool $recursive @return array
[ "findCommandsIn", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Commands.php#L115-L143
train
rexxars/joindin-client
library/JoindIn/Client.php
Client.getEventTalks
public function getEventTalks($eventId, array $options = array()) { $talks = $this->runCommand( 'event.talks.get', array('eventId' => $eventId), $options ); return $this->assignIdsFromUri($talks); }
php
public function getEventTalks($eventId, array $options = array()) { $talks = $this->runCommand( 'event.talks.get', array('eventId' => $eventId), $options ); return $this->assignIdsFromUri($talks); }
[ "public", "function", "getEventTalks", "(", "$", "eventId", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "talks", "=", "$", "this", "->", "runCommand", "(", "'event.talks.get'", ",", "array", "(", "'eventId'", "=>", "$", "eventId"...
Get an array of talks for a given event @param array $options Options for this command, see client.json @return array Array of talks
[ "Get", "an", "array", "of", "talks", "for", "a", "given", "event" ]
7508830f787125218e80b93d39d8a1e54d290130
https://github.com/rexxars/joindin-client/blob/7508830f787125218e80b93d39d8a1e54d290130/library/JoindIn/Client.php#L89-L97
train
rexxars/joindin-client
library/JoindIn/Client.php
Client.factory
public static function factory($config = array()) { $defaults = array( 'base_url' => self::API_URL, 'version' => 'v2.1', 'command.params' => array( 'command.on_complete' => function($command) { $response = $command->getResult(); // We don't need the meta blocks unset($response['meta']); // If we're down to a single element (events, talks etc) // return only this element if (count($response) == 1) { $command->setResult(reset($response)); } } ) ); $required = array( 'base_url', 'version', ); $config = Collection::fromConfig($config, $defaults, $required); $client = new self($config->get('base_url'), $config); // Attach a service description to the client $description = ServiceDescription::factory(__DIR__ . '/client.json'); $client->setDescription($description); return $client; }
php
public static function factory($config = array()) { $defaults = array( 'base_url' => self::API_URL, 'version' => 'v2.1', 'command.params' => array( 'command.on_complete' => function($command) { $response = $command->getResult(); // We don't need the meta blocks unset($response['meta']); // If we're down to a single element (events, talks etc) // return only this element if (count($response) == 1) { $command->setResult(reset($response)); } } ) ); $required = array( 'base_url', 'version', ); $config = Collection::fromConfig($config, $defaults, $required); $client = new self($config->get('base_url'), $config); // Attach a service description to the client $description = ServiceDescription::factory(__DIR__ . '/client.json'); $client->setDescription($description); return $client; }
[ "public", "static", "function", "factory", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "defaults", "=", "array", "(", "'base_url'", "=>", "self", "::", "API_URL", ",", "'version'", "=>", "'v2.1'", ",", "'command.params'", "=>", "array", "(...
Factory method to create a new client. @param array|Collection $config Configuration data @return Client
[ "Factory", "method", "to", "create", "a", "new", "client", "." ]
7508830f787125218e80b93d39d8a1e54d290130
https://github.com/rexxars/joindin-client/blob/7508830f787125218e80b93d39d8a1e54d290130/library/JoindIn/Client.php#L185-L219
train
rexxars/joindin-client
library/JoindIn/Client.php
Client.runCommand
protected function runCommand($command, array $defaultOptions = array(), array $options = array()) { $command = $this->getCommand($command, array_merge( $defaultOptions, $options )); $command->execute(); return $command->getResult(); }
php
protected function runCommand($command, array $defaultOptions = array(), array $options = array()) { $command = $this->getCommand($command, array_merge( $defaultOptions, $options )); $command->execute(); return $command->getResult(); }
[ "protected", "function", "runCommand", "(", "$", "command", ",", "array", "$", "defaultOptions", "=", "array", "(", ")", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "command", "=", "$", "this", "->", "getCommand", "(", "$", "...
Run a command by the given name, merging default and passed options @param string $command Name of command to run @param array $defaultOptions Default options for this command @param array $options User-specified options to merge @return mixed
[ "Run", "a", "command", "by", "the", "given", "name", "merging", "default", "and", "passed", "options" ]
7508830f787125218e80b93d39d8a1e54d290130
https://github.com/rexxars/joindin-client/blob/7508830f787125218e80b93d39d8a1e54d290130/library/JoindIn/Client.php#L229-L237
train
rexxars/joindin-client
library/JoindIn/Client.php
Client.assignIdsFromUri
protected function assignIdsFromUri($entries) { foreach ($entries as &$entry) { $entry['id'] = (int) preg_replace('#.*?(\d+)$#', '$1', $entry['uri']); } return $entries; }
php
protected function assignIdsFromUri($entries) { foreach ($entries as &$entry) { $entry['id'] = (int) preg_replace('#.*?(\d+)$#', '$1', $entry['uri']); } return $entries; }
[ "protected", "function", "assignIdsFromUri", "(", "$", "entries", ")", "{", "foreach", "(", "$", "entries", "as", "&", "$", "entry", ")", "{", "$", "entry", "[", "'id'", "]", "=", "(", "int", ")", "preg_replace", "(", "'#.*?(\\d+)$#'", ",", "'$1'", ","...
Loops through a set of entries, assigning them IDs based on the item URI @param array $entries Entries to assign IDs for @return array
[ "Loops", "through", "a", "set", "of", "entries", "assigning", "them", "IDs", "based", "on", "the", "item", "URI" ]
7508830f787125218e80b93d39d8a1e54d290130
https://github.com/rexxars/joindin-client/blob/7508830f787125218e80b93d39d8a1e54d290130/library/JoindIn/Client.php#L245-L251
train
vdeapps/phpcore-helper
src/Helper.php
Helper.camelCase
public static function camelCase($str, $firstChar = 'lcfirst') { $str = str_replace(['-', '_', '.'], ' ', $str); $str = mb_convert_case($str, MB_CASE_TITLE); $str = str_replace(' ', '', $str); //ucwords('ghjkiol|ghjklo', "|"); if (!function_exists($firstChar)) { $firstChar = 'lcfirst'; } $str = call_user_func($firstChar, $str); return $str; }
php
public static function camelCase($str, $firstChar = 'lcfirst') { $str = str_replace(['-', '_', '.'], ' ', $str); $str = mb_convert_case($str, MB_CASE_TITLE); $str = str_replace(' ', '', $str); //ucwords('ghjkiol|ghjklo', "|"); if (!function_exists($firstChar)) { $firstChar = 'lcfirst'; } $str = call_user_func($firstChar, $str); return $str; }
[ "public", "static", "function", "camelCase", "(", "$", "str", ",", "$", "firstChar", "=", "'lcfirst'", ")", "{", "$", "str", "=", "str_replace", "(", "[", "'-'", ",", "'_'", ",", "'.'", "]", ",", "' '", ",", "$", "str", ")", ";", "$", "str", "=",...
Retourne une chaine en camelCase avec lcfirst|ucfirst @param string $str @param string $firstChar lcfirst|ucfirst default(lcfirst) @return string
[ "Retourne", "une", "chaine", "en", "camelCase", "avec", "lcfirst|ucfirst" ]
838d671b8455b9fce43579d59086903647c4f408
https://github.com/vdeapps/phpcore-helper/blob/838d671b8455b9fce43579d59086903647c4f408/src/Helper.php#L110-L122
train
vdeapps/phpcore-helper
src/Helper.php
Helper.base64Encode
public static function base64Encode($str, $stripEgal = true) { $str64 = base64_encode($str); if ($stripEgal) { return rtrim(strtr($str64, '+/', '-_'), '='); } return $str64; }
php
public static function base64Encode($str, $stripEgal = true) { $str64 = base64_encode($str); if ($stripEgal) { return rtrim(strtr($str64, '+/', '-_'), '='); } return $str64; }
[ "public", "static", "function", "base64Encode", "(", "$", "str", ",", "$", "stripEgal", "=", "true", ")", "{", "$", "str64", "=", "base64_encode", "(", "$", "str", ")", ";", "if", "(", "$", "stripEgal", ")", "{", "return", "rtrim", "(", "strtr", "(",...
base64_decode sans les == de fin @param $str @param bool $stripEgal @return string
[ "base64_decode", "sans", "les", "==", "de", "fin" ]
838d671b8455b9fce43579d59086903647c4f408
https://github.com/vdeapps/phpcore-helper/blob/838d671b8455b9fce43579d59086903647c4f408/src/Helper.php#L132-L140
train
synapsestudios/synapse-base
src/Synapse/Application/UrlGeneratorAwareTrait.php
UrlGeneratorAwareTrait.path
public function path($route, $parameters = array()) { return $this->urlGenerator->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH); }
php
public function path($route, $parameters = array()) { return $this->urlGenerator->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH); }
[ "public", "function", "path", "(", "$", "route", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "urlGenerator", "->", "generate", "(", "$", "route", ",", "$", "parameters", ",", "UrlGeneratorInterface", "::", "ABSO...
Generate a path from the given parameters @param string $route The name of the route @param mixed $parameters An array of parameters @return string The generated path
[ "Generate", "a", "path", "from", "the", "given", "parameters" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Application/UrlGeneratorAwareTrait.php#L31-L34
train
synapsestudios/synapse-base
src/Synapse/Application/UrlGeneratorAwareTrait.php
UrlGeneratorAwareTrait.url
public function url($route, $parameters = array()) { return $this->urlGenerator->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_URL); }
php
public function url($route, $parameters = array()) { return $this->urlGenerator->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_URL); }
[ "public", "function", "url", "(", "$", "route", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "urlGenerator", "->", "generate", "(", "$", "route", ",", "$", "parameters", ",", "UrlGeneratorInterface", "::", "ABSOL...
Generate an absolute URL from the given parameters @param string $route The name of the route @param mixed $parameters An array of parameters @return string The generated URL
[ "Generate", "an", "absolute", "URL", "from", "the", "given", "parameters" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Application/UrlGeneratorAwareTrait.php#L44-L47
train
GustavSoftware/Utils
src/InvalidArgumentException.php
InvalidArgumentException.invalidArgument
public static function invalidArgument( string $class, string $method, string $arg, \Exception $previous = null ): self { return new self( "invalid value of argument \"{$arg}\" in {$class}::{$method}", self::INVALID_ARGUMENT, $previous ); }
php
public static function invalidArgument( string $class, string $method, string $arg, \Exception $previous = null ): self { return new self( "invalid value of argument \"{$arg}\" in {$class}::{$method}", self::INVALID_ARGUMENT, $previous ); }
[ "public", "static", "function", "invalidArgument", "(", "string", "$", "class", ",", "string", "$", "method", ",", "string", "$", "arg", ",", "\\", "Exception", "$", "previous", "=", "null", ")", ":", "self", "{", "return", "new", "self", "(", "\"invalid...
Creates an exception if an invalid argument was given in a method call. @param string $class The containing class @param string $method The method's name @param string $arg The argument's name @param \Exception|null $previous Previous exception @return \Gustav\Utils\InvalidArgumentException The exception
[ "Creates", "an", "exception", "if", "an", "invalid", "argument", "was", "given", "in", "a", "method", "call", "." ]
370131e9baf3477863123ca31972cbbfaaf2f39b
https://github.com/GustavSoftware/Utils/blob/370131e9baf3477863123ca31972cbbfaaf2f39b/src/InvalidArgumentException.php#L53-L64
train
tux-rampage/rampage-php
library/rampage/core/view/helpers/RequireJsHelper.php
RequireJsHelper.setBaseUrl
public function setBaseUrl($url, $replace = true) { if ($replace || !$this->baseUrl) { $this->baseUrl = $url; } return $this; }
php
public function setBaseUrl($url, $replace = true) { if ($replace || !$this->baseUrl) { $this->baseUrl = $url; } return $this; }
[ "public", "function", "setBaseUrl", "(", "$", "url", ",", "$", "replace", "=", "true", ")", "{", "if", "(", "$", "replace", "||", "!", "$", "this", "->", "baseUrl", ")", "{", "$", "this", "->", "baseUrl", "=", "$", "url", ";", "}", "return", "$",...
Set the base URL @see http://requirejs.org/docs/api.html#config-baseUrl @param string $url @param bool $replace Replace the base url if it was already set. @return self
[ "Set", "the", "base", "URL" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/view/helpers/RequireJsHelper.php#L95-L102
train
tux-rampage/rampage-php
library/rampage/core/view/helpers/RequireJsHelper.php
RequireJsHelper.addModule
public function addModule($name, $location, $replace = false) { if ($name == '') { throw new exception\InvalidArgumentException('The require.js module name must not be empty'); } if ($replace || !isset($this->modules[$name])) { $this->modules[$name] = (string)$location; } return $this; }
php
public function addModule($name, $location, $replace = false) { if ($name == '') { throw new exception\InvalidArgumentException('The require.js module name must not be empty'); } if ($replace || !isset($this->modules[$name])) { $this->modules[$name] = (string)$location; } return $this; }
[ "public", "function", "addModule", "(", "$", "name", ",", "$", "location", ",", "$", "replace", "=", "false", ")", "{", "if", "(", "$", "name", "==", "''", ")", "{", "throw", "new", "exception", "\\", "InvalidArgumentException", "(", "'The require.js modul...
Define a require.js module location @see http://requirejs.org/docs/api.html#config-paths @param string $name @param string $location @param bool $replace Replace the module definition if it already exists
[ "Define", "a", "require", ".", "js", "module", "location" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/view/helpers/RequireJsHelper.php#L124-L135
train
tux-rampage/rampage-php
library/rampage/core/view/helpers/RequireJsHelper.php
RequireJsHelper.addPackage
public function addPackage($name, $location = null, $main = null) { $name = (string)$name; if ($name == '') { throw new exception\InvalidArgumentException('The require.js package name must not be empty'); } if (!$location && !$main) { $this->packages[$name] = $name; return $this; } $this->packages[$name] = [ 'name' => $name, ]; if ($location) { $this->packages[$name]['location'] = (string)$location; } if ($main) { $this->packages[$name]['main'] = (string)$main; } return $this; }
php
public function addPackage($name, $location = null, $main = null) { $name = (string)$name; if ($name == '') { throw new exception\InvalidArgumentException('The require.js package name must not be empty'); } if (!$location && !$main) { $this->packages[$name] = $name; return $this; } $this->packages[$name] = [ 'name' => $name, ]; if ($location) { $this->packages[$name]['location'] = (string)$location; } if ($main) { $this->packages[$name]['main'] = (string)$main; } return $this; }
[ "public", "function", "addPackage", "(", "$", "name", ",", "$", "location", "=", "null", ",", "$", "main", "=", "null", ")", "{", "$", "name", "=", "(", "string", ")", "$", "name", ";", "if", "(", "$", "name", "==", "''", ")", "{", "throw", "ne...
Add a package definition. If the package is already defined it will be replaced. @see http://requirejs.org/docs/api.html#packages @param string $name @param string $location @param string $main
[ "Add", "a", "package", "definition", "." ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/view/helpers/RequireJsHelper.php#L147-L173
train
tux-rampage/rampage-php
library/rampage/core/view/helpers/RequireJsHelper.php
RequireJsHelper.addBundle
public function addBundle($name, array $deps) { if ($name == '') { throw new exception\InvalidArgumentException('The require.js bundle name must not be empty'); } $this->bundles[$name] = []; $this->addToBundle($name, $deps); return $this; }
php
public function addBundle($name, array $deps) { if ($name == '') { throw new exception\InvalidArgumentException('The require.js bundle name must not be empty'); } $this->bundles[$name] = []; $this->addToBundle($name, $deps); return $this; }
[ "public", "function", "addBundle", "(", "$", "name", ",", "array", "$", "deps", ")", "{", "if", "(", "$", "name", "==", "''", ")", "{", "throw", "new", "exception", "\\", "InvalidArgumentException", "(", "'The require.js bundle name must not be empty'", ")", "...
Add a new bundle definition. If the bundle is already defined, it will be replaced. @see http://requirejs.org/docs/api.html#config-bundles @param string $name @param array $deps @return self
[ "Add", "a", "new", "bundle", "definition", "." ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/view/helpers/RequireJsHelper.php#L185-L195
train
tux-rampage/rampage-php
library/rampage/core/view/helpers/RequireJsHelper.php
RequireJsHelper.addToBundle
public function addToBundle($name, $deps) { if ($name == '') { throw new exception\InvalidArgumentException('The require.js bundle name must not be empty'); } if (!is_array($deps) && !($deps instanceof \Traversable)) { $deps = [ $deps ]; } if (!isset($this->bundles[$name])) { $this->bundles[$name] = []; } foreach ($deps as $item) { $item = (string)$item; if ($item != '') { $this->bundles[$name][] = $item; } } return $this; }
php
public function addToBundle($name, $deps) { if ($name == '') { throw new exception\InvalidArgumentException('The require.js bundle name must not be empty'); } if (!is_array($deps) && !($deps instanceof \Traversable)) { $deps = [ $deps ]; } if (!isset($this->bundles[$name])) { $this->bundles[$name] = []; } foreach ($deps as $item) { $item = (string)$item; if ($item != '') { $this->bundles[$name][] = $item; } } return $this; }
[ "public", "function", "addToBundle", "(", "$", "name", ",", "$", "deps", ")", "{", "if", "(", "$", "name", "==", "''", ")", "{", "throw", "new", "exception", "\\", "InvalidArgumentException", "(", "'The require.js bundle name must not be empty'", ")", ";", "}"...
Adde dependencies to an existing bundle @see http://requirejs.org/docs/api.html#config-bundles @param string $name @param array|string $deps @return self
[ "Adde", "dependencies", "to", "an", "existing", "bundle" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/view/helpers/RequireJsHelper.php#L205-L228
train
tailored-tunes/mongo-connection-facade
src/TailoredTunes/MongoConnectionFacade/MongoDbConnection.php
MongoDbConnection.connectionString
public function connectionString() { if (empty($this->username) || empty($this->password)) { return sprintf( "mongodb://%s:%d/%s", $this->host, $this->port, $this->db ); } return sprintf( "mongodb://%s:%s@%s:%d/%s", $this->username, $this->password, $this->host, $this->port, $this->db ); }
php
public function connectionString() { if (empty($this->username) || empty($this->password)) { return sprintf( "mongodb://%s:%d/%s", $this->host, $this->port, $this->db ); } return sprintf( "mongodb://%s:%s@%s:%d/%s", $this->username, $this->password, $this->host, $this->port, $this->db ); }
[ "public", "function", "connectionString", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "username", ")", "||", "empty", "(", "$", "this", "->", "password", ")", ")", "{", "return", "sprintf", "(", "\"mongodb://%s:%d/%s\"", ",", "$", "this", ...
Forms the connection String @return String
[ "Forms", "the", "connection", "String" ]
ac81908f6db22ff8de4ffb974e841fa0a466b10a
https://github.com/tailored-tunes/mongo-connection-facade/blob/ac81908f6db22ff8de4ffb974e841fa0a466b10a/src/TailoredTunes/MongoConnectionFacade/MongoDbConnection.php#L66-L84
train
jerel/quick-cache
core/Quick/Cache/Driver/Apc.php
Apc._key
private function _key($identifier) { extract($identifier); $arg_string = ""; return md5(serialize($class . $method . implode('~', $args))); }
php
private function _key($identifier) { extract($identifier); $arg_string = ""; return md5(serialize($class . $method . implode('~', $args))); }
[ "private", "function", "_key", "(", "$", "identifier", ")", "{", "extract", "(", "$", "identifier", ")", ";", "$", "arg_string", "=", "\"\"", ";", "return", "md5", "(", "serialize", "(", "$", "class", ".", "$", "method", ".", "implode", "(", "'~'", "...
Creates a key for cached class methods @param array $identifier class|method|args @return string
[ "Creates", "a", "key", "for", "cached", "class", "methods" ]
e5963482c5f90fe866d4e87545cb7eab5cc65c43
https://github.com/jerel/quick-cache/blob/e5963482c5f90fe866d4e87545cb7eab5cc65c43/core/Quick/Cache/Driver/Apc.php#L91-L95
train
JaredClemence/binn
src/builders/NumericBuilder.php
NumericBuilder.isNegative
public function isNegative( $binaryString ){ $firstBit = $binaryString[0]; $negativeFlag = $firstBit & "\x80"; $isNegative = ord($negativeFlag) == 128; return $isNegative; }
php
public function isNegative( $binaryString ){ $firstBit = $binaryString[0]; $negativeFlag = $firstBit & "\x80"; $isNegative = ord($negativeFlag) == 128; return $isNegative; }
[ "public", "function", "isNegative", "(", "$", "binaryString", ")", "{", "$", "firstBit", "=", "$", "binaryString", "[", "0", "]", ";", "$", "negativeFlag", "=", "$", "firstBit", "&", "\"\\x80\"", ";", "$", "isNegative", "=", "ord", "(", "$", "negativeFla...
Public for testing purposes @param type $binaryString @return type
[ "Public", "for", "testing", "purposes" ]
838591e7a92c0f257c09a1df141d80737a20f7d9
https://github.com/JaredClemence/binn/blob/838591e7a92c0f257c09a1df141d80737a20f7d9/src/builders/NumericBuilder.php#L41-L46
train
JaredClemence/binn
src/builders/NumericBuilder.php
NumericBuilder.addOneToBytePreserveCarry
public function addOneToBytePreserveCarry($currentByte, &$carry) { for( $i = 0; $i < 8; $i++ ){ $bitMaskValue = pow( 2, $i ); $mask = chr( $bitMaskValue ); $filteredBit = $currentByte & $mask; if( $carry == 1 && ord( $filteredBit ) == 0 ){ $currentByte |= $mask; $carry = 0; }else if($carry == 1 && ord( $filteredBit ) >= 1){ $flipMask = ~$mask; $currentByte &= $flipMask; //carry bit remains unchanged } } return $currentByte; }
php
public function addOneToBytePreserveCarry($currentByte, &$carry) { for( $i = 0; $i < 8; $i++ ){ $bitMaskValue = pow( 2, $i ); $mask = chr( $bitMaskValue ); $filteredBit = $currentByte & $mask; if( $carry == 1 && ord( $filteredBit ) == 0 ){ $currentByte |= $mask; $carry = 0; }else if($carry == 1 && ord( $filteredBit ) >= 1){ $flipMask = ~$mask; $currentByte &= $flipMask; //carry bit remains unchanged } } return $currentByte; }
[ "public", "function", "addOneToBytePreserveCarry", "(", "$", "currentByte", ",", "&", "$", "carry", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "8", ";", "$", "i", "++", ")", "{", "$", "bitMaskValue", "=", "pow", "(", "2", ",", ...
We add one by inserting the 1 into the first carry bit. This is public for testing only. @param type $currentByte @param type $carry
[ "We", "add", "one", "by", "inserting", "the", "1", "into", "the", "first", "carry", "bit", "." ]
838591e7a92c0f257c09a1df141d80737a20f7d9
https://github.com/JaredClemence/binn/blob/838591e7a92c0f257c09a1df141d80737a20f7d9/src/builders/NumericBuilder.php#L99-L114
train
brad-jones/import
src/Importer.php
Importer.import
public static function import() { if (count(func_get_args()) >= 2 && func_get_arg(1) !== null) { extract(func_get_arg(1)); } if (count(func_get_args()) < 3 || func_get_arg(2) === true) { $exports = require func_get_arg(0); } else { $exports = include func_get_arg(0); } return $exports; }
php
public static function import() { if (count(func_get_args()) >= 2 && func_get_arg(1) !== null) { extract(func_get_arg(1)); } if (count(func_get_args()) < 3 || func_get_arg(2) === true) { $exports = require func_get_arg(0); } else { $exports = include func_get_arg(0); } return $exports; }
[ "public", "static", "function", "import", "(", ")", "{", "if", "(", "count", "(", "func_get_args", "(", ")", ")", ">=", "2", "&&", "func_get_arg", "(", "1", ")", "!==", "null", ")", "{", "extract", "(", "func_get_arg", "(", "1", ")", ")", ";", "}",...
Includes a file with an empty variable scope. @param string $file The path to the file to import. @param array|null $scope A custom scope to give to the file. @param boolean $require Whether to use require() or include(). @return mixed Anything the file returns.
[ "Includes", "a", "file", "with", "an", "empty", "variable", "scope", "." ]
45918c9a2f59fff094582deef7c4bb0fd782985d
https://github.com/brad-jones/import/blob/45918c9a2f59fff094582deef7c4bb0fd782985d/src/Importer.php#L13-L30
train
MINISTRYGmbH/morrow-core
src/Views/Serpent.php
Serpent.init
public function init($namespace) { // extract template path from class namespace $namespace = trim($namespace, '\\'); $namespace_array = explode('\\', $namespace); $this->template_path = implode('/', array_slice($namespace_array, 1, 2)); $this->template_path .= '/templates/'; // get template name from template router $this->template = call_user_func(Factory::load('Config')->get('router.template'), $namespace); // pass the page variables to the template $this->setContent('page', Factory::load('Page')->get(), true); // cerate template compile path fron namespace array $module_name = implode('/', array_slice($namespace_array, 2, 1)); $this->compile_path = STORAGE_PATH .'serpent_templates_compiled/' . $module_name . '/'; }
php
public function init($namespace) { // extract template path from class namespace $namespace = trim($namespace, '\\'); $namespace_array = explode('\\', $namespace); $this->template_path = implode('/', array_slice($namespace_array, 1, 2)); $this->template_path .= '/templates/'; // get template name from template router $this->template = call_user_func(Factory::load('Config')->get('router.template'), $namespace); // pass the page variables to the template $this->setContent('page', Factory::load('Page')->get(), true); // cerate template compile path fron namespace array $module_name = implode('/', array_slice($namespace_array, 2, 1)); $this->compile_path = STORAGE_PATH .'serpent_templates_compiled/' . $module_name . '/'; }
[ "public", "function", "init", "(", "$", "namespace", ")", "{", "// extract template path from class namespace", "$", "namespace", "=", "trim", "(", "$", "namespace", ",", "'\\\\'", ")", ";", "$", "namespace_array", "=", "explode", "(", "'\\\\'", ",", "$", "nam...
The view handler could extend this method to set some parameters. @param string $namespace The MVC controller class with namespace that inits this instance.
[ "The", "view", "handler", "could", "extend", "this", "method", "to", "set", "some", "parameters", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Views/Serpent.php#L91-L107
train
gossi/trixionary
src/model/Map/SkillVersionTableMap.php
SkillVersionTableMap.doDelete
public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(SkillVersionTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; } elseif ($values instanceof \gossi\trixionary\model\SkillVersion) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(SkillVersionTableMap::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(SkillVersionTableMap::COL_ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(SkillVersionTableMap::COL_VERSION, $value[1])); $criteria->addOr($criterion); } } $query = SkillVersionQuery::create()->mergeWith($criteria); if ($values instanceof Criteria) { SkillVersionTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks foreach ((array) $values as $singleval) { SkillVersionTableMap::removeInstanceFromPool($singleval); } } return $query->delete($con); }
php
public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(SkillVersionTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; } elseif ($values instanceof \gossi\trixionary\model\SkillVersion) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(SkillVersionTableMap::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(SkillVersionTableMap::COL_ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(SkillVersionTableMap::COL_VERSION, $value[1])); $criteria->addOr($criterion); } } $query = SkillVersionQuery::create()->mergeWith($criteria); if ($values instanceof Criteria) { SkillVersionTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks foreach ((array) $values as $singleval) { SkillVersionTableMap::removeInstanceFromPool($singleval); } } return $query->delete($con); }
[ "public", "static", "function", "doDelete", "(", "$", "values", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getW...
Performs a DELETE on the database, given a SkillVersion or Criteria object OR a primary key value. @param mixed $values Criteria or SkillVersion object or primary key or array of primary keys which is used to create the DELETE statement @param ConnectionInterface $con the connection to use @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows if supported by native driver or if emulated using Propel. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "a", "DELETE", "on", "the", "database", "given", "a", "SkillVersion", "or", "Criteria", "object", "OR", "a", "primary", "key", "value", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Map/SkillVersionTableMap.php#L685-L723
train
gossi/trixionary
src/model/Map/SkillVersionTableMap.php
SkillVersionTableMap.doInsert
public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(SkillVersionTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from SkillVersion object } // Set the correct dbName $query = SkillVersionQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use ($con, $query) { return $query->doInsert($con); }); }
php
public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(SkillVersionTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from SkillVersion object } // Set the correct dbName $query = SkillVersionQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use ($con, $query) { return $query->doInsert($con); }); }
[ "public", "static", "function", "doInsert", "(", "$", "criteria", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "ge...
Performs an INSERT on the database, given a SkillVersion or Criteria object. @param mixed $criteria Criteria or SkillVersion object containing data that is used to create the INSERT statement. @param ConnectionInterface $con the ConnectionInterface connection to use @return mixed The new primary key. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "an", "INSERT", "on", "the", "database", "given", "a", "SkillVersion", "or", "Criteria", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Map/SkillVersionTableMap.php#L745-L766
train
tekkla/core-html
Core/Html/Controls/Editbox/Editbox.php
Editbox.addAction
public function addAction(Action $action): Editbox { switch ($action->getType()) { case Action::SAVE: $this->actions[0] = $action; break; case Action::CANCEL: $this->actions[1] = $action; break; case Action::CONTEXT: default: if (empty($this->actions[2])) { $this->actions[2] = []; } $this->actions[2][] = $action; break; } return $this; }
php
public function addAction(Action $action): Editbox { switch ($action->getType()) { case Action::SAVE: $this->actions[0] = $action; break; case Action::CANCEL: $this->actions[1] = $action; break; case Action::CONTEXT: default: if (empty($this->actions[2])) { $this->actions[2] = []; } $this->actions[2][] = $action; break; } return $this; }
[ "public", "function", "addAction", "(", "Action", "$", "action", ")", ":", "Editbox", "{", "switch", "(", "$", "action", "->", "getType", "(", ")", ")", "{", "case", "Action", "::", "SAVE", ":", "$", "this", "->", "actions", "[", "0", "]", "=", "$"...
Adds an action link to actions list @param Action $action @return Editbox
[ "Adds", "an", "action", "link", "to", "actions", "list" ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Controls/Editbox/Editbox.php#L167-L192
train
tekkla/core-html
Core/Html/Controls/Editbox/Editbox.php
Editbox.&
public function &createAction(string $type, string $text, string $href = '', bool $ajax = false, string $confirm = ''): Action { $action = new Action(); $action->setType($type); $action->setText($text); if (!empty($href)) { $action->setHref($href); } $action->setAjax($ajax); if (!empty($confirm)) { $action->setConfirm('confirm'); } $this->addAction($action); return $action; }
php
public function &createAction(string $type, string $text, string $href = '', bool $ajax = false, string $confirm = ''): Action { $action = new Action(); $action->setType($type); $action->setText($text); if (!empty($href)) { $action->setHref($href); } $action->setAjax($ajax); if (!empty($confirm)) { $action->setConfirm('confirm'); } $this->addAction($action); return $action; }
[ "public", "function", "&", "createAction", "(", "string", "$", "type", ",", "string", "$", "text", ",", "string", "$", "href", "=", "''", ",", "bool", "$", "ajax", "=", "false", ",", "string", "$", "confirm", "=", "''", ")", ":", "Action", "{", "$"...
Creates an action object, adds it to the actionslist and returns a reference to it @param string $type @param string $text @param string $href @param string $ajax @param string $confirm @return Action
[ "Creates", "an", "action", "object", "adds", "it", "to", "the", "actionslist", "and", "returns", "a", "reference", "to", "it" ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Controls/Editbox/Editbox.php#L205-L225
train
tekkla/core-html
Core/Html/Controls/Editbox/Editbox.php
Editbox.generateActions
public function generateActions(array $actions): Editbox { foreach ($actions as $action) { $action_object = new Action(); if (empty($action['type'])) { $action['type'] = 'context'; } $action_object->setType($action['type']); if (! empty($action['text'])) { $action_object->setText($action['text']); } if (! empty($action['href'])) { $action_object->setHref($action['href']); } if (isset($action['ajax'])) { $action_object->setAjax($action['ajax']); } if (! empty($action['icon'])) { $action_object->setIcon($action['icon']); } if (! empty($action['confirm'])) { $action_object->setConfirm($action['confirm']); } $this->addAction($action_object); } return $this; }
php
public function generateActions(array $actions): Editbox { foreach ($actions as $action) { $action_object = new Action(); if (empty($action['type'])) { $action['type'] = 'context'; } $action_object->setType($action['type']); if (! empty($action['text'])) { $action_object->setText($action['text']); } if (! empty($action['href'])) { $action_object->setHref($action['href']); } if (isset($action['ajax'])) { $action_object->setAjax($action['ajax']); } if (! empty($action['icon'])) { $action_object->setIcon($action['icon']); } if (! empty($action['confirm'])) { $action_object->setConfirm($action['confirm']); } $this->addAction($action_object); } return $this; }
[ "public", "function", "generateActions", "(", "array", "$", "actions", ")", ":", "Editbox", "{", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "$", "action_object", "=", "new", "Action", "(", ")", ";", "if", "(", "empty", "(", "$", "...
Generate actions from an array of action definitions @param array $actions @return Editbox
[ "Generate", "actions", "from", "an", "array", "of", "action", "definitions" ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Controls/Editbox/Editbox.php#L234-L270
train
GrupaZero/core
src/Gzero/Core/Query/QueryBuilder.php
QueryBuilder.getFilter
public function getFilter(string $fieldName): ?Condition { [$name, $filters] = $this->getArrayAndKeyName($fieldName, 'filters'); return array_first($filters, function ($filter) use ($name) { return $filter->getName() === $name; }); }
php
public function getFilter(string $fieldName): ?Condition { [$name, $filters] = $this->getArrayAndKeyName($fieldName, 'filters'); return array_first($filters, function ($filter) use ($name) { return $filter->getName() === $name; }); }
[ "public", "function", "getFilter", "(", "string", "$", "fieldName", ")", ":", "?", "Condition", "{", "[", "$", "name", ",", "$", "filters", "]", "=", "$", "this", "->", "getArrayAndKeyName", "(", "$", "fieldName", ",", "'filters'", ")", ";", "return", ...
It returns single filter by field name @param string $fieldName Condition field name @throws InvalidArgumentException @return Condition
[ "It", "returns", "single", "filter", "by", "field", "name" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/QueryBuilder.php#L48-L55
train
GrupaZero/core
src/Gzero/Core/Query/QueryBuilder.php
QueryBuilder.getSort
public function getSort($sortName): ?OrderBy { [$name, $sorts] = $this->getArrayAndKeyName($sortName, 'sorts'); return array_first($sorts, function ($sort) use ($name) { return $sort->getName() === $name; }); }
php
public function getSort($sortName): ?OrderBy { [$name, $sorts] = $this->getArrayAndKeyName($sortName, 'sorts'); return array_first($sorts, function ($sort) use ($name) { return $sort->getName() === $name; }); }
[ "public", "function", "getSort", "(", "$", "sortName", ")", ":", "?", "OrderBy", "{", "[", "$", "name", ",", "$", "sorts", "]", "=", "$", "this", "->", "getArrayAndKeyName", "(", "$", "sortName", ",", "'sorts'", ")", ";", "return", "array_first", "(", ...
It returns single sort by field name @param string $sortName Sort field name @throws InvalidArgumentException @return OrderBy
[ "It", "returns", "single", "sort", "by", "field", "name" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/QueryBuilder.php#L90-L97
train
GrupaZero/core
src/Gzero/Core/Query/QueryBuilder.php
QueryBuilder.where
public function where(string $key, string $operation, $value) { if (str_contains($key, '.')) { $fullPath = explode('.', $key); $relationPath = implode('.', array_slice($fullPath, 0, -1)); $relationKey = last($fullPath); $result = array_get($this->relations, $relationPath, ['filters' => [], 'sorts' => []]); $result['filters'][] = new Condition($relationKey, $operation, $value); array_set($this->relations, $relationPath, $result); } else { $this->filters[] = new Condition($key, $operation, $value); } return $this; }
php
public function where(string $key, string $operation, $value) { if (str_contains($key, '.')) { $fullPath = explode('.', $key); $relationPath = implode('.', array_slice($fullPath, 0, -1)); $relationKey = last($fullPath); $result = array_get($this->relations, $relationPath, ['filters' => [], 'sorts' => []]); $result['filters'][] = new Condition($relationKey, $operation, $value); array_set($this->relations, $relationPath, $result); } else { $this->filters[] = new Condition($key, $operation, $value); } return $this; }
[ "public", "function", "where", "(", "string", "$", "key", ",", "string", "$", "operation", ",", "$", "value", ")", "{", "if", "(", "str_contains", "(", "$", "key", ",", "'.'", ")", ")", "{", "$", "fullPath", "=", "explode", "(", "'.'", ",", "$", ...
It adds where condition @param string $key Column name @param string $operation Operation @param mixed $value Value @return $this
[ "It", "adds", "where", "condition" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/QueryBuilder.php#L200-L213
train
GrupaZero/core
src/Gzero/Core/Query/QueryBuilder.php
QueryBuilder.orderBy
public function orderBy(string $key, string $direction) { if (str_contains($key, '.')) { $fullPath = explode('.', $key); $relationPath = implode('.', array_slice($fullPath, 0, -1)); $relationKey = last($fullPath); $result = array_get($this->relations, $relationPath, ['filters' => [], 'sorts' => []]); $result['sorts'][] = new OrderBy($relationKey, $direction); array_set($this->relations, $relationPath, $result); } else { $this->sorts[] = new OrderBy($key, $direction); } return $this; }
php
public function orderBy(string $key, string $direction) { if (str_contains($key, '.')) { $fullPath = explode('.', $key); $relationPath = implode('.', array_slice($fullPath, 0, -1)); $relationKey = last($fullPath); $result = array_get($this->relations, $relationPath, ['filters' => [], 'sorts' => []]); $result['sorts'][] = new OrderBy($relationKey, $direction); array_set($this->relations, $relationPath, $result); } else { $this->sorts[] = new OrderBy($key, $direction); } return $this; }
[ "public", "function", "orderBy", "(", "string", "$", "key", ",", "string", "$", "direction", ")", "{", "if", "(", "str_contains", "(", "$", "key", ",", "'.'", ")", ")", "{", "$", "fullPath", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", ...
It adds order by @param string $key Column name @param string $direction Direction @return $this
[ "It", "adds", "order", "by" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/QueryBuilder.php#L223-L236
train
GrupaZero/core
src/Gzero/Core/Query/QueryBuilder.php
QueryBuilder.applyFilters
public function applyFilters(Builder $query, string $alias = null) { foreach ($this->getFilters() as $filter) { $filter->apply($query, $alias); } }
php
public function applyFilters(Builder $query, string $alias = null) { foreach ($this->getFilters() as $filter) { $filter->apply($query, $alias); } }
[ "public", "function", "applyFilters", "(", "Builder", "$", "query", ",", "string", "$", "alias", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "getFilters", "(", ")", "as", "$", "filter", ")", "{", "$", "filter", "->", "apply", "(", "$", ...
Applies filter to Eloquent Query builder @param Builder $query Eloquent query builder @param string|null $alias SQL alias @return void
[ "Applies", "filter", "to", "Eloquent", "Query", "builder" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/QueryBuilder.php#L282-L287
train
GrupaZero/core
src/Gzero/Core/Query/QueryBuilder.php
QueryBuilder.applyRelationFilters
public function applyRelationFilters(string $relationName, string $alias, Builder $query) { foreach ($this->getRelationFilters($relationName) as $filter) { $filter->apply($query, $alias); } }
php
public function applyRelationFilters(string $relationName, string $alias, Builder $query) { foreach ($this->getRelationFilters($relationName) as $filter) { $filter->apply($query, $alias); } }
[ "public", "function", "applyRelationFilters", "(", "string", "$", "relationName", ",", "string", "$", "alias", ",", "Builder", "$", "query", ")", "{", "foreach", "(", "$", "this", "->", "getRelationFilters", "(", "$", "relationName", ")", "as", "$", "filter"...
Applies filters Eloquent Query builder for relation @param string $relationName Relation name @param string $alias SQL alias @param Builder $query Eloquent query builder @return void
[ "Applies", "filters", "Eloquent", "Query", "builder", "for", "relation" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/QueryBuilder.php#L298-L303
train
GrupaZero/core
src/Gzero/Core/Query/QueryBuilder.php
QueryBuilder.applySorts
public function applySorts(Builder $query, string $alias = null) { foreach ($this->getSorts() as $sort) { $sort->apply($query, $alias); } }
php
public function applySorts(Builder $query, string $alias = null) { foreach ($this->getSorts() as $sort) { $sort->apply($query, $alias); } }
[ "public", "function", "applySorts", "(", "Builder", "$", "query", ",", "string", "$", "alias", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "getSorts", "(", ")", "as", "$", "sort", ")", "{", "$", "sort", "->", "apply", "(", "$", "query...
Applies sorts Eloquent Query builder @param Builder $query Eloquent query builder @param string|null $alias SQL alias @return void
[ "Applies", "sorts", "Eloquent", "Query", "builder" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/QueryBuilder.php#L313-L318
train
GrupaZero/core
src/Gzero/Core/Query/QueryBuilder.php
QueryBuilder.applyRelationSorts
public function applyRelationSorts(string $relationName, string $alias, Builder $query) { foreach ($this->getRelationSorts($relationName) as $sorts) { $sorts->apply($query, $alias); } }
php
public function applyRelationSorts(string $relationName, string $alias, Builder $query) { foreach ($this->getRelationSorts($relationName) as $sorts) { $sorts->apply($query, $alias); } }
[ "public", "function", "applyRelationSorts", "(", "string", "$", "relationName", ",", "string", "$", "alias", ",", "Builder", "$", "query", ")", "{", "foreach", "(", "$", "this", "->", "getRelationSorts", "(", "$", "relationName", ")", "as", "$", "sorts", "...
Applies sorts Eloquent Query builder for relation @param string $relationName Relation name @param string $alias SQL alias @param Builder $query Eloquent query builder @return void
[ "Applies", "sorts", "Eloquent", "Query", "builder", "for", "relation" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/QueryBuilder.php#L329-L334
train