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
phptuts/StarterBundleForSymfony
src/Security/Provider/FacebookProvider.php
FacebookProvider.registerUser
protected function registerUser($email, $facebookUserId) { $className = $this->userService->getUserClass(); /** @var BaseUser $user */ $user = (new $className()); $user->setEmail($email) ->setFacebookUserId($facebookUserId) ->setPlainPassword(base64_encode(random_bytes(20))); $this->userService->registerUser($user, UserService::SOURCE_TYPE_FACEBOOK); return $user; }
php
protected function registerUser($email, $facebookUserId) { $className = $this->userService->getUserClass(); /** @var BaseUser $user */ $user = (new $className()); $user->setEmail($email) ->setFacebookUserId($facebookUserId) ->setPlainPassword(base64_encode(random_bytes(20))); $this->userService->registerUser($user, UserService::SOURCE_TYPE_FACEBOOK); return $user; }
[ "protected", "function", "registerUser", "(", "$", "email", ",", "$", "facebookUserId", ")", "{", "$", "className", "=", "$", "this", "->", "userService", "->", "getUserClass", "(", ")", ";", "/** @var BaseUser $user */", "$", "user", "=", "(", "new", "$", ...
We register the user with their facebook id and email. @param string $email @param string $facebookUserId @return BaseUser
[ "We", "register", "the", "user", "with", "their", "facebook", "id", "and", "email", "." ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Provider/FacebookProvider.php#L105-L116
train
russsiq/bixbite
app/Models/Tag.php
Tag.reIndex
public function reIndex() { $tags = $this->select(['tags.id', 'taggables.tag_id as pivot_tag_id']) ->join('taggables', 'tags.id', '=', 'taggables.tag_id') ->get()->keyBy('id')->all(); $this->whereNotIn('id', array_keys($tags))->delete(); // dd($this->has($model->getMorphClass(), '=', 0)->toSql()); // // The commentable relation on the Comment model will return either a // Post or Video instance, depending on which type of model owns the comment. // $commentable = $comment->commentable; }
php
public function reIndex() { $tags = $this->select(['tags.id', 'taggables.tag_id as pivot_tag_id']) ->join('taggables', 'tags.id', '=', 'taggables.tag_id') ->get()->keyBy('id')->all(); $this->whereNotIn('id', array_keys($tags))->delete(); // dd($this->has($model->getMorphClass(), '=', 0)->toSql()); // // The commentable relation on the Comment model will return either a // Post or Video instance, depending on which type of model owns the comment. // $commentable = $comment->commentable; }
[ "public", "function", "reIndex", "(", ")", "{", "$", "tags", "=", "$", "this", "->", "select", "(", "[", "'tags.id'", ",", "'taggables.tag_id as pivot_tag_id'", "]", ")", "->", "join", "(", "'taggables'", ",", "'tags.id'", ",", "'='", ",", "'taggables.tag_id...
Delete unused tags
[ "Delete", "unused", "tags" ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Tag.php#L35-L48
train
webeweb/core-bundle
Helper/Select2Helper.php
Select2Helper.toResults
public static function toResults(array $items) { $output = []; foreach ($items as $current) { if (false === ($current instanceof Select2ItemInterface)) { throw new InvalidArgumentException("The item must implements Select2ItemInterface"); } $output[] = [ "id" => $current->getSelect2ItemId(), "text" => $current->getSelect2ItemText(), ]; } return $output; }
php
public static function toResults(array $items) { $output = []; foreach ($items as $current) { if (false === ($current instanceof Select2ItemInterface)) { throw new InvalidArgumentException("The item must implements Select2ItemInterface"); } $output[] = [ "id" => $current->getSelect2ItemId(), "text" => $current->getSelect2ItemText(), ]; } return $output; }
[ "public", "static", "function", "toResults", "(", "array", "$", "items", ")", "{", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "items", "as", "$", "current", ")", "{", "if", "(", "false", "===", "(", "$", "current", "instanceof", "Select2...
Convert items into a "results" array. @param Select2ItemInterface[] $items The items. @return array Returns the "results" array. @throws InvalidArgumentException Throws an invalid argument exception if an item does not implement Select2ItemInterface.
[ "Convert", "items", "into", "a", "results", "array", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Helper/Select2Helper.php#L32-L49
train
RogerWaters/react-thread-pool
examples/example_6.php
BalancedThread.SomeUndefinedLongRunningWork
public function SomeUndefinedLongRunningWork($timeToWorkOnSomething, callable $onComplete = null) { if ($this->isExternal()) { $timeToWorkOnSomething *= 100; echo "Start work $timeToWorkOnSomething msec on thread: " . posix_getpid() . PHP_EOL; //just a simulation on different time running process usleep($timeToWorkOnSomething); //not required but return everything you like //lets return a message to display on parent echo "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid(); return "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid(); } else { return $this->asyncCallOnChild(__FUNCTION__, array($timeToWorkOnSomething), $onComplete, function (AsyncMessage $messga) { var_dump($messga->GetResult()->getMessage()); }); } }
php
public function SomeUndefinedLongRunningWork($timeToWorkOnSomething, callable $onComplete = null) { if ($this->isExternal()) { $timeToWorkOnSomething *= 100; echo "Start work $timeToWorkOnSomething msec on thread: " . posix_getpid() . PHP_EOL; //just a simulation on different time running process usleep($timeToWorkOnSomething); //not required but return everything you like //lets return a message to display on parent echo "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid(); return "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid(); } else { return $this->asyncCallOnChild(__FUNCTION__, array($timeToWorkOnSomething), $onComplete, function (AsyncMessage $messga) { var_dump($messga->GetResult()->getMessage()); }); } }
[ "public", "function", "SomeUndefinedLongRunningWork", "(", "$", "timeToWorkOnSomething", ",", "callable", "$", "onComplete", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isExternal", "(", ")", ")", "{", "$", "timeToWorkOnSomething", "*=", "100", ";", ...
Function to do some async work on thread class @param int $timeToWorkOnSomething @param callable $onComplete @return AsyncMessage
[ "Function", "to", "do", "some", "async", "work", "on", "thread", "class" ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/examples/example_6.php#L36-L52
train
reliv/Rcm
admin/src/Form/NewPageForm.php
NewPageForm.isValid
public function isValid() { if ($this->get('page-template')->getValue() == 'blank') { $this->setValidationGroup( [ 'url', 'title', 'main-layout', ] ); } else { $this->setValidationGroup( [ 'url', 'title', 'page-template', ] ); } return parent::isValid(); }
php
public function isValid() { if ($this->get('page-template')->getValue() == 'blank') { $this->setValidationGroup( [ 'url', 'title', 'main-layout', ] ); } else { $this->setValidationGroup( [ 'url', 'title', 'page-template', ] ); } return parent::isValid(); }
[ "public", "function", "isValid", "(", ")", "{", "if", "(", "$", "this", "->", "get", "(", "'page-template'", ")", "->", "getValue", "(", ")", "==", "'blank'", ")", "{", "$", "this", "->", "setValidationGroup", "(", "[", "'url'", ",", "'title'", ",", ...
Is Valid method for the new page form. Adds a validation group depending on if it's a new page or a copy of a template. @return bool
[ "Is", "Valid", "method", "for", "the", "new", "page", "form", ".", "Adds", "a", "validation", "group", "depending", "on", "if", "it", "s", "a", "new", "page", "or", "a", "copy", "of", "a", "template", "." ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Form/NewPageForm.php#L245-L266
train
dadajuice/zephyrus
src/Zephyrus/Database/Broker.php
Broker.selectSingle
protected function selectSingle(string $query, array $parameters = [], string $allowedTags = "") { $statement = $this->query($query, $parameters); $statement->setAllowedHtmlTags($allowedTags); $result = $statement->next($this->fetchStyle); return ($result) ? $result : null; }
php
protected function selectSingle(string $query, array $parameters = [], string $allowedTags = "") { $statement = $this->query($query, $parameters); $statement->setAllowedHtmlTags($allowedTags); $result = $statement->next($this->fetchStyle); return ($result) ? $result : null; }
[ "protected", "function", "selectSingle", "(", "string", "$", "query", ",", "array", "$", "parameters", "=", "[", "]", ",", "string", "$", "allowedTags", "=", "\"\"", ")", "{", "$", "statement", "=", "$", "this", "->", "query", "(", "$", "query", ",", ...
Execute a SELECT query which should return a single data row. Best suited for queries involving primary key in where. Will return null if the query did not return any results. If more than one row is returned, an exception is thrown. @param string $query @param array $parameters @param string $allowedTags @return \stdClass
[ "Execute", "a", "SELECT", "query", "which", "should", "return", "a", "single", "data", "row", ".", "Best", "suited", "for", "queries", "involving", "primary", "key", "in", "where", ".", "Will", "return", "null", "if", "the", "query", "did", "not", "return"...
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Database/Broker.php#L124-L130
train
dadajuice/zephyrus
src/Zephyrus/Database/Broker.php
Broker.select
protected function select(string $query, array $parameters = [], string $allowedTags = ""): array { if (!is_null($this->pager)) { $query .= $this->pager->getSqlLimit(); } $statement = $this->query($query, $parameters); $statement->setAllowedHtmlTags($allowedTags); $results = []; while ($row = $statement->next($this->fetchStyle)) { $results[] = $row; } return $results; }
php
protected function select(string $query, array $parameters = [], string $allowedTags = ""): array { if (!is_null($this->pager)) { $query .= $this->pager->getSqlLimit(); } $statement = $this->query($query, $parameters); $statement->setAllowedHtmlTags($allowedTags); $results = []; while ($row = $statement->next($this->fetchStyle)) { $results[] = $row; } return $results; }
[ "protected", "function", "select", "(", "string", "$", "query", ",", "array", "$", "parameters", "=", "[", "]", ",", "string", "$", "allowedTags", "=", "\"\"", ")", ":", "array", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "pager", ")", ...
Execute a SELECT query which return the entire set of rows in an array. Will return an empty array if the query did not return any results. @param string $query @param array $parameters @param string $allowedTags @return \stdClass[]
[ "Execute", "a", "SELECT", "query", "which", "return", "the", "entire", "set", "of", "rows", "in", "an", "array", ".", "Will", "return", "an", "empty", "array", "if", "the", "query", "did", "not", "return", "any", "results", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Database/Broker.php#L141-L153
train
dadajuice/zephyrus
src/Zephyrus/Database/Broker.php
Broker.transaction
protected function transaction(callable $callback) { try { $this->database->beginTransaction(); $reflect = new \ReflectionFunction($callback); if ($reflect->getNumberOfParameters() == 1) { $result = $callback($this->database); } elseif ($reflect->getNumberOfParameters() == 0) { $result = $callback(); } else { throw new \InvalidArgumentException("Specified callback must have 0 or 1 argument"); } $this->database->commit(); return $result; } catch (\Exception $e) { $this->database->rollback(); throw new DatabaseException($e->getMessage()); } }
php
protected function transaction(callable $callback) { try { $this->database->beginTransaction(); $reflect = new \ReflectionFunction($callback); if ($reflect->getNumberOfParameters() == 1) { $result = $callback($this->database); } elseif ($reflect->getNumberOfParameters() == 0) { $result = $callback(); } else { throw new \InvalidArgumentException("Specified callback must have 0 or 1 argument"); } $this->database->commit(); return $result; } catch (\Exception $e) { $this->database->rollback(); throw new DatabaseException($e->getMessage()); } }
[ "protected", "function", "transaction", "(", "callable", "$", "callback", ")", "{", "try", "{", "$", "this", "->", "database", "->", "beginTransaction", "(", ")", ";", "$", "reflect", "=", "new", "\\", "ReflectionFunction", "(", "$", "callback", ")", ";", ...
Execute a query which should be contain inside a transaction. The specified callback method will optionally receive the Database instance if one argument is defined. Will work with nested transactions if using the TransactionPDO handler. Best suited method for INSERT, UPDATE and DELETE queries. @param callable $callback @return mixed
[ "Execute", "a", "query", "which", "should", "be", "contain", "inside", "a", "transaction", ".", "The", "specified", "callback", "method", "will", "optionally", "receive", "the", "Database", "instance", "if", "one", "argument", "is", "defined", ".", "Will", "wo...
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Database/Broker.php#L164-L182
train
webeweb/core-bundle
Controller/AbstractController.php
AbstractController.hasRolesOrRedirect
protected function hasRolesOrRedirect(array $roles, $or, $redirectUrl, $originUrl = "") { $user = $this->getKernelEventListener()->getUser(); if (false === UserHelper::hasRoles($user, $roles, $or)) { // Throw a bad user role exception with an anonymous user if user is null. $user = null !== $user ? $user : new User("anonymous", ""); throw new BadUserRoleException($user, $roles, $redirectUrl, $originUrl); } return true; }
php
protected function hasRolesOrRedirect(array $roles, $or, $redirectUrl, $originUrl = "") { $user = $this->getKernelEventListener()->getUser(); if (false === UserHelper::hasRoles($user, $roles, $or)) { // Throw a bad user role exception with an anonymous user if user is null. $user = null !== $user ? $user : new User("anonymous", ""); throw new BadUserRoleException($user, $roles, $redirectUrl, $originUrl); } return true; }
[ "protected", "function", "hasRolesOrRedirect", "(", "array", "$", "roles", ",", "$", "or", ",", "$", "redirectUrl", ",", "$", "originUrl", "=", "\"\"", ")", "{", "$", "user", "=", "$", "this", "->", "getKernelEventListener", "(", ")", "->", "getUser", "(...
Determines if the connected user have roles or redirect. @param array $roles The roles. @param bool $or OR ? @param string $redirectUrl The redirect URL. @param string $originUrl The origin URL. @return bool Returns true. @throws BadUserRoleException Throws a bad user role exception.
[ "Determines", "if", "the", "connected", "user", "have", "roles", "or", "redirect", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Controller/AbstractController.php#L120-L132
train
dadajuice/zephyrus
src/Zephyrus/Network/RequestFactory.php
RequestFactory.captureHttpRequest
private static function captureHttpRequest() { $server = $_SERVER; $uri = self::getCompleteRequestUri($server); $method = strtoupper($server['REQUEST_METHOD']); $parameters = self::getParametersFromContentType($server['CONTENT_TYPE'] ?? ContentType::PLAIN); if (isset($parameters['__method'])) { $method = strtoupper($parameters['__method']); } self::$httpRequest = new Request($uri, $method, [ 'parameters' => $parameters, 'cookies' => $_COOKIE, 'files' => $_FILES, 'server' => $server ]); }
php
private static function captureHttpRequest() { $server = $_SERVER; $uri = self::getCompleteRequestUri($server); $method = strtoupper($server['REQUEST_METHOD']); $parameters = self::getParametersFromContentType($server['CONTENT_TYPE'] ?? ContentType::PLAIN); if (isset($parameters['__method'])) { $method = strtoupper($parameters['__method']); } self::$httpRequest = new Request($uri, $method, [ 'parameters' => $parameters, 'cookies' => $_COOKIE, 'files' => $_FILES, 'server' => $server ]); }
[ "private", "static", "function", "captureHttpRequest", "(", ")", "{", "$", "server", "=", "$", "_SERVER", ";", "$", "uri", "=", "self", "::", "getCompleteRequestUri", "(", "$", "server", ")", ";", "$", "method", "=", "strtoupper", "(", "$", "server", "["...
Reads the HTTP data to build corresponding request instance.
[ "Reads", "the", "HTTP", "data", "to", "build", "corresponding", "request", "instance", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Network/RequestFactory.php#L37-L52
train
dadajuice/zephyrus
src/Zephyrus/Network/RequestFactory.php
RequestFactory.getParametersFromContentType
private static function getParametersFromContentType(string $contentType): array { $parameters = array_merge( self::getParametersFromGlobal($_GET), self::getParametersFromGlobal($_POST), self::getParametersFromGlobal($_FILES)); $paramsSource = []; $rawInput = file_get_contents('php://input'); switch ($contentType) { case ContentType::JSON: $paramsSource = (array) json_decode($rawInput); break; case ContentType::XML: case ContentType::XML_APP: $xml = new \SimpleXMLElement($rawInput); $paramsSource = (array) $xml; break; default: parse_str($rawInput, $paramsSource); } return array_merge($parameters, self::getParametersFromGlobal($paramsSource)); }
php
private static function getParametersFromContentType(string $contentType): array { $parameters = array_merge( self::getParametersFromGlobal($_GET), self::getParametersFromGlobal($_POST), self::getParametersFromGlobal($_FILES)); $paramsSource = []; $rawInput = file_get_contents('php://input'); switch ($contentType) { case ContentType::JSON: $paramsSource = (array) json_decode($rawInput); break; case ContentType::XML: case ContentType::XML_APP: $xml = new \SimpleXMLElement($rawInput); $paramsSource = (array) $xml; break; default: parse_str($rawInput, $paramsSource); } return array_merge($parameters, self::getParametersFromGlobal($paramsSource)); }
[ "private", "static", "function", "getParametersFromContentType", "(", "string", "$", "contentType", ")", ":", "array", "{", "$", "parameters", "=", "array_merge", "(", "self", "::", "getParametersFromGlobal", "(", "$", "_GET", ")", ",", "self", "::", "getParamet...
Load every request parameters depending on the request content type and ensure to properly convert raw data to array parameters. @return array
[ "Load", "every", "request", "parameters", "depending", "on", "the", "request", "content", "type", "and", "ensure", "to", "properly", "convert", "raw", "data", "to", "array", "parameters", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Network/RequestFactory.php#L60-L81
train
c9s/CodeGen
src/Block.php
Block.setBody
public function setBody($text) { if (is_string($text)) { $this->lines = explode("\n", $text); } elseif (is_array($text)) { $this->lines = $text; } else { throw new InvalidArgumentTypeException('Invalid body type', $text, array('string', 'array')); } }
php
public function setBody($text) { if (is_string($text)) { $this->lines = explode("\n", $text); } elseif (is_array($text)) { $this->lines = $text; } else { throw new InvalidArgumentTypeException('Invalid body type', $text, array('string', 'array')); } }
[ "public", "function", "setBody", "(", "$", "text", ")", "{", "if", "(", "is_string", "(", "$", "text", ")", ")", "{", "$", "this", "->", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "text", ")", ";", "}", "elseif", "(", "is_array", "(", "$"...
Allow text can be set with array
[ "Allow", "text", "can", "be", "set", "with", "array" ]
4fd58c53d65efd42d4612a8e627a59a51986ccb1
https://github.com/c9s/CodeGen/blob/4fd58c53d65efd42d4612a8e627a59a51986ccb1/src/Block.php#L41-L50
train
reliv/Rcm
immutable-history/src/VersionRepository.php
VersionRepository.findPublishedVersionByLocator
public function findPublishedVersionByLocator(LocatorInterface $locator) { $entity = $this->findActiveVersionByLocator($locator); if ($entity !== null && $entity->getStatus() === VersionStatuses::PUBLISHED) { return $entity; } return null; }
php
public function findPublishedVersionByLocator(LocatorInterface $locator) { $entity = $this->findActiveVersionByLocator($locator); if ($entity !== null && $entity->getStatus() === VersionStatuses::PUBLISHED) { return $entity; } return null; }
[ "public", "function", "findPublishedVersionByLocator", "(", "LocatorInterface", "$", "locator", ")", "{", "$", "entity", "=", "$", "this", "->", "findActiveVersionByLocator", "(", "$", "locator", ")", ";", "if", "(", "$", "entity", "!==", "null", "&&", "$", ...
Finds the most recent "published" or "depublished" version of a resource and if it is "published" returns it, otherwise returns null. @param LocatorInterface $locator @return VersionEntityInterface | null
[ "Finds", "the", "most", "recent", "published", "or", "depublished", "version", "of", "a", "resource", "and", "if", "it", "is", "published", "returns", "it", "otherwise", "returns", "null", "." ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/immutable-history/src/VersionRepository.php#L272-L281
train
reliv/Rcm
immutable-history/src/VersionRepository.php
VersionRepository.findActiveVersionByLocator
protected function findActiveVersionByLocator(LocatorInterface $locator) { $criteria = new Criteria(); $criteria->where( $criteria->expr()->in( 'status', [VersionStatuses::PUBLISHED, VersionStatuses::DEPUBLISHED] ) ); foreach ($locator->toArray() as $column => $value) { $criteria->andWhere($criteria->expr()->eq($column, $value)); } $criteria->orderBy(['id' => Criteria::DESC]); $criteria->setMaxResults(1); $entities = $this->entityManger->getRepository($this->entityClassName)->matching($criteria)->toArray(); if (isset($entities[0])) { return $entities[0]; } return null; }
php
protected function findActiveVersionByLocator(LocatorInterface $locator) { $criteria = new Criteria(); $criteria->where( $criteria->expr()->in( 'status', [VersionStatuses::PUBLISHED, VersionStatuses::DEPUBLISHED] ) ); foreach ($locator->toArray() as $column => $value) { $criteria->andWhere($criteria->expr()->eq($column, $value)); } $criteria->orderBy(['id' => Criteria::DESC]); $criteria->setMaxResults(1); $entities = $this->entityManger->getRepository($this->entityClassName)->matching($criteria)->toArray(); if (isset($entities[0])) { return $entities[0]; } return null; }
[ "protected", "function", "findActiveVersionByLocator", "(", "LocatorInterface", "$", "locator", ")", "{", "$", "criteria", "=", "new", "Criteria", "(", ")", ";", "$", "criteria", "->", "where", "(", "$", "criteria", "->", "expr", "(", ")", "->", "in", "(",...
Find the "active" version which means the most recent version that is either "published" or "depublished" while ignoring "unpublished" versions @param LocatorInterface $locator @return VersionEntityInterface | null
[ "Find", "the", "active", "version", "which", "means", "the", "most", "recent", "version", "that", "is", "either", "published", "or", "depublished", "while", "ignoring", "unpublished", "versions" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/immutable-history/src/VersionRepository.php#L305-L327
train
mradcliffe/xeroclient
src/XeroHelperTrait.php
XeroHelperTrait.addCondition
public function addCondition($field, $value = '', $operator = '==') { if (!in_array($operator, self::$conditionOperators)) { throw new \InvalidArgumentException('Invalid operator'); } // Transform a boolean value to its string representation. if (is_bool($value)) { $value = $value ? 'true' : 'false'; } // Construct condition statement based on operator. if (in_array($operator, ['==', '!='])) { $this->conditions[] = $field . $operator . '"' . $value . '"'; } elseif ($operator === 'guid') { $this->conditions[] = $field . '= Guid("'. $value . '")'; } else { $this->conditions[] = $field . '.' . $operator . '("' . $value . '")'; } return $this; }
php
public function addCondition($field, $value = '', $operator = '==') { if (!in_array($operator, self::$conditionOperators)) { throw new \InvalidArgumentException('Invalid operator'); } // Transform a boolean value to its string representation. if (is_bool($value)) { $value = $value ? 'true' : 'false'; } // Construct condition statement based on operator. if (in_array($operator, ['==', '!='])) { $this->conditions[] = $field . $operator . '"' . $value . '"'; } elseif ($operator === 'guid') { $this->conditions[] = $field . '= Guid("'. $value . '")'; } else { $this->conditions[] = $field . '.' . $operator . '("' . $value . '")'; } return $this; }
[ "public", "function", "addCondition", "(", "$", "field", ",", "$", "value", "=", "''", ",", "$", "operator", "=", "'=='", ")", "{", "if", "(", "!", "in_array", "(", "$", "operator", ",", "self", "::", "$", "conditionOperators", ")", ")", "{", "throw"...
Add a condition to the request. @param string $field The field to add the condition for. @param string $value The value to compare against. @param string $operator The operator to use in the condition: - ==: Equal to the value. - !=: Not equal to the value. - StartsWith: Starts with the value. - EndsWith: Ends with the value. - Contains: Contains the value. - guid: Equality for guid values. See Xero API. @return $this
[ "Add", "a", "condition", "to", "the", "request", "." ]
e9e2550e8585bc185bb8a843ee4f54781a3d4e28
https://github.com/mradcliffe/xeroclient/blob/e9e2550e8585bc185bb8a843ee4f54781a3d4e28/src/XeroHelperTrait.php#L50-L71
train
mradcliffe/xeroclient
src/XeroHelperTrait.php
XeroHelperTrait.compileConditions
public function compileConditions() { $ret = []; if (!empty($this->conditions)) { $ret['where'] = implode(' ', $this->conditions); } return $ret; }
php
public function compileConditions() { $ret = []; if (!empty($this->conditions)) { $ret['where'] = implode(' ', $this->conditions); } return $ret; }
[ "public", "function", "compileConditions", "(", ")", "{", "$", "ret", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "conditions", ")", ")", "{", "$", "ret", "[", "'where'", "]", "=", "implode", "(", "' '", ",", "$", "this",...
Compile the conditions array into a query parameter. @return array An associative array that can be merged into the query options.
[ "Compile", "the", "conditions", "array", "into", "a", "query", "parameter", "." ]
e9e2550e8585bc185bb8a843ee4f54781a3d4e28
https://github.com/mradcliffe/xeroclient/blob/e9e2550e8585bc185bb8a843ee4f54781a3d4e28/src/XeroHelperTrait.php#L98-L105
train
mradcliffe/xeroclient
src/XeroHelperTrait.php
XeroHelperTrait.getRequestParameters
public function getRequestParameters($request_parameters) { $ret = []; $parts = explode('&', $request_parameters); foreach ($parts as $part) { list($key, $value) = explode('=', $part); $key_decoded = urldecode($key); $value_decoded = urldecode($value); $ret[$key_decoded] = $value_decoded; } return $ret; }
php
public function getRequestParameters($request_parameters) { $ret = []; $parts = explode('&', $request_parameters); foreach ($parts as $part) { list($key, $value) = explode('=', $part); $key_decoded = urldecode($key); $value_decoded = urldecode($value); $ret[$key_decoded] = $value_decoded; } return $ret; }
[ "public", "function", "getRequestParameters", "(", "$", "request_parameters", ")", "{", "$", "ret", "=", "[", "]", ";", "$", "parts", "=", "explode", "(", "'&'", ",", "$", "request_parameters", ")", ";", "foreach", "(", "$", "parts", "as", "$", "part", ...
Parse the Authorization HTTP Request parameters. @param string $request_parameters The HTTP Request parameters from the API to the web server. @return array An associative array keyed by the parameter key.
[ "Parse", "the", "Authorization", "HTTP", "Request", "parameters", "." ]
e9e2550e8585bc185bb8a843ee4f54781a3d4e28
https://github.com/mradcliffe/xeroclient/blob/e9e2550e8585bc185bb8a843ee4f54781a3d4e28/src/XeroHelperTrait.php#L136-L147
train
proem/proem
lib/Proem/Dispatch/Dispatcher.php
Dispatcher.handle
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) { while ($route = $this->router->route($request)) { $module = $route->getPayload()['module']; $controller = $route->getPayload()['controller']; $action = $route->getPayload()['action']; $class = str_replace( ['{:module}', '{:controller}'], [$module, $controller], $this->mapping ); try { return $this->assetManager->resolve($class, ['invoke' => $action]); } catch (\LogicException $e) { $this->failures[] = ['route' => $route, 'exception' => $e]; } } }
php
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) { while ($route = $this->router->route($request)) { $module = $route->getPayload()['module']; $controller = $route->getPayload()['controller']; $action = $route->getPayload()['action']; $class = str_replace( ['{:module}', '{:controller}'], [$module, $controller], $this->mapping ); try { return $this->assetManager->resolve($class, ['invoke' => $action]); } catch (\LogicException $e) { $this->failures[] = ['route' => $route, 'exception' => $e]; } } }
[ "public", "function", "handle", "(", "Request", "$", "request", ",", "$", "type", "=", "self", "::", "MASTER_REQUEST", ",", "$", "catch", "=", "true", ")", "{", "while", "(", "$", "route", "=", "$", "this", "->", "router", "->", "route", "(", "$", ...
Handles a Request, converting it to a Response. @return Proem\Http\Response
[ "Handles", "a", "Request", "converting", "it", "to", "a", "Response", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Dispatch/Dispatcher.php#L91-L108
train
russsiq/bixbite
app/Support/WidgetAbstract.php
WidgetAbstract.cacheKey
public function cacheKey() { $this->cacheKey = $this->cacheKey ?? $this->generateCacheKey( auth()->guest() ? 'guest' : auth()->user()->role ); return $this->cacheKey; }
php
public function cacheKey() { $this->cacheKey = $this->cacheKey ?? $this->generateCacheKey( auth()->guest() ? 'guest' : auth()->user()->role ); return $this->cacheKey; }
[ "public", "function", "cacheKey", "(", ")", "{", "$", "this", "->", "cacheKey", "=", "$", "this", "->", "cacheKey", "??", "$", "this", "->", "generateCacheKey", "(", "auth", "(", ")", "->", "guest", "(", ")", "?", "'guest'", ":", "auth", "(", ")", ...
Get a unique key of the widget for caching. @return string
[ "Get", "a", "unique", "key", "of", "the", "widget", "for", "caching", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/WidgetAbstract.php#L91-L99
train
russsiq/bixbite
app/Support/WidgetAbstract.php
WidgetAbstract.cacheKeys
public function cacheKeys() { $keys = []; $roles = array_merge(cache('roles'), ['guest']); foreach ($roles as $role) { $keys[] = $this->generateCacheKey($role); } return implode('|', $keys); }
php
public function cacheKeys() { $keys = []; $roles = array_merge(cache('roles'), ['guest']); foreach ($roles as $role) { $keys[] = $this->generateCacheKey($role); } return implode('|', $keys); }
[ "public", "function", "cacheKeys", "(", ")", "{", "$", "keys", "=", "[", "]", ";", "$", "roles", "=", "array_merge", "(", "cache", "(", "'roles'", ")", ",", "[", "'guest'", "]", ")", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{",...
Get all keys of the widget for clearing cache. @return string
[ "Get", "all", "keys", "of", "the", "widget", "for", "clearing", "cache", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/WidgetAbstract.php#L106-L116
train
russsiq/bixbite
app/Support/WidgetAbstract.php
WidgetAbstract.generateCacheKey
protected function generateCacheKey(string $role) { return md5(serialize(array_merge($this->params, [ 'widget' => get_class($this), 'app_theme' => app_theme(), 'app_locale' => app_locale(), 'role' => $role, ]))); }
php
protected function generateCacheKey(string $role) { return md5(serialize(array_merge($this->params, [ 'widget' => get_class($this), 'app_theme' => app_theme(), 'app_locale' => app_locale(), 'role' => $role, ]))); }
[ "protected", "function", "generateCacheKey", "(", "string", "$", "role", ")", "{", "return", "md5", "(", "serialize", "(", "array_merge", "(", "$", "this", "->", "params", ",", "[", "'widget'", "=>", "get_class", "(", "$", "this", ")", ",", "'app_theme'", ...
Generate a unique cache key depending on the input parameters. @param string $role @return string
[ "Generate", "a", "unique", "cache", "key", "depending", "on", "the", "input", "parameters", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/WidgetAbstract.php#L123-L131
train
russsiq/bixbite
app/Support/WidgetAbstract.php
WidgetAbstract.validator
public function validator() { return Validator::make( $this->params, $this->rules(), $this->messages(), $this->attributes() ); }
php
public function validator() { return Validator::make( $this->params, $this->rules(), $this->messages(), $this->attributes() ); }
[ "public", "function", "validator", "(", ")", "{", "return", "Validator", "::", "make", "(", "$", "this", "->", "params", ",", "$", "this", "->", "rules", "(", ")", ",", "$", "this", "->", "messages", "(", ")", ",", "$", "this", "->", "attributes", ...
Validate incoming parameters. @return mixed
[ "Validate", "incoming", "parameters", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/WidgetAbstract.php#L137-L143
train
russsiq/bixbite
app/Support/WidgetAbstract.php
WidgetAbstract.castParam
protected function castParam($key, $value) { if (is_null($value) or ! $this->hasCast($key)) { return $value; } switch ($this->getCastType($key)) { case 'int': case 'integer': return (int) $value; case 'real': case 'float': case 'double': return (float) $value; case 'string': return (string) $value; case 'bool': case 'boolean': return (bool) $value; case 'array': return (array) $value; case 'collection': return collect((array) $value); default: return $value; } }
php
protected function castParam($key, $value) { if (is_null($value) or ! $this->hasCast($key)) { return $value; } switch ($this->getCastType($key)) { case 'int': case 'integer': return (int) $value; case 'real': case 'float': case 'double': return (float) $value; case 'string': return (string) $value; case 'bool': case 'boolean': return (bool) $value; case 'array': return (array) $value; case 'collection': return collect((array) $value); default: return $value; } }
[ "protected", "function", "castParam", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", "or", "!", "$", "this", "->", "hasCast", "(", "$", "key", ")", ")", "{", "return", "$", "value", ";", "}", "switch",...
Cast an param to a native PHP type. @param string $key @param mixed $value @return mixed
[ "Cast", "an", "param", "to", "a", "native", "PHP", "type", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/WidgetAbstract.php#L169-L195
train
RogerWaters/react-thread-pool
examples/example_3.php
DownloaderThread.download
public function download($url, callable $onComplete = null) { //first check if the function is called external if($this->isExternal()) { $data = file_get_contents($url); //hold the process to simulate more to do ;-) sleep(3); echo "Downloaded: ".strlen($data).' bytes from url: '.$url.PHP_EOL; //return the data //parent thread can handle this if needed return $data; } else { //we are in the parent context //just redirect to the thread //we use async as we dont want to wait for the result //return the handle allow the caller to check result return $this->asyncCallOnChild(__FUNCTION__, array($url), $onComplete); } }
php
public function download($url, callable $onComplete = null) { //first check if the function is called external if($this->isExternal()) { $data = file_get_contents($url); //hold the process to simulate more to do ;-) sleep(3); echo "Downloaded: ".strlen($data).' bytes from url: '.$url.PHP_EOL; //return the data //parent thread can handle this if needed return $data; } else { //we are in the parent context //just redirect to the thread //we use async as we dont want to wait for the result //return the handle allow the caller to check result return $this->asyncCallOnChild(__FUNCTION__, array($url), $onComplete); } }
[ "public", "function", "download", "(", "$", "url", ",", "callable", "$", "onComplete", "=", "null", ")", "{", "//first check if the function is called external\r", "if", "(", "$", "this", "->", "isExternal", "(", ")", ")", "{", "$", "data", "=", "file_get_cont...
Function for downloading urls external @param string $url @param callable $onComplete @return AsyncMessage|string
[ "Function", "for", "downloading", "urls", "external" ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/examples/example_3.php#L24-L45
train
laravelflare/flare
src/Flare/Providers/CompatibilityServiceProvider.php
CompatibilityServiceProvider.registerServiceProviders
protected function registerServiceProviders() { foreach ($this->serviceProviders[$this->flare->compatibility()] as $class) { $this->app->register($class); } }
php
protected function registerServiceProviders() { foreach ($this->serviceProviders[$this->flare->compatibility()] as $class) { $this->app->register($class); } }
[ "protected", "function", "registerServiceProviders", "(", ")", "{", "foreach", "(", "$", "this", "->", "serviceProviders", "[", "$", "this", "->", "flare", "->", "compatibility", "(", ")", "]", "as", "$", "class", ")", "{", "$", "this", "->", "app", "->"...
Register Service Providers.
[ "Register", "Service", "Providers", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Providers/CompatibilityServiceProvider.php#L41-L46
train
dadajuice/zephyrus
src/Zephyrus/Security/EncryptedSessionHandler.php
EncryptedSessionHandler.open
public function open($savePath, $sessionName) { parent::open($savePath, $sessionName); $this->cookieKeyName = "key_$sessionName"; if (empty($_COOKIE[$this->cookieKeyName]) || strpos($_COOKIE[$this->cookieKeyName], ':') === false) { $this->createEncryptionCookie(); return true; } list($this->cryptKey, $this->cryptAuth) = explode(':', $_COOKIE[$this->cookieKeyName]); $this->cryptKey = base64_decode($this->cryptKey); $this->cryptAuth = base64_decode($this->cryptAuth); return true; }
php
public function open($savePath, $sessionName) { parent::open($savePath, $sessionName); $this->cookieKeyName = "key_$sessionName"; if (empty($_COOKIE[$this->cookieKeyName]) || strpos($_COOKIE[$this->cookieKeyName], ':') === false) { $this->createEncryptionCookie(); return true; } list($this->cryptKey, $this->cryptAuth) = explode(':', $_COOKIE[$this->cookieKeyName]); $this->cryptKey = base64_decode($this->cryptKey); $this->cryptAuth = base64_decode($this->cryptAuth); return true; }
[ "public", "function", "open", "(", "$", "savePath", ",", "$", "sessionName", ")", "{", "parent", "::", "open", "(", "$", "savePath", ",", "$", "sessionName", ")", ";", "$", "this", "->", "cookieKeyName", "=", "\"key_$sessionName\"", ";", "if", "(", "empt...
Called on session_start, this method create the. @param string $savePath @param string $sessionName @throws \Exception @return bool
[ "Called", "on", "session_start", "this", "method", "create", "the", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/EncryptedSessionHandler.php#L29-L41
train
dadajuice/zephyrus
src/Zephyrus/Security/EncryptedSessionHandler.php
EncryptedSessionHandler.destroy
public function destroy($sessionId) { parent::destroy($sessionId); if (isset($_COOKIE[$this->cookieKeyName])) { setcookie($this->cookieKeyName, '', 1); unset($_COOKIE[$this->cookieKeyName]); } return true; }
php
public function destroy($sessionId) { parent::destroy($sessionId); if (isset($_COOKIE[$this->cookieKeyName])) { setcookie($this->cookieKeyName, '', 1); unset($_COOKIE[$this->cookieKeyName]); } return true; }
[ "public", "function", "destroy", "(", "$", "sessionId", ")", "{", "parent", "::", "destroy", "(", "$", "sessionId", ")", ";", "if", "(", "isset", "(", "$", "_COOKIE", "[", "$", "this", "->", "cookieKeyName", "]", ")", ")", "{", "setcookie", "(", "$",...
Destroy session file on disk and delete encryption cookie if no session is active after deletion. @param string $sessionId @return bool
[ "Destroy", "session", "file", "on", "disk", "and", "delete", "encryption", "cookie", "if", "no", "session", "is", "active", "after", "deletion", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/EncryptedSessionHandler.php#L62-L70
train
dadajuice/zephyrus
src/Zephyrus/Security/EncryptedSessionHandler.php
EncryptedSessionHandler.encrypt
private function encrypt(string $data): string { $cipher = Cryptography::encrypt($data, $this->cryptKey); list($initializationVector, $cipher) = explode(':', $cipher); $initializationVector = base64_decode($initializationVector); $cipher = base64_decode($cipher); $content = $initializationVector . Cryptography::getEncryptionAlgorithm() . $cipher; $hmac = hash_hmac('sha256', $content, $this->cryptAuth); return $hmac . ':' . base64_encode($initializationVector) . ':' . base64_encode($cipher); }
php
private function encrypt(string $data): string { $cipher = Cryptography::encrypt($data, $this->cryptKey); list($initializationVector, $cipher) = explode(':', $cipher); $initializationVector = base64_decode($initializationVector); $cipher = base64_decode($cipher); $content = $initializationVector . Cryptography::getEncryptionAlgorithm() . $cipher; $hmac = hash_hmac('sha256', $content, $this->cryptAuth); return $hmac . ':' . base64_encode($initializationVector) . ':' . base64_encode($cipher); }
[ "private", "function", "encrypt", "(", "string", "$", "data", ")", ":", "string", "{", "$", "cipher", "=", "Cryptography", "::", "encrypt", "(", "$", "data", ",", "$", "this", "->", "cryptKey", ")", ";", "list", "(", "$", "initializationVector", ",", "...
Encrypt the specified data using the defined algorithm. Also create an Hmac authentication hash. @param string $data @return string
[ "Encrypt", "the", "specified", "data", "using", "the", "defined", "algorithm", ".", "Also", "create", "an", "Hmac", "authentication", "hash", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/EncryptedSessionHandler.php#L99-L108
train
dadajuice/zephyrus
src/Zephyrus/Security/EncryptedSessionHandler.php
EncryptedSessionHandler.decrypt
private function decrypt(string $data): string { list($hmac, $initializationVector, $cipher) = explode(':', $data); $ivReal = base64_decode($initializationVector); $cipherReal = base64_decode($cipher); $validHash = $ivReal . Cryptography::getEncryptionAlgorithm() . $cipherReal; $newHmac = hash_hmac('sha256', $validHash, $this->cryptAuth); if ($hmac !== $newHmac) { throw new \RuntimeException("Invalid decryption key"); } $decrypt = Cryptography::decrypt($initializationVector . ':' . $cipher, $this->cryptKey); return $decrypt; }
php
private function decrypt(string $data): string { list($hmac, $initializationVector, $cipher) = explode(':', $data); $ivReal = base64_decode($initializationVector); $cipherReal = base64_decode($cipher); $validHash = $ivReal . Cryptography::getEncryptionAlgorithm() . $cipherReal; $newHmac = hash_hmac('sha256', $validHash, $this->cryptAuth); if ($hmac !== $newHmac) { throw new \RuntimeException("Invalid decryption key"); } $decrypt = Cryptography::decrypt($initializationVector . ':' . $cipher, $this->cryptKey); return $decrypt; }
[ "private", "function", "decrypt", "(", "string", "$", "data", ")", ":", "string", "{", "list", "(", "$", "hmac", ",", "$", "initializationVector", ",", "$", "cipher", ")", "=", "explode", "(", "':'", ",", "$", "data", ")", ";", "$", "ivReal", "=", ...
Decrypt the specified data using the defined algorithm. Also verify the Hmac authentication hash. Returns false if Hmac validation fails. @param string $data @throws \Exception @return string
[ "Decrypt", "the", "specified", "data", "using", "the", "defined", "algorithm", ".", "Also", "verify", "the", "Hmac", "authentication", "hash", ".", "Returns", "false", "if", "Hmac", "validation", "fails", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/EncryptedSessionHandler.php#L118-L130
train
RogerWaters/react-thread-pool
src/ThreadBase.php
ThreadBase.handleMessage
public function handleMessage(ThreadCommunicator $communicator, $messagePayload) { $action = $messagePayload['action']; $parameters = $messagePayload['parameters']; if (method_exists($this, $action)) { return call_user_func_array(array($this, $action), $parameters); } return false; }
php
public function handleMessage(ThreadCommunicator $communicator, $messagePayload) { $action = $messagePayload['action']; $parameters = $messagePayload['parameters']; if (method_exists($this, $action)) { return call_user_func_array(array($this, $action), $parameters); } return false; }
[ "public", "function", "handleMessage", "(", "ThreadCommunicator", "$", "communicator", ",", "$", "messagePayload", ")", "{", "$", "action", "=", "$", "messagePayload", "[", "'action'", "]", ";", "$", "parameters", "=", "$", "messagePayload", "[", "'parameters'",...
Each message received call this function @param ThreadCommunicator $communicator @param mixed $messagePayload @return mixed
[ "Each", "message", "received", "call", "this", "function" ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ThreadBase.php#L46-L56
train
RogerWaters/react-thread-pool
src/ThreadBase.php
ThreadBase.stop
public function stop() { if ($this->isExternal()) { $this->communicator->getLoop()->stop(); } else { $this->asyncCallOnChild(__FUNCTION__, func_get_args()); } }
php
public function stop() { if ($this->isExternal()) { $this->communicator->getLoop()->stop(); } else { $this->asyncCallOnChild(__FUNCTION__, func_get_args()); } }
[ "public", "function", "stop", "(", ")", "{", "if", "(", "$", "this", "->", "isExternal", "(", ")", ")", "{", "$", "this", "->", "communicator", "->", "getLoop", "(", ")", "->", "stop", "(", ")", ";", "}", "else", "{", "$", "this", "->", "asyncCal...
Stop the external process after all current operations completed
[ "Stop", "the", "external", "process", "after", "all", "current", "operations", "completed" ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ThreadBase.php#L97-L107
train
RogerWaters/react-thread-pool
src/ThreadBase.php
ThreadBase.join
public function join() { if ($this->isExternal()) { $this->communicator->getLoop()->stop(); } else { $this->callOnChild(__FUNCTION__, func_get_args()); } }
php
public function join() { if ($this->isExternal()) { $this->communicator->getLoop()->stop(); } else { $this->callOnChild(__FUNCTION__, func_get_args()); } }
[ "public", "function", "join", "(", ")", "{", "if", "(", "$", "this", "->", "isExternal", "(", ")", ")", "{", "$", "this", "->", "communicator", "->", "getLoop", "(", ")", "->", "stop", "(", ")", ";", "}", "else", "{", "$", "this", "->", "callOnCh...
Stop thread after current works done and return
[ "Stop", "thread", "after", "current", "works", "done", "and", "return" ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ThreadBase.php#L112-L119
train
RogerWaters/react-thread-pool
src/ThreadBase.php
ThreadBase.asyncCallOnChild
protected function asyncCallOnChild($action, array $parameters = array(), callable $onResult = null, callable $onError = null) { if($this->isExternal()) { throw new \RuntimeException("Calling ClientThread::CallOnChild from Child context. Did you mean ClientThread::CallOnParent?"); } else { return $this->communicator->SendMessageAsync($this->encode($action, $parameters), $onResult, $onError); } }
php
protected function asyncCallOnChild($action, array $parameters = array(), callable $onResult = null, callable $onError = null) { if($this->isExternal()) { throw new \RuntimeException("Calling ClientThread::CallOnChild from Child context. Did you mean ClientThread::CallOnParent?"); } else { return $this->communicator->SendMessageAsync($this->encode($action, $parameters), $onResult, $onError); } }
[ "protected", "function", "asyncCallOnChild", "(", "$", "action", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "callable", "$", "onResult", "=", "null", ",", "callable", "$", "onError", "=", "null", ")", "{", "if", "(", "$", "this", "->...
Asynchronous variation of @see ThreadBase::callOnChild this method returns instantly You can ether use the @see MessageFormat::isIsResolved to check the result Or you can provide a callback executed if the message gets resolved If you don't matter on what the call returns just throw away the result @param string $action @param array $parameters @param callable $onResult @param callable $onError @return AsyncMessage
[ "Asynchronous", "variation", "of" ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ThreadBase.php#L192-L202
train
brightnucleus/injector
src/Injector.php
Injector.registerMappings
public function registerMappings(ConfigInterface $config) { $configKeys = [ static::STANDARD_ALIASES => 'mapAliases', static::SHARED_ALIASES => 'shareAliases', static::ARGUMENT_DEFINITIONS => 'defineArguments', static::ARGUMENT_PROVIDERS => 'defineArgumentProviders', static::DELEGATIONS => 'defineDelegations', static::PREPARATIONS => 'definePreparations', ]; try { foreach ($configKeys as $key => $method) { $$key = $config->hasKey($key) ? $config->getKey($key) : []; } $standardAliases = array_merge( $sharedAliases, $standardAliases ); } catch (Exception $exception) { throw new InvalidMappingsException( sprintf( _('Failed to read needed keys from config. Reason: "%1$s".'), $exception->getMessage() ) ); } try { foreach ($configKeys as $key => $method) { array_walk($$key, [$this, $method]); } } catch (Exception $exception) { throw new InvalidMappingsException( sprintf( _('Failed to set up dependency injector. Reason: "%1$s".'), $exception->getMessage() ) ); } }
php
public function registerMappings(ConfigInterface $config) { $configKeys = [ static::STANDARD_ALIASES => 'mapAliases', static::SHARED_ALIASES => 'shareAliases', static::ARGUMENT_DEFINITIONS => 'defineArguments', static::ARGUMENT_PROVIDERS => 'defineArgumentProviders', static::DELEGATIONS => 'defineDelegations', static::PREPARATIONS => 'definePreparations', ]; try { foreach ($configKeys as $key => $method) { $$key = $config->hasKey($key) ? $config->getKey($key) : []; } $standardAliases = array_merge( $sharedAliases, $standardAliases ); } catch (Exception $exception) { throw new InvalidMappingsException( sprintf( _('Failed to read needed keys from config. Reason: "%1$s".'), $exception->getMessage() ) ); } try { foreach ($configKeys as $key => $method) { array_walk($$key, [$this, $method]); } } catch (Exception $exception) { throw new InvalidMappingsException( sprintf( _('Failed to set up dependency injector. Reason: "%1$s".'), $exception->getMessage() ) ); } }
[ "public", "function", "registerMappings", "(", "ConfigInterface", "$", "config", ")", "{", "$", "configKeys", "=", "[", "static", "::", "STANDARD_ALIASES", "=>", "'mapAliases'", ",", "static", "::", "SHARED_ALIASES", "=>", "'shareAliases'", ",", "static", "::", ...
Register mapping definitions. Takes a ConfigInterface and reads the following keys to add definitions: - 'sharedAliases' - 'standardAliases' - 'argumentDefinitions' - 'argumentProviders' - 'delegations' - 'preparations' @since 0.1.0 @param ConfigInterface $config Config file to parse. @throws InvalidMappingsException If a needed key could not be read from the config file. @throws InvalidMappingsException If the dependency injector could not be set up.
[ "Register", "mapping", "definitions", "." ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/Injector.php#L124-L164
train
brightnucleus/injector
src/Injector.php
Injector.defineArguments
protected function defineArguments($argumentSetup, $alias) { foreach ($argumentSetup as $key => $value) { $this->addArgumentDefinition($value, $alias, [$key, null]); } }
php
protected function defineArguments($argumentSetup, $alias) { foreach ($argumentSetup as $key => $value) { $this->addArgumentDefinition($value, $alias, [$key, null]); } }
[ "protected", "function", "defineArguments", "(", "$", "argumentSetup", ",", "$", "alias", ")", "{", "foreach", "(", "$", "argumentSetup", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addArgumentDefinition", "(", "$", "value", ",", ...
Tell our Injector how arguments are defined. @since 0.2.3 @param array $argumentSetup Argument providers setup from configuration file. @param string $alias The alias for which to define the argument. @throws InvalidMappingsException If a required config key could not be found.
[ "Tell", "our", "Injector", "how", "arguments", "are", "defined", "." ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/Injector.php#L209-L214
train
brightnucleus/injector
src/Injector.php
Injector.defineArgumentProviders
protected function defineArgumentProviders($argumentSetup, $argument) { if (! array_key_exists('mappings', $argumentSetup)) { throw new InvalidMappingsException( sprintf( _('Failed to define argument providers for argument "%1$s". ' . 'Reason: The key "mappings" was not found.'), $argument ) ); } array_walk( $argumentSetup['mappings'], [$this, 'addArgumentDefinition'], [$argument, $argumentSetup['interface'] ?: null] ); }
php
protected function defineArgumentProviders($argumentSetup, $argument) { if (! array_key_exists('mappings', $argumentSetup)) { throw new InvalidMappingsException( sprintf( _('Failed to define argument providers for argument "%1$s". ' . 'Reason: The key "mappings" was not found.'), $argument ) ); } array_walk( $argumentSetup['mappings'], [$this, 'addArgumentDefinition'], [$argument, $argumentSetup['interface'] ?: null] ); }
[ "protected", "function", "defineArgumentProviders", "(", "$", "argumentSetup", ",", "$", "argument", ")", "{", "if", "(", "!", "array_key_exists", "(", "'mappings'", ",", "$", "argumentSetup", ")", ")", "{", "throw", "new", "InvalidMappingsException", "(", "spri...
Tell our Injector how to produce required arguments. @since 0.2.0 @param string $argumentSetup Argument providers setup from configuration file. @param string $argument The argument to provide. @throws InvalidMappingsException If a required config key could not be found.
[ "Tell", "our", "Injector", "how", "to", "produce", "required", "arguments", "." ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/Injector.php#L257-L274
train
brightnucleus/injector
src/Injector.php
Injector.addArgumentDefinition
protected function addArgumentDefinition($callable, $alias, $args) { list($argument, $interface) = $args; $value = is_callable($callable) ? $this->getArgumentProxy($alias, $interface, $callable) : $callable; $argumentDefinition = array_key_exists($alias, $this->argumentDefinitions) ? $this->argumentDefinitions[$alias] : []; if ($value instanceof Injection) { $argumentDefinition[$argument] = $value->getAlias(); } else { $argumentDefinition[":${argument}"] = $value; } $this->argumentDefinitions[$alias] = $argumentDefinition; $this->define($alias, $this->argumentDefinitions[$alias]); }
php
protected function addArgumentDefinition($callable, $alias, $args) { list($argument, $interface) = $args; $value = is_callable($callable) ? $this->getArgumentProxy($alias, $interface, $callable) : $callable; $argumentDefinition = array_key_exists($alias, $this->argumentDefinitions) ? $this->argumentDefinitions[$alias] : []; if ($value instanceof Injection) { $argumentDefinition[$argument] = $value->getAlias(); } else { $argumentDefinition[":${argument}"] = $value; } $this->argumentDefinitions[$alias] = $argumentDefinition; $this->define($alias, $this->argumentDefinitions[$alias]); }
[ "protected", "function", "addArgumentDefinition", "(", "$", "callable", ",", "$", "alias", ",", "$", "args", ")", "{", "list", "(", "$", "argument", ",", "$", "interface", ")", "=", "$", "args", ";", "$", "value", "=", "is_callable", "(", "$", "callabl...
Add a single argument definition. @since 0.2.0 @param callable $callable Callable to execute when the argument is needed. @param string $alias Alias to add the argument definition to. @param string $args Additional arguments used for definition. Array containing $argument & $interface. @throws InvalidMappingsException If $callable is not a callable.
[ "Add", "a", "single", "argument", "definition", "." ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/Injector.php#L287-L308
train
brightnucleus/injector
src/Injector.php
Injector.getArgumentProxy
protected function getArgumentProxy($alias, $interface, $callable) { if (null === $interface) { $interface = 'stdClass'; } $factory = new LazyLoadingValueHolderFactory(); $initializer = function ( & $wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, & $initializer ) use ( $alias, $interface, $callable ) { $initializer = null; $wrappedObject = $callable($alias, $interface); return true; }; return $factory->createProxy($interface, $initializer); }
php
protected function getArgumentProxy($alias, $interface, $callable) { if (null === $interface) { $interface = 'stdClass'; } $factory = new LazyLoadingValueHolderFactory(); $initializer = function ( & $wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, & $initializer ) use ( $alias, $interface, $callable ) { $initializer = null; $wrappedObject = $callable($alias, $interface); return true; }; return $factory->createProxy($interface, $initializer); }
[ "protected", "function", "getArgumentProxy", "(", "$", "alias", ",", "$", "interface", ",", "$", "callable", ")", "{", "if", "(", "null", "===", "$", "interface", ")", "{", "$", "interface", "=", "'stdClass'", ";", "}", "$", "factory", "=", "new", "Laz...
Get an argument proxy for a given alias to provide to the injector. @since 0.2.0 @param string $alias Alias that needs the argument. @param string $interface Interface that the proxy implements. @param callable $callable Callable used to initialize the proxy. @return object Argument proxy to provide to the inspector.
[ "Get", "an", "argument", "proxy", "for", "a", "given", "alias", "to", "provide", "to", "the", "injector", "." ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/Injector.php#L321-L346
train
brightnucleus/injector
src/Injector.php
Injector.alias
public function alias($original, $alias) { if (empty($original) || ! is_string($original)) { throw new ConfigException( InjectorException::M_NON_EMPTY_STRING_ALIAS, InjectorException::E_NON_EMPTY_STRING_ALIAS ); } if (empty($alias) || ! is_string($alias)) { throw new ConfigException( InjectorException::M_NON_EMPTY_STRING_ALIAS, InjectorException::E_NON_EMPTY_STRING_ALIAS ); } $originalNormalized = $this->normalizeName($original); if (isset($this->shares[$originalNormalized])) { throw new ConfigException( sprintf( InjectorException::M_SHARED_CANNOT_ALIAS, $this->normalizeName(get_class($this->shares[$originalNormalized])), $alias ), InjectorException::E_SHARED_CANNOT_ALIAS ); } if (array_key_exists($originalNormalized, $this->shares)) { $aliasNormalized = $this->normalizeName($alias); $this->shares[$aliasNormalized] = null; unset($this->shares[$originalNormalized]); } $this->aliases[$originalNormalized] = $alias; return $this; }
php
public function alias($original, $alias) { if (empty($original) || ! is_string($original)) { throw new ConfigException( InjectorException::M_NON_EMPTY_STRING_ALIAS, InjectorException::E_NON_EMPTY_STRING_ALIAS ); } if (empty($alias) || ! is_string($alias)) { throw new ConfigException( InjectorException::M_NON_EMPTY_STRING_ALIAS, InjectorException::E_NON_EMPTY_STRING_ALIAS ); } $originalNormalized = $this->normalizeName($original); if (isset($this->shares[$originalNormalized])) { throw new ConfigException( sprintf( InjectorException::M_SHARED_CANNOT_ALIAS, $this->normalizeName(get_class($this->shares[$originalNormalized])), $alias ), InjectorException::E_SHARED_CANNOT_ALIAS ); } if (array_key_exists($originalNormalized, $this->shares)) { $aliasNormalized = $this->normalizeName($alias); $this->shares[$aliasNormalized] = null; unset($this->shares[$originalNormalized]); } $this->aliases[$originalNormalized] = $alias; return $this; }
[ "public", "function", "alias", "(", "$", "original", ",", "$", "alias", ")", "{", "if", "(", "empty", "(", "$", "original", ")", "||", "!", "is_string", "(", "$", "original", ")", ")", "{", "throw", "new", "ConfigException", "(", "InjectorException", "...
Define an alias for all occurrences of a given typehint Use this method to specify implementation classes for interface and abstract class typehints. @param string $original The typehint to replace @param string $alias The implementation name @throws ConfigException if any argument is empty or not a string @return InjectorInterface
[ "Define", "an", "alias", "for", "all", "occurrences", "of", "a", "given", "typehint" ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/Injector.php#L393-L430
train
brightnucleus/injector
src/Injector.php
Injector.inspect
public function inspect($nameFilter = null, $typeFilter = null) { $result = []; $name = $nameFilter ? $this->normalizeName($nameFilter) : null; if (empty($typeFilter)) { $typeFilter = static::I_ALL; } $types = [ static::I_BINDINGS => 'classDefinitions', static::I_DELEGATES => 'delegates', static::I_PREPARES => 'prepares', static::I_ALIASES => 'aliases', static::I_SHARES => 'shares', ]; foreach ($types as $type => $source) { if ($typeFilter & $type) { $result[$type] = $this->filter($this->{$source}, $name); } } return $result; }
php
public function inspect($nameFilter = null, $typeFilter = null) { $result = []; $name = $nameFilter ? $this->normalizeName($nameFilter) : null; if (empty($typeFilter)) { $typeFilter = static::I_ALL; } $types = [ static::I_BINDINGS => 'classDefinitions', static::I_DELEGATES => 'delegates', static::I_PREPARES => 'prepares', static::I_ALIASES => 'aliases', static::I_SHARES => 'shares', ]; foreach ($types as $type => $source) { if ($typeFilter & $type) { $result[$type] = $this->filter($this->{$source}, $name); } } return $result; }
[ "public", "function", "inspect", "(", "$", "nameFilter", "=", "null", ",", "$", "typeFilter", "=", "null", ")", "{", "$", "result", "=", "[", "]", ";", "$", "name", "=", "$", "nameFilter", "?", "$", "this", "->", "normalizeName", "(", "$", "nameFilte...
Retrieve stored data for the specified definition type Exposes introspection of existing binds/delegates/shares/etc for decoration and composition. @param string $nameFilter An optional class name filter @param int $typeFilter A bitmask of Injector::* type constant flags @return array
[ "Retrieve", "stored", "data", "for", "the", "specified", "definition", "type" ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/Injector.php#L590-L614
train
russsiq/bixbite
app/Models/Theme.php
Theme.getTemplates
public static function getTemplates($path = null, $regex = null) { $dirs = []; $files = []; $path = $path ?? theme_path('views'); $regex = $regex ?? '/\.(tpl|ini|css|js|blade\.php)/'; if (! $path instanceof \DirectoryIterator) { $path = new \DirectoryIterator((string) $path); } foreach ($path as $node) { if ($node->isDir() and ! $node->isDot()) { if (count($tree = self::getTemplates($node->getPathname(), $regex))) { $dirs[$node->getFilename()] = $tree; } } elseif ($node->isFile()) { if (is_null($regex) or preg_match($regex, $name = $node->getFilename())) { $data_path = str_replace(theme_path('views'), '', $node->getPathname()); $files[$data_path] = $name; } } } // asort($dirs); sort($files); return array_merge($dirs, $files); }
php
public static function getTemplates($path = null, $regex = null) { $dirs = []; $files = []; $path = $path ?? theme_path('views'); $regex = $regex ?? '/\.(tpl|ini|css|js|blade\.php)/'; if (! $path instanceof \DirectoryIterator) { $path = new \DirectoryIterator((string) $path); } foreach ($path as $node) { if ($node->isDir() and ! $node->isDot()) { if (count($tree = self::getTemplates($node->getPathname(), $regex))) { $dirs[$node->getFilename()] = $tree; } } elseif ($node->isFile()) { if (is_null($regex) or preg_match($regex, $name = $node->getFilename())) { $data_path = str_replace(theme_path('views'), '', $node->getPathname()); $files[$data_path] = $name; } } } // asort($dirs); sort($files); return array_merge($dirs, $files); }
[ "public", "static", "function", "getTemplates", "(", "$", "path", "=", "null", ",", "$", "regex", "=", "null", ")", "{", "$", "dirs", "=", "[", "]", ";", "$", "files", "=", "[", "]", ";", "$", "path", "=", "$", "path", "??", "theme_path", "(", ...
Creates a tree-structured array of directories and files from a given root folder. Cleaned from: http://stackoverflow.com/questions/952263/deep-recursive-array-of-directory-structure-in-php @param string $path @param string $regex @param boolean $ignoreEmpty Do not add empty directories to the tree @return array
[ "Creates", "a", "tree", "-", "structured", "array", "of", "directories", "and", "files", "from", "a", "given", "root", "folder", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Theme.php#L17-L43
train
lsv/rejseplan-php-api
src/Services/DepartureBoard.php
DepartureBoard.generateUrlOptions
protected function generateUrlOptions(array $options): array { $urlOptions = []; if (isset($options['date'])) { $urlOptions['date'] = $options['date']->format('d.m.y'); $urlOptions['time'] = $options['date']->format('H:i'); unset($options['date']); } return array_merge($urlOptions, $options); }
php
protected function generateUrlOptions(array $options): array { $urlOptions = []; if (isset($options['date'])) { $urlOptions['date'] = $options['date']->format('d.m.y'); $urlOptions['time'] = $options['date']->format('H:i'); unset($options['date']); } return array_merge($urlOptions, $options); }
[ "protected", "function", "generateUrlOptions", "(", "array", "$", "options", ")", ":", "array", "{", "$", "urlOptions", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "options", "[", "'date'", "]", ")", ")", "{", "$", "urlOptions", "[", "'date'", ...
Generate url options. @param array $options @return array
[ "Generate", "url", "options", "." ]
f09add92e160f167a19ff2a290951d202d7ece67
https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/Services/DepartureBoard.php#L177-L187
train
dadajuice/zephyrus
src/Zephyrus/Security/CsrfGuard.php
CsrfGuard.generateHiddenFields
public function generateHiddenFields() { $name = $this->generateFormName(); $token = $this->generateToken($name); $html = '<input type="hidden" name="' . self::REQUEST_TOKEN_NAME . '" value="' . $name . '" />'; $html .= '<input type="hidden" name="' . self::REQUEST_TOKEN_VALUE . '" value="' . $token . '" />'; return $html; }
php
public function generateHiddenFields() { $name = $this->generateFormName(); $token = $this->generateToken($name); $html = '<input type="hidden" name="' . self::REQUEST_TOKEN_NAME . '" value="' . $name . '" />'; $html .= '<input type="hidden" name="' . self::REQUEST_TOKEN_VALUE . '" value="' . $token . '" />'; return $html; }
[ "public", "function", "generateHiddenFields", "(", ")", "{", "$", "name", "=", "$", "this", "->", "generateFormName", "(", ")", ";", "$", "token", "=", "$", "this", "->", "generateToken", "(", "$", "name", ")", ";", "$", "html", "=", "'<input type=\"hidd...
Returns the corresponding HTML hidden fields for the CSRF.
[ "Returns", "the", "corresponding", "HTML", "hidden", "fields", "for", "the", "CSRF", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/CsrfGuard.php#L74-L81
train
dadajuice/zephyrus
src/Zephyrus/Security/CsrfGuard.php
CsrfGuard.guard
public function guard() { if ($this->isHttpMethodFiltered($this->request->getMethod())) { $formName = $this->getProvidedFormName(); $providedToken = $this->getProvidedCsrfToken(); if (is_null($formName) || is_null($providedToken)) { throw new InvalidCsrfException(); } if (!$this->validateToken($formName, $providedToken)) { throw new InvalidCsrfException(); } } }
php
public function guard() { if ($this->isHttpMethodFiltered($this->request->getMethod())) { $formName = $this->getProvidedFormName(); $providedToken = $this->getProvidedCsrfToken(); if (is_null($formName) || is_null($providedToken)) { throw new InvalidCsrfException(); } if (!$this->validateToken($formName, $providedToken)) { throw new InvalidCsrfException(); } } }
[ "public", "function", "guard", "(", ")", "{", "if", "(", "$", "this", "->", "isHttpMethodFiltered", "(", "$", "this", "->", "request", "->", "getMethod", "(", ")", ")", ")", "{", "$", "formName", "=", "$", "this", "->", "getProvidedFormName", "(", ")",...
Proceeds to filter the current request for any CSRF mismatch. Forms must provide its unique name and corresponding generated csrf token. @throws InvalidCsrfException
[ "Proceeds", "to", "filter", "the", "current", "request", "for", "any", "CSRF", "mismatch", ".", "Forms", "must", "provide", "its", "unique", "name", "and", "corresponding", "generated", "csrf", "token", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/CsrfGuard.php#L89-L101
train
dadajuice/zephyrus
src/Zephyrus/Security/CsrfGuard.php
CsrfGuard.injectForms
public function injectForms($html) { preg_match_all("/<form(.*?)>(.*?)<\\/form>/is", $html, $matches, PREG_SET_ORDER); if (is_array($matches)) { foreach ($matches as $match) { if (strpos($match[1], "nocsrf") !== false) { continue; } $hiddenFields = self::generateHiddenFields(); $html = str_replace($match[0], "<form{$match[1]}>{$hiddenFields}{$match[2]}</form>", $html); } } return $html; }
php
public function injectForms($html) { preg_match_all("/<form(.*?)>(.*?)<\\/form>/is", $html, $matches, PREG_SET_ORDER); if (is_array($matches)) { foreach ($matches as $match) { if (strpos($match[1], "nocsrf") !== false) { continue; } $hiddenFields = self::generateHiddenFields(); $html = str_replace($match[0], "<form{$match[1]}>{$hiddenFields}{$match[2]}</form>", $html); } } return $html; }
[ "public", "function", "injectForms", "(", "$", "html", ")", "{", "preg_match_all", "(", "\"/<form(.*?)>(.*?)<\\\\/form>/is\"", ",", "$", "html", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "if", "(", "is_array", "(", "$", "matches", ")", ")", "{", ...
Automatically adds CSRF hidden fields to any forms present in the given HTML. This method is to be used with automatic injection behavior. @param string $html @return string
[ "Automatically", "adds", "CSRF", "hidden", "fields", "to", "any", "forms", "present", "in", "the", "given", "HTML", ".", "This", "method", "is", "to", "be", "used", "with", "automatic", "injection", "behavior", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/CsrfGuard.php#L110-L123
train
dadajuice/zephyrus
src/Zephyrus/Security/CsrfGuard.php
CsrfGuard.generateToken
private function generateToken(string $formName): string { $token = Cryptography::randomString(self::TOKEN_LENGTH); $csrfData = Session::getInstance()->read('__CSRF_TOKEN', []); $csrfData[$formName] = $token; Session::getInstance()->set('__CSRF_TOKEN', $csrfData); return $token; }
php
private function generateToken(string $formName): string { $token = Cryptography::randomString(self::TOKEN_LENGTH); $csrfData = Session::getInstance()->read('__CSRF_TOKEN', []); $csrfData[$formName] = $token; Session::getInstance()->set('__CSRF_TOKEN', $csrfData); return $token; }
[ "private", "function", "generateToken", "(", "string", "$", "formName", ")", ":", "string", "{", "$", "token", "=", "Cryptography", "::", "randomString", "(", "self", "::", "TOKEN_LENGTH", ")", ";", "$", "csrfData", "=", "Session", "::", "getInstance", "(", ...
Generates and stores in the current session a cryptographically random token that shall be validated with the filter method. @param string $formName @throws \Exception @return string
[ "Generates", "and", "stores", "in", "the", "current", "session", "a", "cryptographically", "random", "token", "that", "shall", "be", "validated", "with", "the", "filter", "method", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/CsrfGuard.php#L197-L204
train
dadajuice/zephyrus
src/Zephyrus/Security/CsrfGuard.php
CsrfGuard.validateToken
private function validateToken(string $formName, string $token): bool { $sortedCsrf = $this->getStoredCsrfToken($formName); if (!is_null($sortedCsrf)) { $csrfData = Session::getInstance()->read('__CSRF_TOKEN', []); if (is_null($this->request->getHeader('CSRF_KEEP_ALIVE')) && is_null($this->request->getParameter('CSRF_KEEP_ALIVE'))) { $csrfData[$formName] = ''; Session::getInstance()->set('__CSRF_TOKEN', $csrfData); } return hash_equals($sortedCsrf, $token); } return false; }
php
private function validateToken(string $formName, string $token): bool { $sortedCsrf = $this->getStoredCsrfToken($formName); if (!is_null($sortedCsrf)) { $csrfData = Session::getInstance()->read('__CSRF_TOKEN', []); if (is_null($this->request->getHeader('CSRF_KEEP_ALIVE')) && is_null($this->request->getParameter('CSRF_KEEP_ALIVE'))) { $csrfData[$formName] = ''; Session::getInstance()->set('__CSRF_TOKEN', $csrfData); } return hash_equals($sortedCsrf, $token); } return false; }
[ "private", "function", "validateToken", "(", "string", "$", "formName", ",", "string", "$", "token", ")", ":", "bool", "{", "$", "sortedCsrf", "=", "$", "this", "->", "getStoredCsrfToken", "(", "$", "formName", ")", ";", "if", "(", "!", "is_null", "(", ...
Validates the given token with the one stored for the specified form name. Once validated, good or not, the token is removed from the session. @param $formName @param $token @return bool
[ "Validates", "the", "given", "token", "with", "the", "one", "stored", "for", "the", "specified", "form", "name", ".", "Once", "validated", "good", "or", "not", "the", "token", "is", "removed", "from", "the", "session", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/CsrfGuard.php#L225-L238
train
dadajuice/zephyrus
src/Zephyrus/Security/CsrfGuard.php
CsrfGuard.getStoredCsrfToken
private function getStoredCsrfToken(string $formName): ?string { $csrfData = Session::getInstance()->read('__CSRF_TOKEN'); if (is_null($csrfData)) { return null; } return isset($csrfData[$formName]) ? $csrfData[$formName] : null; }
php
private function getStoredCsrfToken(string $formName): ?string { $csrfData = Session::getInstance()->read('__CSRF_TOKEN'); if (is_null($csrfData)) { return null; } return isset($csrfData[$formName]) ? $csrfData[$formName] : null; }
[ "private", "function", "getStoredCsrfToken", "(", "string", "$", "formName", ")", ":", "?", "string", "{", "$", "csrfData", "=", "Session", "::", "getInstance", "(", ")", "->", "read", "(", "'__CSRF_TOKEN'", ")", ";", "if", "(", "is_null", "(", "$", "csr...
Obtains the CSRF token stored by the server for the corresponding client. Returns null if undefined. @param string $formName @return null|string
[ "Obtains", "the", "CSRF", "token", "stored", "by", "the", "server", "for", "the", "corresponding", "client", ".", "Returns", "null", "if", "undefined", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/CsrfGuard.php#L247-L254
train
dadajuice/zephyrus
src/Zephyrus/Security/CsrfGuard.php
CsrfGuard.isHttpMethodFiltered
private function isHttpMethodFiltered($method): bool { $method = strtoupper($method); if ($this->getSecured && $method == "GET") { return true; } elseif ($this->postSecured && $method == "POST") { return true; } elseif ($this->putSecured && $method == "PUT") { return true; } elseif ($this->deleteSecured && $method == "DELETE") { return true; } return false; }
php
private function isHttpMethodFiltered($method): bool { $method = strtoupper($method); if ($this->getSecured && $method == "GET") { return true; } elseif ($this->postSecured && $method == "POST") { return true; } elseif ($this->putSecured && $method == "PUT") { return true; } elseif ($this->deleteSecured && $method == "DELETE") { return true; } return false; }
[ "private", "function", "isHttpMethodFiltered", "(", "$", "method", ")", ":", "bool", "{", "$", "method", "=", "strtoupper", "(", "$", "method", ")", ";", "if", "(", "$", "this", "->", "getSecured", "&&", "$", "method", "==", "\"GET\"", ")", "{", "retur...
Checks if the specified method should be filtered. @param string $method @return bool
[ "Checks", "if", "the", "specified", "method", "should", "be", "filtered", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/CsrfGuard.php#L293-L306
train
webeweb/core-bundle
Twig/Extension/UtilityTwigExtension.php
UtilityTwigExtension.calcAge
public function calcAge(DateTime $birthDate, DateTime $refDate = null) { return DateTimeRenderer::renderAge($birthDate, $refDate); }
php
public function calcAge(DateTime $birthDate, DateTime $refDate = null) { return DateTimeRenderer::renderAge($birthDate, $refDate); }
[ "public", "function", "calcAge", "(", "DateTime", "$", "birthDate", ",", "DateTime", "$", "refDate", "=", "null", ")", "{", "return", "DateTimeRenderer", "::", "renderAge", "(", "$", "birthDate", ",", "$", "refDate", ")", ";", "}" ]
Calculates an age. @param DateTime $birthDate The birth date. @param DateTime|null $refDate The reference date. @return int Returns teh age. @throws Exception Throws an exception if an error occurs.
[ "Calculates", "an", "age", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/UtilityTwigExtension.php#L43-L45
train
webeweb/core-bundle
Twig/Extension/UtilityTwigExtension.php
UtilityTwigExtension.formatString
public function formatString($string, $format) { $fmt = str_replace("_", "%s", $format); $str = str_split($string); return vsprintf($fmt, $str); }
php
public function formatString($string, $format) { $fmt = str_replace("_", "%s", $format); $str = str_split($string); return vsprintf($fmt, $str); }
[ "public", "function", "formatString", "(", "$", "string", ",", "$", "format", ")", "{", "$", "fmt", "=", "str_replace", "(", "\"_\"", ",", "\"%s\"", ",", "$", "format", ")", ";", "$", "str", "=", "str_split", "(", "$", "string", ")", ";", "return", ...
Format a string. @param string $string The string. @param string $format The format. @return string Returns the formatted string.
[ "Format", "a", "string", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/UtilityTwigExtension.php#L65-L71
train
laravelflare/flare
src/Flare/Admin/Modules/ModuleAdmin.php
ModuleAdmin.getView
public function getView() { if (view()->exists($this->view)) { return $this->view; } if (view()->exists('admin.'.$this->urlPrefix().'.index')) { return 'admin.'.$this->urlPrefix().'.index'; } if (view()->exists('admin.'.$this->urlPrefix())) { return 'admin.'.$this->urlPrefix(); } if (view()->exists('flare::'.$this->view)) { return 'flare::'.$this->view; } return parent::getView(); }
php
public function getView() { if (view()->exists($this->view)) { return $this->view; } if (view()->exists('admin.'.$this->urlPrefix().'.index')) { return 'admin.'.$this->urlPrefix().'.index'; } if (view()->exists('admin.'.$this->urlPrefix())) { return 'admin.'.$this->urlPrefix(); } if (view()->exists('flare::'.$this->view)) { return 'flare::'.$this->view; } return parent::getView(); }
[ "public", "function", "getView", "(", ")", "{", "if", "(", "view", "(", ")", "->", "exists", "(", "$", "this", "->", "view", ")", ")", "{", "return", "$", "this", "->", "view", ";", "}", "if", "(", "view", "(", ")", "->", "exists", "(", "'admin...
Returns the Module Admin View. Determines if a view exists by: Looking for $this->view Then looks for 'admin.modulename.index', Then looks for 'admin.modulename', Then defaults to @return string
[ "Returns", "the", "Module", "Admin", "View", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Modules/ModuleAdmin.php#L37-L56
train
GoIntegro/hateoas
JsonApi/EntityResource.php
EntityResource.getStringId
public static function getStringId(ResourceEntityInterface $entity = NULL) { return is_null($entity) ? NULL : (string) $entity->getId(); }
php
public static function getStringId(ResourceEntityInterface $entity = NULL) { return is_null($entity) ? NULL : (string) $entity->getId(); }
[ "public", "static", "function", "getStringId", "(", "ResourceEntityInterface", "$", "entity", "=", "NULL", ")", "{", "return", "is_null", "(", "$", "entity", ")", "?", "NULL", ":", "(", "string", ")", "$", "entity", "->", "getId", "(", ")", ";", "}" ]
Obtiene el Id de una entidad. @return string @todo Evitar hacer type-casting hasta la serialización.
[ "Obtiene", "el", "Id", "de", "una", "entidad", "." ]
4799794294079f8bd3839e76175134219f876105
https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/JsonApi/EntityResource.php#L110-L115
train
reliv/Rcm
core/src/Entity/ContainerAbstract.php
ContainerAbstract.newInstance
public function newInstance( string $createdByUserId, string $createdReason = Tracking::UNKNOWN_REASON ) { /** @var ContainerInterface|ContainerAbstract $new */ $new = parent::newInstance( $createdByUserId, $createdReason ); $new->lastPublished = new \DateTime(); $new->revisions = new ArrayCollection(); if (!empty($new->publishedRevision)) { $revision = $new->publishedRevision->newInstance( $createdByUserId, $createdReason ); $new->removePublishedRevision(); $new->revisions->add($revision); $new->setStagedRevision($revision); } elseif (!empty($new->stagedRevision)) { $revision = $new->stagedRevision->newInstance( $createdByUserId, $createdReason ); $new->setStagedRevision($revision); $new->revisions->add($revision); } return $new; }
php
public function newInstance( string $createdByUserId, string $createdReason = Tracking::UNKNOWN_REASON ) { /** @var ContainerInterface|ContainerAbstract $new */ $new = parent::newInstance( $createdByUserId, $createdReason ); $new->lastPublished = new \DateTime(); $new->revisions = new ArrayCollection(); if (!empty($new->publishedRevision)) { $revision = $new->publishedRevision->newInstance( $createdByUserId, $createdReason ); $new->removePublishedRevision(); $new->revisions->add($revision); $new->setStagedRevision($revision); } elseif (!empty($new->stagedRevision)) { $revision = $new->stagedRevision->newInstance( $createdByUserId, $createdReason ); $new->setStagedRevision($revision); $new->revisions->add($revision); } return $new; }
[ "public", "function", "newInstance", "(", "string", "$", "createdByUserId", ",", "string", "$", "createdReason", "=", "Tracking", "::", "UNKNOWN_REASON", ")", "{", "/** @var ContainerInterface|ContainerAbstract $new */", "$", "new", "=", "parent", "::", "newInstance", ...
Get a clone with special logic Any copy will be changed to staged @param string $createdByUserId @param string $createdReason @return ContainerInterface|ContainerAbstract
[ "Get", "a", "clone", "with", "special", "logic", "Any", "copy", "will", "be", "changed", "to", "staged" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/ContainerAbstract.php#L110-L142
train
reliv/Rcm
core/src/Entity/ContainerAbstract.php
ContainerAbstract.newInstanceIfHasRevision
public function newInstanceIfHasRevision( string $createdByUserId, string $createdReason = Tracking::UNKNOWN_REASON ) { /** @var ContainerInterface|ContainerAbstract $new */ $new = parent::newInstance( $createdByUserId, $createdReason ); $publishedRevision = $new->getPublishedRevision(); if (empty($publishedRevision)) { return null; } $new->lastPublished = new \DateTime(); $new->revisions = new ArrayCollection(); $new->stagedRevision = null; $new->stagedRevisionId = null; $new->setPublishedRevision( $publishedRevision->newInstance( $createdByUserId, $createdReason ) ); return $new; }
php
public function newInstanceIfHasRevision( string $createdByUserId, string $createdReason = Tracking::UNKNOWN_REASON ) { /** @var ContainerInterface|ContainerAbstract $new */ $new = parent::newInstance( $createdByUserId, $createdReason ); $publishedRevision = $new->getPublishedRevision(); if (empty($publishedRevision)) { return null; } $new->lastPublished = new \DateTime(); $new->revisions = new ArrayCollection(); $new->stagedRevision = null; $new->stagedRevisionId = null; $new->setPublishedRevision( $publishedRevision->newInstance( $createdByUserId, $createdReason ) ); return $new; }
[ "public", "function", "newInstanceIfHasRevision", "(", "string", "$", "createdByUserId", ",", "string", "$", "createdReason", "=", "Tracking", "::", "UNKNOWN_REASON", ")", "{", "/** @var ContainerInterface|ContainerAbstract $new */", "$", "new", "=", "parent", "::", "ne...
This is used mainly for site copies to eliminate pages that are not published @param string $createdByUserId @param string $createdReason @return null|ContainerAbstract|ContainerInterface
[ "This", "is", "used", "mainly", "for", "site", "copies", "to", "eliminate", "pages", "that", "are", "not", "published" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/ContainerAbstract.php#L152-L182
train
reliv/Rcm
core/src/Entity/ContainerAbstract.php
ContainerAbstract.setPublishedRevision
public function setPublishedRevision(Revision $revision) { if (!empty($this->stagedRevision)) { $this->removeStagedRevision(); } $revision->publishRevision(); $this->publishedRevision = $revision; $this->publishedRevisionId = $revision->getRevisionId(); $this->setLastPublished(new \DateTime()); }
php
public function setPublishedRevision(Revision $revision) { if (!empty($this->stagedRevision)) { $this->removeStagedRevision(); } $revision->publishRevision(); $this->publishedRevision = $revision; $this->publishedRevisionId = $revision->getRevisionId(); $this->setLastPublished(new \DateTime()); }
[ "public", "function", "setPublishedRevision", "(", "Revision", "$", "revision", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "stagedRevision", ")", ")", "{", "$", "this", "->", "removeStagedRevision", "(", ")", ";", "}", "$", "revision", "-...
Set the published published revision for the page @param Revision $revision Revision object to add @return void
[ "Set", "the", "published", "published", "revision", "for", "the", "page" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/ContainerAbstract.php#L336-L346
train
reliv/Rcm
core/src/Entity/ContainerAbstract.php
ContainerAbstract.setStagedRevision
public function setStagedRevision(Revision $revision) { if (!empty($this->publishedRevision) && $this->publishedRevision->getRevisionId() == $revision->getRevisionId() ) { $this->removePublishedRevision(); } $this->stagedRevision = $revision; $this->stagedRevisionId = $revision->getRevisionId(); }
php
public function setStagedRevision(Revision $revision) { if (!empty($this->publishedRevision) && $this->publishedRevision->getRevisionId() == $revision->getRevisionId() ) { $this->removePublishedRevision(); } $this->stagedRevision = $revision; $this->stagedRevisionId = $revision->getRevisionId(); }
[ "public", "function", "setStagedRevision", "(", "Revision", "$", "revision", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "publishedRevision", ")", "&&", "$", "this", "->", "publishedRevision", "->", "getRevisionId", "(", ")", "==", "$", "rev...
Sets the staged revision @param Revision $revision Revision object to add @return void
[ "Sets", "the", "staged", "revision" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/ContainerAbstract.php#L375-L385
train
reliv/Rcm
core/src/Entity/ContainerAbstract.php
ContainerAbstract.setSite
public function setSite(Site $site) { $this->site = $site; $this->siteId = $site->getSiteId(); }
php
public function setSite(Site $site) { $this->site = $site; $this->siteId = $site->getSiteId(); }
[ "public", "function", "setSite", "(", "Site", "$", "site", ")", "{", "$", "this", "->", "site", "=", "$", "site", ";", "$", "this", "->", "siteId", "=", "$", "site", "->", "getSiteId", "(", ")", ";", "}" ]
Set site the page belongs to @param Site $site Site object to add @return void
[ "Set", "site", "the", "page", "belongs", "to" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/ContainerAbstract.php#L434-L438
train
reliv/Rcm
core/src/Entity/ContainerAbstract.php
ContainerAbstract.setRevisions
public function setRevisions(array $revisions) { $this->revisions = new ArrayCollection(); /** @var \Rcm\Entity\Revision $revision */ foreach ($revisions as $revision) { if (!$revision instanceof Revision) { throw new InvalidArgumentException( "Invalid Revision passed in. Unable to set array" ); } $this->revisions->set($revision->getRevisionId(), $revision); } }
php
public function setRevisions(array $revisions) { $this->revisions = new ArrayCollection(); /** @var \Rcm\Entity\Revision $revision */ foreach ($revisions as $revision) { if (!$revision instanceof Revision) { throw new InvalidArgumentException( "Invalid Revision passed in. Unable to set array" ); } $this->revisions->set($revision->getRevisionId(), $revision); } }
[ "public", "function", "setRevisions", "(", "array", "$", "revisions", ")", "{", "$", "this", "->", "revisions", "=", "new", "ArrayCollection", "(", ")", ";", "/** @var \\Rcm\\Entity\\Revision $revision */", "foreach", "(", "$", "revisions", "as", "$", "revision", ...
Overwrite revisions and Set a group of revisions @param array $revisions Array of Revisions to be added @throws InvalidArgumentException
[ "Overwrite", "revisions", "and", "Set", "a", "group", "of", "revisions" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/ContainerAbstract.php#L479-L493
train
reliv/Rcm
core/src/Entity/ContainerAbstract.php
ContainerAbstract.getLastSavedDraftRevision
public function getLastSavedDraftRevision() { if (!empty($this->lastSavedDraft)) { return $this->lastSavedDraft; } $published = $this->publishedRevision; $staged = $this->stagedRevision; $arrayCollection = $this->revisions->toArray(); /** @var \Rcm\Entity\Revision $revision */ $revision = end($arrayCollection); if (empty($revision)) { return null; } $found = false; while (!$found) { if (empty($revision)) { break; } elseif (!empty($published) && $published->getRevisionId() == $revision->getRevisionId() ) { $found = false; } elseif (!empty($staged) && $staged->getRevisionId() == $revision->getRevisionId() ) { $found = false; } elseif ($revision->wasPublished()) { $found = false; } else { $found = true; } if (!$found) { $revision = prev($arrayCollection); } } return $this->lastSavedDraft = $revision; }
php
public function getLastSavedDraftRevision() { if (!empty($this->lastSavedDraft)) { return $this->lastSavedDraft; } $published = $this->publishedRevision; $staged = $this->stagedRevision; $arrayCollection = $this->revisions->toArray(); /** @var \Rcm\Entity\Revision $revision */ $revision = end($arrayCollection); if (empty($revision)) { return null; } $found = false; while (!$found) { if (empty($revision)) { break; } elseif (!empty($published) && $published->getRevisionId() == $revision->getRevisionId() ) { $found = false; } elseif (!empty($staged) && $staged->getRevisionId() == $revision->getRevisionId() ) { $found = false; } elseif ($revision->wasPublished()) { $found = false; } else { $found = true; } if (!$found) { $revision = prev($arrayCollection); } } return $this->lastSavedDraft = $revision; }
[ "public", "function", "getLastSavedDraftRevision", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "lastSavedDraft", ")", ")", "{", "return", "$", "this", "->", "lastSavedDraft", ";", "}", "$", "published", "=", "$", "this", "->", "publis...
Return the last draft saved. @return Revision
[ "Return", "the", "last", "draft", "saved", "." ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/ContainerAbstract.php#L500-L543
train
reliv/Rcm
core/src/Entity/ContainerAbstract.php
ContainerAbstract.getRevisionById
public function getRevisionById($revisionId) { $revision = $this->revisions->get($revisionId); if ($revision !== null) { return $revision; //We get here when rendering an unpublished page version } foreach ($this->revisions as $revision) { if ($revision->getRevisionId() === $revisionId) { return $revision; //We get here when publishing a new page version } } return null; }
php
public function getRevisionById($revisionId) { $revision = $this->revisions->get($revisionId); if ($revision !== null) { return $revision; //We get here when rendering an unpublished page version } foreach ($this->revisions as $revision) { if ($revision->getRevisionId() === $revisionId) { return $revision; //We get here when publishing a new page version } } return null; }
[ "public", "function", "getRevisionById", "(", "$", "revisionId", ")", "{", "$", "revision", "=", "$", "this", "->", "revisions", "->", "get", "(", "$", "revisionId", ")", ";", "if", "(", "$", "revision", "!==", "null", ")", "{", "return", "$", "revisio...
Get a page revision by ID @param int $revisionId @return null|Revision
[ "Get", "a", "page", "revision", "by", "ID" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/ContainerAbstract.php#L552-L567
train
dadajuice/zephyrus
src/Zephyrus/Security/IntrusionDetection.php
IntrusionDetection.run
public function run() { $guard = $this->getMonitoringInputs(); if (empty($guard)) { throw new \RuntimeException("Nothing to monitor ! Either configure the IDS to monitor at least one input or completely deactivate this feature."); } $this->manager->run($guard); if ($this->manager->getImpact() > 0) { $data = $this->getDetectionData($this->manager->getReports()); throw new IntrusionDetectionException($data); } }
php
public function run() { $guard = $this->getMonitoringInputs(); if (empty($guard)) { throw new \RuntimeException("Nothing to monitor ! Either configure the IDS to monitor at least one input or completely deactivate this feature."); } $this->manager->run($guard); if ($this->manager->getImpact() > 0) { $data = $this->getDetectionData($this->manager->getReports()); throw new IntrusionDetectionException($data); } }
[ "public", "function", "run", "(", ")", "{", "$", "guard", "=", "$", "this", "->", "getMonitoringInputs", "(", ")", ";", "if", "(", "empty", "(", "$", "guard", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Nothing to monitor ! Either conf...
Execute the intrusion detection analysis using the specified monitored inputs. If an intrusion is detected, the method will launch the detection callback. @throws IntrusionDetectionException
[ "Execute", "the", "intrusion", "detection", "analysis", "using", "the", "specified", "monitored", "inputs", ".", "If", "an", "intrusion", "is", "detected", "the", "method", "will", "launch", "the", "detection", "callback", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/IntrusionDetection.php#L46-L59
train
dadajuice/zephyrus
src/Zephyrus/Security/IntrusionDetection.php
IntrusionDetection.getMonitoringInputs
private function getMonitoringInputs(): array { $guard = []; if ($this->surveillance & self::REQUEST) { $guard['REQUEST'] = $_REQUEST; } if ($this->surveillance & self::GET) { $guard['GET'] = $_GET; } if ($this->surveillance & self::POST) { $guard['POST'] = $_POST; } if ($this->surveillance & self::COOKIE) { $guard['COOKIE'] = $_COOKIE; } return $guard; }
php
private function getMonitoringInputs(): array { $guard = []; if ($this->surveillance & self::REQUEST) { $guard['REQUEST'] = $_REQUEST; } if ($this->surveillance & self::GET) { $guard['GET'] = $_GET; } if ($this->surveillance & self::POST) { $guard['POST'] = $_POST; } if ($this->surveillance & self::COOKIE) { $guard['COOKIE'] = $_COOKIE; } return $guard; }
[ "private", "function", "getMonitoringInputs", "(", ")", ":", "array", "{", "$", "guard", "=", "[", "]", ";", "if", "(", "$", "this", "->", "surveillance", "&", "self", "::", "REQUEST", ")", "{", "$", "guard", "[", "'REQUEST'", "]", "=", "$", "_REQUES...
Retrieves the monitoring inputs to consider depending on the current configuration. @return mixed[]
[ "Retrieves", "the", "monitoring", "inputs", "to", "consider", "depending", "on", "the", "current", "configuration", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/IntrusionDetection.php#L111-L127
train
dadajuice/zephyrus
src/Zephyrus/Security/IntrusionDetection.php
IntrusionDetection.getDetectionData
private function getDetectionData($reports): array { $data = [ 'impact' => 0, 'detections' => [] ]; foreach ($reports as $report) { $variableName = $report->getVarName(); $filters = $report->getFilterMatch(); if (!isset($data['detections'][$variableName])) { $data['detections'][$variableName] = [ 'value' => $report->getVarValue(), 'events' => [] ]; } foreach ($filters as $filter) { $data['detections'][$variableName]['events'][] = [ 'description' => $filter->getDescription(), 'impact' => $filter->getImpact() ]; $data['impact'] += $filter->getImpact(); } } return $data; }
php
private function getDetectionData($reports): array { $data = [ 'impact' => 0, 'detections' => [] ]; foreach ($reports as $report) { $variableName = $report->getVarName(); $filters = $report->getFilterMatch(); if (!isset($data['detections'][$variableName])) { $data['detections'][$variableName] = [ 'value' => $report->getVarValue(), 'events' => [] ]; } foreach ($filters as $filter) { $data['detections'][$variableName]['events'][] = [ 'description' => $filter->getDescription(), 'impact' => $filter->getImpact() ]; $data['impact'] += $filter->getImpact(); } } return $data; }
[ "private", "function", "getDetectionData", "(", "$", "reports", ")", ":", "array", "{", "$", "data", "=", "[", "'impact'", "=>", "0", ",", "'detections'", "=>", "[", "]", "]", ";", "foreach", "(", "$", "reports", "as", "$", "report", ")", "{", "$", ...
Constructs a custom basic associative array based on the PHPIDS report when an intrusion is detected. Will contains essential data such as impact, targeted inputs and detection descriptions. @param Report[] $reports @return mixed[]
[ "Constructs", "a", "custom", "basic", "associative", "array", "based", "on", "the", "PHPIDS", "report", "when", "an", "intrusion", "is", "detected", ".", "Will", "contains", "essential", "data", "such", "as", "impact", "targeted", "inputs", "and", "detection", ...
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/IntrusionDetection.php#L137-L161
train
dadajuice/zephyrus
src/Zephyrus/Security/Session/SessionDecoy.php
SessionDecoy.throwDecoys
public function throwDecoys() { $params = session_get_cookie_params(); $len = strlen(session_id()); foreach ($this->decoys as $decoy) { $value = Cryptography::randomString($len); setcookie( $decoy, $value, $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly'] ); $_COOKIE[$decoy] = $value; } }
php
public function throwDecoys() { $params = session_get_cookie_params(); $len = strlen(session_id()); foreach ($this->decoys as $decoy) { $value = Cryptography::randomString($len); setcookie( $decoy, $value, $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly'] ); $_COOKIE[$decoy] = $value; } }
[ "public", "function", "throwDecoys", "(", ")", "{", "$", "params", "=", "session_get_cookie_params", "(", ")", ";", "$", "len", "=", "strlen", "(", "session_id", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "decoys", "as", "$", "decoy", ")", ...
Throw decoy cookies at session start which are configured exactly as the session cookie. This doesn't contribute in pure security measures, but contribute in hiding server footprints and add a little more confusion to the overall communication.
[ "Throw", "decoy", "cookies", "at", "session", "start", "which", "are", "configured", "exactly", "as", "the", "session", "cookie", ".", "This", "doesn", "t", "contribute", "in", "pure", "security", "measures", "but", "contribute", "in", "hiding", "server", "foo...
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/Session/SessionDecoy.php#L29-L46
train
dadajuice/zephyrus
src/Zephyrus/Security/Session/SessionDecoy.php
SessionDecoy.addRandomDecoys
public function addRandomDecoys($count) { for ($i = 0; $i < $count; ++$i) { $this->addDecoy(Cryptography::randomString(20)); } }
php
public function addRandomDecoys($count) { for ($i = 0; $i < $count; ++$i) { $this->addDecoy(Cryptography::randomString(20)); } }
[ "public", "function", "addRandomDecoys", "(", "$", "count", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "++", "$", "i", ")", "{", "$", "this", "->", "addDecoy", "(", "Cryptography", "::", "randomString", "(", ...
Add a certain amount of random decoy cookies that will be sent along the session cookie. This doesn't contribute in pure security measures, but contribute in hiding server footprints and add a little more confusion to the overall communication. @param int $count
[ "Add", "a", "certain", "amount", "of", "random", "decoy", "cookies", "that", "will", "be", "sent", "along", "the", "session", "cookie", ".", "This", "doesn", "t", "contribute", "in", "pure", "security", "measures", "but", "contribute", "in", "hiding", "serve...
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/Session/SessionDecoy.php#L69-L74
train
dadajuice/zephyrus
src/Zephyrus/Security/Session/SessionDecoy.php
SessionDecoy.destroyDecoys
public function destroyDecoys() { foreach ($this->decoys as $decoy) { setcookie($decoy, '', 1); setcookie($decoy, false); unset($_COOKIE[$decoy]); } }
php
public function destroyDecoys() { foreach ($this->decoys as $decoy) { setcookie($decoy, '', 1); setcookie($decoy, false); unset($_COOKIE[$decoy]); } }
[ "public", "function", "destroyDecoys", "(", ")", "{", "foreach", "(", "$", "this", "->", "decoys", "as", "$", "decoy", ")", "{", "setcookie", "(", "$", "decoy", ",", "''", ",", "1", ")", ";", "setcookie", "(", "$", "decoy", ",", "false", ")", ";", ...
Carefully expires all decoy cookies. Should be called only if decoys are set and on session destroy. @see destroy()
[ "Carefully", "expires", "all", "decoy", "cookies", ".", "Should", "be", "called", "only", "if", "decoys", "are", "set", "and", "on", "session", "destroy", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/Session/SessionDecoy.php#L82-L89
train
RogerWaters/react-thread-pool
src/ErrorHandling/DefaultErrorHandler.php
DefaultErrorHandler.OnUncaughtErrorTriggered
public function OnUncaughtErrorTriggered($errSeverity, $errMessage, $errFile, $errLine, array $errContext) { //@call if (0 === error_reporting()) { return false; } throw new PHPTriggerErrorException($errMessage, $errLine, $errFile, $errSeverity); }
php
public function OnUncaughtErrorTriggered($errSeverity, $errMessage, $errFile, $errLine, array $errContext) { //@call if (0 === error_reporting()) { return false; } throw new PHPTriggerErrorException($errMessage, $errLine, $errFile, $errSeverity); }
[ "public", "function", "OnUncaughtErrorTriggered", "(", "$", "errSeverity", ",", "$", "errMessage", ",", "$", "errFile", ",", "$", "errLine", ",", "array", "$", "errContext", ")", "{", "//@call\r", "if", "(", "0", "===", "error_reporting", "(", ")", ")", "{...
Default error handler callback for @see set_error_handler @param int $errSeverity @param string $errMessage @param string $errFile @param int $errLine @param array $errContext @return bool @throws PHPTriggerErrorException
[ "Default", "error", "handler", "callback", "for" ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ErrorHandling/DefaultErrorHandler.php#L23-L30
train
RogerWaters/react-thread-pool
src/ErrorHandling/DefaultErrorHandler.php
DefaultErrorHandler.OnErrorMessageReachParent
public function OnErrorMessageReachParent($result) { if ($result instanceof SerializableException) { if ($result instanceof SerializableFatalException) { //Fatal exception should be handled separate //This should be tracked on parent throw new ThreadFatalException($result->getMessage() . PHP_EOL . PHP_EOL . $result->getTraceAsString(), $result->getCode()); } //best is to log all the exception information here //you can also inject the variables into normal exception using reflection throw new \Exception($result->getMessage() . PHP_EOL . PHP_EOL . $result->getTraceAsString(), $result->getCode()); } //if it is an error object created from another handler just return it. //this only applies to usage of distinct ErrorHandlers return $result; }
php
public function OnErrorMessageReachParent($result) { if ($result instanceof SerializableException) { if ($result instanceof SerializableFatalException) { //Fatal exception should be handled separate //This should be tracked on parent throw new ThreadFatalException($result->getMessage() . PHP_EOL . PHP_EOL . $result->getTraceAsString(), $result->getCode()); } //best is to log all the exception information here //you can also inject the variables into normal exception using reflection throw new \Exception($result->getMessage() . PHP_EOL . PHP_EOL . $result->getTraceAsString(), $result->getCode()); } //if it is an error object created from another handler just return it. //this only applies to usage of distinct ErrorHandlers return $result; }
[ "public", "function", "OnErrorMessageReachParent", "(", "$", "result", ")", "{", "if", "(", "$", "result", "instanceof", "SerializableException", ")", "{", "if", "(", "$", "result", "instanceof", "SerializableFatalException", ")", "{", "//Fatal exception should be han...
The result from @see IThreadErrorHandler::OnUncaughtException is given as Parameter in the parent thread You can decide how to handle this If you like you could throw an \Exeption to the caller or you can just return a value indicating that function is failed. You can also trigger error here if you like to @param mixed $result @throws \Exception @return mixed
[ "The", "result", "from" ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ErrorHandling/DefaultErrorHandler.php#L54-L69
train
laravelflare/flare
src/Flare/Admin/Admin.php
Admin.registerRoutes
public function registerRoutes(Router $router) { // We will need to throw an exception if a ModelAdmin manages a Model which conflicts with an internal flare endpoint // such as (create, edit, view, delete etc) $router->group(['prefix' => $this->urlPrefix(), 'namespace' => get_called_class(), 'as' => $this->urlPrefix()], function ($router) { $this->registerSubRoutes(); $this->registerController($this->getController()); }); }
php
public function registerRoutes(Router $router) { // We will need to throw an exception if a ModelAdmin manages a Model which conflicts with an internal flare endpoint // such as (create, edit, view, delete etc) $router->group(['prefix' => $this->urlPrefix(), 'namespace' => get_called_class(), 'as' => $this->urlPrefix()], function ($router) { $this->registerSubRoutes(); $this->registerController($this->getController()); }); }
[ "public", "function", "registerRoutes", "(", "Router", "$", "router", ")", "{", "// We will need to throw an exception if a ModelAdmin manages a Model which conflicts with an internal flare endpoint", "// such as (create, edit, view, delete etc) ", "$", "router", "->", "group", "(", ...
Register the routes for this Admin Section. Default routes include, create:, read:, update:, delete: Also attempts to load in ModelAdminController based on the shortName of the class, for overloading and adding additional routes @param \Illuminate\Routing\Router $router
[ "Register", "the", "routes", "for", "this", "Admin", "Section", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Admin.php#L109-L117
train
laravelflare/flare
src/Flare/Admin/Admin.php
Admin.registerSubRoutes
public function registerSubRoutes() { if (!is_array($this->subAdmin)) { return; } foreach ($this->subAdmin as $adminItem) { $this->registerRoute($adminItem->getController(), $adminItem->routeParameters()); } }
php
public function registerSubRoutes() { if (!is_array($this->subAdmin)) { return; } foreach ($this->subAdmin as $adminItem) { $this->registerRoute($adminItem->getController(), $adminItem->routeParameters()); } }
[ "public", "function", "registerSubRoutes", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "subAdmin", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "subAdmin", "as", "$", "adminItem", ")", "{", "$", "this",...
Register subRoutes for Defined Admin instances. @return
[ "Register", "subRoutes", "for", "Defined", "Admin", "instances", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Admin.php#L124-L133
train
laravelflare/flare
src/Flare/Admin/Admin.php
Admin.registerRoute
public static function registerRoute($controller, $parameters = []) { \Route::group($parameters, function ($controller) { \Route::registerController($controller); }); }
php
public static function registerRoute($controller, $parameters = []) { \Route::group($parameters, function ($controller) { \Route::registerController($controller); }); }
[ "public", "static", "function", "registerRoute", "(", "$", "controller", ",", "$", "parameters", "=", "[", "]", ")", "{", "\\", "Route", "::", "group", "(", "$", "parameters", ",", "function", "(", "$", "controller", ")", "{", "\\", "Route", "::", "reg...
Register an individual route. @param string $controller @param array $parameters @return
[ "Register", "an", "individual", "route", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Admin.php#L143-L148
train
laravelflare/flare
src/Flare/Admin/Admin.php
Admin.getRequested
public static function getRequested($key = 'namespace') { if (!\Route::current()) { return; } $currentAction = \Route::current()->getAction(); if (isset($currentAction[$key])) { return $currentAction[$key]; } return; }
php
public static function getRequested($key = 'namespace') { if (!\Route::current()) { return; } $currentAction = \Route::current()->getAction(); if (isset($currentAction[$key])) { return $currentAction[$key]; } return; }
[ "public", "static", "function", "getRequested", "(", "$", "key", "=", "'namespace'", ")", "{", "if", "(", "!", "\\", "Route", "::", "current", "(", ")", ")", "{", "return", ";", "}", "$", "currentAction", "=", "\\", "Route", "::", "current", "(", ")"...
Returns the Requested Route Action as a string, namespace is returned by default. @param string $key @return string|void
[ "Returns", "the", "Requested", "Route", "Action", "as", "a", "string", "namespace", "is", "returned", "by", "default", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Admin.php#L198-L211
train
laravelflare/flare
src/Flare/Admin/Admin.php
Admin.getTitle
public function getTitle() { if (!isset($this->title) || !$this->title) { return Str::title(str_replace('_', ' ', snake_case(preg_replace('/'.static::CLASS_SUFFIX.'$/', '', static::shortName())))); } return $this->title; }
php
public function getTitle() { if (!isset($this->title) || !$this->title) { return Str::title(str_replace('_', ' ', snake_case(preg_replace('/'.static::CLASS_SUFFIX.'$/', '', static::shortName())))); } return $this->title; }
[ "public", "function", "getTitle", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "title", ")", "||", "!", "$", "this", "->", "title", ")", "{", "return", "Str", "::", "title", "(", "str_replace", "(", "'_'", ",", "' '", ",", "sna...
Title of a Admin Section Class. @return string
[ "Title", "of", "a", "Admin", "Section", "Class", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Admin.php#L332-L339
train
laravelflare/flare
src/Flare/Admin/Admin.php
Admin.getPluralTitle
public function getPluralTitle() { if (!isset($this->pluralTitle) || !$this->pluralTitle) { return Str::plural($this->getTitle()); } return $this->pluralTitle; }
php
public function getPluralTitle() { if (!isset($this->pluralTitle) || !$this->pluralTitle) { return Str::plural($this->getTitle()); } return $this->pluralTitle; }
[ "public", "function", "getPluralTitle", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "pluralTitle", ")", "||", "!", "$", "this", "->", "pluralTitle", ")", "{", "return", "Str", "::", "plural", "(", "$", "this", "->", "getTitle", "(...
Plural of the Admin Section Class Title. @return string
[ "Plural", "of", "the", "Admin", "Section", "Class", "Title", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Admin.php#L356-L363
train
laravelflare/flare
src/Flare/Admin/Admin.php
Admin.urlPrefix
public function urlPrefix() { if (!isset($this->urlPrefix) || !$this->urlPrefix) { return str_slug($this->getPluralTitle()); } return $this->urlPrefix; }
php
public function urlPrefix() { if (!isset($this->urlPrefix) || !$this->urlPrefix) { return str_slug($this->getPluralTitle()); } return $this->urlPrefix; }
[ "public", "function", "urlPrefix", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "urlPrefix", ")", "||", "!", "$", "this", "->", "urlPrefix", ")", "{", "return", "str_slug", "(", "$", "this", "->", "getPluralTitle", "(", ")", ")", ...
URL Prefix to a Admin Section Top Level Page. @return string
[ "URL", "Prefix", "to", "a", "Admin", "Section", "Top", "Level", "Page", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Admin.php#L380-L387
train
GoIntegro/hateoas
Http/Url.php
Url.fromString
public static function fromString($url, Url $root = null) { $instance = new static(); $components = static::parseUrl($url); foreach ($components as $component => $value) { $method = 'set' . Inflector::camelize($component); call_user_func(array($instance, $method), $value); } $instance->setOriginal($url); $instance->setRoot($root); return $instance; }
php
public static function fromString($url, Url $root = null) { $instance = new static(); $components = static::parseUrl($url); foreach ($components as $component => $value) { $method = 'set' . Inflector::camelize($component); call_user_func(array($instance, $method), $value); } $instance->setOriginal($url); $instance->setRoot($root); return $instance; }
[ "public", "static", "function", "fromString", "(", "$", "url", ",", "Url", "$", "root", "=", "null", ")", "{", "$", "instance", "=", "new", "static", "(", ")", ";", "$", "components", "=", "static", "::", "parseUrl", "(", "$", "url", ")", ";", "for...
Construye una instancia a partir de un objeto con una interfaz similar. @param string $url @param Url $root NULL por defecto.
[ "Construye", "una", "instancia", "a", "partir", "de", "un", "objeto", "con", "una", "interfaz", "similar", "." ]
4799794294079f8bd3839e76175134219f876105
https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/Http/Url.php#L37-L49
train
GoIntegro/hateoas
Http/Url.php
Url.toArray
public function toArray() { return array( 'scheme' => $this->scheme, 'host' => $this->host, 'port' => $this->port, 'user' => $this->user, 'pass' => $this->pass, 'path' => $this->path, 'query' => $this->query, 'fragment' => $this->fragment ); }
php
public function toArray() { return array( 'scheme' => $this->scheme, 'host' => $this->host, 'port' => $this->port, 'user' => $this->user, 'pass' => $this->pass, 'path' => $this->path, 'query' => $this->query, 'fragment' => $this->fragment ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'scheme'", "=>", "$", "this", "->", "scheme", ",", "'host'", "=>", "$", "this", "->", "host", ",", "'port'", "=>", "$", "this", "->", "port", ",", "'user'", "=>", "$", "this", ...
Convierte la instancia en un array.
[ "Convierte", "la", "instancia", "en", "un", "array", "." ]
4799794294079f8bd3839e76175134219f876105
https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/Http/Url.php#L86-L98
train
GoIntegro/hateoas
Http/Url.php
Url.toAbsoluteUrl
public function toAbsoluteUrl(Url $root = null) { $root = $this->getRoot() ?: $root; if (!$root->isUrlAbsolute()) { throw new \InvalidArgumentException(); } if (!$this->isUrlAbsolute()) { $this->setScheme($root->getScheme()); $this->setHost($root->getHost()); if (!$this->isPathAbsolute()) { $path = $root->getPath(); $path = substr($path, 0, strrpos($path, '/') + 1); $this->setPath($path . $this->getPath()); } } return $this; }
php
public function toAbsoluteUrl(Url $root = null) { $root = $this->getRoot() ?: $root; if (!$root->isUrlAbsolute()) { throw new \InvalidArgumentException(); } if (!$this->isUrlAbsolute()) { $this->setScheme($root->getScheme()); $this->setHost($root->getHost()); if (!$this->isPathAbsolute()) { $path = $root->getPath(); $path = substr($path, 0, strrpos($path, '/') + 1); $this->setPath($path . $this->getPath()); } } return $this; }
[ "public", "function", "toAbsoluteUrl", "(", "Url", "$", "root", "=", "null", ")", "{", "$", "root", "=", "$", "this", "->", "getRoot", "(", ")", "?", ":", "$", "root", ";", "if", "(", "!", "$", "root", "->", "isUrlAbsolute", "(", ")", ")", "{", ...
Obtiene la URL absoluta de un path. @param Url $root @param Url $url @return string La URL absoluta.
[ "Obtiene", "la", "URL", "absoluta", "de", "un", "path", "." ]
4799794294079f8bd3839e76175134219f876105
https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/Http/Url.php#L120-L136
train
reliv/Rcm
core/src/Service/Logger.php
Logger.sendMessageToBrowser
public function sendMessageToBrowser($message) { if (!$this->outputStarted) { ob_start(); echo '<!DOCTYPE html><html lang="en"><head></head><body>'; $this->outputStarted = true; } echo strip_tags($message, '<h1><p><br><hr>'); echo '<br />'; echo str_repeat(" ", 6024), "\n"; ob_flush(); flush(); }
php
public function sendMessageToBrowser($message) { if (!$this->outputStarted) { ob_start(); echo '<!DOCTYPE html><html lang="en"><head></head><body>'; $this->outputStarted = true; } echo strip_tags($message, '<h1><p><br><hr>'); echo '<br />'; echo str_repeat(" ", 6024), "\n"; ob_flush(); flush(); }
[ "public", "function", "sendMessageToBrowser", "(", "$", "message", ")", "{", "if", "(", "!", "$", "this", "->", "outputStarted", ")", "{", "ob_start", "(", ")", ";", "echo", "'<!DOCTYPE html><html lang=\"en\"><head></head><body>'", ";", "$", "this", "->", "outpu...
Send message to browser @param string $message Message to be sent @codeCoverageIgnore
[ "Send", "message", "to", "browser" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/Logger.php#L79-L92
train
traderinteractive/util-php
src/Util.php
Util.getExceptionInfo
public static function getExceptionInfo(Throwable $t) : array { return [ 'type' => get_class($t), 'message' => $t->getMessage(), 'code' => $t->getCode(), 'file' => $t->getFile(), 'line' => $t->getLine(), 'trace' => $t->getTraceAsString(), ]; }
php
public static function getExceptionInfo(Throwable $t) : array { return [ 'type' => get_class($t), 'message' => $t->getMessage(), 'code' => $t->getCode(), 'file' => $t->getFile(), 'line' => $t->getLine(), 'trace' => $t->getTraceAsString(), ]; }
[ "public", "static", "function", "getExceptionInfo", "(", "Throwable", "$", "t", ")", ":", "array", "{", "return", "[", "'type'", "=>", "get_class", "(", "$", "t", ")", ",", "'message'", "=>", "$", "t", "->", "getMessage", "(", ")", ",", "'code'", "=>",...
Returns exception info in array. @param Throwable $t the exception to return info on @return array like: <pre> [ 'type' => 'Exception', 'message' => 'a message', 'code' => 0, 'file' => '/somePath', 'line' => 434, 'trace' => 'a stack trace', ] </pre>
[ "Returns", "exception", "info", "in", "array", "." ]
c463161db7e77c7e72f2553dc4d436e6cb6caa2a
https://github.com/traderinteractive/util-php/blob/c463161db7e77c7e72f2553dc4d436e6cb6caa2a/src/Util.php#L36-L46
train
traderinteractive/util-php
src/Util.php
Util.throwIfNotType
public static function throwIfNotType( array $typesToVariables, bool $failOnWhitespace = false, bool $allowNulls = false ) { foreach ($typesToVariables as $type => $variablesOrVariable) { self::handleTypesToVariables($failOnWhitespace, $allowNulls, $variablesOrVariable, $type); } }
php
public static function throwIfNotType( array $typesToVariables, bool $failOnWhitespace = false, bool $allowNulls = false ) { foreach ($typesToVariables as $type => $variablesOrVariable) { self::handleTypesToVariables($failOnWhitespace, $allowNulls, $variablesOrVariable, $type); } }
[ "public", "static", "function", "throwIfNotType", "(", "array", "$", "typesToVariables", ",", "bool", "$", "failOnWhitespace", "=", "false", ",", "bool", "$", "allowNulls", "=", "false", ")", "{", "foreach", "(", "$", "typesToVariables", "as", "$", "type", "...
Throws an exception if specified variables are not of given types. @param array $typesToVariables like ['string' => [$var1, $var2], 'int' => [$var1, $var2]] or ['string' => $var1, 'integer' => [1, $var2]]. Supported types are the suffixes of the is_* functions such as string for is_string and int for is_int @param bool $failOnWhitespace whether to fail strings if they are whitespace @param bool $allowNulls whether to allow null values to pass through @return void @throws InvalidArgumentException if a key in $typesToVariables was not a string @throws InvalidArgumentException if a key in $typesToVariables did not have an is_ function @throws InvalidArgumentException if a variable is not of correct type @throws InvalidArgumentException if a variable is whitespace and $failOnWhitespace is set
[ "Throws", "an", "exception", "if", "specified", "variables", "are", "not", "of", "given", "types", "." ]
c463161db7e77c7e72f2553dc4d436e6cb6caa2a
https://github.com/traderinteractive/util-php/blob/c463161db7e77c7e72f2553dc4d436e6cb6caa2a/src/Util.php#L186-L194
train
proem/proem
lib/Proem/Util/Structure/DataCollectionTrait.php
DataCollectionTrait.set
public function set($index, $value = null) { if (is_array($index)) { $this->data = array_merge($this->data, $index); } else { $this->data[$index] = $value; } return $this; }
php
public function set($index, $value = null) { if (is_array($index)) { $this->data = array_merge($this->data, $index); } else { $this->data[$index] = $value; } return $this; }
[ "public", "function", "set", "(", "$", "index", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "index", ")", ")", "{", "$", "this", "->", "data", "=", "array_merge", "(", "$", "this", "->", "data", ",", "$", "index", ...
Set a single property or multiple properties at once @param string|array $index @param mixed $value
[ "Set", "a", "single", "property", "or", "multiple", "properties", "at", "once" ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Util/Structure/DataCollectionTrait.php#L58-L66
train
proem/proem
lib/Proem/Util/Structure/DataCollectionTrait.php
DataCollectionTrait.get
public function get($index, $default = null) { if (isset($this->data[$index])) { return $this->data[$index]; } return $default; }
php
public function get($index, $default = null) { if (isset($this->data[$index])) { return $this->data[$index]; } return $default; }
[ "public", "function", "get", "(", "$", "index", ",", "$", "default", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "index", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "$", "index", "]", ...
Retreive a value or an optional default @param string $index @param mixed $default
[ "Retreive", "a", "value", "or", "an", "optional", "default" ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Util/Structure/DataCollectionTrait.php#L74-L81
train
GoIntegro/hateoas
Http/Client.php
Client.setBody
public function setBody($body) { $body = json_encode($body); if ($error = json_last_error()) { throw new \ErrorException($error); } curl_setopt($this->curlHandler, CURLOPT_POSTFIELDS, $body); return $this; }
php
public function setBody($body) { $body = json_encode($body); if ($error = json_last_error()) { throw new \ErrorException($error); } curl_setopt($this->curlHandler, CURLOPT_POSTFIELDS, $body); return $this; }
[ "public", "function", "setBody", "(", "$", "body", ")", "{", "$", "body", "=", "json_encode", "(", "$", "body", ")", ";", "if", "(", "$", "error", "=", "json_last_error", "(", ")", ")", "{", "throw", "new", "\\", "ErrorException", "(", "$", "error", ...
Define el cuerpo de un pedido. @param string El contenido del cuerpo. @throws \ErrorException
[ "Define", "el", "cuerpo", "de", "un", "pedido", "." ]
4799794294079f8bd3839e76175134219f876105
https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/Http/Client.php#L132-L143
train
RxPHP/RxStream
src/FromFileObservable.php
FromFileObservable.cut
public function cut(string $lineEnd = PHP_EOL): Observable { return $this->lift(function () use ($lineEnd) { return new CutOperator($lineEnd); }); }
php
public function cut(string $lineEnd = PHP_EOL): Observable { return $this->lift(function () use ($lineEnd) { return new CutOperator($lineEnd); }); }
[ "public", "function", "cut", "(", "string", "$", "lineEnd", "=", "PHP_EOL", ")", ":", "Observable", "{", "return", "$", "this", "->", "lift", "(", "function", "(", ")", "use", "(", "$", "lineEnd", ")", "{", "return", "new", "CutOperator", "(", "$", "...
Cuts the stream based upon a delimiter. @param string $lineEnd @return \Rx\Observable
[ "Cuts", "the", "stream", "based", "upon", "a", "delimiter", "." ]
9e55d937edbc9bda67114c8ffedbeae487817cd0
https://github.com/RxPHP/RxStream/blob/9e55d937edbc9bda67114c8ffedbeae487817cd0/src/FromFileObservable.php#L65-L70
train
laravelflare/flare
src/Flare/Flare.php
Flare.compatibility
public function compatibility() { if (strpos($this->app->version(), '5.1.') !== false && strpos($this->app->version(), '(LTS)') !== false) { return 'LTS'; } return 'Edge'; }
php
public function compatibility() { if (strpos($this->app->version(), '5.1.') !== false && strpos($this->app->version(), '(LTS)') !== false) { return 'LTS'; } return 'Edge'; }
[ "public", "function", "compatibility", "(", ")", "{", "if", "(", "strpos", "(", "$", "this", "->", "app", "->", "version", "(", ")", ",", "'5.1.'", ")", "!==", "false", "&&", "strpos", "(", "$", "this", "->", "app", "->", "version", "(", ")", ",", ...
Returns the compatibility version of Flare to use. This will either return 'LTS' for Laravel installs of the Long Term Support branch (5.1.x) or 'Edge' for all other versions (including dev-master). @return string
[ "Returns", "the", "compatibility", "version", "of", "Flare", "to", "use", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Flare.php#L351-L358
train
laravelflare/flare
src/Flare/Flare.php
Flare.registerHelper
public function registerHelper($helper, $class) { if (array_key_exists($helper, $this->helpers)) { throw new Exception("Helper method `$helper` has already been defined"); } $this->helpers[$helper] = $class; }
php
public function registerHelper($helper, $class) { if (array_key_exists($helper, $this->helpers)) { throw new Exception("Helper method `$helper` has already been defined"); } $this->helpers[$helper] = $class; }
[ "public", "function", "registerHelper", "(", "$", "helper", ",", "$", "class", ")", "{", "if", "(", "array_key_exists", "(", "$", "helper", ",", "$", "this", "->", "helpers", ")", ")", "{", "throw", "new", "Exception", "(", "\"Helper method `$helper` has alr...
Register a helper method.
[ "Register", "a", "helper", "method", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Flare.php#L363-L370
train
laravelflare/flare
src/Flare/Flare.php
Flare.callHelperMethod
protected function callHelperMethod($method, $parameters) { return $this->app->make($this->helpers[$method], $parameters); }
php
protected function callHelperMethod($method, $parameters) { return $this->app->make($this->helpers[$method], $parameters); }
[ "protected", "function", "callHelperMethod", "(", "$", "method", ",", "$", "parameters", ")", "{", "return", "$", "this", "->", "app", "->", "make", "(", "$", "this", "->", "helpers", "[", "$", "method", "]", ",", "$", "parameters", ")", ";", "}" ]
Call a Helper Method. @param string $method @param mixed $parameters @return mixed
[ "Call", "a", "Helper", "Method", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Flare.php#L390-L393
train
reliv/Rcm
core/src/Service/DomainRedirectService.php
DomainRedirectService.getPrimaryRedirectUrl
public function getPrimaryRedirectUrl(Site $site) { $currentDomain = $site->getDomain()->getDomainName(); $ipValidator = new Ip(); $isIp = $ipValidator->isValid($currentDomain); if ($isIp) { return null; } $primaryDomain = $site->getDomain()->getPrimary(); if (empty($primaryDomain)) { return null; } if ($primaryDomain->getDomainName() == $currentDomain) { return null; } return $primaryDomain->getDomainName(); }
php
public function getPrimaryRedirectUrl(Site $site) { $currentDomain = $site->getDomain()->getDomainName(); $ipValidator = new Ip(); $isIp = $ipValidator->isValid($currentDomain); if ($isIp) { return null; } $primaryDomain = $site->getDomain()->getPrimary(); if (empty($primaryDomain)) { return null; } if ($primaryDomain->getDomainName() == $currentDomain) { return null; } return $primaryDomain->getDomainName(); }
[ "public", "function", "getPrimaryRedirectUrl", "(", "Site", "$", "site", ")", "{", "$", "currentDomain", "=", "$", "site", "->", "getDomain", "(", ")", "->", "getDomainName", "(", ")", ";", "$", "ipValidator", "=", "new", "Ip", "(", ")", ";", "$", "isI...
getPrimaryRedirectUrl If the IP is not a domain and is not the primary, return redirect for primary @param Site $site @return null|string
[ "getPrimaryRedirectUrl", "If", "the", "IP", "is", "not", "a", "domain", "and", "is", "not", "the", "primary", "return", "redirect", "for", "primary" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/DomainRedirectService.php#L68-L90
train
proem/proem
lib/Proem/Filter/ChainEventAbstract.php
ChainEventAbstract.init
public function init(ChainManagerInterface $chainManager, array $params = []) { $this->in($chainManager->getAssetManager()); if ($chainManager->hasEvents()) { $event = $chainManager->getNextEvent(); if (is_object($event)) { $event->init($chainManager); } } $this->out($chainManager->getAssetManager()); return $this; }
php
public function init(ChainManagerInterface $chainManager, array $params = []) { $this->in($chainManager->getAssetManager()); if ($chainManager->hasEvents()) { $event = $chainManager->getNextEvent(); if (is_object($event)) { $event->init($chainManager); } } $this->out($chainManager->getAssetManager()); return $this; }
[ "public", "function", "init", "(", "ChainManagerInterface", "$", "chainManager", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "in", "(", "$", "chainManager", "->", "getAssetManager", "(", ")", ")", ";", "if", "(", "$", "chai...
Bootstrap this event. Executes in() then init() on the next event= in the filter chain before returning to execute out(). @param Proem\Filter\ChainManagerInterface $chainManager @param array Optional extra parameters.
[ "Bootstrap", "this", "event", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Filter/ChainEventAbstract.php#L65-L79
train
ARCANEDEV/LaravelImpersonator
src/Policies/ImpersonationPolicy.php
ImpersonationPolicy.canBeImpersonatedPolicy
public function canBeImpersonatedPolicy(Impersonatable $impersonater, Impersonatable $impersonated) { return $this->canImpersonatePolicy($impersonater) && $impersonated->canBeImpersonated(); }
php
public function canBeImpersonatedPolicy(Impersonatable $impersonater, Impersonatable $impersonated) { return $this->canImpersonatePolicy($impersonater) && $impersonated->canBeImpersonated(); }
[ "public", "function", "canBeImpersonatedPolicy", "(", "Impersonatable", "$", "impersonater", ",", "Impersonatable", "$", "impersonated", ")", "{", "return", "$", "this", "->", "canImpersonatePolicy", "(", "$", "impersonater", ")", "&&", "$", "impersonated", "->", ...
Check if the given user can be impersonated. @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonater @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonated @return bool
[ "Check", "if", "the", "given", "user", "can", "be", "impersonated", "." ]
f72bc3f1bcd11530887b23f62a9975c6321efdf8
https://github.com/ARCANEDEV/LaravelImpersonator/blob/f72bc3f1bcd11530887b23f62a9975c6321efdf8/src/Policies/ImpersonationPolicy.php#L47-L50
train
reliv/Rcm
admin/src/Controller/ApiAdminPageTypesController.php
ApiAdminPageTypesController.getList
public function getList() { /** @var RcmUserService $rcmUserService */ $rcmUserService = $this->serviceLocator->get(RcmUserService::class); //ACCESS CHECK if (!$rcmUserService->isAllowed( ResourceName::RESOURCE_SITES, 'admin' ) ) { $this->getResponse()->setStatusCode(Response::STATUS_CODE_401); return $this->getResponse(); } $config = $this->getConfig(); $pageTypes = $config['Rcm']['pageTypes']; return new ApiJsonModel($pageTypes, 0, 'Success'); }
php
public function getList() { /** @var RcmUserService $rcmUserService */ $rcmUserService = $this->serviceLocator->get(RcmUserService::class); //ACCESS CHECK if (!$rcmUserService->isAllowed( ResourceName::RESOURCE_SITES, 'admin' ) ) { $this->getResponse()->setStatusCode(Response::STATUS_CODE_401); return $this->getResponse(); } $config = $this->getConfig(); $pageTypes = $config['Rcm']['pageTypes']; return new ApiJsonModel($pageTypes, 0, 'Success'); }
[ "public", "function", "getList", "(", ")", "{", "/** @var RcmUserService $rcmUserService */", "$", "rcmUserService", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "RcmUserService", "::", "class", ")", ";", "//ACCESS CHECK", "if", "(", "!", "$", "rc...
getList of available page types @return mixed|JsonModel
[ "getList", "of", "available", "page", "types" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Controller/ApiAdminPageTypesController.php#L35-L55
train
reliv/Rcm
core/src/Validator/PageName.php
PageName.isValid
public function isValid($value) { $this->setValue($value); $pattern = '/^[a-z0-9_\-]*[a-z0-9]$/i'; $this->pageNameOk = true; if (!preg_match($pattern, $value)) { $this->error(self::PAGE_NAME); $this->pageNameOk = false; } return $this->pageNameOk; }
php
public function isValid($value) { $this->setValue($value); $pattern = '/^[a-z0-9_\-]*[a-z0-9]$/i'; $this->pageNameOk = true; if (!preg_match($pattern, $value)) { $this->error(self::PAGE_NAME); $this->pageNameOk = false; } return $this->pageNameOk; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "$", "this", "->", "setValue", "(", "$", "value", ")", ";", "$", "pattern", "=", "'/^[a-z0-9_\\-]*[a-z0-9]$/i'", ";", "$", "this", "->", "pageNameOk", "=", "true", ";", "if", "(", "!", "preg...
Is the page name valid? @param mixed $value Value to be checked @return bool
[ "Is", "the", "page", "name", "valid?" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Validator/PageName.php#L50-L64
train
dadajuice/zephyrus
src/Zephyrus/Application/Session.php
Session.getInstance
final public static function getInstance(?array $configurations = null): self { if (is_null(self::$instance)) { self::$instance = new self($configurations); } return self::$instance; }
php
final public static function getInstance(?array $configurations = null): self { if (is_null(self::$instance)) { self::$instance = new self($configurations); } return self::$instance; }
[ "final", "public", "static", "function", "getInstance", "(", "?", "array", "$", "configurations", "=", "null", ")", ":", "self", "{", "if", "(", "is_null", "(", "self", "::", "$", "instance", ")", ")", "{", "self", "::", "$", "instance", "=", "new", ...
Obtain the single allowed instance for Session through singleton pattern method. @return Session
[ "Obtain", "the", "single", "allowed", "instance", "for", "Session", "through", "singleton", "pattern", "method", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Session.php#L46-L52
train
dadajuice/zephyrus
src/Zephyrus/Application/Session.php
Session.has
public function has(string $key, $value = null): bool { return is_null($value) ? isset($_SESSION[$key]) : isset($_SESSION[$key]) && $_SESSION[$key] == $value; }
php
public function has(string $key, $value = null): bool { return is_null($value) ? isset($_SESSION[$key]) : isset($_SESSION[$key]) && $_SESSION[$key] == $value; }
[ "public", "function", "has", "(", "string", "$", "key", ",", "$", "value", "=", "null", ")", ":", "bool", "{", "return", "is_null", "(", "$", "value", ")", "?", "isset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ":", "isset", "(", "$", "...
Determines if the specified key exists in the current session. Optionally, if the value argument is used, it also validates that the value is exactly the one provided. @param string $key @param mixed $value @return bool
[ "Determines", "if", "the", "specified", "key", "exists", "in", "the", "current", "session", ".", "Optionally", "if", "the", "value", "argument", "is", "used", "it", "also", "validates", "that", "the", "value", "is", "exactly", "the", "one", "provided", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Session.php#L76-L81
train
dadajuice/zephyrus
src/Zephyrus/Application/Session.php
Session.remove
public function remove(string $key) { if (isset($_SESSION[$key])) { $_SESSION[$key] = ''; unset($_SESSION[$key]); } }
php
public function remove(string $key) { if (isset($_SESSION[$key])) { $_SESSION[$key] = ''; unset($_SESSION[$key]); } }
[ "public", "function", "remove", "(", "string", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ")", "{", "$", "_SESSION", "[", "$", "key", "]", "=", "''", ";", "unset", "(", "$", "_SESSION", "[", "$", ...
Removes the session data associated with the provided key. @param string $key
[ "Removes", "the", "session", "data", "associated", "with", "the", "provided", "key", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Session.php#L99-L105
train
dadajuice/zephyrus
src/Zephyrus/Application/Session.php
Session.initialize
private function initialize() { $this->name = (isset($this->configurations['name'])) ? $this->configurations['name'] : self::DEFAULT_SESSION_NAME; $this->assignSessionLifetime(); if (isset($this->configurations['encryption_enabled']) && $this->configurations['encryption_enabled']) { $this->handler = new EncryptedSessionHandler(); } $this->security = new SecuritySession($this->configurations); }
php
private function initialize() { $this->name = (isset($this->configurations['name'])) ? $this->configurations['name'] : self::DEFAULT_SESSION_NAME; $this->assignSessionLifetime(); if (isset($this->configurations['encryption_enabled']) && $this->configurations['encryption_enabled']) { $this->handler = new EncryptedSessionHandler(); } $this->security = new SecuritySession($this->configurations); }
[ "private", "function", "initialize", "(", ")", "{", "$", "this", "->", "name", "=", "(", "isset", "(", "$", "this", "->", "configurations", "[", "'name'", "]", ")", ")", "?", "$", "this", "->", "configurations", "[", "'name'", "]", ":", "self", "::",...
Initializes all data required from various setting to implement the session class. Can be overwritten by children class to add new features.
[ "Initializes", "all", "data", "required", "from", "various", "setting", "to", "implement", "the", "session", "class", ".", "Can", "be", "overwritten", "by", "children", "class", "to", "add", "new", "features", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Session.php#L210-L221
train
dadajuice/zephyrus
src/Zephyrus/Application/Session.php
Session.assignSessionLifetime
private function assignSessionLifetime() { if (isset($this->configurations['lifetime'])) { $lifetime = $this->configurations['lifetime']; ini_set('session.gc_maxlifetime', $lifetime * 1.2); session_set_cookie_params($lifetime); } }
php
private function assignSessionLifetime() { if (isset($this->configurations['lifetime'])) { $lifetime = $this->configurations['lifetime']; ini_set('session.gc_maxlifetime', $lifetime * 1.2); session_set_cookie_params($lifetime); } }
[ "private", "function", "assignSessionLifetime", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "configurations", "[", "'lifetime'", "]", ")", ")", "{", "$", "lifetime", "=", "$", "this", "->", "configurations", "[", "'lifetime'", "]", ";", "i...
Registers a different session lifetime if configured. Assigns the gc_maxlifetime with a little more time to make sure the client cookie expires before the server garbage collector.
[ "Registers", "a", "different", "session", "lifetime", "if", "configured", ".", "Assigns", "the", "gc_maxlifetime", "with", "a", "little", "more", "time", "to", "make", "sure", "the", "client", "cookie", "expires", "before", "the", "server", "garbage", "collector...
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Session.php#L228-L235
train
webeweb/core-bundle
EventListener/KernelEventListener.php
KernelEventListener.handleBadUserRoleException
protected function handleBadUserRoleException(GetResponseForExceptionEvent $event, BadUserRoleException $ex) { if (null !== $ex->getRedirectUrl()) { $event->setResponse(new RedirectResponse($ex->getRedirectUrl())); } return $event; }
php
protected function handleBadUserRoleException(GetResponseForExceptionEvent $event, BadUserRoleException $ex) { if (null !== $ex->getRedirectUrl()) { $event->setResponse(new RedirectResponse($ex->getRedirectUrl())); } return $event; }
[ "protected", "function", "handleBadUserRoleException", "(", "GetResponseForExceptionEvent", "$", "event", ",", "BadUserRoleException", "$", "ex", ")", "{", "if", "(", "null", "!==", "$", "ex", "->", "getRedirectUrl", "(", ")", ")", "{", "$", "event", "->", "se...
Handle a bad user role exception. @param GetResponseForExceptionEvent $event The event. @param BadUserRoleException $ex The exception. @return GetResponseForExceptionEvent Returns the event.
[ "Handle", "a", "bad", "user", "role", "exception", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/EventListener/KernelEventListener.php#L84-L89
train