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
traderinteractive/memoize-php
src/Predis.php
Predis.cache
private function cache(string $key, string $value, int $cacheTime = null) { try { $this->client->set($key, $value); if ($cacheTime !== null) { $this->client->expire($key, $cacheTime); } } catch (\Exception $e) { // We don't want exceptions in accessing the cache to break functionality. // The cache should be as transparent as possible. // If insight is needed into these exceptions, // a better way would be by notifying an observer with the errors. } }
php
private function cache(string $key, string $value, int $cacheTime = null) { try { $this->client->set($key, $value); if ($cacheTime !== null) { $this->client->expire($key, $cacheTime); } } catch (\Exception $e) { // We don't want exceptions in accessing the cache to break functionality. // The cache should be as transparent as possible. // If insight is needed into these exceptions, // a better way would be by notifying an observer with the errors. } }
[ "private", "function", "cache", "(", "string", "$", "key", ",", "string", "$", "value", ",", "int", "$", "cacheTime", "=", "null", ")", "{", "try", "{", "$", "this", "->", "client", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "if",...
Caches the value into redis with errors suppressed. @param string $key The key. @param string $value The value. @param int $cacheTime The optional cache time @return void
[ "Caches", "the", "value", "into", "redis", "with", "errors", "suppressed", "." ]
0e8a29e372bb30255b93a09d704228741581a930
https://github.com/traderinteractive/memoize-php/blob/0e8a29e372bb30255b93a09d704228741581a930/src/Predis.php#L80-L94
train
br-monteiro/htr-core
src/Init/Bootstrap.php
Bootstrap.setUp
private function setUp(): self { fn::allowCors(); fn::allowHeader(); $this->configApp(); $this->configRoutes(); return $this; }
php
private function setUp(): self { fn::allowCors(); fn::allowHeader(); $this->configApp(); $this->configRoutes(); return $this; }
[ "private", "function", "setUp", "(", ")", ":", "self", "{", "fn", "::", "allowCors", "(", ")", ";", "fn", "::", "allowHeader", "(", ")", ";", "$", "this", "->", "configApp", "(", ")", ";", "$", "this", "->", "configRoutes", "(", ")", ";", "return",...
SetUp the system @author Edson B S Monteiro <bruno.monteirodg@gmail.com> @since 1.0 @return $this
[ "SetUp", "the", "system" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Init/Bootstrap.php#L31-L39
train
chameleon-system/sanitycheck
src/Handler/CheckHandler.php
CheckHandler.doChecks
private function doChecks(array $checkList) { $retValue = array(); if (empty($checkList)) { $retValue[] = new CheckOutcome('message.nochecks', array(), CheckOutcome::NOTICE); return $retValue; } /** @var CheckInterface $check */ foreach ($checkList as $check) { try { $retValue = array_merge($retValue, $check->performCheck()); } catch (\Exception $e) { $retValue[] = new CheckOutcome( 'message.exception', array('%0%' => $e->getMessage()), CheckOutcome::EXCEPTION ); } } if (empty($retValue)) { $retValue[] = new CheckOutcome('message.nooutcome', array(), CheckOutcome::NOTICE); } return $retValue; }
php
private function doChecks(array $checkList) { $retValue = array(); if (empty($checkList)) { $retValue[] = new CheckOutcome('message.nochecks', array(), CheckOutcome::NOTICE); return $retValue; } /** @var CheckInterface $check */ foreach ($checkList as $check) { try { $retValue = array_merge($retValue, $check->performCheck()); } catch (\Exception $e) { $retValue[] = new CheckOutcome( 'message.exception', array('%0%' => $e->getMessage()), CheckOutcome::EXCEPTION ); } } if (empty($retValue)) { $retValue[] = new CheckOutcome('message.nooutcome', array(), CheckOutcome::NOTICE); } return $retValue; }
[ "private", "function", "doChecks", "(", "array", "$", "checkList", ")", "{", "$", "retValue", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "checkList", ")", ")", "{", "$", "retValue", "[", "]", "=", "new", "CheckOutcome", "(", "'message...
Does the actual work on the concrete and configured checks. @param $checkList [CheckInterface] @return CheckOutcome[]
[ "Does", "the", "actual", "work", "on", "the", "concrete", "and", "configured", "checks", "." ]
373aee88ccd64f8b61a8001cd0c8c5af5ff0c59d
https://github.com/chameleon-system/sanitycheck/blob/373aee88ccd64f8b61a8001cd0c8c5af5ff0c59d/src/Handler/CheckHandler.php#L97-L123
train
AeonDigital/PHP-Tools
src/JSON.php
JSON.indent
public static function indent(string $strJSON) : string { $strReturn = ""; $indentLevel = 0; $insideQuotes = false; $insideEscape = false; $endLineLevel = null; $utf8split = preg_split('//u', $strJSON, -1, PREG_SPLIT_NO_EMPTY); for ($i = 0; $i < count($utf8split); $i++) { $c = $utf8split[$i]; $newLineLevel = null; $post = ""; if ($endLineLevel !== null) { $newLineLevel = $endLineLevel; $endLineLevel = null; } if ($insideEscape === true) { $insideEscape = false; } elseif ($c === '"') { $insideQuotes = !$insideQuotes; } elseif ($insideQuotes === false) { switch ($c) { case "}": case "]": $indentLevel--; $endLineLevel = null; $newLineLevel = $indentLevel; break; case "{": case "[": $indentLevel++; case ",": $endLineLevel = $indentLevel; break; case ":": $post = " "; break; case " ": case "\t": case "\n": case "\r": $c = ""; $endLineLevel = $newLineLevel; $newLineLevel = null; break; } } elseif ($c === "\\") { $insideEscape = true; } if ($newLineLevel !== null) { $strReturn .= "\n" . str_repeat("\t", $newLineLevel); } $strReturn .= $c . $post; } return $strReturn; }
php
public static function indent(string $strJSON) : string { $strReturn = ""; $indentLevel = 0; $insideQuotes = false; $insideEscape = false; $endLineLevel = null; $utf8split = preg_split('//u', $strJSON, -1, PREG_SPLIT_NO_EMPTY); for ($i = 0; $i < count($utf8split); $i++) { $c = $utf8split[$i]; $newLineLevel = null; $post = ""; if ($endLineLevel !== null) { $newLineLevel = $endLineLevel; $endLineLevel = null; } if ($insideEscape === true) { $insideEscape = false; } elseif ($c === '"') { $insideQuotes = !$insideQuotes; } elseif ($insideQuotes === false) { switch ($c) { case "}": case "]": $indentLevel--; $endLineLevel = null; $newLineLevel = $indentLevel; break; case "{": case "[": $indentLevel++; case ",": $endLineLevel = $indentLevel; break; case ":": $post = " "; break; case " ": case "\t": case "\n": case "\r": $c = ""; $endLineLevel = $newLineLevel; $newLineLevel = null; break; } } elseif ($c === "\\") { $insideEscape = true; } if ($newLineLevel !== null) { $strReturn .= "\n" . str_repeat("\t", $newLineLevel); } $strReturn .= $c . $post; } return $strReturn; }
[ "public", "static", "function", "indent", "(", "string", "$", "strJSON", ")", ":", "string", "{", "$", "strReturn", "=", "\"\"", ";", "$", "indentLevel", "=", "0", ";", "$", "insideQuotes", "=", "false", ";", "$", "insideEscape", "=", "false", ";", "$"...
Identa adequadamente uma string representante de um objeto JSON. @param string $strJSON String que será identada. @return string
[ "Identa", "adequadamente", "uma", "string", "representante", "de", "um", "objeto", "JSON", "." ]
502fad10aadb37fce98bd3994e866a8bfdc8dc00
https://github.com/AeonDigital/PHP-Tools/blob/502fad10aadb37fce98bd3994e866a8bfdc8dc00/src/JSON.php#L80-L148
train
AeonDigital/PHP-Tools
src/JSON.php
JSON.save
public static function save(string $absoluteSystemPathToFile, $JSON, int $options = 0) : bool { $strJSON = $JSON; // Se o objeto passado não for uma string, converte-o if (is_string($JSON) === false) { $strJSON = json_encode($JSON, $options); } // Identa corretamente o objeto JSON $strJSON = self::indent($strJSON); // Salva-o no local definido. $r = file_put_contents($absoluteSystemPathToFile, $strJSON); return (($r === false) ? false : true); }
php
public static function save(string $absoluteSystemPathToFile, $JSON, int $options = 0) : bool { $strJSON = $JSON; // Se o objeto passado não for uma string, converte-o if (is_string($JSON) === false) { $strJSON = json_encode($JSON, $options); } // Identa corretamente o objeto JSON $strJSON = self::indent($strJSON); // Salva-o no local definido. $r = file_put_contents($absoluteSystemPathToFile, $strJSON); return (($r === false) ? false : true); }
[ "public", "static", "function", "save", "(", "string", "$", "absoluteSystemPathToFile", ",", "$", "JSON", ",", "int", "$", "options", "=", "0", ")", ":", "bool", "{", "$", "strJSON", "=", "$", "JSON", ";", "// Se o objeto passado não for uma string, converte-o",...
Salva o um objeto JSON (representado por uma String, Array Associativo ou objeto "StdClass" no caminho informado. @param string $absoluteSystemPathToFile Caminho completo até o arquivo que será salvo. @param string|array|StdClass $JSON Objeto que será salvo como um arquivo JSON. @param int $options [Flags](http://php.net/manual/pt_BR/json.constants.php) para salvar o documeno JSON. @return bool
[ "Salva", "o", "um", "objeto", "JSON", "(", "representado", "por", "uma", "String", "Array", "Associativo", "ou", "objeto", "StdClass", "no", "caminho", "informado", "." ]
502fad10aadb37fce98bd3994e866a8bfdc8dc00
https://github.com/AeonDigital/PHP-Tools/blob/502fad10aadb37fce98bd3994e866a8bfdc8dc00/src/JSON.php#L170-L186
train
CMProductions/http-client
src/RequestFactory.php
RequestFactory.create
public function create($serviceKey, $requestKey, array $parameters = []) { $config = $this->getParamOrFail($this->config, $serviceKey); $service = $this->getServiceParams($config); $request = $this->getRequestParams($config, $requestKey, $service); $uri = $this->buildUri($service['endpoint'], $request['path'], $request['query']); list($optionalParameters, $placeholders) = $this->separateParameters($request['body'], $parameters); $values = array_values($parameters); $body = $this->buildBody($request['body'], $request['headers'], $placeholders, $values, $optionalParameters); return $this->buildRequest( $request['method'], $this->replace($uri, $placeholders, $values), $this->replaceAll($request['headers'], $placeholders, $values), $body, $request['version'], $request['retries'], $request['options'], $serviceKey, $requestKey ); }
php
public function create($serviceKey, $requestKey, array $parameters = []) { $config = $this->getParamOrFail($this->config, $serviceKey); $service = $this->getServiceParams($config); $request = $this->getRequestParams($config, $requestKey, $service); $uri = $this->buildUri($service['endpoint'], $request['path'], $request['query']); list($optionalParameters, $placeholders) = $this->separateParameters($request['body'], $parameters); $values = array_values($parameters); $body = $this->buildBody($request['body'], $request['headers'], $placeholders, $values, $optionalParameters); return $this->buildRequest( $request['method'], $this->replace($uri, $placeholders, $values), $this->replaceAll($request['headers'], $placeholders, $values), $body, $request['version'], $request['retries'], $request['options'], $serviceKey, $requestKey ); }
[ "public", "function", "create", "(", "$", "serviceKey", ",", "$", "requestKey", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "config", "=", "$", "this", "->", "getParamOrFail", "(", "$", "this", "->", "config", ",", "$", "serviceKey",...
Builds a request based on the service and request name, with the given parameters @param string $serviceKey @param string $requestKey @param array $parameters @return Request
[ "Builds", "a", "request", "based", "on", "the", "service", "and", "request", "name", "with", "the", "given", "parameters" ]
d7e5a74cdf94b6b50a229db6698c81fd055ff2ce
https://github.com/CMProductions/http-client/blob/d7e5a74cdf94b6b50a229db6698c81fd055ff2ce/src/RequestFactory.php#L35-L58
train
Orbitale/DoctrineTools
AbstractFixture.php
AbstractFixture.fixtureObject
private function fixtureObject(array $data): void { $obj = $this->createNewInstance($data); // Sometimes keys are specified in fixtures. // We must make sure Doctrine will force them to be saved. // Support for non-composite primary keys only. // /!\ Be careful, this will override the generator type for ALL objects of the same entity class! // This means that it _may_ break objects for which ids are not provided in the fixtures. $metadata = $this->manager->getClassMetadata($this->getEntityClass()); $primaryKey = $metadata->getIdentifierFieldNames(); if (1 === \count($primaryKey) && isset($data[$primaryKey[0]])) { $metadata->setIdGeneratorType($metadata::GENERATOR_TYPE_NONE); $metadata->setIdGenerator(new AssignedGenerator()); } // And finally we persist the item $this->manager->persist($obj); // If we need to flush it, then we do it too. if ( $this->numberOfIteratedObjects > 0 && $this->flushEveryXIterations() > 0 && $this->numberOfIteratedObjects % $this->flushEveryXIterations() === 0 ) { $this->manager->flush(); if ($this->clearEMOnFlush) { $this->manager->clear(); } } // If we have to add a reference, we do it if ($prefix = $this->getReferencePrefix()) { $methodName = $this->getMethodNameForReference(); $reference = null; if (method_exists($obj, $methodName)) { $reference = $obj->{$methodName}(); } elseif (method_exists($obj, '__toString')) { $reference = (string) $obj; } if (!$reference) { throw new RuntimeException(sprintf( 'If you want to specify a reference with prefix "%s", method "%s" or "%s" must exist in the class, or you can override the "%s" method and add your own.', $prefix, $methodName, '__toString()', 'getMethodNameForReference' )); } $this->addReference($prefix.$reference, $obj); } }
php
private function fixtureObject(array $data): void { $obj = $this->createNewInstance($data); // Sometimes keys are specified in fixtures. // We must make sure Doctrine will force them to be saved. // Support for non-composite primary keys only. // /!\ Be careful, this will override the generator type for ALL objects of the same entity class! // This means that it _may_ break objects for which ids are not provided in the fixtures. $metadata = $this->manager->getClassMetadata($this->getEntityClass()); $primaryKey = $metadata->getIdentifierFieldNames(); if (1 === \count($primaryKey) && isset($data[$primaryKey[0]])) { $metadata->setIdGeneratorType($metadata::GENERATOR_TYPE_NONE); $metadata->setIdGenerator(new AssignedGenerator()); } // And finally we persist the item $this->manager->persist($obj); // If we need to flush it, then we do it too. if ( $this->numberOfIteratedObjects > 0 && $this->flushEveryXIterations() > 0 && $this->numberOfIteratedObjects % $this->flushEveryXIterations() === 0 ) { $this->manager->flush(); if ($this->clearEMOnFlush) { $this->manager->clear(); } } // If we have to add a reference, we do it if ($prefix = $this->getReferencePrefix()) { $methodName = $this->getMethodNameForReference(); $reference = null; if (method_exists($obj, $methodName)) { $reference = $obj->{$methodName}(); } elseif (method_exists($obj, '__toString')) { $reference = (string) $obj; } if (!$reference) { throw new RuntimeException(sprintf( 'If you want to specify a reference with prefix "%s", method "%s" or "%s" must exist in the class, or you can override the "%s" method and add your own.', $prefix, $methodName, '__toString()', 'getMethodNameForReference' )); } $this->addReference($prefix.$reference, $obj); } }
[ "private", "function", "fixtureObject", "(", "array", "$", "data", ")", ":", "void", "{", "$", "obj", "=", "$", "this", "->", "createNewInstance", "(", "$", "data", ")", ";", "// Sometimes keys are specified in fixtures.", "// We must make sure Doctrine will force the...
Creates the object and persist it in database. @param object $data
[ "Creates", "the", "object", "and", "persist", "it", "in", "database", "." ]
517a321786073a9bc935bb0cb3014df4bb25dade
https://github.com/Orbitale/DoctrineTools/blob/517a321786073a9bc935bb0cb3014df4bb25dade/AbstractFixture.php#L119-L170
train
Orbitale/DoctrineTools
AbstractFixture.php
AbstractFixture.createNewInstance
protected function createNewInstance(array $data): object { $instance = self::getInstantiator()->instantiate($this->getEntityClass()); $refl = $this->getReflection(); foreach ($data as $key => $value) { $prop = $refl->getProperty($key); $prop->setAccessible(true); if ($value instanceof Closure) { $value = $value($instance, $this, $this->manager); } $prop->setValue($instance, $value); } return $instance; }
php
protected function createNewInstance(array $data): object { $instance = self::getInstantiator()->instantiate($this->getEntityClass()); $refl = $this->getReflection(); foreach ($data as $key => $value) { $prop = $refl->getProperty($key); $prop->setAccessible(true); if ($value instanceof Closure) { $value = $value($instance, $this, $this->manager); } $prop->setValue($instance, $value); } return $instance; }
[ "protected", "function", "createNewInstance", "(", "array", "$", "data", ")", ":", "object", "{", "$", "instance", "=", "self", "::", "getInstantiator", "(", ")", "->", "instantiate", "(", "$", "this", "->", "getEntityClass", "(", ")", ")", ";", "$", "re...
Creates a new instance of the class associated with the fixture. Override this method if you have constructor arguments to manage yourself depending on input data. @param array $data @return object
[ "Creates", "a", "new", "instance", "of", "the", "class", "associated", "with", "the", "fixture", ".", "Override", "this", "method", "if", "you", "have", "constructor", "arguments", "to", "manage", "yourself", "depending", "on", "input", "data", "." ]
517a321786073a9bc935bb0cb3014df4bb25dade
https://github.com/Orbitale/DoctrineTools/blob/517a321786073a9bc935bb0cb3014df4bb25dade/AbstractFixture.php#L251-L269
train
chameleon-system/sanitycheck
src/Check/DiskSpaceCheck.php
DiskSpaceCheck.checkDiskSpace
private function checkDiskSpace() { $retValue = array(); $freeSpace = disk_free_space($this->directory); $totalSpace = disk_total_space($this->directory); if (0 === $totalSpace) { $retValue[] = new CheckOutcome( 'check.disk_space.totalzero', array('%0%' => $this->directory), CheckOutcome::ERROR ); return $retValue; } $percentage = 100 * ($freeSpace / $totalSpace); $maxLevel = 0; $maxStrategy = self::STRATEGY_ABSOLUTE; foreach ($this->thresholdData as $level => $data) { $threshold = $data[0]; $strategy = $data[1]; switch ($strategy) { case self::STRATEGY_ABSOLUTE: if (($freeSpace < $threshold) && $level > $maxLevel) { $maxLevel = $level; $maxStrategy = self::STRATEGY_ABSOLUTE; } break; case self::STRATEGY_PERCENTAGE: if (($percentage < $threshold) && $level > $maxLevel) { $maxLevel = $level; $maxStrategy = self::STRATEGY_PERCENTAGE; } break; default: $retValue[] = new CheckOutcome( 'check.disk_space.invalid_strategy', array('%0%' => $strategy), CheckOutcome::ERROR ); break; } } if ($maxLevel > 0) { $retValue[] = new CheckOutcome( 'check.disk_space.lowspace', array( '%0%' => $this->directory, '%1%' => $this->formatSpaceLeft($freeSpace, $totalSpace, $maxStrategy), ), $maxLevel ); } else { $retValue[] = new CheckOutcome('check.disk_space.ok', array(), CheckOutcome::OK); } return $retValue; }
php
private function checkDiskSpace() { $retValue = array(); $freeSpace = disk_free_space($this->directory); $totalSpace = disk_total_space($this->directory); if (0 === $totalSpace) { $retValue[] = new CheckOutcome( 'check.disk_space.totalzero', array('%0%' => $this->directory), CheckOutcome::ERROR ); return $retValue; } $percentage = 100 * ($freeSpace / $totalSpace); $maxLevel = 0; $maxStrategy = self::STRATEGY_ABSOLUTE; foreach ($this->thresholdData as $level => $data) { $threshold = $data[0]; $strategy = $data[1]; switch ($strategy) { case self::STRATEGY_ABSOLUTE: if (($freeSpace < $threshold) && $level > $maxLevel) { $maxLevel = $level; $maxStrategy = self::STRATEGY_ABSOLUTE; } break; case self::STRATEGY_PERCENTAGE: if (($percentage < $threshold) && $level > $maxLevel) { $maxLevel = $level; $maxStrategy = self::STRATEGY_PERCENTAGE; } break; default: $retValue[] = new CheckOutcome( 'check.disk_space.invalid_strategy', array('%0%' => $strategy), CheckOutcome::ERROR ); break; } } if ($maxLevel > 0) { $retValue[] = new CheckOutcome( 'check.disk_space.lowspace', array( '%0%' => $this->directory, '%1%' => $this->formatSpaceLeft($freeSpace, $totalSpace, $maxStrategy), ), $maxLevel ); } else { $retValue[] = new CheckOutcome('check.disk_space.ok', array(), CheckOutcome::OK); } return $retValue; }
[ "private", "function", "checkDiskSpace", "(", ")", "{", "$", "retValue", "=", "array", "(", ")", ";", "$", "freeSpace", "=", "disk_free_space", "(", "$", "this", "->", "directory", ")", ";", "$", "totalSpace", "=", "disk_total_space", "(", "$", "this", "...
Checks the space left on the disk given by the configured directory. @return array
[ "Checks", "the", "space", "left", "on", "the", "disk", "given", "by", "the", "configured", "directory", "." ]
373aee88ccd64f8b61a8001cd0c8c5af5ff0c59d
https://github.com/chameleon-system/sanitycheck/blob/373aee88ccd64f8b61a8001cd0c8c5af5ff0c59d/src/Check/DiskSpaceCheck.php#L100-L158
train
br-monteiro/htr-core
src/Common/ValidateAuthentication.php
ValidateAuthentication.token
public static function token(Request $request) { $authorization = $request->getHeader('Authorization'); if (!isset($authorization[0])) { throw new HeaderWithoutAuthorizationException('The request does not contain the Authorization header'); } $token = preg_replace('/^\w+\s/', '', $authorization[0]); return Authenticator::decodeToken($token); }
php
public static function token(Request $request) { $authorization = $request->getHeader('Authorization'); if (!isset($authorization[0])) { throw new HeaderWithoutAuthorizationException('The request does not contain the Authorization header'); } $token = preg_replace('/^\w+\s/', '', $authorization[0]); return Authenticator::decodeToken($token); }
[ "public", "static", "function", "token", "(", "Request", "$", "request", ")", "{", "$", "authorization", "=", "$", "request", "->", "getHeader", "(", "'Authorization'", ")", ";", "if", "(", "!", "isset", "(", "$", "authorization", "[", "0", "]", ")", "...
Returns the data of token passed on Request @author Edson B S Monteiro <bruno.monteirodg@gmail.com> @since 1.0 @param Request $request @return \stdClass @throws HeaderWithoutAuthorizationException
[ "Returns", "the", "data", "of", "token", "passed", "on", "Request" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Common/ValidateAuthentication.php#L27-L38
train
br-monteiro/htr-core
src/Common/ValidateAuthentication.php
ValidateAuthentication.user
public static function user(Request $request) { try { $data = self::token($request); $repository = db::em()->getRepository(cfg::USER_ENTITY); return $repository->find($data->data->id ?? 0); } catch (HeaderWithoutAuthorizationException $ex) { return false; } }
php
public static function user(Request $request) { try { $data = self::token($request); $repository = db::em()->getRepository(cfg::USER_ENTITY); return $repository->find($data->data->id ?? 0); } catch (HeaderWithoutAuthorizationException $ex) { return false; } }
[ "public", "static", "function", "user", "(", "Request", "$", "request", ")", "{", "try", "{", "$", "data", "=", "self", "::", "token", "(", "$", "request", ")", ";", "$", "repository", "=", "db", "::", "em", "(", ")", "->", "getRepository", "(", "c...
Returns the data of User according Database @author Edson B S Monteiro <bruno.monteirodg@gmail.com> @since 1.0 @param Request $request @return boolean|{UserEntity}
[ "Returns", "the", "data", "of", "User", "according", "Database" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Common/ValidateAuthentication.php#L47-L57
train
electro-modules/matisse-components
MatisseComponents/Models/File.php
File.scopeOfField
public function scopeOfField ($query, $fieldName) { $fieldName = str_segmentsLast ($fieldName, '.'); return exists ($fieldName) ? $query->where ('group', $fieldName) : $query; }
php
public function scopeOfField ($query, $fieldName) { $fieldName = str_segmentsLast ($fieldName, '.'); return exists ($fieldName) ? $query->where ('group', $fieldName) : $query; }
[ "public", "function", "scopeOfField", "(", "$", "query", ",", "$", "fieldName", ")", "{", "$", "fieldName", "=", "str_segmentsLast", "(", "$", "fieldName", ",", "'.'", ")", ";", "return", "exists", "(", "$", "fieldName", ")", "?", "$", "query", "->", "...
A query scope that restricts results to files bound to a specific field on the owner model. @param Builder $query @param string $fieldName @return mixed
[ "A", "query", "scope", "that", "restricts", "results", "to", "files", "bound", "to", "a", "specific", "field", "on", "the", "owner", "model", "." ]
3a746f796157ef72b585a5994394483fbe500861
https://github.com/electro-modules/matisse-components/blob/3a746f796157ef72b585a5994394483fbe500861/MatisseComponents/Models/File.php#L101-L105
train
stubbles/stubbles-console
src/main/php/WorkingDirectory.php
WorkingDirectory.changeTo
public function changeTo(string $target): bool { if (file_exists($target) && @chdir($target) === true) { $this->current = $target; return true; } return false; }
php
public function changeTo(string $target): bool { if (file_exists($target) && @chdir($target) === true) { $this->current = $target; return true; } return false; }
[ "public", "function", "changeTo", "(", "string", "$", "target", ")", ":", "bool", "{", "if", "(", "file_exists", "(", "$", "target", ")", "&&", "@", "chdir", "(", "$", "target", ")", "===", "true", ")", "{", "$", "this", "->", "current", "=", "$", ...
change current working directory to given target Please note that this really has a side effect - it doesn't just change a value inside this object, it really changed the global current working directory for the whole PHP application! @param string $target directory to change current working directory to @return bool whether change was successful
[ "change", "current", "working", "directory", "to", "given", "target" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/WorkingDirectory.php#L65-L73
train
cedx/which.php
RoboFile.php
RoboFile.build
function build(): Result { $version = $this->taskSemVer('.semver')->setFormat('%M.%m.%p')->__toString(); return $this->taskReplaceInFile('bin/which')->regex("/const packageVersion = '\d+(\.\d+){2}'/")->to("const packageVersion = '$version'")->run(); }
php
function build(): Result { $version = $this->taskSemVer('.semver')->setFormat('%M.%m.%p')->__toString(); return $this->taskReplaceInFile('bin/which')->regex("/const packageVersion = '\d+(\.\d+){2}'/")->to("const packageVersion = '$version'")->run(); }
[ "function", "build", "(", ")", ":", "Result", "{", "$", "version", "=", "$", "this", "->", "taskSemVer", "(", "'.semver'", ")", "->", "setFormat", "(", "'%M.%m.%p'", ")", "->", "__toString", "(", ")", ";", "return", "$", "this", "->", "taskReplaceInFile"...
Builds the project. @return Result The task result.
[ "Builds", "the", "project", "." ]
3ab7702edaec4cc0059af609f7edb84bf3a8bb91
https://github.com/cedx/which.php/blob/3ab7702edaec4cc0059af609f7edb84bf3a8bb91/RoboFile.php#L27-L30
train
AeonDigital/PHP-Tools
src/StringExtension.php
StringExtension.insert
public static function insert(string $s, int $i, string $n) : string { return mb_substr_replace($s, $n, $i, 0); }
php
public static function insert(string $s, int $i, string $n) : string { return mb_substr_replace($s, $n, $i, 0); }
[ "public", "static", "function", "insert", "(", "string", "$", "s", ",", "int", "$", "i", ",", "string", "$", "n", ")", ":", "string", "{", "return", "mb_substr_replace", "(", "$", "s", ",", "$", "n", ",", "$", "i", ",", "0", ")", ";", "}" ]
Insere uma string no indice indicado da string original. @param string $s String original. @param int $i Indice a partir de onde o texto novo será adicionado. @param string $n String que será adicionada naquela posição. @return string
[ "Insere", "uma", "string", "no", "indice", "indicado", "da", "string", "original", "." ]
502fad10aadb37fce98bd3994e866a8bfdc8dc00
https://github.com/AeonDigital/PHP-Tools/blob/502fad10aadb37fce98bd3994e866a8bfdc8dc00/src/StringExtension.php#L47-L50
train
AeonDigital/PHP-Tools
src/StringExtension.php
StringExtension.remove
public static function remove(string $s, int $i, int $l) : string { return mb_substr_replace($s, "", $i, $l); }
php
public static function remove(string $s, int $i, int $l) : string { return mb_substr_replace($s, "", $i, $l); }
[ "public", "static", "function", "remove", "(", "string", "$", "s", ",", "int", "$", "i", ",", "int", "$", "l", ")", ":", "string", "{", "return", "mb_substr_replace", "(", "$", "s", ",", "\"\"", ",", "$", "i", ",", "$", "l", ")", ";", "}" ]
Remove uma cadeia de caracteres dentro dos limites indicados. @param string $s String original. @param int $i Índice onde começará o corte de caracteres. @param int $l Quantidade de caracteres que serão removidos. @return string
[ "Remove", "uma", "cadeia", "de", "caracteres", "dentro", "dos", "limites", "indicados", "." ]
502fad10aadb37fce98bd3994e866a8bfdc8dc00
https://github.com/AeonDigital/PHP-Tools/blob/502fad10aadb37fce98bd3994e866a8bfdc8dc00/src/StringExtension.php#L70-L73
train
chameleon-system/sanitycheck
src/Output/LogCheckOutput.php
LogCheckOutput.getLogLevel
protected function getLogLevel($outcomeLevel) { switch ($outcomeLevel) { case CheckOutcome::OK: return LogLevel::INFO; case CheckOutcome::NOTICE: return LogLevel::NOTICE; case CheckOutcome::WARNING: return LogLevel::WARNING; case CheckOutcome::ERROR: return LogLevel::ERROR; case CheckOutcome::EXCEPTION: return LogLevel::ERROR; default: return LogLevel::ERROR; } }
php
protected function getLogLevel($outcomeLevel) { switch ($outcomeLevel) { case CheckOutcome::OK: return LogLevel::INFO; case CheckOutcome::NOTICE: return LogLevel::NOTICE; case CheckOutcome::WARNING: return LogLevel::WARNING; case CheckOutcome::ERROR: return LogLevel::ERROR; case CheckOutcome::EXCEPTION: return LogLevel::ERROR; default: return LogLevel::ERROR; } }
[ "protected", "function", "getLogLevel", "(", "$", "outcomeLevel", ")", "{", "switch", "(", "$", "outcomeLevel", ")", "{", "case", "CheckOutcome", "::", "OK", ":", "return", "LogLevel", "::", "INFO", ";", "case", "CheckOutcome", "::", "NOTICE", ":", "return",...
Translates a given check level to a log level. @param int $outcomeLevel the outcome level @return string A log level as defined in Psr\Log\LogLevel
[ "Translates", "a", "given", "check", "level", "to", "a", "log", "level", "." ]
373aee88ccd64f8b61a8001cd0c8c5af5ff0c59d
https://github.com/chameleon-system/sanitycheck/blob/373aee88ccd64f8b61a8001cd0c8c5af5ff0c59d/src/Output/LogCheckOutput.php#L77-L93
train
stubbles/stubbles-console
src/main/php/ConsoleApp.php
ConsoleApp.getBindingsForApp
protected static function getBindingsForApp(string $className): array { $bindings = parent::getBindingsForApp($className); $bindings[] = function(Binder $binder) { $binder->bind(InputStream::class) ->named('stdin') ->toInstance(ConsoleInputStream::forIn()); $binder->bind(OutputStream::class) ->named('stdout') ->toInstance(ConsoleOutputStream::forOut()); $binder->bind(OutputStream::class) ->named('stderr') ->toInstance(ConsoleOutputStream::forError()); }; return $bindings; }
php
protected static function getBindingsForApp(string $className): array { $bindings = parent::getBindingsForApp($className); $bindings[] = function(Binder $binder) { $binder->bind(InputStream::class) ->named('stdin') ->toInstance(ConsoleInputStream::forIn()); $binder->bind(OutputStream::class) ->named('stdout') ->toInstance(ConsoleOutputStream::forOut()); $binder->bind(OutputStream::class) ->named('stderr') ->toInstance(ConsoleOutputStream::forError()); }; return $bindings; }
[ "protected", "static", "function", "getBindingsForApp", "(", "string", "$", "className", ")", ":", "array", "{", "$", "bindings", "=", "parent", "::", "getBindingsForApp", "(", "$", "className", ")", ";", "$", "bindings", "[", "]", "=", "function", "(", "B...
creates list of bindings from given class @internal @param string $className full qualified class name of class to create an instance of @return \stubbles\ioc\module\BindingModule[]
[ "creates", "list", "of", "bindings", "from", "given", "class" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/ConsoleApp.php#L59-L75
train
stubbles/stubbles-console
src/main/php/ConsoleOutputStream.php
ConsoleOutputStream.forError
public static function forError(): OutputStream { if (null === self::$err) { self::$err = self::create('php://stderr'); } return self::$err; }
php
public static function forError(): OutputStream { if (null === self::$err) { self::$err = self::create('php://stderr'); } return self::$err; }
[ "public", "static", "function", "forError", "(", ")", ":", "OutputStream", "{", "if", "(", "null", "===", "self", "::", "$", "err", ")", "{", "self", "::", "$", "err", "=", "self", "::", "create", "(", "'php://stderr'", ")", ";", "}", "return", "self...
comfort method for getting a console error stream @return \stubbles\streams\OutputStream
[ "comfort", "method", "for", "getting", "a", "console", "error", "stream" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/ConsoleOutputStream.php#L62-L69
train
stubbles/stubbles-console
src/main/php/ConsoleOutputStream.php
ConsoleOutputStream.create
private static function create(string $target): OutputStream { $out = new self(fopen($target, 'w')); $encoding = self::detectOutputEncoding(); if ('UTF-8' !== $encoding) { $out = new EncodingOutputStream($out, $encoding . '//IGNORE'); } return $out; }
php
private static function create(string $target): OutputStream { $out = new self(fopen($target, 'w')); $encoding = self::detectOutputEncoding(); if ('UTF-8' !== $encoding) { $out = new EncodingOutputStream($out, $encoding . '//IGNORE'); } return $out; }
[ "private", "static", "function", "create", "(", "string", "$", "target", ")", ":", "OutputStream", "{", "$", "out", "=", "new", "self", "(", "fopen", "(", "$", "target", ",", "'w'", ")", ")", ";", "$", "encoding", "=", "self", "::", "detectOutputEncodi...
creates output stream with respect to output encoding @param string $target @return \stubbles\streams\OutputStream
[ "creates", "output", "stream", "with", "respect", "to", "output", "encoding" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/ConsoleOutputStream.php#L77-L86
train
edmondscommerce/phpqa
src/Helper.php
Helper.getProjectRootDirectory
public static function getProjectRootDirectory(): string { if (null === self::$projectRootDirectory) { $reflection = new \ReflectionClass(ClassLoader::class); self::$projectRootDirectory = \dirname((string)$reflection->getFileName(), 3); } return self::$projectRootDirectory; }
php
public static function getProjectRootDirectory(): string { if (null === self::$projectRootDirectory) { $reflection = new \ReflectionClass(ClassLoader::class); self::$projectRootDirectory = \dirname((string)$reflection->getFileName(), 3); } return self::$projectRootDirectory; }
[ "public", "static", "function", "getProjectRootDirectory", "(", ")", ":", "string", "{", "if", "(", "null", "===", "self", "::", "$", "projectRootDirectory", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "ClassLoader", "::", "class", ...
Get the absolute path to the root of the current project It does this by working from the Composer autoloader which we know will be in a certain place in `vendor` @return string @throws \Exception
[ "Get", "the", "absolute", "path", "to", "the", "root", "of", "the", "current", "project" ]
fdcaa19f7505d16f7c751991cc2e4d113891be91
https://github.com/edmondscommerce/phpqa/blob/fdcaa19f7505d16f7c751991cc2e4d113891be91/src/Helper.php#L22-L30
train
symbiote/php-wordpress-database-tools
src/WordpressUtility.php
WordpressUtility.utf8_json_encode
public static function utf8_json_encode($arr, $options = 0, $depth = 512) { // NOTE(Jake): Might be able to get more speed out of this (if need be) by making it just json_encode // and if it fails with JSON_ERROR_UTF8, then do the recursive walk $utf8_arr = $arr; array_walk_recursive($utf8_arr, array(__CLASS__, '_utf8_json_encode_recursive')); $result = json_encode($utf8_arr, $options, $depth); return $result; }
php
public static function utf8_json_encode($arr, $options = 0, $depth = 512) { // NOTE(Jake): Might be able to get more speed out of this (if need be) by making it just json_encode // and if it fails with JSON_ERROR_UTF8, then do the recursive walk $utf8_arr = $arr; array_walk_recursive($utf8_arr, array(__CLASS__, '_utf8_json_encode_recursive')); $result = json_encode($utf8_arr, $options, $depth); return $result; }
[ "public", "static", "function", "utf8_json_encode", "(", "$", "arr", ",", "$", "options", "=", "0", ",", "$", "depth", "=", "512", ")", "{", "// NOTE(Jake): Might be able to get more speed out of this (if need be) by making it just json_encode", "//\t\t\t and if it fails wi...
Encodes an array of data to be UTF8 over using html entities @var array
[ "Encodes", "an", "array", "of", "data", "to", "be", "UTF8", "over", "using", "html", "entities" ]
93b1ae969722d7235dbbe6374f381daea0e0d5d7
https://github.com/symbiote/php-wordpress-database-tools/blob/93b1ae969722d7235dbbe6374f381daea0e0d5d7/src/WordpressUtility.php#L102-L109
train
CMProductions/http-client
src/Client/Traits/RequestBuilderTrait.php
RequestBuilderTrait.createRequest
protected function createRequest($service, $requestId, array $parameters = []) { try { return $this->factory()->create($service, $requestId, $parameters); } catch (RuntimeException $exception) { $this->logBuildError($service, $requestId, $exception); throw $exception; } catch (\Exception $exception) { $this->logBuildError($service, $requestId, $exception); throw new RequestBuildException($exception); } }
php
protected function createRequest($service, $requestId, array $parameters = []) { try { return $this->factory()->create($service, $requestId, $parameters); } catch (RuntimeException $exception) { $this->logBuildError($service, $requestId, $exception); throw $exception; } catch (\Exception $exception) { $this->logBuildError($service, $requestId, $exception); throw new RequestBuildException($exception); } }
[ "protected", "function", "createRequest", "(", "$", "service", ",", "$", "requestId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "try", "{", "return", "$", "this", "->", "factory", "(", ")", "->", "create", "(", "$", "service", ",", "$...
Builds a request @param string $service @param string $requestId @param array $parameters @return Request @throws RequestBuildException @throws RuntimeException
[ "Builds", "a", "request" ]
d7e5a74cdf94b6b50a229db6698c81fd055ff2ce
https://github.com/CMProductions/http-client/blob/d7e5a74cdf94b6b50a229db6698c81fd055ff2ce/src/Client/Traits/RequestBuilderTrait.php#L35-L46
train
br-monteiro/htr-core
src/Database/EntityAbstract.php
EntityAbstract.configEntityManager
private static function configEntityManager() { if (self::$entityManager) { return; } $isDevMode = cfg::htrFileConfigs()->devmode ?? false; $paths = [cfg::baseDir() . cfg::PATH_ENTITIES]; // the connection configuration if ($isDevMode) { $dbParams = cfg::DATABASE_CONFIGS_DEV; } else { $dbParams = cfg::DATABASE_CONFIGS_PRD; } $cache = new ArrayCache(); $reader = new AnnotationReader(); $driver = new AnnotationDriver($reader, $paths); $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $config->setMetadataDriverImpl($driver); self::$entityManager = EntityManager::create($dbParams, $config); }
php
private static function configEntityManager() { if (self::$entityManager) { return; } $isDevMode = cfg::htrFileConfigs()->devmode ?? false; $paths = [cfg::baseDir() . cfg::PATH_ENTITIES]; // the connection configuration if ($isDevMode) { $dbParams = cfg::DATABASE_CONFIGS_DEV; } else { $dbParams = cfg::DATABASE_CONFIGS_PRD; } $cache = new ArrayCache(); $reader = new AnnotationReader(); $driver = new AnnotationDriver($reader, $paths); $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $config->setMetadataDriverImpl($driver); self::$entityManager = EntityManager::create($dbParams, $config); }
[ "private", "static", "function", "configEntityManager", "(", ")", "{", "if", "(", "self", "::", "$", "entityManager", ")", "{", "return", ";", "}", "$", "isDevMode", "=", "cfg", "::", "htrFileConfigs", "(", ")", "->", "devmode", "??", "false", ";", "$", ...
Config the Entity Manager of Doctrine @author Edson B S Monteiro <bruno.monteirodg@gmail.com> @since 1.0
[ "Config", "the", "Entity", "Manager", "of", "Doctrine" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Database/EntityAbstract.php#L22-L48
train
dmvdbrugge/dynamic-components
src/Executor.php
Executor.setInterval
public function setInterval(int $seconds, ?int $microseconds = null): void { if (func_num_args() === 1) { $microseconds = $seconds; $seconds = 0; } Assert::notNull($microseconds, 'Cannot set $microseconds to null. Set to 0 for no microseconds.'); parent::setInterval($seconds, $microseconds); $this->seconds = $seconds; $this->microseconds = $microseconds; }
php
public function setInterval(int $seconds, ?int $microseconds = null): void { if (func_num_args() === 1) { $microseconds = $seconds; $seconds = 0; } Assert::notNull($microseconds, 'Cannot set $microseconds to null. Set to 0 for no microseconds.'); parent::setInterval($seconds, $microseconds); $this->seconds = $seconds; $this->microseconds = $microseconds; }
[ "public", "function", "setInterval", "(", "int", "$", "seconds", ",", "?", "int", "$", "microseconds", "=", "null", ")", ":", "void", "{", "if", "(", "func_num_args", "(", ")", "===", "1", ")", "{", "$", "microseconds", "=", "$", "seconds", ";", "$",...
Just like \UI\Executor, if you only give 1 param, it will be treated as microseconds.
[ "Just", "like", "\\", "UI", "\\", "Executor", "if", "you", "only", "give", "1", "param", "it", "will", "be", "treated", "as", "microseconds", "." ]
f5d6b48ee3ce16d15c60b637452873a9f2c75769
https://github.com/dmvdbrugge/dynamic-components/blob/f5d6b48ee3ce16d15c60b637452873a9f2c75769/src/Executor.php#L53-L65
train
netlogix/Netlogix.Cqrs
Classes/Netlogix/Cqrs/Log/CommandLogger.php
CommandLogger.logCommand
public function logCommand(AbstractCommand $command, \Exception $exception = null) { $commandLogEntry = $this->commandLogEntryRepository->findOneByCommand($command); $isNewObject = !$commandLogEntry; if ($isNewObject) { $commandLogEntry = new CommandLogEntry($command); } $commandLogEntry->setException($exception === null ? null : new ExceptionData($exception)); if ($isNewObject) { $this->commandLogEntryRepository->add($commandLogEntry); } else { $this->commandLogEntryRepository->update($commandLogEntry); } $this->entityManager->flush($commandLogEntry); }
php
public function logCommand(AbstractCommand $command, \Exception $exception = null) { $commandLogEntry = $this->commandLogEntryRepository->findOneByCommand($command); $isNewObject = !$commandLogEntry; if ($isNewObject) { $commandLogEntry = new CommandLogEntry($command); } $commandLogEntry->setException($exception === null ? null : new ExceptionData($exception)); if ($isNewObject) { $this->commandLogEntryRepository->add($commandLogEntry); } else { $this->commandLogEntryRepository->update($commandLogEntry); } $this->entityManager->flush($commandLogEntry); }
[ "public", "function", "logCommand", "(", "AbstractCommand", "$", "command", ",", "\\", "Exception", "$", "exception", "=", "null", ")", "{", "$", "commandLogEntry", "=", "$", "this", "->", "commandLogEntryRepository", "->", "findOneByCommand", "(", "$", "command...
Log the given command @param AbstractCommand $command @param \Exception $exception
[ "Log", "the", "given", "command" ]
5f3a151c8189d744feb0ee802d6766450aaa4dd0
https://github.com/netlogix/Netlogix.Cqrs/blob/5f3a151c8189d744feb0ee802d6766450aaa4dd0/Classes/Netlogix/Cqrs/Log/CommandLogger.php#L35-L52
train
br-monteiro/htr-core
src/Common/HttpFunctions.php
HttpFunctions.allowCors
public static function allowCors() { $origin = filter_input(INPUT_SERVER, 'HTTP_ORIGIN'); $protocol = filter_input(INPUT_SERVER, 'REQUEST_SCHEME') ?? 'http'; $host = preg_replace("/^http(s)?:\/{2}/", "", $origin); $allowedHosts = cfg::ALLOW_CORS; $allowedHosts[] = cfg::HOST_DEV; if (in_array($host, $allowedHosts)) { header("Access-Control-Allow-Origin: " . $protocol . "://" . $host); } }
php
public static function allowCors() { $origin = filter_input(INPUT_SERVER, 'HTTP_ORIGIN'); $protocol = filter_input(INPUT_SERVER, 'REQUEST_SCHEME') ?? 'http'; $host = preg_replace("/^http(s)?:\/{2}/", "", $origin); $allowedHosts = cfg::ALLOW_CORS; $allowedHosts[] = cfg::HOST_DEV; if (in_array($host, $allowedHosts)) { header("Access-Control-Allow-Origin: " . $protocol . "://" . $host); } }
[ "public", "static", "function", "allowCors", "(", ")", "{", "$", "origin", "=", "filter_input", "(", "INPUT_SERVER", ",", "'HTTP_ORIGIN'", ")", ";", "$", "protocol", "=", "filter_input", "(", "INPUT_SERVER", ",", "'REQUEST_SCHEME'", ")", "??", "'http'", ";", ...
Set header Access-Control-Allow-Origin to Allowed hosts
[ "Set", "header", "Access", "-", "Control", "-", "Allow", "-", "Origin", "to", "Allowed", "hosts" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Common/HttpFunctions.php#L12-L23
train
marczhermo/search-list
src/Client/MySQLClient.php
MySQLClient.createClient
public function createClient() { $indexConfig = ArrayList::create(Config::config()->get('indices')) ->filter(['name' => $this->indexName])->first(); $this->clientAPI = new DataList($indexConfig['class']); $this->indexConfig = $indexConfig; return $this->clientAPI; }
php
public function createClient() { $indexConfig = ArrayList::create(Config::config()->get('indices')) ->filter(['name' => $this->indexName])->first(); $this->clientAPI = new DataList($indexConfig['class']); $this->indexConfig = $indexConfig; return $this->clientAPI; }
[ "public", "function", "createClient", "(", ")", "{", "$", "indexConfig", "=", "ArrayList", "::", "create", "(", "Config", "::", "config", "(", ")", "->", "get", "(", "'indices'", ")", ")", "->", "filter", "(", "[", "'name'", "=>", "$", "this", "->", ...
Instantiates the Client Library API
[ "Instantiates", "the", "Client", "Library", "API" ]
851f42b021c5934a2905026d57feb85e595b8f80
https://github.com/marczhermo/search-list/blob/851f42b021c5934a2905026d57feb85e595b8f80/src/Client/MySQLClient.php#L22-L31
train
CharlotteDunois/Validator
src/Rules/Callback.php
Callback.prototype
static function prototype(callable $callable) { /** @var \ReflectionMethod|\ReflectionFunction $prototype */ if(\is_array($callable)) { $prototype = new \ReflectionMethod($callable[0], $callable[1]); } else { $prototype = new \ReflectionFunction($callable); } $signature = ''; /** @var \ReflectionParameter $param */ foreach($prototype->getParameters() as $param) { $type = $param->getType(); $signature .= ($type->allowsNull() ? '?' : '').$type->getName().($param->isOptional() ? '?' : '').','; } $signature = \substr($signature, 0, -1); $return = $prototype->getReturnType(); if($return !== null) { $signature .= '='.($return->allowsNull() ? '?' : '').$return->getName(); } if(empty($signature)) { throw new \InvalidArgumentException('Given callable has no signature to build'); } return $signature; }
php
static function prototype(callable $callable) { /** @var \ReflectionMethod|\ReflectionFunction $prototype */ if(\is_array($callable)) { $prototype = new \ReflectionMethod($callable[0], $callable[1]); } else { $prototype = new \ReflectionFunction($callable); } $signature = ''; /** @var \ReflectionParameter $param */ foreach($prototype->getParameters() as $param) { $type = $param->getType(); $signature .= ($type->allowsNull() ? '?' : '').$type->getName().($param->isOptional() ? '?' : '').','; } $signature = \substr($signature, 0, -1); $return = $prototype->getReturnType(); if($return !== null) { $signature .= '='.($return->allowsNull() ? '?' : '').$return->getName(); } if(empty($signature)) { throw new \InvalidArgumentException('Given callable has no signature to build'); } return $signature; }
[ "static", "function", "prototype", "(", "callable", "$", "callable", ")", "{", "/** @var \\ReflectionMethod|\\ReflectionFunction $prototype */", "if", "(", "\\", "is_array", "(", "$", "callable", ")", ")", "{", "$", "prototype", "=", "new", "\\", "ReflectionMethod"...
Turns a callable into a callback signature. @param callable $callable @return string @throws \InvalidArgumentException
[ "Turns", "a", "callable", "into", "a", "callback", "signature", "." ]
0c7abddc87174039145bf0ce21d56937f1851365
https://github.com/CharlotteDunois/Validator/blob/0c7abddc87174039145bf0ce21d56937f1851365/src/Rules/Callback.php#L93-L122
train
honey-comb/starter
src/Repositories/Traits/HCQueryBuilderTrait.php
HCQueryBuilderTrait.checkForTrashed
protected function checkForTrashed(Builder $query, Request $request): Builder { if ($request->filled('trashed') && $request->input('trashed') === '1') { $query->onlyTrashed(); } return $query; }
php
protected function checkForTrashed(Builder $query, Request $request): Builder { if ($request->filled('trashed') && $request->input('trashed') === '1') { $query->onlyTrashed(); } return $query; }
[ "protected", "function", "checkForTrashed", "(", "Builder", "$", "query", ",", "Request", "$", "request", ")", ":", "Builder", "{", "if", "(", "$", "request", "->", "filled", "(", "'trashed'", ")", "&&", "$", "request", "->", "input", "(", "'trashed'", "...
Check for trashed records option @param Builder $query @param Request $request @return mixed
[ "Check", "for", "trashed", "records", "option" ]
2c5330a49eb5204a6b748368aca835b7ecb02393
https://github.com/honey-comb/starter/blob/2c5330a49eb5204a6b748368aca835b7ecb02393/src/Repositories/Traits/HCQueryBuilderTrait.php#L226-L233
train
GrottoPress/jentil
app/libraries/Jentil.php
Jentil.is
public function is(string $mode): bool { $rel_dir = $this->getUtilities()->fileSystem->relativeDir(); return ('package' === $mode && $rel_dir) || ('theme' === $mode && !$rel_dir); }
php
public function is(string $mode): bool { $rel_dir = $this->getUtilities()->fileSystem->relativeDir(); return ('package' === $mode && $rel_dir) || ('theme' === $mode && !$rel_dir); }
[ "public", "function", "is", "(", "string", "$", "mode", ")", ":", "bool", "{", "$", "rel_dir", "=", "$", "this", "->", "getUtilities", "(", ")", "->", "fileSystem", "->", "relativeDir", "(", ")", ";", "return", "(", "'package'", "===", "$", "mode", "...
Checks if installed as 'theme' or as 'package'
[ "Checks", "if", "installed", "as", "theme", "or", "as", "package" ]
ad3341c91e0386256d4a2fbe8b7a201c9b706c10
https://github.com/GrottoPress/jentil/blob/ad3341c91e0386256d4a2fbe8b7a201c9b706c10/app/libraries/Jentil.php#L67-L74
train
bytic/omnipay-mobilpay
src/Models/Request.php
Request.buildAccessParameters
public function buildAccessParameters($public_key, &$env_key, &$enc_data) { $params = $this->builParametersList(); if (is_null($params)) { return false; } $src_data = Mobilpay_Payment_Request::buildQueryString($params); $enc_data = ''; $env_keys = []; $result = openssl_seal($src_data, $enc_data, $env_keys, array($public_key)); if ($result === false) { $env_key = null; $enc_data = null; return false; } $env_key = base64_encode($env_keys[0]); $enc_data = base64_encode($enc_data); return true; }
php
public function buildAccessParameters($public_key, &$env_key, &$enc_data) { $params = $this->builParametersList(); if (is_null($params)) { return false; } $src_data = Mobilpay_Payment_Request::buildQueryString($params); $enc_data = ''; $env_keys = []; $result = openssl_seal($src_data, $enc_data, $env_keys, array($public_key)); if ($result === false) { $env_key = null; $enc_data = null; return false; } $env_key = base64_encode($env_keys[0]); $enc_data = base64_encode($enc_data); return true; }
[ "public", "function", "buildAccessParameters", "(", "$", "public_key", ",", "&", "$", "env_key", ",", "&", "$", "enc_data", ")", "{", "$", "params", "=", "$", "this", "->", "builParametersList", "(", ")", ";", "if", "(", "is_null", "(", "$", "params", ...
access Mobilpay.Ro secure payment portal @param resource $public_key - obtained by calling openssl_pkey_get_public @param string &$env_key - returns envelope key base64 encoded or null if function fails @param string &$enc_data - returns data to post base64 encoded or null if function fails @return boolean
[ "access", "Mobilpay", ".", "Ro", "secure", "payment", "portal" ]
2195de762a587d05cef90f2d92b90e91939a45a6
https://github.com/bytic/omnipay-mobilpay/blob/2195de762a587d05cef90f2d92b90e91939a45a6/src/Models/Request.php#L124-L144
train
wikimedia/mediawiki-tools-minus-x
src/CheckCommand.php
CheckCommand.progress
protected function progress( $marker ) { $this->output->write( $marker ); $this->progressCount++; if ( $this->progressCount > 60 ) { $this->progressCount = 0; $this->output->write( "\n" ); } }
php
protected function progress( $marker ) { $this->output->write( $marker ); $this->progressCount++; if ( $this->progressCount > 60 ) { $this->progressCount = 0; $this->output->write( "\n" ); } }
[ "protected", "function", "progress", "(", "$", "marker", ")", "{", "$", "this", "->", "output", "->", "write", "(", "$", "marker", ")", ";", "$", "this", "->", "progressCount", "++", ";", "if", "(", "$", "this", "->", "progressCount", ">", "60", ")",...
Output a progress marker @param string $marker Either ".", "E" or "S"
[ "Output", "a", "progress", "marker" ]
5b4651983be787d30e58503891e6a8981295e4f5
https://github.com/wikimedia/mediawiki-tools-minus-x/blob/5b4651983be787d30e58503891e6a8981295e4f5/src/CheckCommand.php#L104-L111
train
wikimedia/mediawiki-tools-minus-x
src/CheckCommand.php
CheckCommand.setup
protected function setup() { $this->output->writeln( [ 'MinusX', '======', ] ); $rawPath = $this->input->getArgument( 'path' ); $path = realpath( $rawPath ); if ( !$path ) { $this->output->writeln( 'Error: Invalid path specified' ); return 1; } return $path; }
php
protected function setup() { $this->output->writeln( [ 'MinusX', '======', ] ); $rawPath = $this->input->getArgument( 'path' ); $path = realpath( $rawPath ); if ( !$path ) { $this->output->writeln( 'Error: Invalid path specified' ); return 1; } return $path; }
[ "protected", "function", "setup", "(", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "[", "'MinusX'", ",", "'======'", ",", "]", ")", ";", "$", "rawPath", "=", "$", "this", "->", "input", "->", "getArgument", "(", "'path'", ")", ";", ...
Do basic setup @return int|string If an int, it should be the status code to exit with
[ "Do", "basic", "setup" ]
5b4651983be787d30e58503891e6a8981295e4f5
https://github.com/wikimedia/mediawiki-tools-minus-x/blob/5b4651983be787d30e58503891e6a8981295e4f5/src/CheckCommand.php#L118-L132
train
wikimedia/mediawiki-tools-minus-x
src/CheckCommand.php
CheckCommand.loadConfig
protected function loadConfig( $path ) { $confPath = $path . '/.minus-x.json'; if ( !file_exists( $confPath ) ) { return; } $config = json_decode( file_get_contents( $confPath ), true ); if ( !is_array( $config ) ) { $this->output->writeln( 'Error: .minus-x.json is not valid JSON' ); return 1; } if ( isset( $config['ignore'] ) ) { $this->ignoredFiles = array_map( function ( $a ) use ( $path ) { return realpath( $path . '/' . $a ); }, $config['ignore'] ); } if ( isset( $config['ignoreDirectories'] ) ) { $this->ignoredDirs = array_map( function ( $a ) use ( $path ) { return realpath( $path . '/' . $a ); }, $config['ignoreDirectories'] ); } if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) { // On Windows, is_executable() always returns true, so whitelist those // files $this->whitelist[] = 'application/x-dosexec'; } }
php
protected function loadConfig( $path ) { $confPath = $path . '/.minus-x.json'; if ( !file_exists( $confPath ) ) { return; } $config = json_decode( file_get_contents( $confPath ), true ); if ( !is_array( $config ) ) { $this->output->writeln( 'Error: .minus-x.json is not valid JSON' ); return 1; } if ( isset( $config['ignore'] ) ) { $this->ignoredFiles = array_map( function ( $a ) use ( $path ) { return realpath( $path . '/' . $a ); }, $config['ignore'] ); } if ( isset( $config['ignoreDirectories'] ) ) { $this->ignoredDirs = array_map( function ( $a ) use ( $path ) { return realpath( $path . '/' . $a ); }, $config['ignoreDirectories'] ); } if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) { // On Windows, is_executable() always returns true, so whitelist those // files $this->whitelist[] = 'application/x-dosexec'; } }
[ "protected", "function", "loadConfig", "(", "$", "path", ")", "{", "$", "confPath", "=", "$", "path", ".", "'/.minus-x.json'", ";", "if", "(", "!", "file_exists", "(", "$", "confPath", ")", ")", "{", "return", ";", "}", "$", "config", "=", "json_decode...
Load configuration from .minus-x.json @param string $path Root directory that JSON file should be in @return int|null If an int, status code to exit with
[ "Load", "configuration", "from", ".", "minus", "-", "x", ".", "json" ]
5b4651983be787d30e58503891e6a8981295e4f5
https://github.com/wikimedia/mediawiki-tools-minus-x/blob/5b4651983be787d30e58503891e6a8981295e4f5/src/CheckCommand.php#L140-L169
train
wikimedia/mediawiki-tools-minus-x
src/CheckCommand.php
CheckCommand.filterDirs
public function filterDirs( SplFileInfo $current ) { if ( $current->isDir() ) { if ( in_array( $current->getFilename(), $this->defaultIgnoredDirs ) ) { // Default ignored directories can be anywhere in the directory structure return false; } elseif ( in_array( $current->getRealPath(), $this->ignoredDirs ) ) { // Ignored dirs are relative to root, and stored as absolute paths return false; } } return true; }
php
public function filterDirs( SplFileInfo $current ) { if ( $current->isDir() ) { if ( in_array( $current->getFilename(), $this->defaultIgnoredDirs ) ) { // Default ignored directories can be anywhere in the directory structure return false; } elseif ( in_array( $current->getRealPath(), $this->ignoredDirs ) ) { // Ignored dirs are relative to root, and stored as absolute paths return false; } } return true; }
[ "public", "function", "filterDirs", "(", "SplFileInfo", "$", "current", ")", "{", "if", "(", "$", "current", "->", "isDir", "(", ")", ")", "{", "if", "(", "in_array", "(", "$", "current", "->", "getFilename", "(", ")", ",", "$", "this", "->", "defaul...
Filter out ignored directories, split into a separate function for easier readability. Used by RecursiveCallbackFilterIterator @param SplFileInfo $current File/directory to check @return bool
[ "Filter", "out", "ignored", "directories", "split", "into", "a", "separate", "function", "for", "easier", "readability", ".", "Used", "by", "RecursiveCallbackFilterIterator" ]
5b4651983be787d30e58503891e6a8981295e4f5
https://github.com/wikimedia/mediawiki-tools-minus-x/blob/5b4651983be787d30e58503891e6a8981295e4f5/src/CheckCommand.php#L213-L225
train
wikimedia/mediawiki-tools-minus-x
src/CheckCommand.php
CheckCommand.checkPath
protected function checkPath( $path ) { $iterator = new RecursiveIteratorIterator( new RecursiveCallbackFilterIterator( new RecursiveDirectoryIterator( $path ), [ $this, 'filterDirs' ] ) ); $bad = []; /** @var SplFileInfo $file */ foreach ( $iterator as $file ) { // Skip directories if ( !$file->isFile() ) { continue; } // Skip whitelisted files if ( in_array( $file->getPathname(), $this->ignoredFiles ) ) { $this->progress( 'S' ); continue; } if ( !$file->isExecutable() ) { $this->progress( '.' ); continue; } if ( !$this->checkFile( $file ) ) { $this->progress( 'E' ); $bad[] = $file; } else { $this->progress( '.' ); } } return $bad; }
php
protected function checkPath( $path ) { $iterator = new RecursiveIteratorIterator( new RecursiveCallbackFilterIterator( new RecursiveDirectoryIterator( $path ), [ $this, 'filterDirs' ] ) ); $bad = []; /** @var SplFileInfo $file */ foreach ( $iterator as $file ) { // Skip directories if ( !$file->isFile() ) { continue; } // Skip whitelisted files if ( in_array( $file->getPathname(), $this->ignoredFiles ) ) { $this->progress( 'S' ); continue; } if ( !$file->isExecutable() ) { $this->progress( '.' ); continue; } if ( !$this->checkFile( $file ) ) { $this->progress( 'E' ); $bad[] = $file; } else { $this->progress( '.' ); } } return $bad; }
[ "protected", "function", "checkPath", "(", "$", "path", ")", "{", "$", "iterator", "=", "new", "RecursiveIteratorIterator", "(", "new", "RecursiveCallbackFilterIterator", "(", "new", "RecursiveDirectoryIterator", "(", "$", "path", ")", ",", "[", "$", "this", ","...
Recursively search a directory and check it @param string $path Directory @return SplFileInfo[]
[ "Recursively", "search", "a", "directory", "and", "check", "it" ]
5b4651983be787d30e58503891e6a8981295e4f5
https://github.com/wikimedia/mediawiki-tools-minus-x/blob/5b4651983be787d30e58503891e6a8981295e4f5/src/CheckCommand.php#L233-L268
train
honey-comb/starter
src/Models/HCModel.php
HCModel.getFillableFields
public static function getFillableFields(bool $join = false) { $list = with(new static)->getFillable(); if ($join) { //to use default sort_by command array_push($list, 'created_at'); foreach ($list as &$value) $value = self::getTableName() . '.' . $value; } return $list; }
php
public static function getFillableFields(bool $join = false) { $list = with(new static)->getFillable(); if ($join) { //to use default sort_by command array_push($list, 'created_at'); foreach ($list as &$value) $value = self::getTableName() . '.' . $value; } return $list; }
[ "public", "static", "function", "getFillableFields", "(", "bool", "$", "join", "=", "false", ")", "{", "$", "list", "=", "with", "(", "new", "static", ")", "->", "getFillable", "(", ")", ";", "if", "(", "$", "join", ")", "{", "//to use default sort_by co...
Function which gets fillable fields array @param bool $join @return array
[ "Function", "which", "gets", "fillable", "fields", "array" ]
2c5330a49eb5204a6b748368aca835b7ecb02393
https://github.com/honey-comb/starter/blob/2c5330a49eb5204a6b748368aca835b7ecb02393/src/Models/HCModel.php#L63-L76
train
hiqdev/hipanel-module-client
src/models/Client.php
Client.getSortedPurses
public function getSortedPurses() { $purses = $this->purses; if (empty($purses)) { return $purses; } $getOrder = function ($currency) { $order = ['usd' => 0, 'eur' => 1]; return $order[$currency] ?? 100; }; usort($purses, function ($a, $b) use ($getOrder) { return $getOrder($a->currency) <=> $getOrder($b->currency); }); return $purses; }
php
public function getSortedPurses() { $purses = $this->purses; if (empty($purses)) { return $purses; } $getOrder = function ($currency) { $order = ['usd' => 0, 'eur' => 1]; return $order[$currency] ?? 100; }; usort($purses, function ($a, $b) use ($getOrder) { return $getOrder($a->currency) <=> $getOrder($b->currency); }); return $purses; }
[ "public", "function", "getSortedPurses", "(", ")", "{", "$", "purses", "=", "$", "this", "->", "purses", ";", "if", "(", "empty", "(", "$", "purses", ")", ")", "{", "return", "$", "purses", ";", "}", "$", "getOrder", "=", "function", "(", "$", "cur...
Sort related purses like `usd`, `eur`, other... @return array
[ "Sort", "related", "purses", "like", "usd", "eur", "other", "..." ]
569d87de369ccf8646087dde566d26a41995c8cb
https://github.com/hiqdev/hipanel-module-client/blob/569d87de369ccf8646087dde566d26a41995c8cb/src/models/Client.php#L438-L456
train
edineibauer/uebConfig
public/src/Config/UpdateSystem.php
UpdateSystem.createCoreImages
private function createCoreImages() { Helper::createFolderIfNoExist(PATH_HOME . "assetsPublic/img"); $config = json_decode(file_get_contents(PATH_HOME . "_config/config.json"), true); copy(PATH_HOME . VENDOR . "config/public/assets/dino.png", PATH_HOME . "assetsPublic/img/dino.png"); copy(PATH_HOME . VENDOR . "config/public/assets/file.png", PATH_HOME . "assetsPublic/img/file.png"); copy(PATH_HOME . VENDOR . "config/public/assets/save.gif", PATH_HOME . "assetsPublic/img/save.gif"); copy(PATH_HOME . VENDOR . "config/public/assets/file_type.svg", PATH_HOME . "assetsPublic/img/file_type.svg"); copy(PATH_HOME . VENDOR . "config/public/assets/image-not-found.png", PATH_HOME . "assetsPublic/img/img.png"); if(file_exists(PATH_HOME . (!empty($config['favicon']) ? "uploads/site/favicon.png" : VENDOR . "config/public/assets/favicon.png"))) copy(PATH_HOME . (!empty($config['favicon']) ? "uploads/site/favicon.png" : VENDOR . "config/public/assets/favicon.png"), PATH_HOME . "assetsPublic/img/favicon.png"); if(!empty($config['logo']) && file_exists(PATH_HOME . "uploads/site/logo.png")) copy(PATH_HOME . "uploads/site/logo.png", PATH_HOME . "assetsPublic/img/logo.png"); elseif(file_exists(PATH_HOME . "assetsPublic/img/logo.png")) unlink(PATH_HOME . "assetsPublic/img/logo.png"); }
php
private function createCoreImages() { Helper::createFolderIfNoExist(PATH_HOME . "assetsPublic/img"); $config = json_decode(file_get_contents(PATH_HOME . "_config/config.json"), true); copy(PATH_HOME . VENDOR . "config/public/assets/dino.png", PATH_HOME . "assetsPublic/img/dino.png"); copy(PATH_HOME . VENDOR . "config/public/assets/file.png", PATH_HOME . "assetsPublic/img/file.png"); copy(PATH_HOME . VENDOR . "config/public/assets/save.gif", PATH_HOME . "assetsPublic/img/save.gif"); copy(PATH_HOME . VENDOR . "config/public/assets/file_type.svg", PATH_HOME . "assetsPublic/img/file_type.svg"); copy(PATH_HOME . VENDOR . "config/public/assets/image-not-found.png", PATH_HOME . "assetsPublic/img/img.png"); if(file_exists(PATH_HOME . (!empty($config['favicon']) ? "uploads/site/favicon.png" : VENDOR . "config/public/assets/favicon.png"))) copy(PATH_HOME . (!empty($config['favicon']) ? "uploads/site/favicon.png" : VENDOR . "config/public/assets/favicon.png"), PATH_HOME . "assetsPublic/img/favicon.png"); if(!empty($config['logo']) && file_exists(PATH_HOME . "uploads/site/logo.png")) copy(PATH_HOME . "uploads/site/logo.png", PATH_HOME . "assetsPublic/img/logo.png"); elseif(file_exists(PATH_HOME . "assetsPublic/img/logo.png")) unlink(PATH_HOME . "assetsPublic/img/logo.png"); }
[ "private", "function", "createCoreImages", "(", ")", "{", "Helper", "::", "createFolderIfNoExist", "(", "PATH_HOME", ".", "\"assetsPublic/img\"", ")", ";", "$", "config", "=", "json_decode", "(", "file_get_contents", "(", "PATH_HOME", ".", "\"_config/config.json\"", ...
Cria Imagens do sistema
[ "Cria", "Imagens", "do", "sistema" ]
6792d15656f5a9f78f2510d4850aa21102f96c1f
https://github.com/edineibauer/uebConfig/blob/6792d15656f5a9f78f2510d4850aa21102f96c1f/public/src/Config/UpdateSystem.php#L395-L413
train
edineibauer/uebConfig
public/src/Config/UpdateSystem.php
UpdateSystem.createMinifyAssetsLib
private function createMinifyAssetsLib() { Helper::createFolderIfNoExist(PATH_HOME . 'assetsPublic/cache'); Helper::createFolderIfNoExist(PATH_HOME . 'assetsPublic/view'); //Remove todos os dados das pastas de assets foreach (Helper::listFolder(PATH_HOME . "assetsPublic/cache") as $cache) { if(!is_dir(PATH_HOME . "assetsPublic/cache/" . $cache)) unlink(PATH_HOME . "assetsPublic/cache/" . $cache); } foreach (Helper::listFolder(PATH_HOME . "assetsPublic/view") as $cache) { if(!is_dir(PATH_HOME . "assetsPublic/view/" . $cache)) unlink(PATH_HOME . "assetsPublic/view/" . $cache); } $vendors = Config::getViewPermissoes(); $this->createRepositorioCache($vendors); $this->downloadAssetsCache($vendors); foreach ($vendors as $lib) { $path = PATH_HOME . VENDOR . $lib . "/public/"; if (file_exists($path . "view")) { foreach (Helper::listFolder($path . "view") as $view) { if (preg_match('/.php$/i', $view)) { //para cada view $nameView = str_replace('.php', '', $view); if(!in_array($nameView, ['updateSystema'])) $this->createViewAssets($path, $nameView); } } } } }
php
private function createMinifyAssetsLib() { Helper::createFolderIfNoExist(PATH_HOME . 'assetsPublic/cache'); Helper::createFolderIfNoExist(PATH_HOME . 'assetsPublic/view'); //Remove todos os dados das pastas de assets foreach (Helper::listFolder(PATH_HOME . "assetsPublic/cache") as $cache) { if(!is_dir(PATH_HOME . "assetsPublic/cache/" . $cache)) unlink(PATH_HOME . "assetsPublic/cache/" . $cache); } foreach (Helper::listFolder(PATH_HOME . "assetsPublic/view") as $cache) { if(!is_dir(PATH_HOME . "assetsPublic/view/" . $cache)) unlink(PATH_HOME . "assetsPublic/view/" . $cache); } $vendors = Config::getViewPermissoes(); $this->createRepositorioCache($vendors); $this->downloadAssetsCache($vendors); foreach ($vendors as $lib) { $path = PATH_HOME . VENDOR . $lib . "/public/"; if (file_exists($path . "view")) { foreach (Helper::listFolder($path . "view") as $view) { if (preg_match('/.php$/i', $view)) { //para cada view $nameView = str_replace('.php', '', $view); if(!in_array($nameView, ['updateSystema'])) $this->createViewAssets($path, $nameView); } } } } }
[ "private", "function", "createMinifyAssetsLib", "(", ")", "{", "Helper", "::", "createFolderIfNoExist", "(", "PATH_HOME", ".", "'assetsPublic/cache'", ")", ";", "Helper", "::", "createFolderIfNoExist", "(", "PATH_HOME", ".", "'assetsPublic/view'", ")", ";", "//Remove ...
Minifica todos os assets das bibliotecas
[ "Minifica", "todos", "os", "assets", "das", "bibliotecas" ]
6792d15656f5a9f78f2510d4850aa21102f96c1f
https://github.com/edineibauer/uebConfig/blob/6792d15656f5a9f78f2510d4850aa21102f96c1f/public/src/Config/UpdateSystem.php#L660-L694
train
CMProductions/http-client
src/Provider/HttpClientServiceProvider.php
HttpClientServiceProvider.getBuilder
private function getBuilder(Container $pimple) { $builder = ClientBuilder::create(); $this->setFactory($builder, $pimple); $this->setSender($builder, $pimple); $this->setLogger($builder, $pimple); return $builder; }
php
private function getBuilder(Container $pimple) { $builder = ClientBuilder::create(); $this->setFactory($builder, $pimple); $this->setSender($builder, $pimple); $this->setLogger($builder, $pimple); return $builder; }
[ "private", "function", "getBuilder", "(", "Container", "$", "pimple", ")", "{", "$", "builder", "=", "ClientBuilder", "::", "create", "(", ")", ";", "$", "this", "->", "setFactory", "(", "$", "builder", ",", "$", "pimple", ")", ";", "$", "this", "->", ...
Builds the container @param Container $pimple @return Client
[ "Builds", "the", "container" ]
d7e5a74cdf94b6b50a229db6698c81fd055ff2ce
https://github.com/CMProductions/http-client/blob/d7e5a74cdf94b6b50a229db6698c81fd055ff2ce/src/Provider/HttpClientServiceProvider.php#L62-L71
train
cedx/which.php
lib/Finder.php
Finder.find
function find(string $command): \Generator { foreach ($this->getPath() as $directory) yield from $this->findExecutables($directory, $command); }
php
function find(string $command): \Generator { foreach ($this->getPath() as $directory) yield from $this->findExecutables($directory, $command); }
[ "function", "find", "(", "string", "$", "command", ")", ":", "\\", "Generator", "{", "foreach", "(", "$", "this", "->", "getPath", "(", ")", "as", "$", "directory", ")", "yield", "from", "$", "this", "->", "findExecutables", "(", "$", "directory", ",",...
Finds the instances of an executable in the system path. @param string $command The command to be resolved. @return \Generator The paths of the executables found.
[ "Finds", "the", "instances", "of", "an", "executable", "in", "the", "system", "path", "." ]
3ab7702edaec4cc0059af609f7edb84bf3a8bb91
https://github.com/cedx/which.php/blob/3ab7702edaec4cc0059af609f7edb84bf3a8bb91/lib/Finder.php#L60-L62
train
cedx/which.php
lib/Finder.php
Finder.isExecutable
function isExecutable(string $file): bool { $fileInfo = new \SplFileInfo($file); if (!$fileInfo->isFile()) return false; if ($fileInfo->isExecutable()) return true; return static::isWindows() ? $this->checkFileExtension($fileInfo) : $this->checkFilePermissions($fileInfo); }
php
function isExecutable(string $file): bool { $fileInfo = new \SplFileInfo($file); if (!$fileInfo->isFile()) return false; if ($fileInfo->isExecutable()) return true; return static::isWindows() ? $this->checkFileExtension($fileInfo) : $this->checkFilePermissions($fileInfo); }
[ "function", "isExecutable", "(", "string", "$", "file", ")", ":", "bool", "{", "$", "fileInfo", "=", "new", "\\", "SplFileInfo", "(", "$", "file", ")", ";", "if", "(", "!", "$", "fileInfo", "->", "isFile", "(", ")", ")", "return", "false", ";", "if...
Gets a value indicating whether the specified file is executable. @param string $file The path of the file to be checked. @return bool `true` if the specified file is executable, otherwise `false`.
[ "Gets", "a", "value", "indicating", "whether", "the", "specified", "file", "is", "executable", "." ]
3ab7702edaec4cc0059af609f7edb84bf3a8bb91
https://github.com/cedx/which.php/blob/3ab7702edaec4cc0059af609f7edb84bf3a8bb91/lib/Finder.php#L93-L98
train
cedx/which.php
lib/Finder.php
Finder.checkFileExtension
private function checkFileExtension(\SplFileInfo $fileInfo): bool { $extension = mb_strtolower($fileInfo->getExtension()); return mb_strlen($extension) ? in_array(".$extension", $this->getExtensions()->getArrayCopy()) : false; }
php
private function checkFileExtension(\SplFileInfo $fileInfo): bool { $extension = mb_strtolower($fileInfo->getExtension()); return mb_strlen($extension) ? in_array(".$extension", $this->getExtensions()->getArrayCopy()) : false; }
[ "private", "function", "checkFileExtension", "(", "\\", "SplFileInfo", "$", "fileInfo", ")", ":", "bool", "{", "$", "extension", "=", "mb_strtolower", "(", "$", "fileInfo", "->", "getExtension", "(", ")", ")", ";", "return", "mb_strlen", "(", "$", "extension...
Checks that the specified file is executable according to the executable file extensions. @param \SplFileInfo $fileInfo The file to be checked. @return bool Value indicating whether the specified file is executable.
[ "Checks", "that", "the", "specified", "file", "is", "executable", "according", "to", "the", "executable", "file", "extensions", "." ]
3ab7702edaec4cc0059af609f7edb84bf3a8bb91
https://github.com/cedx/which.php/blob/3ab7702edaec4cc0059af609f7edb84bf3a8bb91/lib/Finder.php#L105-L108
train
cedx/which.php
lib/Finder.php
Finder.checkFilePermissions
private function checkFilePermissions(\SplFileInfo $fileInfo): bool { // Others. $perms = $fileInfo->getPerms(); if ($perms & 0001) return true; // Group. $gid = function_exists('posix_getgid') ? posix_getgid() : -1; if ($perms & 0010) return $gid == $fileInfo->getGroup(); // Owner. $uid = function_exists('posix_getuid') ? posix_getuid() : -1; if ($perms & 0100) return $uid == $fileInfo->getOwner(); // Root. return $perms & (0100 | 0010) ? $uid == 0 : false; }
php
private function checkFilePermissions(\SplFileInfo $fileInfo): bool { // Others. $perms = $fileInfo->getPerms(); if ($perms & 0001) return true; // Group. $gid = function_exists('posix_getgid') ? posix_getgid() : -1; if ($perms & 0010) return $gid == $fileInfo->getGroup(); // Owner. $uid = function_exists('posix_getuid') ? posix_getuid() : -1; if ($perms & 0100) return $uid == $fileInfo->getOwner(); // Root. return $perms & (0100 | 0010) ? $uid == 0 : false; }
[ "private", "function", "checkFilePermissions", "(", "\\", "SplFileInfo", "$", "fileInfo", ")", ":", "bool", "{", "// Others.", "$", "perms", "=", "$", "fileInfo", "->", "getPerms", "(", ")", ";", "if", "(", "$", "perms", "&", "0001", ")", "return", "true...
Checks that the specified file is executable according to its permissions. @param \SplFileInfo $fileInfo The file to be checked. @return bool Value indicating whether the specified file is executable.
[ "Checks", "that", "the", "specified", "file", "is", "executable", "according", "to", "its", "permissions", "." ]
3ab7702edaec4cc0059af609f7edb84bf3a8bb91
https://github.com/cedx/which.php/blob/3ab7702edaec4cc0059af609f7edb84bf3a8bb91/lib/Finder.php#L115-L130
train
cedx/which.php
lib/Finder.php
Finder.findExecutables
private function findExecutables(string $directory, string $command): \Generator { foreach (array_merge([''], $this->getExtensions()->getArrayCopy()) as $extension) { $resolvedPath = Path::makeAbsolute(Path::join($directory, $command).mb_strtolower($extension), getcwd() ?: '.'); if ($this->isExecutable($resolvedPath)) yield str_replace('/', DIRECTORY_SEPARATOR, $resolvedPath); } }
php
private function findExecutables(string $directory, string $command): \Generator { foreach (array_merge([''], $this->getExtensions()->getArrayCopy()) as $extension) { $resolvedPath = Path::makeAbsolute(Path::join($directory, $command).mb_strtolower($extension), getcwd() ?: '.'); if ($this->isExecutable($resolvedPath)) yield str_replace('/', DIRECTORY_SEPARATOR, $resolvedPath); } }
[ "private", "function", "findExecutables", "(", "string", "$", "directory", ",", "string", "$", "command", ")", ":", "\\", "Generator", "{", "foreach", "(", "array_merge", "(", "[", "''", "]", ",", "$", "this", "->", "getExtensions", "(", ")", "->", "getA...
Finds the instances of an executable in the specified directory. @param string $directory The directory path. @param string $command The command to be resolved. @return \Generator The paths of the executables found.
[ "Finds", "the", "instances", "of", "an", "executable", "in", "the", "specified", "directory", "." ]
3ab7702edaec4cc0059af609f7edb84bf3a8bb91
https://github.com/cedx/which.php/blob/3ab7702edaec4cc0059af609f7edb84bf3a8bb91/lib/Finder.php#L138-L143
train
chameleon-system/sanitycheck-bundle
Resolver/SymfonyContainerCheckResolver.php
SymfonyContainerCheckResolver.lookupCheckByServiceId
protected function lookupCheckByServiceId($name) { try { return $this->container->get($name); } catch (\InvalidArgumentException $e) { throw new CheckNotFoundException('Check not found: '.$name, 0, $e); } }
php
protected function lookupCheckByServiceId($name) { try { return $this->container->get($name); } catch (\InvalidArgumentException $e) { throw new CheckNotFoundException('Check not found: '.$name, 0, $e); } }
[ "protected", "function", "lookupCheckByServiceId", "(", "$", "name", ")", "{", "try", "{", "return", "$", "this", "->", "container", "->", "get", "(", "$", "name", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "throw"...
Gets a check from the container. @param string $name The check's service id @throws CheckNotFoundException if the check is not registered as a service @return CheckInterface
[ "Gets", "a", "check", "from", "the", "container", "." ]
7d95fabd0af212acbdee226dbe754dca3046f225
https://github.com/chameleon-system/sanitycheck-bundle/blob/7d95fabd0af212acbdee226dbe754dca3046f225/Resolver/SymfonyContainerCheckResolver.php#L95-L102
train
stubbles/stubbles-console
src/main/php/input/HelpScreen.php
HelpScreen.readAppDescription
private function readAppDescription($object): string { $annotations = annotationsOf($object); if (!$annotations->contain('AppDescription')) { return ''; } return $annotations->firstNamed('AppDescription')->getValue() . "\n"; }
php
private function readAppDescription($object): string { $annotations = annotationsOf($object); if (!$annotations->contain('AppDescription')) { return ''; } return $annotations->firstNamed('AppDescription')->getValue() . "\n"; }
[ "private", "function", "readAppDescription", "(", "$", "object", ")", ":", "string", "{", "$", "annotations", "=", "annotationsOf", "(", "$", "object", ")", ";", "if", "(", "!", "$", "annotations", "->", "contain", "(", "'AppDescription'", ")", ")", "{", ...
retrieves app description for given object @param object $object @return string
[ "retrieves", "app", "description", "for", "given", "object" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/input/HelpScreen.php#L68-L76
train
stubbles/stubbles-console
src/main/php/input/HelpScreen.php
HelpScreen.getOptionName
private function getOptionName(TargetMethod $targetMethod): string { $name = $targetMethod->paramName(); $prefix = strlen($name) === 1 ? '-' : '--'; $suffix = $targetMethod->requiresParameter() ? ' ' . $targetMethod->valueDescription() : ''; return $prefix . $name . $suffix; }
php
private function getOptionName(TargetMethod $targetMethod): string { $name = $targetMethod->paramName(); $prefix = strlen($name) === 1 ? '-' : '--'; $suffix = $targetMethod->requiresParameter() ? ' ' . $targetMethod->valueDescription() : ''; return $prefix . $name . $suffix; }
[ "private", "function", "getOptionName", "(", "TargetMethod", "$", "targetMethod", ")", ":", "string", "{", "$", "name", "=", "$", "targetMethod", "->", "paramName", "(", ")", ";", "$", "prefix", "=", "strlen", "(", "$", "name", ")", "===", "1", "?", "'...
retrieves name of option @param \stubbles\input\broker\TargetMethod $targetMethod @return string
[ "retrieves", "name", "of", "option" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/input/HelpScreen.php#L84-L90
train
electro-modules/matisse-components
MatisseComponents/Handlers/FileFieldHandler.php
FileFieldHandler.newUpload
private function newUpload (BaseModel $model, $fieldName, UploadedFileInterface $file) { // Check is there are already files on this field. $filesRelation = $model->files (); /** @var Builder $filesQuery */ $filesQuery = $filesRelation->ofField ($fieldName); /** @var File[] $files */ $files = $filesQuery->get (); // Save new file $data = File::getFileData ($file->getClientFilename (), FileUtil::getUploadedFilePath ($file), $fieldName); /** @var File $fileModel */ $fileModel = $filesRelation->create ($data); $this->repository->saveUploadedFile ($fileModel->path, $file); // Delete the previous files of this field, if any exists. // This is only performed AFTER the new file is successfully uploaded. foreach ($files as $file) $file->delete (); // If everything went ok, save the models. if (!in_array ($fieldName, $model::GALLERY_FIELDS)) $model[$fieldName] = $fileModel->path; $model->save (); }
php
private function newUpload (BaseModel $model, $fieldName, UploadedFileInterface $file) { // Check is there are already files on this field. $filesRelation = $model->files (); /** @var Builder $filesQuery */ $filesQuery = $filesRelation->ofField ($fieldName); /** @var File[] $files */ $files = $filesQuery->get (); // Save new file $data = File::getFileData ($file->getClientFilename (), FileUtil::getUploadedFilePath ($file), $fieldName); /** @var File $fileModel */ $fileModel = $filesRelation->create ($data); $this->repository->saveUploadedFile ($fileModel->path, $file); // Delete the previous files of this field, if any exists. // This is only performed AFTER the new file is successfully uploaded. foreach ($files as $file) $file->delete (); // If everything went ok, save the models. if (!in_array ($fieldName, $model::GALLERY_FIELDS)) $model[$fieldName] = $fileModel->path; $model->save (); }
[ "private", "function", "newUpload", "(", "BaseModel", "$", "model", ",", "$", "fieldName", ",", "UploadedFileInterface", "$", "file", ")", "{", "// Check is there are already files on this field.", "$", "filesRelation", "=", "$", "model", "->", "files", "(", ")", ...
Handle the case where a file has been uploaded for a field, possibly replacing another already set on the field. @param BaseModel|FilesModelTrait $model @param string $fieldName @param UploadedFileInterface $file @throws \Exception @throws \League\Flysystem\FileExistsException @throws \League\Flysystem\InvalidArgumentException
[ "Handle", "the", "case", "where", "a", "file", "has", "been", "uploaded", "for", "a", "field", "possibly", "replacing", "another", "already", "set", "on", "the", "field", "." ]
3a746f796157ef72b585a5994394483fbe500861
https://github.com/electro-modules/matisse-components/blob/3a746f796157ef72b585a5994394483fbe500861/MatisseComponents/Handlers/FileFieldHandler.php#L158-L182
train
electro-modules/matisse-components
MatisseComponents/Handlers/FileFieldHandler.php
FileFieldHandler.noUpload
private function noUpload (BaseModel $model, $fieldName) { if (!isset ($model[$fieldName])) { // Check is there are already files on this field. $filesRelation = $model->files (); /** @var Builder $filesQuery */ $filesQuery = $filesRelation->ofField ($fieldName); /** @var File[] $files */ $files = $filesQuery->get (); // Delete the previous files of this field, if any exists. foreach ($files as $file) $file->delete (); } }
php
private function noUpload (BaseModel $model, $fieldName) { if (!isset ($model[$fieldName])) { // Check is there are already files on this field. $filesRelation = $model->files (); /** @var Builder $filesQuery */ $filesQuery = $filesRelation->ofField ($fieldName); /** @var File[] $files */ $files = $filesQuery->get (); // Delete the previous files of this field, if any exists. foreach ($files as $file) $file->delete (); } }
[ "private", "function", "noUpload", "(", "BaseModel", "$", "model", ",", "$", "fieldName", ")", "{", "if", "(", "!", "isset", "(", "$", "model", "[", "$", "fieldName", "]", ")", ")", "{", "// Check is there are already files on this field.", "$", "filesRelation...
Handle the case where no file has been uploaded for a field, but the field may have been cleared. @param BaseModel|FilesModelTrait $model @param string $fieldName @throws \Exception
[ "Handle", "the", "case", "where", "no", "file", "has", "been", "uploaded", "for", "a", "field", "but", "the", "field", "may", "have", "been", "cleared", "." ]
3a746f796157ef72b585a5994394483fbe500861
https://github.com/electro-modules/matisse-components/blob/3a746f796157ef72b585a5994394483fbe500861/MatisseComponents/Handlers/FileFieldHandler.php#L191-L205
train
stubbles/stubbles-console
src/main/php/creator/FileCreator.php
FileCreator.fileNameforClass
protected function fileNameforClass(string $className, string $type = 'main'): string { if (file_exists($this->rootpath->to('composer.json'))) { $composer = json_decode( file_get_contents($this->rootpath->to('composer.json')), true ); if (isset($composer['autoload']['psr-4'])) { return $this->fileNameForPsr4( $composer['autoload']['psr-4'], $className, $type ); } } // assume psr-0 with standard stubbles pathes return $this->rootpath->to( 'src', $type, 'php', str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php' ); }
php
protected function fileNameforClass(string $className, string $type = 'main'): string { if (file_exists($this->rootpath->to('composer.json'))) { $composer = json_decode( file_get_contents($this->rootpath->to('composer.json')), true ); if (isset($composer['autoload']['psr-4'])) { return $this->fileNameForPsr4( $composer['autoload']['psr-4'], $className, $type ); } } // assume psr-0 with standard stubbles pathes return $this->rootpath->to( 'src', $type, 'php', str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php' ); }
[ "protected", "function", "fileNameforClass", "(", "string", "$", "className", ",", "string", "$", "type", "=", "'main'", ")", ":", "string", "{", "if", "(", "file_exists", "(", "$", "this", "->", "rootpath", "->", "to", "(", "'composer.json'", ")", ")", ...
returns name of class file to create @param string $className @param string $type @return string
[ "returns", "name", "of", "class", "file", "to", "create" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/creator/FileCreator.php#L67-L90
train
stubbles/stubbles-console
src/main/php/creator/FileCreator.php
FileCreator.fileNameForPsr4
private function fileNameForPsr4(array $psr4Pathes, string $className, string $type): string { foreach ($psr4Pathes as $prefix => $path) { if (substr($className, 0, strlen($prefix)) === $prefix) { return $this->rootpath->to( str_replace('main', $type, $path), str_replace( '\\', DIRECTORY_SEPARATOR, str_replace($prefix, '', $className) ) . '.php' ); } } throw new \UnexpectedValueException( 'No PSR-4 path for class ' . $className . ' found in composer.json' ); }
php
private function fileNameForPsr4(array $psr4Pathes, string $className, string $type): string { foreach ($psr4Pathes as $prefix => $path) { if (substr($className, 0, strlen($prefix)) === $prefix) { return $this->rootpath->to( str_replace('main', $type, $path), str_replace( '\\', DIRECTORY_SEPARATOR, str_replace($prefix, '', $className) ) . '.php' ); } } throw new \UnexpectedValueException( 'No PSR-4 path for class ' . $className . ' found in composer.json' ); }
[ "private", "function", "fileNameForPsr4", "(", "array", "$", "psr4Pathes", ",", "string", "$", "className", ",", "string", "$", "type", ")", ":", "string", "{", "foreach", "(", "$", "psr4Pathes", "as", "$", "prefix", "=>", "$", "path", ")", "{", "if", ...
retrieve psr-4 compatible file name @param array $psr4Pathes map of psr-4 pathes from composer.json @param string $className name of class to retrieve file name for @param string $type whether it a normal class or a test class @return string @throws \UnexpectedValueException
[ "retrieve", "psr", "-", "4", "compatible", "file", "name" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/creator/FileCreator.php#L101-L119
train
stubbles/stubbles-console
src/main/php/creator/FileCreator.php
FileCreator.createFile
protected function createFile(string $fileName, string $className, string $template) { $directory = dirname($fileName); if (!file_exists($directory . '/.')) { mkdir($directory, 0755, true); } file_put_contents( $fileName, str_replace( ['{NAMESPACE}', '{CLASS}'], [$this->namespaceOf($className), $this->nonQualifiedClassNameOf($className) ], $this->resourceLoader->load($this->pathForTemplate($template)) ) ); }
php
protected function createFile(string $fileName, string $className, string $template) { $directory = dirname($fileName); if (!file_exists($directory . '/.')) { mkdir($directory, 0755, true); } file_put_contents( $fileName, str_replace( ['{NAMESPACE}', '{CLASS}'], [$this->namespaceOf($className), $this->nonQualifiedClassNameOf($className) ], $this->resourceLoader->load($this->pathForTemplate($template)) ) ); }
[ "protected", "function", "createFile", "(", "string", "$", "fileName", ",", "string", "$", "className", ",", "string", "$", "template", ")", "{", "$", "directory", "=", "dirname", "(", "$", "fileName", ")", ";", "if", "(", "!", "file_exists", "(", "$", ...
creates file of given type for given class @param string $fileName @param string $className @param string $template
[ "creates", "file", "of", "given", "type", "for", "given", "class" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/creator/FileCreator.php#L128-L145
train
stubbles/stubbles-console
src/main/php/creator/FileCreator.php
FileCreator.pathForTemplate
private function pathForTemplate(string $template): string { $pathes = $this->resourceLoader->availableResourceUris('creator/' . $template); if (!isset($pathes[0])) { throw new \RuntimeException('Could not load template ' . $template); } return $pathes[0]; }
php
private function pathForTemplate(string $template): string { $pathes = $this->resourceLoader->availableResourceUris('creator/' . $template); if (!isset($pathes[0])) { throw new \RuntimeException('Could not load template ' . $template); } return $pathes[0]; }
[ "private", "function", "pathForTemplate", "(", "string", "$", "template", ")", ":", "string", "{", "$", "pathes", "=", "$", "this", "->", "resourceLoader", "->", "availableResourceUris", "(", "'creator/'", ".", "$", "template", ")", ";", "if", "(", "!", "i...
finds absolute path for given template file @param string $template @return string @throws \RuntimeException
[ "finds", "absolute", "path", "for", "given", "template", "file" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/creator/FileCreator.php#L154-L162
train
stubbles/stubbles-console
src/main/php/input/ArgumentParser.php
ArgumentParser.parseArgs
private function parseArgs(): array { if (null === $this->options && count($this->longopts) === 0 && null === $this->userInput) { return $this->fixArgs($_SERVER['argv']); } if (null !== $this->userInput) { $this->collectOptionsFromUserInputClass(); } $parseCommandLineOptions = $this->cliOptionParser; $parsedVars = $parseCommandLineOptions($this->options, $this->longopts); if (false === $parsedVars) { throw new \RuntimeException( 'Error parsing "' . join(' ', $_SERVER['argv']) . '" with ' . $this->options . ' and ' . join(' ', $this->longopts) ); } return $this->fixArgs($_SERVER['argv'], $parsedVars); }
php
private function parseArgs(): array { if (null === $this->options && count($this->longopts) === 0 && null === $this->userInput) { return $this->fixArgs($_SERVER['argv']); } if (null !== $this->userInput) { $this->collectOptionsFromUserInputClass(); } $parseCommandLineOptions = $this->cliOptionParser; $parsedVars = $parseCommandLineOptions($this->options, $this->longopts); if (false === $parsedVars) { throw new \RuntimeException( 'Error parsing "' . join(' ', $_SERVER['argv']) . '" with ' . $this->options . ' and ' . join(' ', $this->longopts) ); } return $this->fixArgs($_SERVER['argv'], $parsedVars); }
[ "private", "function", "parseArgs", "(", ")", ":", "array", "{", "if", "(", "null", "===", "$", "this", "->", "options", "&&", "count", "(", "$", "this", "->", "longopts", ")", "===", "0", "&&", "null", "===", "$", "this", "->", "userInput", ")", "...
returns parsed arguments @return array @throws \RuntimeException
[ "returns", "parsed", "arguments" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/input/ArgumentParser.php#L141-L162
train
stubbles/stubbles-console
src/main/php/input/ArgumentParser.php
ArgumentParser.fixArgs
private function fixArgs(array $args, array $parsedVars = []): array { array_shift($args); // script name $vars = []; $position = 0; foreach ($args as $arg) { if (isset($parsedVars[substr($arg, 1)]) || isset($parsedVars[substr($arg, 2)]) || in_array($arg, $parsedVars)) { continue; } $vars['argv.' . $position] = $arg; $position++; } return array_merge($vars, $parsedVars); }
php
private function fixArgs(array $args, array $parsedVars = []): array { array_shift($args); // script name $vars = []; $position = 0; foreach ($args as $arg) { if (isset($parsedVars[substr($arg, 1)]) || isset($parsedVars[substr($arg, 2)]) || in_array($arg, $parsedVars)) { continue; } $vars['argv.' . $position] = $arg; $position++; } return array_merge($vars, $parsedVars); }
[ "private", "function", "fixArgs", "(", "array", "$", "args", ",", "array", "$", "parsedVars", "=", "[", "]", ")", ":", "array", "{", "array_shift", "(", "$", "args", ")", ";", "// script name", "$", "vars", "=", "[", "]", ";", "$", "position", "=", ...
retrieves list of arguments @param array $args @param array $parsedVars @return array
[ "retrieves", "list", "of", "arguments" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/input/ArgumentParser.php#L171-L186
train
stubbles/stubbles-console
src/main/php/input/ArgumentParser.php
ArgumentParser.collectOptionsFromUserInputClass
private function collectOptionsFromUserInputClass() { foreach (RequestBroker::targetMethodsOf($this->userInput) as $targetMethod) { $name = $targetMethod->paramName(); if (substr($name, 0, 5) === 'argv.') { continue; } if (strlen($name) === 1) { $this->options .= $name . ($targetMethod->requiresParameter() ? ':' : ''); } else { $this->longopts[] = $name . ($targetMethod->requiresParameter() ? ':' : ''); } } if (null === $this->options || !strpos($this->options, 'h')) { $this->options .= 'h'; } if (!in_array('help', $this->longopts)) { $this->longopts[] = 'help'; } }
php
private function collectOptionsFromUserInputClass() { foreach (RequestBroker::targetMethodsOf($this->userInput) as $targetMethod) { $name = $targetMethod->paramName(); if (substr($name, 0, 5) === 'argv.') { continue; } if (strlen($name) === 1) { $this->options .= $name . ($targetMethod->requiresParameter() ? ':' : ''); } else { $this->longopts[] = $name . ($targetMethod->requiresParameter() ? ':' : ''); } } if (null === $this->options || !strpos($this->options, 'h')) { $this->options .= 'h'; } if (!in_array('help', $this->longopts)) { $this->longopts[] = 'help'; } }
[ "private", "function", "collectOptionsFromUserInputClass", "(", ")", "{", "foreach", "(", "RequestBroker", "::", "targetMethodsOf", "(", "$", "this", "->", "userInput", ")", "as", "$", "targetMethod", ")", "{", "$", "name", "=", "$", "targetMethod", "->", "par...
parses options from user input class
[ "parses", "options", "from", "user", "input", "class" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/input/ArgumentParser.php#L191-L213
train
GrottoPress/jentil
app/libraries/Jentil/Utilities/Page.php
Page.getType
private function getType(): array { if (!$this->type || $this->is('customize_preview')) { $this->type = parent::type(); } return $this->type; }
php
private function getType(): array { if (!$this->type || $this->is('customize_preview')) { $this->type = parent::type(); } return $this->type; }
[ "private", "function", "getType", "(", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "type", "||", "$", "this", "->", "is", "(", "'customize_preview'", ")", ")", "{", "$", "this", "->", "type", "=", "parent", "::", "type", "(", ")", ...
Page type is used too many times on archives for getting posts mods, so let's make sure method is called only once per page cycle, except, of course, in the customizer. @return string[int]
[ "Page", "type", "is", "used", "too", "many", "times", "on", "archives", "for", "getting", "posts", "mods", "so", "let", "s", "make", "sure", "method", "is", "called", "only", "once", "per", "page", "cycle", "except", "of", "course", "in", "the", "customi...
ad3341c91e0386256d4a2fbe8b7a201c9b706c10
https://github.com/GrottoPress/jentil/blob/ad3341c91e0386256d4a2fbe8b7a201c9b706c10/app/libraries/Jentil/Utilities/Page.php#L82-L89
train
honey-comb/starter
src/Providers/HCBaseServiceProvider.php
HCBaseServiceProvider.loadRoutes
protected function loadRoutes(Router $router): void { foreach ($this->getRoutes() as $route) { $router->namespace($this->namespace) ->group($route); } }
php
protected function loadRoutes(Router $router): void { foreach ($this->getRoutes() as $route) { $router->namespace($this->namespace) ->group($route); } }
[ "protected", "function", "loadRoutes", "(", "Router", "$", "router", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "getRoutes", "(", ")", "as", "$", "route", ")", "{", "$", "router", "->", "namespace", "(", "$", "this", "->", "namespace", ...
Load package routes @param Router $router
[ "Load", "package", "routes" ]
2c5330a49eb5204a6b748368aca835b7ecb02393
https://github.com/honey-comb/starter/blob/2c5330a49eb5204a6b748368aca835b7ecb02393/src/Providers/HCBaseServiceProvider.php#L99-L105
train
honey-comb/starter
src/Http/Controllers/HCFormManagerController.php
HCFormManagerController.getStructure
public function getStructure(string $key, string $type = null): JsonResponse { try { $form = $this->formManager->getForm($key, $type); } catch (HCException $exception) { return $this->response->error($exception->getMessage()); } return $this->response->success('OK', $form); }
php
public function getStructure(string $key, string $type = null): JsonResponse { try { $form = $this->formManager->getForm($key, $type); } catch (HCException $exception) { return $this->response->error($exception->getMessage()); } return $this->response->success('OK', $form); }
[ "public", "function", "getStructure", "(", "string", "$", "key", ",", "string", "$", "type", "=", "null", ")", ":", "JsonResponse", "{", "try", "{", "$", "form", "=", "$", "this", "->", "formManager", "->", "getForm", "(", "$", "key", ",", "$", "type...
Get form structure as json object @param string $key @param string|null $type @return JsonResponse @throws \Illuminate\Contracts\Container\BindingResolutionException @throws \ReflectionException
[ "Get", "form", "structure", "as", "json", "object" ]
2c5330a49eb5204a6b748368aca835b7ecb02393
https://github.com/honey-comb/starter/blob/2c5330a49eb5204a6b748368aca835b7ecb02393/src/Http/Controllers/HCFormManagerController.php#L75-L84
train
CMProductions/http-client
src/Client/Traits/ClientTrait.php
ClientTrait.send
public function send(Request $request) { $this->logger()->debug('Sending request. {request}', [ 'request' => $request, ]); $response = $this->sendOrRetry($request, $request->getRetries()); $this->logger()->debug('Response received. {response}', [ 'request' => $request, 'response' => $response, ]); return $response; }
php
public function send(Request $request) { $this->logger()->debug('Sending request. {request}', [ 'request' => $request, ]); $response = $this->sendOrRetry($request, $request->getRetries()); $this->logger()->debug('Response received. {response}', [ 'request' => $request, 'response' => $response, ]); return $response; }
[ "public", "function", "send", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "logger", "(", ")", "->", "debug", "(", "'Sending request. {request}'", ",", "[", "'request'", "=>", "$", "request", ",", "]", ")", ";", "$", "response", "=", "$...
Executes a request returning back the response @param Request $request @return Response @throws RequestExecutionException @throws RuntimeException
[ "Executes", "a", "request", "returning", "back", "the", "response" ]
d7e5a74cdf94b6b50a229db6698c81fd055ff2ce
https://github.com/CMProductions/http-client/blob/d7e5a74cdf94b6b50a229db6698c81fd055ff2ce/src/Client/Traits/ClientTrait.php#L39-L53
train
Orbitale/DoctrineTools
EntityRepositoryHelperTrait.php
EntityRepositoryHelperTrait.findAllRoot
public function findAllRoot($indexBy = null): iterable { $this->checkRepository(); $data = $this->createQueryBuilder('object') ->getQuery() ->getResult() ; if ($data && $indexBy) { $data = $this->sortCollection($data, $indexBy); } return $data; }
php
public function findAllRoot($indexBy = null): iterable { $this->checkRepository(); $data = $this->createQueryBuilder('object') ->getQuery() ->getResult() ; if ($data && $indexBy) { $data = $this->sortCollection($data, $indexBy); } return $data; }
[ "public", "function", "findAllRoot", "(", "$", "indexBy", "=", "null", ")", ":", "iterable", "{", "$", "this", "->", "checkRepository", "(", ")", ";", "$", "data", "=", "$", "this", "->", "createQueryBuilder", "(", "'object'", ")", "->", "getQuery", "(",...
Finds all objects and retrieve only "root" objects, without their associated relatives. This prevends potential "fetch=EAGER" to be thrown.
[ "Finds", "all", "objects", "and", "retrieve", "only", "root", "objects", "without", "their", "associated", "relatives", ".", "This", "prevends", "potential", "fetch", "=", "EAGER", "to", "be", "thrown", "." ]
517a321786073a9bc935bb0cb3014df4bb25dade
https://github.com/Orbitale/DoctrineTools/blob/517a321786073a9bc935bb0cb3014df4bb25dade/EntityRepositoryHelperTrait.php#L34-L48
train
Orbitale/DoctrineTools
EntityRepositoryHelperTrait.php
EntityRepositoryHelperTrait.findAllArray
public function findAllArray($indexBy = null): array { $this->checkRepository(); $data = $this->createQueryBuilder('object', $indexBy)->getQuery()->getArrayResult(); if ($data && $indexBy) { $data = $this->sortCollection($data, $indexBy); } return $data; }
php
public function findAllArray($indexBy = null): array { $this->checkRepository(); $data = $this->createQueryBuilder('object', $indexBy)->getQuery()->getArrayResult(); if ($data && $indexBy) { $data = $this->sortCollection($data, $indexBy); } return $data; }
[ "public", "function", "findAllArray", "(", "$", "indexBy", "=", "null", ")", ":", "array", "{", "$", "this", "->", "checkRepository", "(", ")", ";", "$", "data", "=", "$", "this", "->", "createQueryBuilder", "(", "'object'", ",", "$", "indexBy", ")", "...
Finds all objects and fetches them as array.
[ "Finds", "all", "objects", "and", "fetches", "them", "as", "array", "." ]
517a321786073a9bc935bb0cb3014df4bb25dade
https://github.com/Orbitale/DoctrineTools/blob/517a321786073a9bc935bb0cb3014df4bb25dade/EntityRepositoryHelperTrait.php#L53-L64
train
Orbitale/DoctrineTools
EntityRepositoryHelperTrait.php
EntityRepositoryHelperTrait.getNumberOfElements
public function getNumberOfElements(): ?int { $this->checkRepository(); return $this->_em->createQueryBuilder() ->select('count(a)') ->from($this->getEntityName(), 'a') ->getQuery() ->getSingleScalarResult() ; }
php
public function getNumberOfElements(): ?int { $this->checkRepository(); return $this->_em->createQueryBuilder() ->select('count(a)') ->from($this->getEntityName(), 'a') ->getQuery() ->getSingleScalarResult() ; }
[ "public", "function", "getNumberOfElements", "(", ")", ":", "?", "int", "{", "$", "this", "->", "checkRepository", "(", ")", ";", "return", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'count(a)'", ")", "->", "fro...
Gets total number of elements in the table.
[ "Gets", "total", "number", "of", "elements", "in", "the", "table", "." ]
517a321786073a9bc935bb0cb3014df4bb25dade
https://github.com/Orbitale/DoctrineTools/blob/517a321786073a9bc935bb0cb3014df4bb25dade/EntityRepositoryHelperTrait.php#L125-L135
train
Orbitale/DoctrineTools
EntityRepositoryHelperTrait.php
EntityRepositoryHelperTrait.sortCollection
public function sortCollection(iterable $collection, $indexBy = null): iterable { $this->checkRepository(); $finalCollection = []; $currentObject = current($collection); $accessor = class_exists('Symfony\Component\PropertyAccess\PropertyAccess') ? PropertyAccess::createPropertyAccessor() : null; if ('_primary' === $indexBy || true === $indexBy) { $indexBy = $this->getClassMetadata()->getSingleIdentifierFieldName(); } if (is_object($currentObject) && property_exists($currentObject, $indexBy) && method_exists($currentObject, 'get'.ucfirst($indexBy))) { // Sorts a list of objects only if the property and its getter exist foreach ($collection as $entity) { $id = $accessor ? $accessor->getValue($entity, $indexBy) : $entity->{'get'.ucFirst($indexBy)}; $finalCollection[$id] = $entity; } return $finalCollection; } if (is_array($currentObject) && array_key_exists($indexBy, $currentObject)) { // Sorts a list of arrays only if the key exists foreach ($collection as $array) { $finalCollection[$array[$indexBy]] = $array; } return $finalCollection; } if ($collection) { throw new \InvalidArgumentException('The collection to sort by index seems to be invalid.'); } return $collection; }
php
public function sortCollection(iterable $collection, $indexBy = null): iterable { $this->checkRepository(); $finalCollection = []; $currentObject = current($collection); $accessor = class_exists('Symfony\Component\PropertyAccess\PropertyAccess') ? PropertyAccess::createPropertyAccessor() : null; if ('_primary' === $indexBy || true === $indexBy) { $indexBy = $this->getClassMetadata()->getSingleIdentifierFieldName(); } if (is_object($currentObject) && property_exists($currentObject, $indexBy) && method_exists($currentObject, 'get'.ucfirst($indexBy))) { // Sorts a list of objects only if the property and its getter exist foreach ($collection as $entity) { $id = $accessor ? $accessor->getValue($entity, $indexBy) : $entity->{'get'.ucFirst($indexBy)}; $finalCollection[$id] = $entity; } return $finalCollection; } if (is_array($currentObject) && array_key_exists($indexBy, $currentObject)) { // Sorts a list of arrays only if the key exists foreach ($collection as $array) { $finalCollection[$array[$indexBy]] = $array; } return $finalCollection; } if ($collection) { throw new \InvalidArgumentException('The collection to sort by index seems to be invalid.'); } return $collection; }
[ "public", "function", "sortCollection", "(", "iterable", "$", "collection", ",", "$", "indexBy", "=", "null", ")", ":", "iterable", "{", "$", "this", "->", "checkRepository", "(", ")", ";", "$", "finalCollection", "=", "[", "]", ";", "$", "currentObject", ...
Sorts a collection by a specific key, usually the primary key one, but you can specify any key. For "cleanest" uses, you'd better use a primary or unique key.
[ "Sorts", "a", "collection", "by", "a", "specific", "key", "usually", "the", "primary", "key", "one", "but", "you", "can", "specify", "any", "key", ".", "For", "cleanest", "uses", "you", "d", "better", "use", "a", "primary", "or", "unique", "key", "." ]
517a321786073a9bc935bb0cb3014df4bb25dade
https://github.com/Orbitale/DoctrineTools/blob/517a321786073a9bc935bb0cb3014df4bb25dade/EntityRepositoryHelperTrait.php#L142-L177
train
edmondscommerce/phpqa
src/PHPUnit/CheckAnnotations.php
CheckAnnotations.main
public function main(string $pathToTestsDirectory): array { if (!is_dir($pathToTestsDirectory)) { throw new \InvalidArgumentException( '$pathToTestsDirectory "' . $pathToTestsDirectory . '" does not exist"' ); } $this->largePath = $pathToTestsDirectory . '/Large'; $this->mediumPath = $pathToTestsDirectory . '/Medium'; $this->smallPath = $pathToTestsDirectory . '/Small'; $this->checkLarge(); $this->checkMedium(); $this->checkSmall(); return $this->errors; }
php
public function main(string $pathToTestsDirectory): array { if (!is_dir($pathToTestsDirectory)) { throw new \InvalidArgumentException( '$pathToTestsDirectory "' . $pathToTestsDirectory . '" does not exist"' ); } $this->largePath = $pathToTestsDirectory . '/Large'; $this->mediumPath = $pathToTestsDirectory . '/Medium'; $this->smallPath = $pathToTestsDirectory . '/Small'; $this->checkLarge(); $this->checkMedium(); $this->checkSmall(); return $this->errors; }
[ "public", "function", "main", "(", "string", "$", "pathToTestsDirectory", ")", ":", "array", "{", "if", "(", "!", "is_dir", "(", "$", "pathToTestsDirectory", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$pathToTestsDirectory \"'", ".",...
Check the Large and Medium directories, if they exist, and then assert that all tests have the correct annotation @param string $pathToTestsDirectory @return array of errors
[ "Check", "the", "Large", "and", "Medium", "directories", "if", "they", "exist", "and", "then", "assert", "that", "all", "tests", "have", "the", "correct", "annotation" ]
fdcaa19f7505d16f7c751991cc2e4d113891be91
https://github.com/edmondscommerce/phpqa/blob/fdcaa19f7505d16f7c751991cc2e4d113891be91/src/PHPUnit/CheckAnnotations.php#L42-L57
train
matthewbdaly/proper
src/Traits/IsCollection.php
IsCollection.groupBy
public function groupBy(string $key) { $items = []; foreach ($this->items as $item) { $items[$item[$key]][] = $item; } return new static($items); }
php
public function groupBy(string $key) { $items = []; foreach ($this->items as $item) { $items[$item[$key]][] = $item; } return new static($items); }
[ "public", "function", "groupBy", "(", "string", "$", "key", ")", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "items", "[", "$", "item", "[", "$", "key", "]", "]", "[", "...
Group by a given key @param string $key Key to group by. @return Collectable
[ "Group", "by", "a", "given", "key" ]
dac8d6f9ff245b189c57139b79b9dd08cb13bfdd
https://github.com/matthewbdaly/proper/blob/dac8d6f9ff245b189c57139b79b9dd08cb13bfdd/src/Traits/IsCollection.php#L378-L385
train
br-monteiro/htr-core
src/Common/Json.php
Json.decode
public static function decode(string $value) { $stdObject = json_decode($value); // catch error if it occurs self::catchError(); if (self::getError()) { return self::getError(); } return $stdObject; }
php
public static function decode(string $value) { $stdObject = json_decode($value); // catch error if it occurs self::catchError(); if (self::getError()) { return self::getError(); } return $stdObject; }
[ "public", "static", "function", "decode", "(", "string", "$", "value", ")", "{", "$", "stdObject", "=", "json_decode", "(", "$", "value", ")", ";", "// catch error if it occurs", "self", "::", "catchError", "(", ")", ";", "if", "(", "self", "::", "getError...
Decode the JSON string to \stdClass @author Edson B S Monteiro <bruno.monteirodg@gmail.com> @since 1.0 @param string $value @return \stdClass|string
[ "Decode", "the", "JSON", "string", "to", "\\", "stdClass" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Common/Json.php#L52-L63
train
br-monteiro/htr-core
src/Common/Json.php
Json.catchError
private static function catchError() { switch (json_last_error()) { case JSON_ERROR_NONE: self::$error = false; break; case JSON_ERROR_DEPTH: self::$error = 'Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: self::$error = 'Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: self::$error = 'Unexpected control character found'; break; case JSON_ERROR_SYNTAX: self::$error = 'Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: self::$error = 'Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: self::$error = 'Unknown error'; break; } }
php
private static function catchError() { switch (json_last_error()) { case JSON_ERROR_NONE: self::$error = false; break; case JSON_ERROR_DEPTH: self::$error = 'Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: self::$error = 'Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: self::$error = 'Unexpected control character found'; break; case JSON_ERROR_SYNTAX: self::$error = 'Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: self::$error = 'Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: self::$error = 'Unknown error'; break; } }
[ "private", "static", "function", "catchError", "(", ")", "{", "switch", "(", "json_last_error", "(", ")", ")", "{", "case", "JSON_ERROR_NONE", ":", "self", "::", "$", "error", "=", "false", ";", "break", ";", "case", "JSON_ERROR_DEPTH", ":", "self", "::", ...
Catch error if it occurs @author Edson B S Monteiro <bruno.monteirodg@gmail.com> @since 1.0
[ "Catch", "error", "if", "it", "occurs" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Common/Json.php#L83-L108
train
br-monteiro/htr-core
src/Common/Json.php
Json.validate
public static function validate($data, string $fileSchema): bool { /** * Throw an \Exception in case if there's no file or is unreadable */ if (!file_exists($fileSchema) || !is_readable($fileSchema)) { throw new \Exception("The file {$fileSchema} not exists or is not readable."); } $jsonSchema = self::decode(file_get_contents($fileSchema)); self::getValidator()->validate($data, $jsonSchema); return self::getValidator()->isValid(); }
php
public static function validate($data, string $fileSchema): bool { /** * Throw an \Exception in case if there's no file or is unreadable */ if (!file_exists($fileSchema) || !is_readable($fileSchema)) { throw new \Exception("The file {$fileSchema} not exists or is not readable."); } $jsonSchema = self::decode(file_get_contents($fileSchema)); self::getValidator()->validate($data, $jsonSchema); return self::getValidator()->isValid(); }
[ "public", "static", "function", "validate", "(", "$", "data", ",", "string", "$", "fileSchema", ")", ":", "bool", "{", "/**\n * Throw an \\Exception in case if there's no file or is unreadable\n */", "if", "(", "!", "file_exists", "(", "$", "fileSchema", ...
Check if the data is according JSON Schema @author Edson B S Monteiro <bruno.monteirodg@gmail.com> @since 1.0 @param \stdClass|array $data @param string $fileSchema @return bool @throws \Exception
[ "Check", "if", "the", "data", "is", "according", "JSON", "Schema" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Common/Json.php#L120-L134
train
stubbles/stubbles-console
src/main/php/input/RequestParser.php
RequestParser.parseInto
public function parseInto($object, string $group = null) { if ($this->request->hasParam('h') || $this->request->hasParam('help')) { throw new HelpScreen( $this->request->readEnv('SCRIPT_NAME')->unsecure(), $object, $group ); } $this->requestBroker->procure($this->request, $object, $group); if ($this->request->paramErrors()->exist()) { throw new InvalidOptionValue( $this->request->paramErrors(), $this->errorMessages ); } if (method_exists($object, 'finalizeInput')) { $object->finalizeInput(); } return $object; }
php
public function parseInto($object, string $group = null) { if ($this->request->hasParam('h') || $this->request->hasParam('help')) { throw new HelpScreen( $this->request->readEnv('SCRIPT_NAME')->unsecure(), $object, $group ); } $this->requestBroker->procure($this->request, $object, $group); if ($this->request->paramErrors()->exist()) { throw new InvalidOptionValue( $this->request->paramErrors(), $this->errorMessages ); } if (method_exists($object, 'finalizeInput')) { $object->finalizeInput(); } return $object; }
[ "public", "function", "parseInto", "(", "$", "object", ",", "string", "$", "group", "=", "null", ")", "{", "if", "(", "$", "this", "->", "request", "->", "hasParam", "(", "'h'", ")", "||", "$", "this", "->", "request", "->", "hasParam", "(", "'help'"...
parses request data into given object Prints help for given object when -h or --help param is set. @param object $object @param string $group restrict parsing to given group @return object @throws \stubbles\console\input\HelpScreen @throws \stubbles\console\input\InvalidOptionValue
[ "parses", "request", "data", "into", "given", "object" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/input/RequestParser.php#L82-L105
train
br-monteiro/htr-core
src/Database/AdapterResults.php
AdapterResults.makeObject
private static function makeObject($entity) { $methodsGet = get_class_methods($entity); $methodsGet = array_filter($methodsGet, function($value) { return (bool) preg_match('/^get.*$/', $value); }); $std = new \stdClass(); foreach ($methodsGet as $attribute) { $name = str_replace('get', '', $attribute); $name = lcfirst($name); $std->$name = $entity->$attribute(); } return $std; }
php
private static function makeObject($entity) { $methodsGet = get_class_methods($entity); $methodsGet = array_filter($methodsGet, function($value) { return (bool) preg_match('/^get.*$/', $value); }); $std = new \stdClass(); foreach ($methodsGet as $attribute) { $name = str_replace('get', '', $attribute); $name = lcfirst($name); $std->$name = $entity->$attribute(); } return $std; }
[ "private", "static", "function", "makeObject", "(", "$", "entity", ")", "{", "$", "methodsGet", "=", "get_class_methods", "(", "$", "entity", ")", ";", "$", "methodsGet", "=", "array_filter", "(", "$", "methodsGet", ",", "function", "(", "$", "value", ")",...
Extract the attributes of etities @author Edson B S Monteiro <bruno.monteirodg@gmail.com> @since 1.0 @param mixed $entity @return \stdClass
[ "Extract", "the", "attributes", "of", "etities" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Database/AdapterResults.php#L18-L31
train
br-monteiro/htr-core
src/Database/AdapterResults.php
AdapterResults.adapter
final public static function adapter($result) { if (is_array($result)) { $arr = []; foreach ($result as $key => $value) { $arr[$key] = self::makeObject($value); } return $arr; } return self::makeObject($result); }
php
final public static function adapter($result) { if (is_array($result)) { $arr = []; foreach ($result as $key => $value) { $arr[$key] = self::makeObject($value); } return $arr; } return self::makeObject($result); }
[ "final", "public", "static", "function", "adapter", "(", "$", "result", ")", "{", "if", "(", "is_array", "(", "$", "result", ")", ")", "{", "$", "arr", "=", "[", "]", ";", "foreach", "(", "$", "result", "as", "$", "key", "=>", "$", "value", ")", ...
Adapter the results @author Edson B S Monteiro <bruno.monteirodg@gmail.com> @since 1.0 @param mixed $result @return \stdClass
[ "Adapter", "the", "results" ]
04c85684e9317fdc52c47aacb357661b4939fb4b
https://github.com/br-monteiro/htr-core/blob/04c85684e9317fdc52c47aacb357661b4939fb4b/src/Database/AdapterResults.php#L41-L52
train
honey-comb/starter
src/Helpers/HCConfigParseHelper.php
HCConfigParseHelper.sortByPriority
private function sortByPriority(array $filePaths): array { $toSort = []; foreach ($filePaths as $filePath) { $file = json_decode(file_get_contents($filePath), true); $sequence = Arr::get($file, 'general.sequence', 0); $toSort[$sequence][] = $filePath; } ksort($toSort); return Arr::collapse($toSort); }
php
private function sortByPriority(array $filePaths): array { $toSort = []; foreach ($filePaths as $filePath) { $file = json_decode(file_get_contents($filePath), true); $sequence = Arr::get($file, 'general.sequence', 0); $toSort[$sequence][] = $filePath; } ksort($toSort); return Arr::collapse($toSort); }
[ "private", "function", "sortByPriority", "(", "array", "$", "filePaths", ")", ":", "array", "{", "$", "toSort", "=", "[", "]", ";", "foreach", "(", "$", "filePaths", "as", "$", "filePath", ")", "{", "$", "file", "=", "json_decode", "(", "file_get_content...
Sort hc-config.json files by sequence @param array $filePaths @return array
[ "Sort", "hc", "-", "config", ".", "json", "files", "by", "sequence" ]
2c5330a49eb5204a6b748368aca835b7ecb02393
https://github.com/honey-comb/starter/blob/2c5330a49eb5204a6b748368aca835b7ecb02393/src/Helpers/HCConfigParseHelper.php#L66-L81
train
stubbles/stubbles-console
src/main/php/input/ConsoleRequest.php
ConsoleRequest.readEnv
public function readEnv(string $envName): ValueReader { return new ValueReader( $this->env->errors(), $envName, $this->env->value($envName) ); }
php
public function readEnv(string $envName): ValueReader { return new ValueReader( $this->env->errors(), $envName, $this->env->value($envName) ); }
[ "public", "function", "readEnv", "(", "string", "$", "envName", ")", ":", "ValueReader", "{", "return", "new", "ValueReader", "(", "$", "this", "->", "env", "->", "errors", "(", ")", ",", "$", "envName", ",", "$", "this", "->", "env", "->", "value", ...
returns request value from params for validation @param string $envName name of environment value @return \stubbles\input\ValueReader
[ "returns", "request", "value", "from", "params", "for", "validation" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/input/ConsoleRequest.php#L117-L124
train
honey-comb/starter
src/Services/HCLanguageService.php
HCLanguageService.getInterfaceActiveLanguages
public function getInterfaceActiveLanguages(): Collection { return cache()->remember($this->interfaceCacheKey, now()->addWeek(), function () { return $this->getRepository()->getInterfaceLanguages(); }); }
php
public function getInterfaceActiveLanguages(): Collection { return cache()->remember($this->interfaceCacheKey, now()->addWeek(), function () { return $this->getRepository()->getInterfaceLanguages(); }); }
[ "public", "function", "getInterfaceActiveLanguages", "(", ")", ":", "Collection", "{", "return", "cache", "(", ")", "->", "remember", "(", "$", "this", "->", "interfaceCacheKey", ",", "now", "(", ")", "->", "addWeek", "(", ")", ",", "function", "(", ")", ...
Get all available interface languages @return Collection @throws \Exception
[ "Get", "all", "available", "interface", "languages" ]
2c5330a49eb5204a6b748368aca835b7ecb02393
https://github.com/honey-comb/starter/blob/2c5330a49eb5204a6b748368aca835b7ecb02393/src/Services/HCLanguageService.php#L89-L94
train
hiqdev/hipanel-module-client
src/logic/PhoneConfirmer.php
PhoneConfirmer.requestCode
public function requestCode() { if (!$this->notifyTries->isIntervalSatisfied()) { throw new PhoneConfirmationException('Minimum interval between confirmation code requests is not satisfied'); } if (!$this->notifyTries->tries_left) { throw new PhoneConfirmationException('Tries are exceeded. Please, contact support.'); } try { Contact::perform('notify-confirm-phone', [ 'id' => $this->model->id, 'type' => $this->model->type, ]); } catch (ResponseErrorException $e) { throw new PhoneConfirmationException('Failed to request code confirmation', 0, $e); } return true; }
php
public function requestCode() { if (!$this->notifyTries->isIntervalSatisfied()) { throw new PhoneConfirmationException('Minimum interval between confirmation code requests is not satisfied'); } if (!$this->notifyTries->tries_left) { throw new PhoneConfirmationException('Tries are exceeded. Please, contact support.'); } try { Contact::perform('notify-confirm-phone', [ 'id' => $this->model->id, 'type' => $this->model->type, ]); } catch (ResponseErrorException $e) { throw new PhoneConfirmationException('Failed to request code confirmation', 0, $e); } return true; }
[ "public", "function", "requestCode", "(", ")", "{", "if", "(", "!", "$", "this", "->", "notifyTries", "->", "isIntervalSatisfied", "(", ")", ")", "{", "throw", "new", "PhoneConfirmationException", "(", "'Minimum interval between confirmation code requests is not satisfi...
Requests API to send the phone number confirmation code. @throws PhoneConfirmationException @return bool
[ "Requests", "API", "to", "send", "the", "phone", "number", "confirmation", "code", "." ]
569d87de369ccf8646087dde566d26a41995c8cb
https://github.com/hiqdev/hipanel-module-client/blob/569d87de369ccf8646087dde566d26a41995c8cb/src/logic/PhoneConfirmer.php#L47-L66
train
hiqdev/hipanel-module-client
src/logic/PhoneConfirmer.php
PhoneConfirmer.submitCode
public function submitCode() { if (!$this->model->validate()) { throw new PhoneConfirmationException('Form validation failed'); } try { Contact::perform('confirm-phone', [ 'id' => $this->model->id, 'type' => $this->model->type, 'phone' => $this->model->phone, 'code' => $this->model->code, ]); } catch (ResponseErrorException $e) { if ($e->getMessage() === 'wrong code') { throw new PhoneConfirmationException(Yii::t('hipanel:client', 'Wrong confirmation code')); } throw new PhoneConfirmationException($e->getMessage()); } return true; }
php
public function submitCode() { if (!$this->model->validate()) { throw new PhoneConfirmationException('Form validation failed'); } try { Contact::perform('confirm-phone', [ 'id' => $this->model->id, 'type' => $this->model->type, 'phone' => $this->model->phone, 'code' => $this->model->code, ]); } catch (ResponseErrorException $e) { if ($e->getMessage() === 'wrong code') { throw new PhoneConfirmationException(Yii::t('hipanel:client', 'Wrong confirmation code')); } throw new PhoneConfirmationException($e->getMessage()); } return true; }
[ "public", "function", "submitCode", "(", ")", "{", "if", "(", "!", "$", "this", "->", "model", "->", "validate", "(", ")", ")", "{", "throw", "new", "PhoneConfirmationException", "(", "'Form validation failed'", ")", ";", "}", "try", "{", "Contact", "::", ...
Sends the phone number confirmation code to the API. @throws PhoneConfirmationException @return bool whether code was submitted successfully
[ "Sends", "the", "phone", "number", "confirmation", "code", "to", "the", "API", "." ]
569d87de369ccf8646087dde566d26a41995c8cb
https://github.com/hiqdev/hipanel-module-client/blob/569d87de369ccf8646087dde566d26a41995c8cb/src/logic/PhoneConfirmer.php#L74-L96
train
symbiote/php-wordpress-database-tools
src/WordpressDatabase.php
WordpressDatabase.getTerms
public function getTerms($taxonomy) { static $table = 'terms'; $this->_init(); $taxonomy = $this->_db->real_escape_string($taxonomy); $termIds = $this->_query('SELECT term_taxonomy_id FROM '.$this->getTable('term_taxonomy').' WHERE taxonomy = \''.$taxonomy.'\'', 'term_taxonomy_id', true); $result = $this->_query('SELECT * FROM '.$this->getTable($table).' WHERE term_id IN ('.implode(',', $termIds).')', 'term_id'); foreach ($result as &$item) { $item[self::HINT]['table'] = $table; unset($item); } return $result; }
php
public function getTerms($taxonomy) { static $table = 'terms'; $this->_init(); $taxonomy = $this->_db->real_escape_string($taxonomy); $termIds = $this->_query('SELECT term_taxonomy_id FROM '.$this->getTable('term_taxonomy').' WHERE taxonomy = \''.$taxonomy.'\'', 'term_taxonomy_id', true); $result = $this->_query('SELECT * FROM '.$this->getTable($table).' WHERE term_id IN ('.implode(',', $termIds).')', 'term_id'); foreach ($result as &$item) { $item[self::HINT]['table'] = $table; unset($item); } return $result; }
[ "public", "function", "getTerms", "(", "$", "taxonomy", ")", "{", "static", "$", "table", "=", "'terms'", ";", "$", "this", "->", "_init", "(", ")", ";", "$", "taxonomy", "=", "$", "this", "->", "_db", "->", "real_escape_string", "(", "$", "taxonomy", ...
Get all terms that exist in a taxonomy type. To determine what taxonomy types are available, call 'getTermTypes' and use one of the names provided. @return array
[ "Get", "all", "terms", "that", "exist", "in", "a", "taxonomy", "type", ".", "To", "determine", "what", "taxonomy", "types", "are", "available", "call", "getTermTypes", "and", "use", "one", "of", "the", "names", "provided", "." ]
93b1ae969722d7235dbbe6374f381daea0e0d5d7
https://github.com/symbiote/php-wordpress-database-tools/blob/93b1ae969722d7235dbbe6374f381daea0e0d5d7/src/WordpressDatabase.php#L113-L124
train
symbiote/php-wordpress-database-tools
src/WordpressDatabase.php
WordpressDatabase.getFrontPageID
public function getFrontPageID() { // Core WP only handles either 'page' or 'posts' as of 2016-07-22 $type = $this->getOption('show_on_front'); if ($type !== 'page') { throw new Exception('Cannot use "'.__FUNCTION__.'" if Wordpress database isn\'t using a page as it\'s home page. Type = '.$type); } $wordpressID = $this->getOption('page_on_front'); if ($wordpressID) { return $wordpressID; } else { $wordpressID = ($wordpressID === false) ? 'false' : $wordpressID; // Fix printing of 'false' throw new Exception('Invalid ID #'.$wordpressID.' returned from "'.__FUNCTION__.'"'); } }
php
public function getFrontPageID() { // Core WP only handles either 'page' or 'posts' as of 2016-07-22 $type = $this->getOption('show_on_front'); if ($type !== 'page') { throw new Exception('Cannot use "'.__FUNCTION__.'" if Wordpress database isn\'t using a page as it\'s home page. Type = '.$type); } $wordpressID = $this->getOption('page_on_front'); if ($wordpressID) { return $wordpressID; } else { $wordpressID = ($wordpressID === false) ? 'false' : $wordpressID; // Fix printing of 'false' throw new Exception('Invalid ID #'.$wordpressID.' returned from "'.__FUNCTION__.'"'); } }
[ "public", "function", "getFrontPageID", "(", ")", "{", "// Core WP only handles either 'page' or 'posts' as of 2016-07-22", "$", "type", "=", "$", "this", "->", "getOption", "(", "'show_on_front'", ")", ";", "if", "(", "$", "type", "!==", "'page'", ")", "{", "thro...
Return the front page. Throw an exception if this Wordpress DB isn't using a 'page' as the homepage and is showing a post listing instead. @return array|null
[ "Return", "the", "front", "page", "." ]
93b1ae969722d7235dbbe6374f381daea0e0d5d7
https://github.com/symbiote/php-wordpress-database-tools/blob/93b1ae969722d7235dbbe6374f381daea0e0d5d7/src/WordpressDatabase.php#L197-L211
train
hiqdev/hipanel-module-client
src/forms/EmployeeForm.php
EmployeeForm.extractContract
protected function extractContract($contact) { foreach ($contact->documents as $document) { if ($document->type === 'contract') { $document->scenario = $this->scenario; return $document; } } return null; }
php
protected function extractContract($contact) { foreach ($contact->documents as $document) { if ($document->type === 'contract') { $document->scenario = $this->scenario; return $document; } } return null; }
[ "protected", "function", "extractContract", "(", "$", "contact", ")", "{", "foreach", "(", "$", "contact", "->", "documents", "as", "$", "document", ")", "{", "if", "(", "$", "document", "->", "type", "===", "'contract'", ")", "{", "$", "document", "->",...
Extracts contract out of documents array. @param Contact $contact @return Document|null
[ "Extracts", "contract", "out", "of", "documents", "array", "." ]
569d87de369ccf8646087dde566d26a41995c8cb
https://github.com/hiqdev/hipanel-module-client/blob/569d87de369ccf8646087dde566d26a41995c8cb/src/forms/EmployeeForm.php#L85-L96
train
hiqdev/hipanel-module-client
src/forms/EmployeeForm.php
EmployeeForm.validate
public function validate() { $contacts = $this->getContactsCollection(); if (!$contacts->validate()) { return $contacts->getFirstError(); } if ($this->getContract() !== null) { if (!$this->getContract()->validate()) { return reset($this->getContract()->getFirstErrors()); } } return true; }
php
public function validate() { $contacts = $this->getContactsCollection(); if (!$contacts->validate()) { return $contacts->getFirstError(); } if ($this->getContract() !== null) { if (!$this->getContract()->validate()) { return reset($this->getContract()->getFirstErrors()); } } return true; }
[ "public", "function", "validate", "(", ")", "{", "$", "contacts", "=", "$", "this", "->", "getContactsCollection", "(", ")", ";", "if", "(", "!", "$", "contacts", "->", "validate", "(", ")", ")", "{", "return", "$", "contacts", "->", "getFirstError", "...
Validates all models of the form. @return true|string
[ "Validates", "all", "models", "of", "the", "form", "." ]
569d87de369ccf8646087dde566d26a41995c8cb
https://github.com/hiqdev/hipanel-module-client/blob/569d87de369ccf8646087dde566d26a41995c8cb/src/forms/EmployeeForm.php#L171-L185
train
hiqdev/hipanel-module-client
src/forms/EmployeeForm.php
EmployeeForm.save
public function save() { $collection = $this->getContactsCollection(); try { $contractSaved = true; $contactsSaved = $collection->save(); if ($this->getContract() !== null) { $this->getContract()->save(); } return $contactsSaved && $contractSaved; } catch (ResponseErrorException $e) { return $e->getMessage(); } }
php
public function save() { $collection = $this->getContactsCollection(); try { $contractSaved = true; $contactsSaved = $collection->save(); if ($this->getContract() !== null) { $this->getContract()->save(); } return $contactsSaved && $contractSaved; } catch (ResponseErrorException $e) { return $e->getMessage(); } }
[ "public", "function", "save", "(", ")", "{", "$", "collection", "=", "$", "this", "->", "getContactsCollection", "(", ")", ";", "try", "{", "$", "contractSaved", "=", "true", ";", "$", "contactsSaved", "=", "$", "collection", "->", "save", "(", ")", ";...
Saves all model of the form. @return bool
[ "Saves", "all", "model", "of", "the", "form", "." ]
569d87de369ccf8646087dde566d26a41995c8cb
https://github.com/hiqdev/hipanel-module-client/blob/569d87de369ccf8646087dde566d26a41995c8cb/src/forms/EmployeeForm.php#L192-L208
train
hiqdev/hipanel-module-client
src/forms/EmployeeForm.php
EmployeeForm.contactLocalization
protected function contactLocalization($originalContact, $language, $createWhenNotExists = true) { $originalContact->scenario = $this->scenario; if ($language === self::LANGUAGE_DEFAULT) { $originalContact->localization = $language; return $originalContact; } foreach ($originalContact->localizations as $contact) { if ($contact->localization === $language) { $contact->scenario = $this->scenario; return $contact; } } if (!$createWhenNotExists) { return null; } /** @var Contact $model */ $model = clone $originalContact; $model->setAttributes([ 'id' => null, 'type' => 'localized', 'localization' => $language, ]); return $model; }
php
protected function contactLocalization($originalContact, $language, $createWhenNotExists = true) { $originalContact->scenario = $this->scenario; if ($language === self::LANGUAGE_DEFAULT) { $originalContact->localization = $language; return $originalContact; } foreach ($originalContact->localizations as $contact) { if ($contact->localization === $language) { $contact->scenario = $this->scenario; return $contact; } } if (!$createWhenNotExists) { return null; } /** @var Contact $model */ $model = clone $originalContact; $model->setAttributes([ 'id' => null, 'type' => 'localized', 'localization' => $language, ]); return $model; }
[ "protected", "function", "contactLocalization", "(", "$", "originalContact", ",", "$", "language", ",", "$", "createWhenNotExists", "=", "true", ")", "{", "$", "originalContact", "->", "scenario", "=", "$", "this", "->", "scenario", ";", "if", "(", "$", "lan...
Gets localized version of this contact. @param $originalContact @param $language @param bool $createWhenNotExists @return Contact
[ "Gets", "localized", "version", "of", "this", "contact", "." ]
569d87de369ccf8646087dde566d26a41995c8cb
https://github.com/hiqdev/hipanel-module-client/blob/569d87de369ccf8646087dde566d26a41995c8cb/src/forms/EmployeeForm.php#L267-L298
train
GrottoPress/jentil
app/libraries/Jentil/Setups/Views/Search.php
Search.searchQuery
private function searchQuery(): string { $url = \parse_url($this->app->utilities->page->URL('full')); \parse_str(($url['query'] ?? ''), $query_params); return $query_params['s'] ?? ''; }
php
private function searchQuery(): string { $url = \parse_url($this->app->utilities->page->URL('full')); \parse_str(($url['query'] ?? ''), $query_params); return $query_params['s'] ?? ''; }
[ "private", "function", "searchQuery", "(", ")", ":", "string", "{", "$", "url", "=", "\\", "parse_url", "(", "$", "this", "->", "app", "->", "utilities", "->", "page", "->", "URL", "(", "'full'", ")", ")", ";", "\\", "parse_str", "(", "(", "$", "ur...
Returns the value of the 's' query parameter in the current page's URL. Unlike WordPress' `get_search_query()`, this looks for the presence of 's' query parameter in the URL, and ignores any URL rewrites of the search page URL.
[ "Returns", "the", "value", "of", "the", "s", "query", "parameter", "in", "the", "current", "page", "s", "URL", "." ]
ad3341c91e0386256d4a2fbe8b7a201c9b706c10
https://github.com/GrottoPress/jentil/blob/ad3341c91e0386256d4a2fbe8b7a201c9b706c10/app/libraries/Jentil/Setups/Views/Search.php#L62-L68
train
GrottoPress/jentil
app/libraries/Jentil/Utilities/FileSystem.php
FileSystem.dir
public function dir(string $type, string $append = ''): string { return $this->_dir($type, $append); }
php
public function dir(string $type, string $append = ''): string { return $this->_dir($type, $append); }
[ "public", "function", "dir", "(", "string", "$", "type", ",", "string", "$", "append", "=", "''", ")", ":", "string", "{", "return", "$", "this", "->", "_dir", "(", "$", "type", ",", "$", "append", ")", ";", "}" ]
Get Jentil directory @param string $type 'path' or 'url'.
[ "Get", "Jentil", "directory" ]
ad3341c91e0386256d4a2fbe8b7a201c9b706c10
https://github.com/GrottoPress/jentil/blob/ad3341c91e0386256d4a2fbe8b7a201c9b706c10/app/libraries/Jentil/Utilities/FileSystem.php#L38-L41
train
GrottoPress/jentil
app/libraries/Jentil/Utilities/FileSystem.php
FileSystem.partialsDir
public function partialsDir( string $type, string $append = '', string $form = '' ): string { return $this->_dir($type, "/app/partials{$append}", $form); }
php
public function partialsDir( string $type, string $append = '', string $form = '' ): string { return $this->_dir($type, "/app/partials{$append}", $form); }
[ "public", "function", "partialsDir", "(", "string", "$", "type", ",", "string", "$", "append", "=", "''", ",", "string", "$", "form", "=", "''", ")", ":", "string", "{", "return", "$", "this", "->", "_dir", "(", "$", "type", ",", "\"/app/partials{$appe...
Get Jentil partials directory @param string $type 'path' or 'url'. @param string $form 'relative' or 'absolute'.
[ "Get", "Jentil", "partials", "directory" ]
ad3341c91e0386256d4a2fbe8b7a201c9b706c10
https://github.com/GrottoPress/jentil/blob/ad3341c91e0386256d4a2fbe8b7a201c9b706c10/app/libraries/Jentil/Utilities/FileSystem.php#L49-L55
train
GrottoPress/jentil
app/libraries/Jentil/Utilities/FileSystem.php
FileSystem.templatesDir
public function templatesDir( string $type, string $append = '', string $form = '' ): string { return $this->_dir($type, "/app/templates{$append}", $form); }
php
public function templatesDir( string $type, string $append = '', string $form = '' ): string { return $this->_dir($type, "/app/templates{$append}", $form); }
[ "public", "function", "templatesDir", "(", "string", "$", "type", ",", "string", "$", "append", "=", "''", ",", "string", "$", "form", "=", "''", ")", ":", "string", "{", "return", "$", "this", "->", "_dir", "(", "$", "type", ",", "\"/app/templates{$ap...
Get Jentil templates directory @param string $type 'path' or 'url'. @param string $form 'relative' or 'absolute'.
[ "Get", "Jentil", "templates", "directory" ]
ad3341c91e0386256d4a2fbe8b7a201c9b706c10
https://github.com/GrottoPress/jentil/blob/ad3341c91e0386256d4a2fbe8b7a201c9b706c10/app/libraries/Jentil/Utilities/FileSystem.php#L63-L69
train
GrottoPress/jentil
app/libraries/Jentil/Utilities/FileSystem.php
FileSystem.vendorDir
public function vendorDir( string $type, string $append = '', string $form = '' ): string { $rel_dir = \explode('/', $this->relativeDir()); $vendor = \reset($rel_dir) ?: 'vendor'; return 'relative' === $form ? "{$vendor}{$append}" : $this->themeDir($type, "/{$vendor}{$append}"); }
php
public function vendorDir( string $type, string $append = '', string $form = '' ): string { $rel_dir = \explode('/', $this->relativeDir()); $vendor = \reset($rel_dir) ?: 'vendor'; return 'relative' === $form ? "{$vendor}{$append}" : $this->themeDir($type, "/{$vendor}{$append}"); }
[ "public", "function", "vendorDir", "(", "string", "$", "type", ",", "string", "$", "append", "=", "''", ",", "string", "$", "form", "=", "''", ")", ":", "string", "{", "$", "rel_dir", "=", "\\", "explode", "(", "'/'", ",", "$", "this", "->", "relat...
Get composer's vendor directory @param string $type 'path' or 'url'. @param string $form 'relative' or 'absolute'.
[ "Get", "composer", "s", "vendor", "directory" ]
ad3341c91e0386256d4a2fbe8b7a201c9b706c10
https://github.com/GrottoPress/jentil/blob/ad3341c91e0386256d4a2fbe8b7a201c9b706c10/app/libraries/Jentil/Utilities/FileSystem.php#L77-L88
train
GrottoPress/jentil
app/libraries/Jentil/Utilities/FileSystem.php
FileSystem.themeDir
public function themeDir(string $type, string $append = ''): string { $stylesheet = $type === 'path' ? \get_stylesheet_directory() : \get_stylesheet_directory_uri(); if (0 === strpos($this->{'dir'.\ucfirst($type)}, $stylesheet)) { return $stylesheet.$append; } $template = $type === 'path' ? \get_template_directory() : \get_template_directory_uri(); return $template.$append; }
php
public function themeDir(string $type, string $append = ''): string { $stylesheet = $type === 'path' ? \get_stylesheet_directory() : \get_stylesheet_directory_uri(); if (0 === strpos($this->{'dir'.\ucfirst($type)}, $stylesheet)) { return $stylesheet.$append; } $template = $type === 'path' ? \get_template_directory() : \get_template_directory_uri(); return $template.$append; }
[ "public", "function", "themeDir", "(", "string", "$", "type", ",", "string", "$", "append", "=", "''", ")", ":", "string", "{", "$", "stylesheet", "=", "$", "type", "===", "'path'", "?", "\\", "get_stylesheet_directory", "(", ")", ":", "\\", "get_stylesh...
Get directory of theme under which Jentil is installed. @param string $type 'url' or 'path' @return string Path. Same as $this->dir() if Jentil is theme.
[ "Get", "directory", "of", "theme", "under", "which", "Jentil", "is", "installed", "." ]
ad3341c91e0386256d4a2fbe8b7a201c9b706c10
https://github.com/GrottoPress/jentil/blob/ad3341c91e0386256d4a2fbe8b7a201c9b706c10/app/libraries/Jentil/Utilities/FileSystem.php#L110-L125
train
stubbles/stubbles-console
src/main/php/Console.php
Console.prompt
public function prompt(string $message, ParamErrors $paramErrors = null): ValueReader { $this->out->write($message); return $this->readValue($paramErrors); }
php
public function prompt(string $message, ParamErrors $paramErrors = null): ValueReader { $this->out->write($message); return $this->readValue($paramErrors); }
[ "public", "function", "prompt", "(", "string", "$", "message", ",", "ParamErrors", "$", "paramErrors", "=", "null", ")", ":", "ValueReader", "{", "$", "this", "->", "out", "->", "write", "(", "$", "message", ")", ";", "return", "$", "this", "->", "read...
prompt user for entering a value Echhos given message to stdout and expects the user to enter a value on stdin. In case you need access to error messages that may happen during value validation you need to supply <ParamErrors>, errors will be accumulated therein under the param name stdin. @api @param string $message message to show before requesting user input @param \stubbles\input\errors\ParamErrors $paramErrors collection to add any errors to @return \stubbles\input\ValueReader @since 2.1.0
[ "prompt", "user", "for", "entering", "a", "value" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/Console.php#L73-L77
train
stubbles/stubbles-console
src/main/php/Console.php
Console.confirm
public function confirm(string $message, string $default = null): bool { $result = null; while (null === $result) { $result = $this->prompt($message)->ifIsOneOf(['y', 'Y', 'n', 'N', '']); if ('' === $result) { $result = ((null !== $default) ? ($default) : (null)); } } return strtolower($result) === 'y'; }
php
public function confirm(string $message, string $default = null): bool { $result = null; while (null === $result) { $result = $this->prompt($message)->ifIsOneOf(['y', 'Y', 'n', 'N', '']); if ('' === $result) { $result = ((null !== $default) ? ($default) : (null)); } } return strtolower($result) === 'y'; }
[ "public", "function", "confirm", "(", "string", "$", "message", ",", "string", "$", "default", "=", "null", ")", ":", "bool", "{", "$", "result", "=", "null", ";", "while", "(", "null", "===", "$", "result", ")", "{", "$", "result", "=", "$", "this...
ask the user to confirm something Repeats the message until user enters <y> or <n> (case insensitive). In case a default is given and the users enters nothing this default will be used - if the default is <y> it will return <true>, and <false> otherwise. @api @param string $message message to show before requesting user input @param string $default default selection if user enters nothing @return bool @since 2.1.0
[ "ask", "the", "user", "to", "confirm", "something" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/Console.php#L93-L104
train
stubbles/stubbles-console
src/main/php/Console.php
Console.readValue
public function readValue(ParamErrors $paramErrors = null): ValueReader { if (null === $paramErrors) { return ValueReader::forValue($this->in->readLine()); } return new ValueReader($paramErrors, 'stdin', Value::of($this->in->readLine())); }
php
public function readValue(ParamErrors $paramErrors = null): ValueReader { if (null === $paramErrors) { return ValueReader::forValue($this->in->readLine()); } return new ValueReader($paramErrors, 'stdin', Value::of($this->in->readLine())); }
[ "public", "function", "readValue", "(", "ParamErrors", "$", "paramErrors", "=", "null", ")", ":", "ValueReader", "{", "if", "(", "null", "===", "$", "paramErrors", ")", "{", "return", "ValueReader", "::", "forValue", "(", "$", "this", "->", "in", "->", "...
reads a value from command line input Read a value entered on stdin. Returns a <ValueReader> which can be used to get a typed value. In case you need access to error messages that may happen during value validation you need to supply <ParamErrors>, errors will be accumulated therein under the param name stdin. @api @param \stubbles\input\errors\ParamErrors $paramErrors collection to add any errors to @return \stubbles\input\ValueReader @since 2.1.0
[ "reads", "a", "value", "from", "command", "line", "input" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/Console.php#L119-L126
train
stubbles/stubbles-console
src/main/php/Console.php
Console.close
public function close() { $this->in->close(); $this->out->close(); $this->err->close(); }
php
public function close() { $this->in->close(); $this->out->close(); $this->err->close(); }
[ "public", "function", "close", "(", ")", "{", "$", "this", "->", "in", "->", "close", "(", ")", ";", "$", "this", "->", "out", "->", "close", "(", ")", ";", "$", "this", "->", "err", "->", "close", "(", ")", ";", "}" ]
closes all underlying streams @since 2.4.0
[ "closes", "all", "underlying", "streams" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/Console.php#L311-L316
train
electro-modules/matisse-components
MatisseComponents/Dropzone.php
Dropzone.dropzoneUpload
static function dropzoneUpload ($request, $response) { $ds = DIRECTORY_SEPARATOR; $storeFolder = self::TEMP_STORE_FOLDER_NAME; $storePath = sys_get_temp_dir().$ds.$storeFolder; if (!is_dir($storePath)) mkdir($storePath); $file = ""; foreach ($request->getUploadedFiles() as $oFile) { $filename = $oFile->getClientFilename (); $filePath = $storePath.$ds.$filename; $oFile->moveTo($filePath); $file = $filePath; } return Http::jsonResponse ($response,$file); }
php
static function dropzoneUpload ($request, $response) { $ds = DIRECTORY_SEPARATOR; $storeFolder = self::TEMP_STORE_FOLDER_NAME; $storePath = sys_get_temp_dir().$ds.$storeFolder; if (!is_dir($storePath)) mkdir($storePath); $file = ""; foreach ($request->getUploadedFiles() as $oFile) { $filename = $oFile->getClientFilename (); $filePath = $storePath.$ds.$filename; $oFile->moveTo($filePath); $file = $filePath; } return Http::jsonResponse ($response,$file); }
[ "static", "function", "dropzoneUpload", "(", "$", "request", ",", "$", "response", ")", "{", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "$", "storeFolder", "=", "self", "::", "TEMP_STORE_FOLDER_NAME", ";", "$", "storePath", "=", "sys_get_temp_dir", "(", ")", ...
Handles file uploads. @param ServerRequestInterface $request @param ResponseInterface $response @return ResponseInterface @internal param ContentRepositoryInterface $repository
[ "Handles", "file", "uploads", "." ]
3a746f796157ef72b585a5994394483fbe500861
https://github.com/electro-modules/matisse-components/blob/3a746f796157ef72b585a5994394483fbe500861/MatisseComponents/Dropzone.php#L129-L147
train
electro-modules/matisse-components
MatisseComponents/Dropzone.php
Dropzone.getFieldValue
private function getFieldValue() { $model = $this->modelController->getModel(); $fieldName = str_replace('model/','', $this->props->name); return $model->$fieldName; }
php
private function getFieldValue() { $model = $this->modelController->getModel(); $fieldName = str_replace('model/','', $this->props->name); return $model->$fieldName; }
[ "private", "function", "getFieldValue", "(", ")", "{", "$", "model", "=", "$", "this", "->", "modelController", "->", "getModel", "(", ")", ";", "$", "fieldName", "=", "str_replace", "(", "'model/'", ",", "''", ",", "$", "this", "->", "props", "->", "n...
Private function to get value of this drozpone field @return mixed
[ "Private", "function", "to", "get", "value", "of", "this", "drozpone", "field" ]
3a746f796157ef72b585a5994394483fbe500861
https://github.com/electro-modules/matisse-components/blob/3a746f796157ef72b585a5994394483fbe500861/MatisseComponents/Dropzone.php#L162-L167
train
electro-modules/matisse-components
MatisseComponents/Dropzone.php
Dropzone.getImagesInFieldValue
private function getImagesInFieldValue($value) { $aImages = explode(',', $value); $arrImages = []; foreach ($aImages as $aImage) { $oImage = File::where('path',$aImage)->first(); if (!$oImage) continue; $fileName = "$oImage->name.$oImage->ext"; $arrImages[] = [ 'filename' => $fileName, 'virtuaPath' => $oImage->path, 'path' => $oImage->image ? $this->contentRepository->getImageUrl($oImage->path,[ 'w' => 120, 'h' => 120, 'fit' => 'crop', ]) : $this->contentRepository->getFileUrl($oImage->path), 'pathDownload' => ($oImage->image ? $this->contentRepository->getImageUrl($oImage->path) : $this->contentRepository->getFileUrl($oImage->path))."?f=".$fileName, 'icon' => !$oImage->image ? $this->props->genericIconPath : '' ]; } return $arrImages; }
php
private function getImagesInFieldValue($value) { $aImages = explode(',', $value); $arrImages = []; foreach ($aImages as $aImage) { $oImage = File::where('path',$aImage)->first(); if (!$oImage) continue; $fileName = "$oImage->name.$oImage->ext"; $arrImages[] = [ 'filename' => $fileName, 'virtuaPath' => $oImage->path, 'path' => $oImage->image ? $this->contentRepository->getImageUrl($oImage->path,[ 'w' => 120, 'h' => 120, 'fit' => 'crop', ]) : $this->contentRepository->getFileUrl($oImage->path), 'pathDownload' => ($oImage->image ? $this->contentRepository->getImageUrl($oImage->path) : $this->contentRepository->getFileUrl($oImage->path))."?f=".$fileName, 'icon' => !$oImage->image ? $this->props->genericIconPath : '' ]; } return $arrImages; }
[ "private", "function", "getImagesInFieldValue", "(", "$", "value", ")", "{", "$", "aImages", "=", "explode", "(", "','", ",", "$", "value", ")", ";", "$", "arrImages", "=", "[", "]", ";", "foreach", "(", "$", "aImages", "as", "$", "aImage", ")", "{",...
Private function to get all uploaded images in this dropzone @param $value @return array
[ "Private", "function", "to", "get", "all", "uploaded", "images", "in", "this", "dropzone" ]
3a746f796157ef72b585a5994394483fbe500861
https://github.com/electro-modules/matisse-components/blob/3a746f796157ef72b585a5994394483fbe500861/MatisseComponents/Dropzone.php#L174-L196
train
stubbles/stubbles-console
src/main/php/Executor.php
Executor.execute
public function execute(string $command, callable $collect = null, string $redirect = '2>&1'): self { foreach ($this->outputOf($command, $redirect) as $line) { if (null !== $collect) { $collect($line); } } return $this; }
php
public function execute(string $command, callable $collect = null, string $redirect = '2>&1'): self { foreach ($this->outputOf($command, $redirect) as $line) { if (null !== $collect) { $collect($line); } } return $this; }
[ "public", "function", "execute", "(", "string", "$", "command", ",", "callable", "$", "collect", "=", "null", ",", "string", "$", "redirect", "=", "'2>&1'", ")", ":", "self", "{", "foreach", "(", "$", "this", "->", "outputOf", "(", "$", "command", ",",...
executes given command @param string $command @param callable $collect optional callable which will receive each line from the command output @param string $redirect optional how to redirect error output @return \stubbles\console\Executor
[ "executes", "given", "command" ]
9b8d8e0d92e3c6b629a0fa860ace957016d20047
https://github.com/stubbles/stubbles-console/blob/9b8d8e0d92e3c6b629a0fa860ace957016d20047/src/main/php/Executor.php#L54-L63
train