id
int32
0
241k
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
15,500
bluelyte/transmission-remote
src/Remote.php
Remote.setPort
public function setPort($port) { if (!ctype_digit($port)) { trigger_error('Port must be a positive integer: ' . var_export($port, true), E_USER_ERROR); } $this->port = $port; }
php
public function setPort($port) { if (!ctype_digit($port)) { trigger_error('Port must be a positive integer: ' . var_export($port, true), E_USER_ERROR); } $this->port = $port; }
[ "public", "function", "setPort", "(", "$", "port", ")", "{", "if", "(", "!", "ctype_digit", "(", "$", "port", ")", ")", "{", "trigger_error", "(", "'Port must be a positive integer: '", ".", "var_export", "(", "$", "port", ",", "true", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "this", "->", "port", "=", "$", "port", ";", "}" ]
Sets the port on which to operate the daemon. @param string $port
[ "Sets", "the", "port", "on", "which", "to", "operate", "the", "daemon", "." ]
82683b8b9101f623dbd6c1923348cff00380250c
https://github.com/bluelyte/transmission-remote/blob/82683b8b9101f623dbd6c1923348cff00380250c/src/Remote.php#L83-L89
15,501
bluelyte/transmission-remote
src/Remote.php
Remote.setDownloadPath
public function setDownloadPath($downloadPath) { if (!is_dir($downloadPath) || !is_writable($downloadPath)) { trigger_error('Cannot write to directory: ' . $downloadPath, E_USER_ERROR); } $this->downloadPath = $downloadPath; }
php
public function setDownloadPath($downloadPath) { if (!is_dir($downloadPath) || !is_writable($downloadPath)) { trigger_error('Cannot write to directory: ' . $downloadPath, E_USER_ERROR); } $this->downloadPath = $downloadPath; }
[ "public", "function", "setDownloadPath", "(", "$", "downloadPath", ")", "{", "if", "(", "!", "is_dir", "(", "$", "downloadPath", ")", "||", "!", "is_writable", "(", "$", "downloadPath", ")", ")", "{", "trigger_error", "(", "'Cannot write to directory: '", ".", "$", "downloadPath", ",", "E_USER_ERROR", ")", ";", "}", "$", "this", "->", "downloadPath", "=", "$", "downloadPath", ";", "}" ]
Sets the path at which to store downloaded files. @param string $downloadPath
[ "Sets", "the", "path", "at", "which", "to", "store", "downloaded", "files", "." ]
82683b8b9101f623dbd6c1923348cff00380250c
https://github.com/bluelyte/transmission-remote/blob/82683b8b9101f623dbd6c1923348cff00380250c/src/Remote.php#L106-L112
15,502
bluelyte/transmission-remote
src/Remote.php
Remote.execute
protected function execute($command) { $process = proc_open($command, array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes); fclose($pipes[2]); $this->output = stream_get_contents($pipes[1]); fclose($pipes[1]); $status = proc_get_status($process); $this->status = $status['exitcode']; proc_close($process); }
php
protected function execute($command) { $process = proc_open($command, array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes); fclose($pipes[2]); $this->output = stream_get_contents($pipes[1]); fclose($pipes[1]); $status = proc_get_status($process); $this->status = $status['exitcode']; proc_close($process); }
[ "protected", "function", "execute", "(", "$", "command", ")", "{", "$", "process", "=", "proc_open", "(", "$", "command", ",", "array", "(", "1", "=>", "array", "(", "'pipe'", ",", "'w'", ")", ",", "2", "=>", "array", "(", "'pipe'", ",", "'w'", ")", ")", ",", "$", "pipes", ")", ";", "fclose", "(", "$", "pipes", "[", "2", "]", ")", ";", "$", "this", "->", "output", "=", "stream_get_contents", "(", "$", "pipes", "[", "1", "]", ")", ";", "fclose", "(", "$", "pipes", "[", "1", "]", ")", ";", "$", "status", "=", "proc_get_status", "(", "$", "process", ")", ";", "$", "this", "->", "status", "=", "$", "status", "[", "'exitcode'", "]", ";", "proc_close", "(", "$", "process", ")", ";", "}" ]
Execute a shell command. @param string $command
[ "Execute", "a", "shell", "command", "." ]
82683b8b9101f623dbd6c1923348cff00380250c
https://github.com/bluelyte/transmission-remote/blob/82683b8b9101f623dbd6c1923348cff00380250c/src/Remote.php#L131-L140
15,503
bluelyte/transmission-remote
src/Remote.php
Remote.start
public function start() { if ($this->started) { return; } $auth = $this->getAuthFlag(); $command = 'transmission-remote -C ' . $auth . ' -' . ($this->encryption ? 'er' : 'ep') . ' -p ' . $this->port . ' -' . ($this->upnp ? 'm' : 'M') . ($this->downloadPath ? ' -w ' . $this->downloadPath : ''); $this->execute($command); $this->execute('transmission-remote ' . $auth . ' -l'); if ($this->getStatus() == 1) { $this->execute('transmission-daemon'); } $this->started = true; }
php
public function start() { if ($this->started) { return; } $auth = $this->getAuthFlag(); $command = 'transmission-remote -C ' . $auth . ' -' . ($this->encryption ? 'er' : 'ep') . ' -p ' . $this->port . ' -' . ($this->upnp ? 'm' : 'M') . ($this->downloadPath ? ' -w ' . $this->downloadPath : ''); $this->execute($command); $this->execute('transmission-remote ' . $auth . ' -l'); if ($this->getStatus() == 1) { $this->execute('transmission-daemon'); } $this->started = true; }
[ "public", "function", "start", "(", ")", "{", "if", "(", "$", "this", "->", "started", ")", "{", "return", ";", "}", "$", "auth", "=", "$", "this", "->", "getAuthFlag", "(", ")", ";", "$", "command", "=", "'transmission-remote -C '", ".", "$", "auth", ".", "' -'", ".", "(", "$", "this", "->", "encryption", "?", "'er'", ":", "'ep'", ")", ".", "' -p '", ".", "$", "this", "->", "port", ".", "' -'", ".", "(", "$", "this", "->", "upnp", "?", "'m'", ":", "'M'", ")", ".", "(", "$", "this", "->", "downloadPath", "?", "' -w '", ".", "$", "this", "->", "downloadPath", ":", "''", ")", ";", "$", "this", "->", "execute", "(", "$", "command", ")", ";", "$", "this", "->", "execute", "(", "'transmission-remote '", ".", "$", "auth", ".", "' -l'", ")", ";", "if", "(", "$", "this", "->", "getStatus", "(", ")", "==", "1", ")", "{", "$", "this", "->", "execute", "(", "'transmission-daemon'", ")", ";", "}", "$", "this", "->", "started", "=", "true", ";", "}" ]
Starts the daemon.
[ "Starts", "the", "daemon", "." ]
82683b8b9101f623dbd6c1923348cff00380250c
https://github.com/bluelyte/transmission-remote/blob/82683b8b9101f623dbd6c1923348cff00380250c/src/Remote.php#L175-L196
15,504
bluelyte/transmission-remote
src/Remote.php
Remote.addTorrents
public function addTorrents($paths) { if (is_array($paths)) { $paths = implode(' ', $paths); } $this->execute('transmission-remote ' . $this->getAuthFlag() . ' -a ' . $paths); }
php
public function addTorrents($paths) { if (is_array($paths)) { $paths = implode(' ', $paths); } $this->execute('transmission-remote ' . $this->getAuthFlag() . ' -a ' . $paths); }
[ "public", "function", "addTorrents", "(", "$", "paths", ")", "{", "if", "(", "is_array", "(", "$", "paths", ")", ")", "{", "$", "paths", "=", "implode", "(", "' '", ",", "$", "paths", ")", ";", "}", "$", "this", "->", "execute", "(", "'transmission-remote '", ".", "$", "this", "->", "getAuthFlag", "(", ")", ".", "' -a '", ".", "$", "paths", ")", ";", "}" ]
Adds a torrent to download. @param string|array $path Space-delimited list or array of paths to one or more .torrent files
[ "Adds", "a", "torrent", "to", "download", "." ]
82683b8b9101f623dbd6c1923348cff00380250c
https://github.com/bluelyte/transmission-remote/blob/82683b8b9101f623dbd6c1923348cff00380250c/src/Remote.php#L204-L210
15,505
jasny/router
src/Router/UrlParsing.php
UrlParsing.splitUrl
protected function splitUrl($url) { $path = parse_url(trim($url, '/'), PHP_URL_PATH); return $path ? explode('/', $path) : array(); }
php
protected function splitUrl($url) { $path = parse_url(trim($url, '/'), PHP_URL_PATH); return $path ? explode('/', $path) : array(); }
[ "protected", "function", "splitUrl", "(", "$", "url", ")", "{", "$", "path", "=", "parse_url", "(", "trim", "(", "$", "url", ",", "'/'", ")", ",", "PHP_URL_PATH", ")", ";", "return", "$", "path", "?", "explode", "(", "'/'", ",", "$", "path", ")", ":", "array", "(", ")", ";", "}" ]
Get parts of a URL path @param string $url @return array
[ "Get", "parts", "of", "a", "URL", "path" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/UrlParsing.php#L16-L20
15,506
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.initPermissionsRelatedById
public function initPermissionsRelatedById($overrideExisting = true) { if (null !== $this->collPermissionsRelatedById && !$overrideExisting) { return; } $this->collPermissionsRelatedById = new ObjectCollection(); $this->collPermissionsRelatedById->setModel('\Alchemy\Component\Cerberus\Model\Permission'); }
php
public function initPermissionsRelatedById($overrideExisting = true) { if (null !== $this->collPermissionsRelatedById && !$overrideExisting) { return; } $this->collPermissionsRelatedById = new ObjectCollection(); $this->collPermissionsRelatedById->setModel('\Alchemy\Component\Cerberus\Model\Permission'); }
[ "public", "function", "initPermissionsRelatedById", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collPermissionsRelatedById", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collPermissionsRelatedById", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collPermissionsRelatedById", "->", "setModel", "(", "'\\Alchemy\\Component\\Cerberus\\Model\\Permission'", ")", ";", "}" ]
Initializes the collPermissionsRelatedById collection. By default this just sets the collPermissionsRelatedById collection to an empty array (like clearcollPermissionsRelatedById()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collPermissionsRelatedById", "collection", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L1568-L1575
15,507
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.getPermissionsRelatedById
public function getPermissionsRelatedById(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collPermissionsRelatedByIdPartial && !$this->isNew(); if (null === $this->collPermissionsRelatedById || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPermissionsRelatedById) { // return empty collection $this->initPermissionsRelatedById(); } else { $collPermissionsRelatedById = ChildPermissionQuery::create(null, $criteria) ->filterByPermissionRelatedByParentId($this) ->find($con); if (null !== $criteria) { if (false !== $this->collPermissionsRelatedByIdPartial && count($collPermissionsRelatedById)) { $this->initPermissionsRelatedById(false); foreach ($collPermissionsRelatedById as $obj) { if (false == $this->collPermissionsRelatedById->contains($obj)) { $this->collPermissionsRelatedById->append($obj); } } $this->collPermissionsRelatedByIdPartial = true; } return $collPermissionsRelatedById; } if ($partial && $this->collPermissionsRelatedById) { foreach ($this->collPermissionsRelatedById as $obj) { if ($obj->isNew()) { $collPermissionsRelatedById[] = $obj; } } } $this->collPermissionsRelatedById = $collPermissionsRelatedById; $this->collPermissionsRelatedByIdPartial = false; } } return $this->collPermissionsRelatedById; }
php
public function getPermissionsRelatedById(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collPermissionsRelatedByIdPartial && !$this->isNew(); if (null === $this->collPermissionsRelatedById || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPermissionsRelatedById) { // return empty collection $this->initPermissionsRelatedById(); } else { $collPermissionsRelatedById = ChildPermissionQuery::create(null, $criteria) ->filterByPermissionRelatedByParentId($this) ->find($con); if (null !== $criteria) { if (false !== $this->collPermissionsRelatedByIdPartial && count($collPermissionsRelatedById)) { $this->initPermissionsRelatedById(false); foreach ($collPermissionsRelatedById as $obj) { if (false == $this->collPermissionsRelatedById->contains($obj)) { $this->collPermissionsRelatedById->append($obj); } } $this->collPermissionsRelatedByIdPartial = true; } return $collPermissionsRelatedById; } if ($partial && $this->collPermissionsRelatedById) { foreach ($this->collPermissionsRelatedById as $obj) { if ($obj->isNew()) { $collPermissionsRelatedById[] = $obj; } } } $this->collPermissionsRelatedById = $collPermissionsRelatedById; $this->collPermissionsRelatedByIdPartial = false; } } return $this->collPermissionsRelatedById; }
[ "public", "function", "getPermissionsRelatedById", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collPermissionsRelatedByIdPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collPermissionsRelatedById", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collPermissionsRelatedById", ")", "{", "// return empty collection", "$", "this", "->", "initPermissionsRelatedById", "(", ")", ";", "}", "else", "{", "$", "collPermissionsRelatedById", "=", "ChildPermissionQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByPermissionRelatedByParentId", "(", "$", "this", ")", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "if", "(", "false", "!==", "$", "this", "->", "collPermissionsRelatedByIdPartial", "&&", "count", "(", "$", "collPermissionsRelatedById", ")", ")", "{", "$", "this", "->", "initPermissionsRelatedById", "(", "false", ")", ";", "foreach", "(", "$", "collPermissionsRelatedById", "as", "$", "obj", ")", "{", "if", "(", "false", "==", "$", "this", "->", "collPermissionsRelatedById", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "this", "->", "collPermissionsRelatedById", "->", "append", "(", "$", "obj", ")", ";", "}", "}", "$", "this", "->", "collPermissionsRelatedByIdPartial", "=", "true", ";", "}", "return", "$", "collPermissionsRelatedById", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collPermissionsRelatedById", ")", "{", "foreach", "(", "$", "this", "->", "collPermissionsRelatedById", "as", "$", "obj", ")", "{", "if", "(", "$", "obj", "->", "isNew", "(", ")", ")", "{", "$", "collPermissionsRelatedById", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collPermissionsRelatedById", "=", "$", "collPermissionsRelatedById", ";", "$", "this", "->", "collPermissionsRelatedByIdPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collPermissionsRelatedById", ";", "}" ]
Gets an array of ChildPermission objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildPermission is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return ObjectCollection|ChildPermission[] List of ChildPermission objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildPermission", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L1591-L1633
15,508
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.countPermissionsRelatedById
public function countPermissionsRelatedById(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collPermissionsRelatedByIdPartial && !$this->isNew(); if (null === $this->collPermissionsRelatedById || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPermissionsRelatedById) { return 0; } if ($partial && !$criteria) { return count($this->getPermissionsRelatedById()); } $query = ChildPermissionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByPermissionRelatedByParentId($this) ->count($con); } return count($this->collPermissionsRelatedById); }
php
public function countPermissionsRelatedById(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collPermissionsRelatedByIdPartial && !$this->isNew(); if (null === $this->collPermissionsRelatedById || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPermissionsRelatedById) { return 0; } if ($partial && !$criteria) { return count($this->getPermissionsRelatedById()); } $query = ChildPermissionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByPermissionRelatedByParentId($this) ->count($con); } return count($this->collPermissionsRelatedById); }
[ "public", "function", "countPermissionsRelatedById", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collPermissionsRelatedByIdPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collPermissionsRelatedById", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collPermissionsRelatedById", ")", "{", "return", "0", ";", "}", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getPermissionsRelatedById", "(", ")", ")", ";", "}", "$", "query", "=", "ChildPermissionQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByPermissionRelatedByParentId", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "return", "count", "(", "$", "this", "->", "collPermissionsRelatedById", ")", ";", "}" ]
Returns the number of related Permission objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related Permission objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "Permission", "objects", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L1677-L1700
15,509
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.addPermissionRelatedById
public function addPermissionRelatedById(ChildPermission $l) { if ($this->collPermissionsRelatedById === null) { $this->initPermissionsRelatedById(); $this->collPermissionsRelatedByIdPartial = true; } if (!$this->collPermissionsRelatedById->contains($l)) { $this->doAddPermissionRelatedById($l); } return $this; }
php
public function addPermissionRelatedById(ChildPermission $l) { if ($this->collPermissionsRelatedById === null) { $this->initPermissionsRelatedById(); $this->collPermissionsRelatedByIdPartial = true; } if (!$this->collPermissionsRelatedById->contains($l)) { $this->doAddPermissionRelatedById($l); } return $this; }
[ "public", "function", "addPermissionRelatedById", "(", "ChildPermission", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collPermissionsRelatedById", "===", "null", ")", "{", "$", "this", "->", "initPermissionsRelatedById", "(", ")", ";", "$", "this", "->", "collPermissionsRelatedByIdPartial", "=", "true", ";", "}", "if", "(", "!", "$", "this", "->", "collPermissionsRelatedById", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "doAddPermissionRelatedById", "(", "$", "l", ")", ";", "}", "return", "$", "this", ";", "}" ]
Method called to associate a ChildPermission object to this object through the ChildPermission foreign key attribute. @param ChildPermission $l ChildPermission @return $this|\Alchemy\Component\Cerberus\Model\Permission The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildPermission", "object", "to", "this", "object", "through", "the", "ChildPermission", "foreign", "key", "attribute", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L1709-L1721
15,510
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.getRolePermissions
public function getRolePermissions(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collRolePermissionsPartial && !$this->isNew(); if (null === $this->collRolePermissions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRolePermissions) { // return empty collection $this->initRolePermissions(); } else { $collRolePermissions = ChildRolePermissionQuery::create(null, $criteria) ->filterByPermission($this) ->find($con); if (null !== $criteria) { if (false !== $this->collRolePermissionsPartial && count($collRolePermissions)) { $this->initRolePermissions(false); foreach ($collRolePermissions as $obj) { if (false == $this->collRolePermissions->contains($obj)) { $this->collRolePermissions->append($obj); } } $this->collRolePermissionsPartial = true; } return $collRolePermissions; } if ($partial && $this->collRolePermissions) { foreach ($this->collRolePermissions as $obj) { if ($obj->isNew()) { $collRolePermissions[] = $obj; } } } $this->collRolePermissions = $collRolePermissions; $this->collRolePermissionsPartial = false; } } return $this->collRolePermissions; }
php
public function getRolePermissions(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collRolePermissionsPartial && !$this->isNew(); if (null === $this->collRolePermissions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRolePermissions) { // return empty collection $this->initRolePermissions(); } else { $collRolePermissions = ChildRolePermissionQuery::create(null, $criteria) ->filterByPermission($this) ->find($con); if (null !== $criteria) { if (false !== $this->collRolePermissionsPartial && count($collRolePermissions)) { $this->initRolePermissions(false); foreach ($collRolePermissions as $obj) { if (false == $this->collRolePermissions->contains($obj)) { $this->collRolePermissions->append($obj); } } $this->collRolePermissionsPartial = true; } return $collRolePermissions; } if ($partial && $this->collRolePermissions) { foreach ($this->collRolePermissions as $obj) { if ($obj->isNew()) { $collRolePermissions[] = $obj; } } } $this->collRolePermissions = $collRolePermissions; $this->collRolePermissionsPartial = false; } } return $this->collRolePermissions; }
[ "public", "function", "getRolePermissions", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collRolePermissionsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collRolePermissions", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collRolePermissions", ")", "{", "// return empty collection", "$", "this", "->", "initRolePermissions", "(", ")", ";", "}", "else", "{", "$", "collRolePermissions", "=", "ChildRolePermissionQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByPermission", "(", "$", "this", ")", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "if", "(", "false", "!==", "$", "this", "->", "collRolePermissionsPartial", "&&", "count", "(", "$", "collRolePermissions", ")", ")", "{", "$", "this", "->", "initRolePermissions", "(", "false", ")", ";", "foreach", "(", "$", "collRolePermissions", "as", "$", "obj", ")", "{", "if", "(", "false", "==", "$", "this", "->", "collRolePermissions", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "this", "->", "collRolePermissions", "->", "append", "(", "$", "obj", ")", ";", "}", "}", "$", "this", "->", "collRolePermissionsPartial", "=", "true", ";", "}", "return", "$", "collRolePermissions", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collRolePermissions", ")", "{", "foreach", "(", "$", "this", "->", "collRolePermissions", "as", "$", "obj", ")", "{", "if", "(", "$", "obj", "->", "isNew", "(", ")", ")", "{", "$", "collRolePermissions", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collRolePermissions", "=", "$", "collRolePermissions", ";", "$", "this", "->", "collRolePermissionsPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collRolePermissions", ";", "}" ]
Gets an array of ChildRolePermission objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildPermission is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return ObjectCollection|ChildRolePermission[] List of ChildRolePermission objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildRolePermission", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L1809-L1851
15,511
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.countRolePermissions
public function countRolePermissions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRolePermissionsPartial && !$this->isNew(); if (null === $this->collRolePermissions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRolePermissions) { return 0; } if ($partial && !$criteria) { return count($this->getRolePermissions()); } $query = ChildRolePermissionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByPermission($this) ->count($con); } return count($this->collRolePermissions); }
php
public function countRolePermissions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRolePermissionsPartial && !$this->isNew(); if (null === $this->collRolePermissions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRolePermissions) { return 0; } if ($partial && !$criteria) { return count($this->getRolePermissions()); } $query = ChildRolePermissionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByPermission($this) ->count($con); } return count($this->collRolePermissions); }
[ "public", "function", "countRolePermissions", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collRolePermissionsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collRolePermissions", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collRolePermissions", ")", "{", "return", "0", ";", "}", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getRolePermissions", "(", ")", ")", ";", "}", "$", "query", "=", "ChildRolePermissionQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByPermission", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "return", "count", "(", "$", "this", "->", "collRolePermissions", ")", ";", "}" ]
Returns the number of related RolePermission objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related RolePermission objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "RolePermission", "objects", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L1898-L1921
15,512
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.getRolePermissionsJoinRole
public function getRolePermissionsJoinRole(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildRolePermissionQuery::create(null, $criteria); $query->joinWith('Role', $joinBehavior); return $this->getRolePermissions($query, $con); }
php
public function getRolePermissionsJoinRole(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildRolePermissionQuery::create(null, $criteria); $query->joinWith('Role', $joinBehavior); return $this->getRolePermissions($query, $con); }
[ "public", "function", "getRolePermissionsJoinRole", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildRolePermissionQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "$", "query", "->", "joinWith", "(", "'Role'", ",", "$", "joinBehavior", ")", ";", "return", "$", "this", "->", "getRolePermissions", "(", "$", "query", ",", "$", "con", ")", ";", "}" ]
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this Permission is new, it will return an empty collection; or if this Permission has previously been saved, it will retrieve related RolePermissions from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in Permission. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildRolePermission[] List of ChildRolePermission objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "Permission", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", "or", "if", "this", "Permission", "has", "previously", "been", "saved", "it", "will", "retrieve", "related", "RolePermissions", "from", "storage", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L1990-L1996
15,513
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.getRoles
public function getRoles(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collRolesPartial && !$this->isNew(); if (null === $this->collRoles || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collRoles) { $this->initRoles(); } } else { $query = ChildRoleQuery::create(null, $criteria) ->filterByPermission($this); $collRoles = $query->find($con); if (null !== $criteria) { return $collRoles; } if ($partial && $this->collRoles) { //make sure that already added objects gets added to the list of the database. foreach ($this->collRoles as $obj) { if (!$collRoles->contains($obj)) { $collRoles[] = $obj; } } } $this->collRoles = $collRoles; $this->collRolesPartial = false; } } return $this->collRoles; }
php
public function getRoles(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collRolesPartial && !$this->isNew(); if (null === $this->collRoles || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collRoles) { $this->initRoles(); } } else { $query = ChildRoleQuery::create(null, $criteria) ->filterByPermission($this); $collRoles = $query->find($con); if (null !== $criteria) { return $collRoles; } if ($partial && $this->collRoles) { //make sure that already added objects gets added to the list of the database. foreach ($this->collRoles as $obj) { if (!$collRoles->contains($obj)) { $collRoles[] = $obj; } } } $this->collRoles = $collRoles; $this->collRolesPartial = false; } } return $this->collRoles; }
[ "public", "function", "getRoles", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collRolesPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collRoles", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "// return empty collection", "if", "(", "null", "===", "$", "this", "->", "collRoles", ")", "{", "$", "this", "->", "initRoles", "(", ")", ";", "}", "}", "else", "{", "$", "query", "=", "ChildRoleQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByPermission", "(", "$", "this", ")", ";", "$", "collRoles", "=", "$", "query", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "return", "$", "collRoles", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collRoles", ")", "{", "//make sure that already added objects gets added to the list of the database.", "foreach", "(", "$", "this", "->", "collRoles", "as", "$", "obj", ")", "{", "if", "(", "!", "$", "collRoles", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "collRoles", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collRoles", "=", "$", "collRoles", ";", "$", "this", "->", "collRolesPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collRoles", ";", "}" ]
Gets a collection of ChildRole objects related by a many-to-many relationship to the current object by way of the role_permission cross-reference table. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildPermission is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria Optional query object to filter the query @param ConnectionInterface $con Optional connection object @return ObjectCollection|ChildRole[] List of ChildRole objects
[ "Gets", "a", "collection", "of", "ChildRole", "objects", "related", "by", "a", "many", "-", "to", "-", "many", "relationship", "to", "the", "current", "object", "by", "way", "of", "the", "role_permission", "cross", "-", "reference", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L2054-L2087
15,514
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.countRoles
public function countRoles(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRolesPartial && !$this->isNew(); if (null === $this->collRoles || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRoles) { return 0; } else { if ($partial && !$criteria) { return count($this->getRoles()); } $query = ChildRoleQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByPermission($this) ->count($con); } } else { return count($this->collRoles); } }
php
public function countRoles(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRolesPartial && !$this->isNew(); if (null === $this->collRoles || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRoles) { return 0; } else { if ($partial && !$criteria) { return count($this->getRoles()); } $query = ChildRoleQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByPermission($this) ->count($con); } } else { return count($this->collRoles); } }
[ "public", "function", "countRoles", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collRolesPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collRoles", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collRoles", ")", "{", "return", "0", ";", "}", "else", "{", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getRoles", "(", ")", ")", ";", "}", "$", "query", "=", "ChildRoleQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByPermission", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "}", "else", "{", "return", "count", "(", "$", "this", "->", "collRoles", ")", ";", "}", "}" ]
Gets the number of Role objects related by a many-to-many relationship to the current object by way of the role_permission cross-reference table. @param Criteria $criteria Optional query object to filter the query @param boolean $distinct Set to true to force count distinct @param ConnectionInterface $con Optional connection object @return int the number of related Role objects
[ "Gets", "the", "number", "of", "Role", "objects", "related", "by", "a", "many", "-", "to", "-", "many", "relationship", "to", "the", "current", "object", "by", "way", "of", "the", "role_permission", "cross", "-", "reference", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L2132-L2156
15,515
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Permission.php
Permission.removeRole
public function removeRole(ChildRole $role) { if ($this->getRoles()->contains($role)) { $rolePermission = new ChildRolePermission(); $rolePermission->setRole($role); if ($role->isPermissionsLoaded()) { //remove the back reference if available $role->getPermissions()->removeObject($this); } $rolePermission->setPermission($this); $this->removeRolePermission(clone $rolePermission); $rolePermission->clear(); $this->collRoles->remove($this->collRoles->search($role)); if (null === $this->rolesScheduledForDeletion) { $this->rolesScheduledForDeletion = clone $this->collRoles; $this->rolesScheduledForDeletion->clear(); } $this->rolesScheduledForDeletion->push($role); } return $this; }
php
public function removeRole(ChildRole $role) { if ($this->getRoles()->contains($role)) { $rolePermission = new ChildRolePermission(); $rolePermission->setRole($role); if ($role->isPermissionsLoaded()) { //remove the back reference if available $role->getPermissions()->removeObject($this); } $rolePermission->setPermission($this); $this->removeRolePermission(clone $rolePermission); $rolePermission->clear(); $this->collRoles->remove($this->collRoles->search($role)); if (null === $this->rolesScheduledForDeletion) { $this->rolesScheduledForDeletion = clone $this->collRoles; $this->rolesScheduledForDeletion->clear(); } $this->rolesScheduledForDeletion->push($role); } return $this; }
[ "public", "function", "removeRole", "(", "ChildRole", "$", "role", ")", "{", "if", "(", "$", "this", "->", "getRoles", "(", ")", "->", "contains", "(", "$", "role", ")", ")", "{", "$", "rolePermission", "=", "new", "ChildRolePermission", "(", ")", ";", "$", "rolePermission", "->", "setRole", "(", "$", "role", ")", ";", "if", "(", "$", "role", "->", "isPermissionsLoaded", "(", ")", ")", "{", "//remove the back reference if available", "$", "role", "->", "getPermissions", "(", ")", "->", "removeObject", "(", "$", "this", ")", ";", "}", "$", "rolePermission", "->", "setPermission", "(", "$", "this", ")", ";", "$", "this", "->", "removeRolePermission", "(", "clone", "$", "rolePermission", ")", ";", "$", "rolePermission", "->", "clear", "(", ")", ";", "$", "this", "->", "collRoles", "->", "remove", "(", "$", "this", "->", "collRoles", "->", "search", "(", "$", "role", ")", ")", ";", "if", "(", "null", "===", "$", "this", "->", "rolesScheduledForDeletion", ")", "{", "$", "this", "->", "rolesScheduledForDeletion", "=", "clone", "$", "this", "->", "collRoles", ";", "$", "this", "->", "rolesScheduledForDeletion", "->", "clear", "(", ")", ";", "}", "$", "this", "->", "rolesScheduledForDeletion", "->", "push", "(", "$", "role", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove role of this object through the role_permission cross reference table. @param ChildRole $role @return ChildPermission The current object (for fluent API support)
[ "Remove", "role", "of", "this", "object", "through", "the", "role_permission", "cross", "reference", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Permission.php#L2212-L2238
15,516
czim/laravel-pxlcms
src/Sluggable/SluggableTranslatedTrait.php
SluggableTranslatedTrait.findBySlug
public static function findBySlug($slug, $locale = null) { /** @var \Dimsav\Translatable\Translatable $model */ $model = (new static); /** @var SluggableTrait $translationModel */ $translationModel = $model->getTranslationModelName(); $parentKey = $model->getRelationKey(); $translationInstance = $translationModel::findBySlug($slug, $locale); if (empty($translationInstance)) return null; return static::find($translationInstance->{$parentKey}); }
php
public static function findBySlug($slug, $locale = null) { /** @var \Dimsav\Translatable\Translatable $model */ $model = (new static); /** @var SluggableTrait $translationModel */ $translationModel = $model->getTranslationModelName(); $parentKey = $model->getRelationKey(); $translationInstance = $translationModel::findBySlug($slug, $locale); if (empty($translationInstance)) return null; return static::find($translationInstance->{$parentKey}); }
[ "public", "static", "function", "findBySlug", "(", "$", "slug", ",", "$", "locale", "=", "null", ")", "{", "/** @var \\Dimsav\\Translatable\\Translatable $model */", "$", "model", "=", "(", "new", "static", ")", ";", "/** @var SluggableTrait $translationModel */", "$", "translationModel", "=", "$", "model", "->", "getTranslationModelName", "(", ")", ";", "$", "parentKey", "=", "$", "model", "->", "getRelationKey", "(", ")", ";", "$", "translationInstance", "=", "$", "translationModel", "::", "findBySlug", "(", "$", "slug", ",", "$", "locale", ")", ";", "if", "(", "empty", "(", "$", "translationInstance", ")", ")", "return", "null", ";", "return", "static", "::", "find", "(", "$", "translationInstance", "->", "{", "$", "parentKey", "}", ")", ";", "}" ]
Find by slug on translated attribute @param string $slug @param string $locale optional, if omitted returns for any locale @return $this|null
[ "Find", "by", "slug", "on", "translated", "attribute" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTranslatedTrait.php#L20-L34
15,517
czim/laravel-pxlcms
src/Sluggable/SluggableTranslatedTrait.php
SluggableTranslatedTrait.scopeWhereSlug
public function scopeWhereSlug($query, $slug, $locale = null) { return $query->whereHas('translations', function ($query) use ($slug, $locale) { return $query->whereSlug($slug, $locale, true); }); }
php
public function scopeWhereSlug($query, $slug, $locale = null) { return $query->whereHas('translations', function ($query) use ($slug, $locale) { return $query->whereSlug($slug, $locale, true); }); }
[ "public", "function", "scopeWhereSlug", "(", "$", "query", ",", "$", "slug", ",", "$", "locale", "=", "null", ")", "{", "return", "$", "query", "->", "whereHas", "(", "'translations'", ",", "function", "(", "$", "query", ")", "use", "(", "$", "slug", ",", "$", "locale", ")", "{", "return", "$", "query", "->", "whereSlug", "(", "$", "slug", ",", "$", "locale", ",", "true", ")", ";", "}", ")", ";", "}" ]
Scopes query for slug on translated attribute @param \Illuminate\Database\Eloquent\Builder $query @param string $slug @param string $locale @return $this|null
[ "Scopes", "query", "for", "slug", "on", "translated", "attribute" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTranslatedTrait.php#L44-L49
15,518
vincentchalamon/VinceCmsSonataAdminBundle
Admin/Entity/ArticleAdmin.php
ArticleAdmin.createQuery
public function createQuery($context = 'list') { $query = parent::createQuery($context); $query->leftJoin($query->getRootAlias().'.template', 'template')->addSelect('template') ->leftJoin('template.areas', 'area')->addSelect('area') ->leftJoin($query->getRootAlias().'.metas', 'articleMeta')->addSelect('articleMeta') ->leftJoin('articleMeta.meta', 'meta')->addSelect('meta'); return $query; }
php
public function createQuery($context = 'list') { $query = parent::createQuery($context); $query->leftJoin($query->getRootAlias().'.template', 'template')->addSelect('template') ->leftJoin('template.areas', 'area')->addSelect('area') ->leftJoin($query->getRootAlias().'.metas', 'articleMeta')->addSelect('articleMeta') ->leftJoin('articleMeta.meta', 'meta')->addSelect('meta'); return $query; }
[ "public", "function", "createQuery", "(", "$", "context", "=", "'list'", ")", "{", "$", "query", "=", "parent", "::", "createQuery", "(", "$", "context", ")", ";", "$", "query", "->", "leftJoin", "(", "$", "query", "->", "getRootAlias", "(", ")", ".", "'.template'", ",", "'template'", ")", "->", "addSelect", "(", "'template'", ")", "->", "leftJoin", "(", "'template.areas'", ",", "'area'", ")", "->", "addSelect", "(", "'area'", ")", "->", "leftJoin", "(", "$", "query", "->", "getRootAlias", "(", ")", ".", "'.metas'", ",", "'articleMeta'", ")", "->", "addSelect", "(", "'articleMeta'", ")", "->", "leftJoin", "(", "'articleMeta.meta'", ",", "'meta'", ")", "->", "addSelect", "(", "'meta'", ")", ";", "return", "$", "query", ";", "}" ]
Need to override createQuery method because or list order & joins {@inheritdoc}
[ "Need", "to", "override", "createQuery", "method", "because", "or", "list", "order", "&", "joins" ]
edc768061734a92ba116488dd7b61ad40af21ceb
https://github.com/vincentchalamon/VinceCmsSonataAdminBundle/blob/edc768061734a92ba116488dd7b61ad40af21ceb/Admin/Entity/ArticleAdmin.php#L192-L201
15,519
chippyash/Math-Type-Calculator
src/Chippyash/Math/Type/Traits/CheckIntTypes.php
CheckIntTypes.checkIntTypes
protected function checkIntTypes(NumericTypeInterface $a, NumericTypeInterface $b) { $a1 = ($a instanceof IntType ? $a : $a->asIntType()); $b1 = ($a instanceof IntType ? $b : $b->asIntType()); return [$a1, $b1]; }
php
protected function checkIntTypes(NumericTypeInterface $a, NumericTypeInterface $b) { $a1 = ($a instanceof IntType ? $a : $a->asIntType()); $b1 = ($a instanceof IntType ? $b : $b->asIntType()); return [$a1, $b1]; }
[ "protected", "function", "checkIntTypes", "(", "NumericTypeInterface", "$", "a", ",", "NumericTypeInterface", "$", "b", ")", "{", "$", "a1", "=", "(", "$", "a", "instanceof", "IntType", "?", "$", "a", ":", "$", "a", "->", "asIntType", "(", ")", ")", ";", "$", "b1", "=", "(", "$", "a", "instanceof", "IntType", "?", "$", "b", ":", "$", "b", "->", "asIntType", "(", ")", ")", ";", "return", "[", "$", "a1", ",", "$", "b1", "]", ";", "}" ]
Check for integer type, converting if necessary @param NumericTypeInterface $a @param NumericTypeInterface $b @return array [IntType, IntType]
[ "Check", "for", "integer", "type", "converting", "if", "necessary" ]
2a2fae0ab4d052772d3dd45745efd5a91f88b9e3
https://github.com/chippyash/Math-Type-Calculator/blob/2a2fae0ab4d052772d3dd45745efd5a91f88b9e3/src/Chippyash/Math/Type/Traits/CheckIntTypes.php#L28-L34
15,520
drunomics/service-utils
src/Core/Config/ConfigFactoryTrait.php
ConfigFactoryTrait.getConfigFactory
public function getConfigFactory() { if (empty($this->configFactory)) { $this->configFactory = \Drupal::service('config.factory'); } return $this->configFactory; }
php
public function getConfigFactory() { if (empty($this->configFactory)) { $this->configFactory = \Drupal::service('config.factory'); } return $this->configFactory; }
[ "public", "function", "getConfigFactory", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "configFactory", ")", ")", "{", "$", "this", "->", "configFactory", "=", "\\", "Drupal", "::", "service", "(", "'config.factory'", ")", ";", "}", "return", "$", "this", "->", "configFactory", ";", "}" ]
Gets the config factory. @return \Drupal\Core\Config\ConfigFactoryInterface The config factory.
[ "Gets", "the", "config", "factory", "." ]
56761750043132365ef4ae5d9e0cf4263459328f
https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/Core/Config/ConfigFactoryTrait.php#L38-L43
15,521
gregorybesson/PlaygroundCore
src/Validator/MailDomain.php
MailDomain.setFile
public function setFile($file) { if (empty($file) || false === stream_resolve_include_path($file)) { throw new Exception\InvalidArgumentException('Invalid options to validator provided'); } $this->options['file'] = $file; return $this; }
php
public function setFile($file) { if (empty($file) || false === stream_resolve_include_path($file)) { throw new Exception\InvalidArgumentException('Invalid options to validator provided'); } $this->options['file'] = $file; return $this; }
[ "public", "function", "setFile", "(", "$", "file", ")", "{", "if", "(", "empty", "(", "$", "file", ")", "||", "false", "===", "stream_resolve_include_path", "(", "$", "file", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Invalid options to validator provided'", ")", ";", "}", "$", "this", "->", "options", "[", "'file'", "]", "=", "$", "file", ";", "return", "$", "this", ";", "}" ]
Sets the path to the file @param string $path to the file @return MailDomain Provides a fluent interface @throws Exception\InvalidArgumentException When file is not found
[ "Sets", "the", "path", "to", "the", "file" ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Validator/MailDomain.php#L48-L56
15,522
tonicospinelli/class-generation
src/ClassGeneration/Property.php
Property.setType
public function setType($type) { $this->type = (string)$type; $this->getDocBlock()->getTagCollection()->removeByName(Tag::TAG_VAR); $tag = Tag::createFromProperty($this); $this->getDocBlock()->addTag($tag); return $this; }
php
public function setType($type) { $this->type = (string)$type; $this->getDocBlock()->getTagCollection()->removeByName(Tag::TAG_VAR); $tag = Tag::createFromProperty($this); $this->getDocBlock()->addTag($tag); return $this; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "$", "this", "->", "type", "=", "(", "string", ")", "$", "type", ";", "$", "this", "->", "getDocBlock", "(", ")", "->", "getTagCollection", "(", ")", "->", "removeByName", "(", "Tag", "::", "TAG_VAR", ")", ";", "$", "tag", "=", "Tag", "::", "createFromProperty", "(", "$", "this", ")", ";", "$", "this", "->", "getDocBlock", "(", ")", "->", "addTag", "(", "$", "tag", ")", ";", "return", "$", "this", ";", "}" ]
Sets the property's type. @param string $type @return Property
[ "Sets", "the", "property", "s", "type", "." ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/Property.php#L146-L156
15,523
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/Query/Criteria.php
Criteria.toUrlQuery
public function toUrlQuery() { $queryData = array(); foreach (self::$properties as $p => $setter) { if ($this->$p !== null) { $queryData[$p] = $this->$p; } } return http_build_query($queryData); }
php
public function toUrlQuery() { $queryData = array(); foreach (self::$properties as $p => $setter) { if ($this->$p !== null) { $queryData[$p] = $this->$p; } } return http_build_query($queryData); }
[ "public", "function", "toUrlQuery", "(", ")", "{", "$", "queryData", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "properties", "as", "$", "p", "=>", "$", "setter", ")", "{", "if", "(", "$", "this", "->", "$", "p", "!==", "null", ")", "{", "$", "queryData", "[", "$", "p", "]", "=", "$", "this", "->", "$", "p", ";", "}", "}", "return", "http_build_query", "(", "$", "queryData", ")", ";", "}" ]
Returns the resulting url-encoded query string. @return string
[ "Returns", "the", "resulting", "url", "-", "encoded", "query", "string", "." ]
a020149ffde815be17634542010814cf854c3d5f
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/Query/Criteria.php#L68-L77
15,524
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/Query/Criteria.php
Criteria.set
public function set($criteria) { if ($criteria instanceof Criteria) { //this is much faster than using the same method that's used for arrays (see below) $this->limit = $criteria->limit; $this->offset = $criteria->offset; $this->sort = $criteria->sort; $this->filter = $criteria->filter; $this->after = $criteria->after; $this->loadonly = $criteria->loadonly; } elseif (is_string($criteria)) { //parse the string into an array and then parse the array $criteria = $this->parseHttpQuery($criteria); } if (is_array($criteria)) { foreach (self::$properties as $p => $setter) { if (isset($criteria[$p])) { $this->$setter($criteria[$p]); } } } }
php
public function set($criteria) { if ($criteria instanceof Criteria) { //this is much faster than using the same method that's used for arrays (see below) $this->limit = $criteria->limit; $this->offset = $criteria->offset; $this->sort = $criteria->sort; $this->filter = $criteria->filter; $this->after = $criteria->after; $this->loadonly = $criteria->loadonly; } elseif (is_string($criteria)) { //parse the string into an array and then parse the array $criteria = $this->parseHttpQuery($criteria); } if (is_array($criteria)) { foreach (self::$properties as $p => $setter) { if (isset($criteria[$p])) { $this->$setter($criteria[$p]); } } } }
[ "public", "function", "set", "(", "$", "criteria", ")", "{", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "//this is much faster than using the same method that's used for arrays (see below)", "$", "this", "->", "limit", "=", "$", "criteria", "->", "limit", ";", "$", "this", "->", "offset", "=", "$", "criteria", "->", "offset", ";", "$", "this", "->", "sort", "=", "$", "criteria", "->", "sort", ";", "$", "this", "->", "filter", "=", "$", "criteria", "->", "filter", ";", "$", "this", "->", "after", "=", "$", "criteria", "->", "after", ";", "$", "this", "->", "loadonly", "=", "$", "criteria", "->", "loadonly", ";", "}", "elseif", "(", "is_string", "(", "$", "criteria", ")", ")", "{", "//parse the string into an array and then parse the array", "$", "criteria", "=", "$", "this", "->", "parseHttpQuery", "(", "$", "criteria", ")", ";", "}", "if", "(", "is_array", "(", "$", "criteria", ")", ")", "{", "foreach", "(", "self", "::", "$", "properties", "as", "$", "p", "=>", "$", "setter", ")", "{", "if", "(", "isset", "(", "$", "criteria", "[", "$", "p", "]", ")", ")", "{", "$", "this", "->", "$", "setter", "(", "$", "criteria", "[", "$", "p", "]", ")", ";", "}", "}", "}", "}" ]
Sets multiple parameters at once. @param mixed $criteria Can be one of the following: <ul> <li>Another Criteria object - copies that object's criteria into this one. Competely replaces the current object's values, unsetting those which have not been set in $criteria</li> <li>An array - sets the parameters present in the array. Parameters not present in the array will <b>not</b> be unset. If you wish to unset certain parameters, set them to null in the array.</li> <li>A string - the resulting query string (without a leading question mark), will be parsed back into the individual parameters and processed like an array.</li> </ul>
[ "Sets", "multiple", "parameters", "at", "once", "." ]
a020149ffde815be17634542010814cf854c3d5f
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/Query/Criteria.php#L247-L269
15,525
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/Query/Criteria.php
Criteria.parseHttpQuery
private function parseHttpQuery($query) { /* can't use parse_str, because the minimum supported PHP version * is 5.3, which still has the magic_quotes_gpc option that affects its * result, so some users could hypothetically have that enabled */ if (empty($query)) { return array(); } $result = array(); $parts = explode('&', $query); foreach ($parts as $p) { $keyval = explode('=', $p); $result[urldecode($keyval[0])] = urldecode($keyval[1]); } return $result; }
php
private function parseHttpQuery($query) { /* can't use parse_str, because the minimum supported PHP version * is 5.3, which still has the magic_quotes_gpc option that affects its * result, so some users could hypothetically have that enabled */ if (empty($query)) { return array(); } $result = array(); $parts = explode('&', $query); foreach ($parts as $p) { $keyval = explode('=', $p); $result[urldecode($keyval[0])] = urldecode($keyval[1]); } return $result; }
[ "private", "function", "parseHttpQuery", "(", "$", "query", ")", "{", "/* can't use parse_str, because the minimum supported PHP version\n * is 5.3, which still has the magic_quotes_gpc option that affects its\n * result, so some users could hypothetically have that enabled */", "if", "(", "empty", "(", "$", "query", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "$", "parts", "=", "explode", "(", "'&'", ",", "$", "query", ")", ";", "foreach", "(", "$", "parts", "as", "$", "p", ")", "{", "$", "keyval", "=", "explode", "(", "'='", ",", "$", "p", ")", ";", "$", "result", "[", "urldecode", "(", "$", "keyval", "[", "0", "]", ")", "]", "=", "urldecode", "(", "$", "keyval", "[", "1", "]", ")", ";", "}", "return", "$", "result", ";", "}" ]
Parses a http query into a key-value array, similar to PHP's parse_str function. @param string $query query string (without a leading question mark) @return array
[ "Parses", "a", "http", "query", "into", "a", "key", "-", "value", "array", "similar", "to", "PHP", "s", "parse_str", "function", "." ]
a020149ffde815be17634542010814cf854c3d5f
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/Query/Criteria.php#L276-L292
15,526
innobrig/flex-input
src/Input.php
Input.fromCookie
public static function fromCookie ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_COOKIE, $filter, $args); } return self::getPassedValue ($key, $default, 'C', $filter, $args); }
php
public static function fromCookie ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_COOKIE, $filter, $args); } return self::getPassedValue ($key, $default, 'C', $filter, $args); }
[ "public", "static", "function", "fromCookie", "(", "$", "key", ",", "$", "default", "=", "null", ",", "$", "filter", "=", "null", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "key", ")", "{", "return", "self", "::", "filterArray", "(", "$", "_COOKIE", ",", "$", "filter", ",", "$", "args", ")", ";", "}", "return", "self", "::", "getPassedValue", "(", "$", "key", ",", "$", "default", ",", "'C'", ",", "$", "filter", ",", "$", "args", ")", ";", "}" ]
Wrapper for COOKIE input @param string $key The input field to return. @param mixed $default The value to return if the requested field is not found (optional) (default=false). @param string $filter The filter directive to apply to the retrieved input (optional) (default=null) @param array $args The filter processing args to apply (optional) (default=array()) @return array|mixed @throws \Exception
[ "Wrapper", "for", "COOKIE", "input" ]
81db6cd22820d310d35be9a71d545dafffb21c64
https://github.com/innobrig/flex-input/blob/81db6cd22820d310d35be9a71d545dafffb21c64/src/Input.php#L33-L40
15,527
innobrig/flex-input
src/Input.php
Input.fromDelete
public static function fromDelete ($key, $default=null, $filter=null, $args=array()) { if (!$key) { $values = array(); parse_str (file_get_contents("php://input"), $values); return self::filterArray ($values, $filter, $args); } return self::getPassedValue ($key, $default, 'D', $filter, $args); }
php
public static function fromDelete ($key, $default=null, $filter=null, $args=array()) { if (!$key) { $values = array(); parse_str (file_get_contents("php://input"), $values); return self::filterArray ($values, $filter, $args); } return self::getPassedValue ($key, $default, 'D', $filter, $args); }
[ "public", "static", "function", "fromDelete", "(", "$", "key", ",", "$", "default", "=", "null", ",", "$", "filter", "=", "null", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "key", ")", "{", "$", "values", "=", "array", "(", ")", ";", "parse_str", "(", "file_get_contents", "(", "\"php://input\"", ")", ",", "$", "values", ")", ";", "return", "self", "::", "filterArray", "(", "$", "values", ",", "$", "filter", ",", "$", "args", ")", ";", "}", "return", "self", "::", "getPassedValue", "(", "$", "key", ",", "$", "default", ",", "'D'", ",", "$", "filter", ",", "$", "args", ")", ";", "}" ]
Wrapper for DELETE input @param string $key The input field to return. @param mixed $default The value to return if the requested field is not found (optional) (default=false). @param string $filter The filter directive to apply to the retrieved input (optional) (default=null) @param array $args The filter processing args to apply (optional) (default=array()) @return array|mixed @throws \Exception
[ "Wrapper", "for", "DELETE", "input" ]
81db6cd22820d310d35be9a71d545dafffb21c64
https://github.com/innobrig/flex-input/blob/81db6cd22820d310d35be9a71d545dafffb21c64/src/Input.php#L54-L63
15,528
innobrig/flex-input
src/Input.php
Input.fromFiles
public static function fromFiles ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_FILES, $filter, $args); } return self::getPassedValue ($key, $default, 'F', $filter, $args); }
php
public static function fromFiles ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_FILES, $filter, $args); } return self::getPassedValue ($key, $default, 'F', $filter, $args); }
[ "public", "static", "function", "fromFiles", "(", "$", "key", ",", "$", "default", "=", "null", ",", "$", "filter", "=", "null", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "key", ")", "{", "return", "self", "::", "filterArray", "(", "$", "_FILES", ",", "$", "filter", ",", "$", "args", ")", ";", "}", "return", "self", "::", "getPassedValue", "(", "$", "key", ",", "$", "default", ",", "'F'", ",", "$", "filter", ",", "$", "args", ")", ";", "}" ]
Wrapper for FILES input @param string $key The input field to return. @param mixed $default The value to return if the requested field is not found (optional) (default=false). @param string $filter The filter directive to apply to the retrieved input (optional) (default=null) @param array $args The filter processing args to apply (optional) (default=array()) @return array|mixed @throws \Exception
[ "Wrapper", "for", "FILES", "input" ]
81db6cd22820d310d35be9a71d545dafffb21c64
https://github.com/innobrig/flex-input/blob/81db6cd22820d310d35be9a71d545dafffb21c64/src/Input.php#L77-L84
15,529
innobrig/flex-input
src/Input.php
Input.fromGet
public static function fromGet ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_GET, $filter, $args); } return self::getPassedValue ($key, $default, 'G', $filter, $args); }
php
public static function fromGet ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_GET, $filter, $args); } return self::getPassedValue ($key, $default, 'G', $filter, $args); }
[ "public", "static", "function", "fromGet", "(", "$", "key", ",", "$", "default", "=", "null", ",", "$", "filter", "=", "null", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "key", ")", "{", "return", "self", "::", "filterArray", "(", "$", "_GET", ",", "$", "filter", ",", "$", "args", ")", ";", "}", "return", "self", "::", "getPassedValue", "(", "$", "key", ",", "$", "default", ",", "'G'", ",", "$", "filter", ",", "$", "args", ")", ";", "}" ]
Wrapper for GET input @param string $key The input field to return. @param mixed $default The value to return if the requested field is not found (optional) (default=false). @param string $filter The filter directive to apply to the retrieved input (optional) (default=null) @param array $args The filter processing args to apply (optional) (default=array()) @return array|mixed @throws \Exception
[ "Wrapper", "for", "GET", "input" ]
81db6cd22820d310d35be9a71d545dafffb21c64
https://github.com/innobrig/flex-input/blob/81db6cd22820d310d35be9a71d545dafffb21c64/src/Input.php#L98-L105
15,530
innobrig/flex-input
src/Input.php
Input.fromPost
public static function fromPost ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_POST, $filter, $args); } return self::getPassedValue ($key, $default, 'P', $filter, $args); }
php
public static function fromPost ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_POST, $filter, $args); } return self::getPassedValue ($key, $default, 'P', $filter, $args); }
[ "public", "static", "function", "fromPost", "(", "$", "key", ",", "$", "default", "=", "null", ",", "$", "filter", "=", "null", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "key", ")", "{", "return", "self", "::", "filterArray", "(", "$", "_POST", ",", "$", "filter", ",", "$", "args", ")", ";", "}", "return", "self", "::", "getPassedValue", "(", "$", "key", ",", "$", "default", ",", "'P'", ",", "$", "filter", ",", "$", "args", ")", ";", "}" ]
Wrapper for POST input @param string $key The input field to return. @param mixed $default The value to return if the requested field is not found (optional) (default=false). @param string $filter The filter directive to apply to the retrieved input (optional) (default=null) @param array $args The filter processing args to apply (optional) (default=array()) @return array|mixed @throws \Exception
[ "Wrapper", "for", "POST", "input" ]
81db6cd22820d310d35be9a71d545dafffb21c64
https://github.com/innobrig/flex-input/blob/81db6cd22820d310d35be9a71d545dafffb21c64/src/Input.php#L119-L126
15,531
innobrig/flex-input
src/Input.php
Input.fromRequest
public static function fromRequest ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_REQUEST, $filter, $args); } return self::getPassedValue ($key, $default, 'R', $filter, $args); }
php
public static function fromRequest ($key, $default=null, $filter=null, $args=array()) { if (!$key) { return self::filterArray ($_REQUEST, $filter, $args); } return self::getPassedValue ($key, $default, 'R', $filter, $args); }
[ "public", "static", "function", "fromRequest", "(", "$", "key", ",", "$", "default", "=", "null", ",", "$", "filter", "=", "null", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "key", ")", "{", "return", "self", "::", "filterArray", "(", "$", "_REQUEST", ",", "$", "filter", ",", "$", "args", ")", ";", "}", "return", "self", "::", "getPassedValue", "(", "$", "key", ",", "$", "default", ",", "'R'", ",", "$", "filter", ",", "$", "args", ")", ";", "}" ]
Wrapper for REQUEST input @param string $key The input field to return. @param mixed $default The value to return if the requested field is not found (optional) (default=false). @param string $filter The filter directive to apply to the retrieved input (optional) (default=null) @param array $args The filter processing args to apply (optional) (default=array()) @return array|mixed @throws \Exception
[ "Wrapper", "for", "REQUEST", "input" ]
81db6cd22820d310d35be9a71d545dafffb21c64
https://github.com/innobrig/flex-input/blob/81db6cd22820d310d35be9a71d545dafffb21c64/src/Input.php#L184-L191
15,532
innobrig/flex-input
src/Input.php
Input.filterArray
protected static function filterArray (array $values, $filter=null, $args=array(), $doTrim=true) { if (!$values) { return $values; } if (!$filter) { $filter = self::$defaultFilter; } if (!$args) { $args = array ('flags' => self::$defaultFlags); } foreach ($values as $k=>$v) { if (is_array($v)) { $values[$k] = self::filterArray ($v, $filter, $args, $doTrim); } else { $values[$k] = filter_var (self::trim($v, $doTrim), $filter, $args); } } return $values; }
php
protected static function filterArray (array $values, $filter=null, $args=array(), $doTrim=true) { if (!$values) { return $values; } if (!$filter) { $filter = self::$defaultFilter; } if (!$args) { $args = array ('flags' => self::$defaultFlags); } foreach ($values as $k=>$v) { if (is_array($v)) { $values[$k] = self::filterArray ($v, $filter, $args, $doTrim); } else { $values[$k] = filter_var (self::trim($v, $doTrim), $filter, $args); } } return $values; }
[ "protected", "static", "function", "filterArray", "(", "array", "$", "values", ",", "$", "filter", "=", "null", ",", "$", "args", "=", "array", "(", ")", ",", "$", "doTrim", "=", "true", ")", "{", "if", "(", "!", "$", "values", ")", "{", "return", "$", "values", ";", "}", "if", "(", "!", "$", "filter", ")", "{", "$", "filter", "=", "self", "::", "$", "defaultFilter", ";", "}", "if", "(", "!", "$", "args", ")", "{", "$", "args", "=", "array", "(", "'flags'", "=>", "self", "::", "$", "defaultFlags", ")", ";", "}", "foreach", "(", "$", "values", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "$", "values", "[", "$", "k", "]", "=", "self", "::", "filterArray", "(", "$", "v", ",", "$", "filter", ",", "$", "args", ",", "$", "doTrim", ")", ";", "}", "else", "{", "$", "values", "[", "$", "k", "]", "=", "filter_var", "(", "self", "::", "trim", "(", "$", "v", ",", "$", "doTrim", ")", ",", "$", "filter", ",", "$", "args", ")", ";", "}", "}", "return", "$", "values", ";", "}" ]
Filter an array item by item. This function is recursive array safe. @param array $values The array to filter @param string $filter The filter directive to apply to the retrieved input (optional) (default=null) @param array $args The filter processing args to apply (optional) (default=array()) @param bool $doTrim Whether or not to apply trim() to retrieved parameter (optional) (default=true) @return array
[ "Filter", "an", "array", "item", "by", "item", ".", "This", "function", "is", "recursive", "array", "safe", "." ]
81db6cd22820d310d35be9a71d545dafffb21c64
https://github.com/innobrig/flex-input/blob/81db6cd22820d310d35be9a71d545dafffb21c64/src/Input.php#L332-L355
15,533
christeredvartsen/sysinfo
src/SysInfo/Linux/Disk.php
Disk.sumField
private function sumField($devices = null, $partitions = null, $field) { $result = 0; if ($devices) { $devices = (array) $devices; } if (is_array($devices)) { $devices = array_flip($devices); } if ($partitions) { $partitions = (array) $partitions; } if (is_array($partitions)) { $partitions = array_flip($partitions); } foreach ($this->devices as $device => $partition) { if ($devices && !isset($devices[$device])) { continue; } foreach ($partition as $p => $info) { if ($partitions && !isset($partitions[$p])) { continue; } $result += $info[$field]; } } return $result; }
php
private function sumField($devices = null, $partitions = null, $field) { $result = 0; if ($devices) { $devices = (array) $devices; } if (is_array($devices)) { $devices = array_flip($devices); } if ($partitions) { $partitions = (array) $partitions; } if (is_array($partitions)) { $partitions = array_flip($partitions); } foreach ($this->devices as $device => $partition) { if ($devices && !isset($devices[$device])) { continue; } foreach ($partition as $p => $info) { if ($partitions && !isset($partitions[$p])) { continue; } $result += $info[$field]; } } return $result; }
[ "private", "function", "sumField", "(", "$", "devices", "=", "null", ",", "$", "partitions", "=", "null", ",", "$", "field", ")", "{", "$", "result", "=", "0", ";", "if", "(", "$", "devices", ")", "{", "$", "devices", "=", "(", "array", ")", "$", "devices", ";", "}", "if", "(", "is_array", "(", "$", "devices", ")", ")", "{", "$", "devices", "=", "array_flip", "(", "$", "devices", ")", ";", "}", "if", "(", "$", "partitions", ")", "{", "$", "partitions", "=", "(", "array", ")", "$", "partitions", ";", "}", "if", "(", "is_array", "(", "$", "partitions", ")", ")", "{", "$", "partitions", "=", "array_flip", "(", "$", "partitions", ")", ";", "}", "foreach", "(", "$", "this", "->", "devices", "as", "$", "device", "=>", "$", "partition", ")", "{", "if", "(", "$", "devices", "&&", "!", "isset", "(", "$", "devices", "[", "$", "device", "]", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "partition", "as", "$", "p", "=>", "$", "info", ")", "{", "if", "(", "$", "partitions", "&&", "!", "isset", "(", "$", "partitions", "[", "$", "p", "]", ")", ")", "{", "continue", ";", "}", "$", "result", "+=", "$", "info", "[", "$", "field", "]", ";", "}", "}", "return", "$", "result", ";", "}" ]
Calcuate a sum @param string|string[] $devices The name of the device to fetch, for instance "sda", or an array of device names: array('hda', 'hdb'). @param int|int[] $partitions Which partition(s) to fetch info about. @return int
[ "Calcuate", "a", "sum" ]
f1a8acb2997a41b52e9da970e5db041acd5b2ea3
https://github.com/christeredvartsen/sysinfo/blob/f1a8acb2997a41b52e9da970e5db041acd5b2ea3/src/SysInfo/Linux/Disk.php#L86-L120
15,534
shawnsandy/ui-pages
src/Controllers/GithubLoginController.php
GithubLoginController.loginUser
protected function loginUser($user) { $this->session->put( config('pagekit.session_key', 'pagekit_session'), [ 'github_id' => $user->id, 'github_name' => $user->name, 'github_email' => $user->email ] ); $this->session->save(); }
php
protected function loginUser($user) { $this->session->put( config('pagekit.session_key', 'pagekit_session'), [ 'github_id' => $user->id, 'github_name' => $user->name, 'github_email' => $user->email ] ); $this->session->save(); }
[ "protected", "function", "loginUser", "(", "$", "user", ")", "{", "$", "this", "->", "session", "->", "put", "(", "config", "(", "'pagekit.session_key'", ",", "'pagekit_session'", ")", ",", "[", "'github_id'", "=>", "$", "user", "->", "id", ",", "'github_name'", "=>", "$", "user", "->", "name", ",", "'github_email'", "=>", "$", "user", "->", "email", "]", ")", ";", "$", "this", "->", "session", "->", "save", "(", ")", ";", "}" ]
Checks if the user credentials matches the credentials stored in the config @param $user
[ "Checks", "if", "the", "user", "credentials", "matches", "the", "credentials", "stored", "in", "the", "config" ]
11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8
https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/Controllers/GithubLoginController.php#L76-L87
15,535
gregorybesson/PlaygroundCore
src/TwitterCard/Config.php
Config.getTags
public function getTags($useDefault = null) { if (is_null($useDefault)) { $useDefault = $this->useDefault; } $tags = array(); foreach ($this->tags as $tag) { if (!array_key_exists($tag->getProperty(), $tags)) { $tags[$tag->getProperty()] = $tag->getValue(); } } if ($useDefault) { foreach ($this->defaultTags as $tag) { if (!array_key_exists($tag->getProperty(), $tags)) { $tags[$tag->getProperty()] = $tag->getValue(); } } } return $tags; }
php
public function getTags($useDefault = null) { if (is_null($useDefault)) { $useDefault = $this->useDefault; } $tags = array(); foreach ($this->tags as $tag) { if (!array_key_exists($tag->getProperty(), $tags)) { $tags[$tag->getProperty()] = $tag->getValue(); } } if ($useDefault) { foreach ($this->defaultTags as $tag) { if (!array_key_exists($tag->getProperty(), $tags)) { $tags[$tag->getProperty()] = $tag->getValue(); } } } return $tags; }
[ "public", "function", "getTags", "(", "$", "useDefault", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "useDefault", ")", ")", "{", "$", "useDefault", "=", "$", "this", "->", "useDefault", ";", "}", "$", "tags", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "tags", "as", "$", "tag", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "tag", "->", "getProperty", "(", ")", ",", "$", "tags", ")", ")", "{", "$", "tags", "[", "$", "tag", "->", "getProperty", "(", ")", "]", "=", "$", "tag", "->", "getValue", "(", ")", ";", "}", "}", "if", "(", "$", "useDefault", ")", "{", "foreach", "(", "$", "this", "->", "defaultTags", "as", "$", "tag", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "tag", "->", "getProperty", "(", ")", ",", "$", "tags", ")", ")", "{", "$", "tags", "[", "$", "tag", "->", "getProperty", "(", ")", "]", "=", "$", "tag", "->", "getValue", "(", ")", ";", "}", "}", "}", "return", "$", "tags", ";", "}" ]
return the tags merged with the defaults @return array
[ "return", "the", "tags", "merged", "with", "the", "defaults" ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/TwitterCard/Config.php#L89-L108
15,536
sokil/php-rest
src/Sokil/Rest/Client/Factory.php
Factory.getConnection
public function getConnection() { if(!$this->_connection) { $this->_connection = new \Guzzle\Http\Client($this->getHost()); } return $this->_connection; }
php
public function getConnection() { if(!$this->_connection) { $this->_connection = new \Guzzle\Http\Client($this->getHost()); } return $this->_connection; }
[ "public", "function", "getConnection", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_connection", ")", "{", "$", "this", "->", "_connection", "=", "new", "\\", "Guzzle", "\\", "Http", "\\", "Client", "(", "$", "this", "->", "getHost", "(", ")", ")", ";", "}", "return", "$", "this", "->", "_connection", ";", "}" ]
Get Guzzle RESTful client @return \Guzzle\Http\Client
[ "Get", "Guzzle", "RESTful", "client" ]
5399d4ca38d3595de68598605d3d0d70f7ecfc7b
https://github.com/sokil/php-rest/blob/5399d4ca38d3595de68598605d3d0d70f7ecfc7b/src/Sokil/Rest/Client/Factory.php#L63-L70
15,537
goblindegook/Syllables
src/Template/Loader/Taxonomy.php
Taxonomy._should_load_template
protected function _should_load_template() { return ( \is_tax() || \is_category() || \is_tag() ) && ! empty( $this->term ) && in_array( $this->taxonomy, $this->taxonomies ); }
php
protected function _should_load_template() { return ( \is_tax() || \is_category() || \is_tag() ) && ! empty( $this->term ) && in_array( $this->taxonomy, $this->taxonomies ); }
[ "protected", "function", "_should_load_template", "(", ")", "{", "return", "(", "\\", "is_tax", "(", ")", "||", "\\", "is_category", "(", ")", "||", "\\", "is_tag", "(", ")", ")", "&&", "!", "empty", "(", "$", "this", "->", "term", ")", "&&", "in_array", "(", "$", "this", "->", "taxonomy", ",", "$", "this", "->", "taxonomies", ")", ";", "}" ]
Determines whether a custom template for a taxonomy term should be loaded. @return boolean Whether a custom template should be loaded. @uses \is_category() @uses \is_tag() @uses \is_tax() @codeCoverageIgnore
[ "Determines", "whether", "a", "custom", "template", "for", "a", "taxonomy", "term", "should", "be", "loaded", "." ]
1a98cd15e37595a85b242242f88fee38c4e36acc
https://github.com/goblindegook/Syllables/blob/1a98cd15e37595a85b242242f88fee38c4e36acc/src/Template/Loader/Taxonomy.php#L73-L77
15,538
activecollab/databasestructure
src/Builder/BaseTypeClassBuilder.php
BaseTypeClassBuilder.buildFields
private function buildFields(array $fields, $indent, array &$result) { $stringified_field_names = []; $fields_with_default_value = []; foreach ($fields as $field) { if ($field instanceof ScalarField && $field->getShouldBeAddedToModel()) { $stringified_field_names[] = var_export($field->getName(), true); if ($field->getName() != 'id' && $field->getDefaultValue() !== null) { $fields_with_default_value[$field->getName()] = $field->getDefaultValue(); } } } $result[] = ''; $result[] = $indent . '/**'; $result[] = $indent . ' * Table fields that are managed by this entity.'; $result[] = $indent . ' *'; $result[] = $indent . ' * @var array'; $result[] = $indent . ' */'; $result[] = $indent . 'protected $fields = [' . implode(', ', $stringified_field_names) . '];'; if (count($fields_with_default_value)) { $result[] = ''; $result[] = $indent . '/**'; $result[] = $indent . ' * List of default field values.'; $result[] = $indent . ' *'; $result[] = $indent . ' * @var array'; $result[] = $indent . ' */'; $result[] = $indent . 'protected $default_field_values = ['; foreach ($fields_with_default_value as $field_name => $default_value) { $result[] = $indent . ' ' . var_export($field_name, true) . ' => ' . var_export($default_value, true) . ','; } $result[] = $indent . '];'; } }
php
private function buildFields(array $fields, $indent, array &$result) { $stringified_field_names = []; $fields_with_default_value = []; foreach ($fields as $field) { if ($field instanceof ScalarField && $field->getShouldBeAddedToModel()) { $stringified_field_names[] = var_export($field->getName(), true); if ($field->getName() != 'id' && $field->getDefaultValue() !== null) { $fields_with_default_value[$field->getName()] = $field->getDefaultValue(); } } } $result[] = ''; $result[] = $indent . '/**'; $result[] = $indent . ' * Table fields that are managed by this entity.'; $result[] = $indent . ' *'; $result[] = $indent . ' * @var array'; $result[] = $indent . ' */'; $result[] = $indent . 'protected $fields = [' . implode(', ', $stringified_field_names) . '];'; if (count($fields_with_default_value)) { $result[] = ''; $result[] = $indent . '/**'; $result[] = $indent . ' * List of default field values.'; $result[] = $indent . ' *'; $result[] = $indent . ' * @var array'; $result[] = $indent . ' */'; $result[] = $indent . 'protected $default_field_values = ['; foreach ($fields_with_default_value as $field_name => $default_value) { $result[] = $indent . ' ' . var_export($field_name, true) . ' => ' . var_export($default_value, true) . ','; } $result[] = $indent . '];'; } }
[ "private", "function", "buildFields", "(", "array", "$", "fields", ",", "$", "indent", ",", "array", "&", "$", "result", ")", "{", "$", "stringified_field_names", "=", "[", "]", ";", "$", "fields_with_default_value", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "$", "field", "instanceof", "ScalarField", "&&", "$", "field", "->", "getShouldBeAddedToModel", "(", ")", ")", "{", "$", "stringified_field_names", "[", "]", "=", "var_export", "(", "$", "field", "->", "getName", "(", ")", ",", "true", ")", ";", "if", "(", "$", "field", "->", "getName", "(", ")", "!=", "'id'", "&&", "$", "field", "->", "getDefaultValue", "(", ")", "!==", "null", ")", "{", "$", "fields_with_default_value", "[", "$", "field", "->", "getName", "(", ")", "]", "=", "$", "field", "->", "getDefaultValue", "(", ")", ";", "}", "}", "}", "$", "result", "[", "]", "=", "''", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'/**'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' * Table fields that are managed by this entity.'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' *'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' * @var array'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' */'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'protected $fields = ['", ".", "implode", "(", "', '", ",", "$", "stringified_field_names", ")", ".", "'];'", ";", "if", "(", "count", "(", "$", "fields_with_default_value", ")", ")", "{", "$", "result", "[", "]", "=", "''", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'/**'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' * List of default field values.'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' *'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' * @var array'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' */'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'protected $default_field_values = ['", ";", "foreach", "(", "$", "fields_with_default_value", "as", "$", "field_name", "=>", "$", "default_value", ")", "{", "$", "result", "[", "]", "=", "$", "indent", ".", "' '", ".", "var_export", "(", "$", "field_name", ",", "true", ")", ".", "' => '", ".", "var_export", "(", "$", "default_value", ",", "true", ")", ".", "','", ";", "}", "$", "result", "[", "]", "=", "$", "indent", ".", "'];'", ";", "}", "}" ]
Build field definitions. @param FieldInterface[] $fields @param string $indent @param array $result
[ "Build", "field", "definitions", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/BaseTypeClassBuilder.php#L273-L311
15,539
activecollab/databasestructure
src/Builder/BaseTypeClassBuilder.php
BaseTypeClassBuilder.buildGeneratedFields
public function buildGeneratedFields(array $generated_field_names, $indent, array &$result) { $result[] = ''; $result[] = $indent . '/**'; $result[] = $indent . ' * Generated fields that are loaded, but not managed by the entity..'; $result[] = $indent . ' *'; $result[] = $indent . ' * @var array'; $result[] = $indent . ' */'; $result[] = $indent . 'protected $generated_fields = [' . implode(', ', array_map(function ($field_name) { return var_export($field_name, true); }, $generated_field_names)) . '];'; }
php
public function buildGeneratedFields(array $generated_field_names, $indent, array &$result) { $result[] = ''; $result[] = $indent . '/**'; $result[] = $indent . ' * Generated fields that are loaded, but not managed by the entity..'; $result[] = $indent . ' *'; $result[] = $indent . ' * @var array'; $result[] = $indent . ' */'; $result[] = $indent . 'protected $generated_fields = [' . implode(', ', array_map(function ($field_name) { return var_export($field_name, true); }, $generated_field_names)) . '];'; }
[ "public", "function", "buildGeneratedFields", "(", "array", "$", "generated_field_names", ",", "$", "indent", ",", "array", "&", "$", "result", ")", "{", "$", "result", "[", "]", "=", "''", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'/**'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' * Generated fields that are loaded, but not managed by the entity..'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' *'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' * @var array'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' */'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'protected $generated_fields = ['", ".", "implode", "(", "', '", ",", "array_map", "(", "function", "(", "$", "field_name", ")", "{", "return", "var_export", "(", "$", "field_name", ",", "true", ")", ";", "}", ",", "$", "generated_field_names", ")", ")", ".", "'];'", ";", "}" ]
Build a list of generated fields. @param string[] $generated_field_names @param string $indent @param array $result
[ "Build", "a", "list", "of", "generated", "fields", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/BaseTypeClassBuilder.php#L320-L331
15,540
activecollab/databasestructure
src/Builder/BaseTypeClassBuilder.php
BaseTypeClassBuilder.buildGeneratedFieldGetter
private function buildGeneratedFieldGetter($field_name, $caster, $indent, array &$result) { $short_getter = null; switch ($caster) { case ValueCasterInterface::CAST_INT: $return_type = 'int'; break; case ValueCasterInterface::CAST_FLOAT: $return_type = 'float'; break; case ValueCasterInterface::CAST_BOOL: $return_type = 'bool'; break; case ValueCasterInterface::CAST_DATE: $return_type = '\\' . DateValueInterface::class; break; case ValueCasterInterface::CAST_DATETIME: $return_type = '\\' . DateTimeValueInterface::class; break; case ValueCasterInterface::CAST_JSON: $return_type = 'mixed'; break; default: $return_type = 'string'; } if ($this->useShortGetterName($field_name)) { $short_getter = $this->getShortGetterName($field_name); $lines[] = ''; $lines[] = '/**'; $lines[] = ' * Return value of ' . $field_name . ' field.'; $lines[] = ' *'; $lines[] = ' * @return ' . $return_type; $lines[] = ' */'; $lines[] = 'public function ' . $short_getter . '()'; $lines[] = '{'; $lines[] = ' return $this->getFieldValue(' . var_export($field_name, true) . ');'; $lines[] = '}'; } $lines[] = ''; $lines[] = '/**'; $lines[] = ' * Return value of ' . $field_name . ' field.'; $lines[] = ' *'; $lines[] = ' * @return ' . $return_type; if ($short_getter && $this->getStructure()->getConfig('deprecate_long_bool_field_getter')) { $lines[] = " * @deprecated use $short_getter()"; } $lines[] = ' */'; $lines[] = 'public function ' . $this->getGetterName($field_name) . '()'; $lines[] = '{'; $lines[] = ' return $this->getFieldValue(' . var_export($field_name, true) . ');'; $lines[] = '}'; $lines[] = ''; foreach ($lines as $line) { $result[] = $line ? $indent . $line : ''; } }
php
private function buildGeneratedFieldGetter($field_name, $caster, $indent, array &$result) { $short_getter = null; switch ($caster) { case ValueCasterInterface::CAST_INT: $return_type = 'int'; break; case ValueCasterInterface::CAST_FLOAT: $return_type = 'float'; break; case ValueCasterInterface::CAST_BOOL: $return_type = 'bool'; break; case ValueCasterInterface::CAST_DATE: $return_type = '\\' . DateValueInterface::class; break; case ValueCasterInterface::CAST_DATETIME: $return_type = '\\' . DateTimeValueInterface::class; break; case ValueCasterInterface::CAST_JSON: $return_type = 'mixed'; break; default: $return_type = 'string'; } if ($this->useShortGetterName($field_name)) { $short_getter = $this->getShortGetterName($field_name); $lines[] = ''; $lines[] = '/**'; $lines[] = ' * Return value of ' . $field_name . ' field.'; $lines[] = ' *'; $lines[] = ' * @return ' . $return_type; $lines[] = ' */'; $lines[] = 'public function ' . $short_getter . '()'; $lines[] = '{'; $lines[] = ' return $this->getFieldValue(' . var_export($field_name, true) . ');'; $lines[] = '}'; } $lines[] = ''; $lines[] = '/**'; $lines[] = ' * Return value of ' . $field_name . ' field.'; $lines[] = ' *'; $lines[] = ' * @return ' . $return_type; if ($short_getter && $this->getStructure()->getConfig('deprecate_long_bool_field_getter')) { $lines[] = " * @deprecated use $short_getter()"; } $lines[] = ' */'; $lines[] = 'public function ' . $this->getGetterName($field_name) . '()'; $lines[] = '{'; $lines[] = ' return $this->getFieldValue(' . var_export($field_name, true) . ');'; $lines[] = '}'; $lines[] = ''; foreach ($lines as $line) { $result[] = $line ? $indent . $line : ''; } }
[ "private", "function", "buildGeneratedFieldGetter", "(", "$", "field_name", ",", "$", "caster", ",", "$", "indent", ",", "array", "&", "$", "result", ")", "{", "$", "short_getter", "=", "null", ";", "switch", "(", "$", "caster", ")", "{", "case", "ValueCasterInterface", "::", "CAST_INT", ":", "$", "return_type", "=", "'int'", ";", "break", ";", "case", "ValueCasterInterface", "::", "CAST_FLOAT", ":", "$", "return_type", "=", "'float'", ";", "break", ";", "case", "ValueCasterInterface", "::", "CAST_BOOL", ":", "$", "return_type", "=", "'bool'", ";", "break", ";", "case", "ValueCasterInterface", "::", "CAST_DATE", ":", "$", "return_type", "=", "'\\\\'", ".", "DateValueInterface", "::", "class", ";", "break", ";", "case", "ValueCasterInterface", "::", "CAST_DATETIME", ":", "$", "return_type", "=", "'\\\\'", ".", "DateTimeValueInterface", "::", "class", ";", "break", ";", "case", "ValueCasterInterface", "::", "CAST_JSON", ":", "$", "return_type", "=", "'mixed'", ";", "break", ";", "default", ":", "$", "return_type", "=", "'string'", ";", "}", "if", "(", "$", "this", "->", "useShortGetterName", "(", "$", "field_name", ")", ")", "{", "$", "short_getter", "=", "$", "this", "->", "getShortGetterName", "(", "$", "field_name", ")", ";", "$", "lines", "[", "]", "=", "''", ";", "$", "lines", "[", "]", "=", "'/**'", ";", "$", "lines", "[", "]", "=", "' * Return value of '", ".", "$", "field_name", ".", "' field.'", ";", "$", "lines", "[", "]", "=", "' *'", ";", "$", "lines", "[", "]", "=", "' * @return '", ".", "$", "return_type", ";", "$", "lines", "[", "]", "=", "' */'", ";", "$", "lines", "[", "]", "=", "'public function '", ".", "$", "short_getter", ".", "'()'", ";", "$", "lines", "[", "]", "=", "'{'", ";", "$", "lines", "[", "]", "=", "' return $this->getFieldValue('", ".", "var_export", "(", "$", "field_name", ",", "true", ")", ".", "');'", ";", "$", "lines", "[", "]", "=", "'}'", ";", "}", "$", "lines", "[", "]", "=", "''", ";", "$", "lines", "[", "]", "=", "'/**'", ";", "$", "lines", "[", "]", "=", "' * Return value of '", ".", "$", "field_name", ".", "' field.'", ";", "$", "lines", "[", "]", "=", "' *'", ";", "$", "lines", "[", "]", "=", "' * @return '", ".", "$", "return_type", ";", "if", "(", "$", "short_getter", "&&", "$", "this", "->", "getStructure", "(", ")", "->", "getConfig", "(", "'deprecate_long_bool_field_getter'", ")", ")", "{", "$", "lines", "[", "]", "=", "\" * @deprecated use $short_getter()\"", ";", "}", "$", "lines", "[", "]", "=", "' */'", ";", "$", "lines", "[", "]", "=", "'public function '", ".", "$", "this", "->", "getGetterName", "(", "$", "field_name", ")", ".", "'()'", ";", "$", "lines", "[", "]", "=", "'{'", ";", "$", "lines", "[", "]", "=", "' return $this->getFieldValue('", ".", "var_export", "(", "$", "field_name", ",", "true", ")", ".", "');'", ";", "$", "lines", "[", "]", "=", "'}'", ";", "$", "lines", "[", "]", "=", "''", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "result", "[", "]", "=", "$", "line", "?", "$", "indent", ".", "$", "line", ":", "''", ";", "}", "}" ]
Build getter for generated field. @param string $field_name @param string $caster @param string $indent @param array $result
[ "Build", "getter", "for", "generated", "field", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/BaseTypeClassBuilder.php#L466-L528
15,541
activecollab/databasestructure
src/Builder/BaseTypeClassBuilder.php
BaseTypeClassBuilder.useShortGetterName
private function useShortGetterName($field_name) { return substr($field_name, 0, 3) === 'is_' || in_array(substr($field_name, 0, 4), ['has_', 'had_', 'was_']) || in_array(substr($field_name, 0, 5), ['were_', 'have_']); }
php
private function useShortGetterName($field_name) { return substr($field_name, 0, 3) === 'is_' || in_array(substr($field_name, 0, 4), ['has_', 'had_', 'was_']) || in_array(substr($field_name, 0, 5), ['were_', 'have_']); }
[ "private", "function", "useShortGetterName", "(", "$", "field_name", ")", "{", "return", "substr", "(", "$", "field_name", ",", "0", ",", "3", ")", "===", "'is_'", "||", "in_array", "(", "substr", "(", "$", "field_name", ",", "0", ",", "4", ")", ",", "[", "'has_'", ",", "'had_'", ",", "'was_'", "]", ")", "||", "in_array", "(", "substr", "(", "$", "field_name", ",", "0", ",", "5", ")", ",", "[", "'were_'", ",", "'have_'", "]", ")", ";", "}" ]
Return true if we should use a short getter name. @param string $field_name @return bool
[ "Return", "true", "if", "we", "should", "use", "a", "short", "getter", "name", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/BaseTypeClassBuilder.php#L536-L539
15,542
activecollab/databasestructure
src/Builder/BaseTypeClassBuilder.php
BaseTypeClassBuilder.buildJsonSerialize
private function buildJsonSerialize(array $serialize, $indent, array &$result) { if (count($serialize)) { $result[] = ''; $result[] = $indent . '/**'; $result[] = $indent . ' * Prepare object properties so they can be serialized to JSON.'; $result[] = $indent . ' *'; $result[] = $indent . ' * @return array'; $result[] = $indent . ' */'; $result[] = $indent . 'public function jsonSerialize()'; $result[] = $indent . '{'; $result[] = $indent . ' return array_merge(parent::jsonSerialize(), ['; foreach ($serialize as $field) { $result[] = $indent . ' ' . var_export($field, true) . ' => $this->' . $this->getGetterName($field) . '(),'; } $result[] = $indent . ' ]);'; $result[] = $indent . '}'; } }
php
private function buildJsonSerialize(array $serialize, $indent, array &$result) { if (count($serialize)) { $result[] = ''; $result[] = $indent . '/**'; $result[] = $indent . ' * Prepare object properties so they can be serialized to JSON.'; $result[] = $indent . ' *'; $result[] = $indent . ' * @return array'; $result[] = $indent . ' */'; $result[] = $indent . 'public function jsonSerialize()'; $result[] = $indent . '{'; $result[] = $indent . ' return array_merge(parent::jsonSerialize(), ['; foreach ($serialize as $field) { $result[] = $indent . ' ' . var_export($field, true) . ' => $this->' . $this->getGetterName($field) . '(),'; } $result[] = $indent . ' ]);'; $result[] = $indent . '}'; } }
[ "private", "function", "buildJsonSerialize", "(", "array", "$", "serialize", ",", "$", "indent", ",", "array", "&", "$", "result", ")", "{", "if", "(", "count", "(", "$", "serialize", ")", ")", "{", "$", "result", "[", "]", "=", "''", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'/**'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' * Prepare object properties so they can be serialized to JSON.'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' *'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' * @return array'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' */'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'public function jsonSerialize()'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'{'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "' return array_merge(parent::jsonSerialize(), ['", ";", "foreach", "(", "$", "serialize", "as", "$", "field", ")", "{", "$", "result", "[", "]", "=", "$", "indent", ".", "' '", ".", "var_export", "(", "$", "field", ",", "true", ")", ".", "' => $this->'", ".", "$", "this", "->", "getGetterName", "(", "$", "field", ")", ".", "'(),'", ";", "}", "$", "result", "[", "]", "=", "$", "indent", ".", "' ]);'", ";", "$", "result", "[", "]", "=", "$", "indent", ".", "'}'", ";", "}", "}" ]
Build JSON serialize method, if we need to serialize extra fields. @param array $serialize @param string $indent @param array $result
[ "Build", "JSON", "serialize", "method", "if", "we", "need", "to", "serialize", "extra", "fields", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/BaseTypeClassBuilder.php#L548-L568
15,543
activecollab/databasestructure
src/Builder/BaseTypeClassBuilder.php
BaseTypeClassBuilder.buildValidatePresenceLinesForScalarField
private function buildValidatePresenceLinesForScalarField(ScalarField $field, $line_indent, array &$validator_lines) { if ($field instanceof RequiredInterface && $field instanceof UniqueInterface) { if ($field->isRequired() && $field->isUnique()) { $validator_lines[] = $line_indent . $this->buildValidatePresenceAndUniquenessLine($field->getName(), $field->getUniquenessContext()); } elseif ($field->isRequired()) { $validator_lines[] = $line_indent . $this->buildValidatePresenceLine($field->getName()); } elseif ($field->isUnique()) { $validator_lines[] = $line_indent . $this->buildValidateUniquenessLine($field->getName(), $field->getUniquenessContext()); } } elseif ($field instanceof RequiredInterface && $field->isRequired()) { $validator_lines[] = $line_indent . $this->buildValidatePresenceLine($field->getName()); } elseif ($field instanceof UniqueInterface && $field->isUnique()) { $validator_lines[] = $line_indent . $this->buildValidateUniquenessLine($field->getName(), $field->getUniquenessContext()); } }
php
private function buildValidatePresenceLinesForScalarField(ScalarField $field, $line_indent, array &$validator_lines) { if ($field instanceof RequiredInterface && $field instanceof UniqueInterface) { if ($field->isRequired() && $field->isUnique()) { $validator_lines[] = $line_indent . $this->buildValidatePresenceAndUniquenessLine($field->getName(), $field->getUniquenessContext()); } elseif ($field->isRequired()) { $validator_lines[] = $line_indent . $this->buildValidatePresenceLine($field->getName()); } elseif ($field->isUnique()) { $validator_lines[] = $line_indent . $this->buildValidateUniquenessLine($field->getName(), $field->getUniquenessContext()); } } elseif ($field instanceof RequiredInterface && $field->isRequired()) { $validator_lines[] = $line_indent . $this->buildValidatePresenceLine($field->getName()); } elseif ($field instanceof UniqueInterface && $field->isUnique()) { $validator_lines[] = $line_indent . $this->buildValidateUniquenessLine($field->getName(), $field->getUniquenessContext()); } }
[ "private", "function", "buildValidatePresenceLinesForScalarField", "(", "ScalarField", "$", "field", ",", "$", "line_indent", ",", "array", "&", "$", "validator_lines", ")", "{", "if", "(", "$", "field", "instanceof", "RequiredInterface", "&&", "$", "field", "instanceof", "UniqueInterface", ")", "{", "if", "(", "$", "field", "->", "isRequired", "(", ")", "&&", "$", "field", "->", "isUnique", "(", ")", ")", "{", "$", "validator_lines", "[", "]", "=", "$", "line_indent", ".", "$", "this", "->", "buildValidatePresenceAndUniquenessLine", "(", "$", "field", "->", "getName", "(", ")", ",", "$", "field", "->", "getUniquenessContext", "(", ")", ")", ";", "}", "elseif", "(", "$", "field", "->", "isRequired", "(", ")", ")", "{", "$", "validator_lines", "[", "]", "=", "$", "line_indent", ".", "$", "this", "->", "buildValidatePresenceLine", "(", "$", "field", "->", "getName", "(", ")", ")", ";", "}", "elseif", "(", "$", "field", "->", "isUnique", "(", ")", ")", "{", "$", "validator_lines", "[", "]", "=", "$", "line_indent", ".", "$", "this", "->", "buildValidateUniquenessLine", "(", "$", "field", "->", "getName", "(", ")", ",", "$", "field", "->", "getUniquenessContext", "(", ")", ")", ";", "}", "}", "elseif", "(", "$", "field", "instanceof", "RequiredInterface", "&&", "$", "field", "->", "isRequired", "(", ")", ")", "{", "$", "validator_lines", "[", "]", "=", "$", "line_indent", ".", "$", "this", "->", "buildValidatePresenceLine", "(", "$", "field", "->", "getName", "(", ")", ")", ";", "}", "elseif", "(", "$", "field", "instanceof", "UniqueInterface", "&&", "$", "field", "->", "isUnique", "(", ")", ")", "{", "$", "validator_lines", "[", "]", "=", "$", "line_indent", ".", "$", "this", "->", "buildValidateUniquenessLine", "(", "$", "field", "->", "getName", "(", ")", ",", "$", "field", "->", "getUniquenessContext", "(", ")", ")", ";", "}", "}" ]
Build validate lines for scalar fields. @param ScalarField $field @param string $line_indent @param array $validator_lines
[ "Build", "validate", "lines", "for", "scalar", "fields", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/BaseTypeClassBuilder.php#L628-L643
15,544
activecollab/databasestructure
src/Builder/BaseTypeClassBuilder.php
BaseTypeClassBuilder.buildValidateUniquenessLine
private function buildValidateUniquenessLine($field_name, array $context) { $field_names = [var_export($field_name, true)]; foreach ($context as $v) { $field_names[] = var_export($v, true); } return '$validator->unique(' . implode(', ', $field_names) . ');'; }
php
private function buildValidateUniquenessLine($field_name, array $context) { $field_names = [var_export($field_name, true)]; foreach ($context as $v) { $field_names[] = var_export($v, true); } return '$validator->unique(' . implode(', ', $field_names) . ');'; }
[ "private", "function", "buildValidateUniquenessLine", "(", "$", "field_name", ",", "array", "$", "context", ")", "{", "$", "field_names", "=", "[", "var_export", "(", "$", "field_name", ",", "true", ")", "]", ";", "foreach", "(", "$", "context", "as", "$", "v", ")", "{", "$", "field_names", "[", "]", "=", "var_export", "(", "$", "v", ",", "true", ")", ";", "}", "return", "'$validator->unique('", ".", "implode", "(", "', '", ",", "$", "field_names", ")", ".", "');'", ";", "}" ]
Build validator uniqueness line. @param string $field_name @param array $context @return string
[ "Build", "validator", "uniqueness", "line", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/BaseTypeClassBuilder.php#L663-L672
15,545
e0ipso/drupal-unit-autoload
src/AutoloaderBootstrap.php
AutoloaderBootstrap.registerDrupalPaths
protected function registerDrupalPaths($composer_config) { if (empty($composer_config['class-location'])) { return; } $this->loader->setClassMap((array) $composer_config['class-location']); $this->load(); }
php
protected function registerDrupalPaths($composer_config) { if (empty($composer_config['class-location'])) { return; } $this->loader->setClassMap((array) $composer_config['class-location']); $this->load(); }
[ "protected", "function", "registerDrupalPaths", "(", "$", "composer_config", ")", "{", "if", "(", "empty", "(", "$", "composer_config", "[", "'class-location'", "]", ")", ")", "{", "return", ";", "}", "$", "this", "->", "loader", "->", "setClassMap", "(", "(", "array", ")", "$", "composer_config", "[", "'class-location'", "]", ")", ";", "$", "this", "->", "load", "(", ")", ";", "}" ]
Register the path based autoloader. @param object $composer_config The Composer configuration.
[ "Register", "the", "path", "based", "autoloader", "." ]
7ce147b269c7333eca31e2cd04b736d6274b9cbf
https://github.com/e0ipso/drupal-unit-autoload/blob/7ce147b269c7333eca31e2cd04b736d6274b9cbf/src/AutoloaderBootstrap.php#L102-L108
15,546
e0ipso/drupal-unit-autoload
src/AutoloaderBootstrap.php
AutoloaderBootstrap.registerPsr
protected function registerPsr(array $composer_config) { $psr0 = $psr4 = array(); if (!empty($composer_config['psr-0'])) { $psr0 = (array) $composer_config['psr-0']; } if (!empty($composer_config['psr-4'])) { $psr4 = (array) $composer_config['psr-4']; } if (empty($psr4) && empty($psr0)) { return; } $this->loader->setPsrClassMap(array( 'psr-0' => $psr0, 'psr-4' => $psr4, )); $this->loader->registerPsr($this->classLoader); }
php
protected function registerPsr(array $composer_config) { $psr0 = $psr4 = array(); if (!empty($composer_config['psr-0'])) { $psr0 = (array) $composer_config['psr-0']; } if (!empty($composer_config['psr-4'])) { $psr4 = (array) $composer_config['psr-4']; } if (empty($psr4) && empty($psr0)) { return; } $this->loader->setPsrClassMap(array( 'psr-0' => $psr0, 'psr-4' => $psr4, )); $this->loader->registerPsr($this->classLoader); }
[ "protected", "function", "registerPsr", "(", "array", "$", "composer_config", ")", "{", "$", "psr0", "=", "$", "psr4", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "composer_config", "[", "'psr-0'", "]", ")", ")", "{", "$", "psr0", "=", "(", "array", ")", "$", "composer_config", "[", "'psr-0'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "composer_config", "[", "'psr-4'", "]", ")", ")", "{", "$", "psr4", "=", "(", "array", ")", "$", "composer_config", "[", "'psr-4'", "]", ";", "}", "if", "(", "empty", "(", "$", "psr4", ")", "&&", "empty", "(", "$", "psr0", ")", ")", "{", "return", ";", "}", "$", "this", "->", "loader", "->", "setPsrClassMap", "(", "array", "(", "'psr-0'", "=>", "$", "psr0", ",", "'psr-4'", "=>", "$", "psr4", ",", ")", ")", ";", "$", "this", "->", "loader", "->", "registerPsr", "(", "$", "this", "->", "classLoader", ")", ";", "}" ]
Use Composer's autoloader to register the PRS-0 and PSR-4 paths. @param array $composer_config The Composer configuration.
[ "Use", "Composer", "s", "autoloader", "to", "register", "the", "PRS", "-", "0", "and", "PSR", "-", "4", "paths", "." ]
7ce147b269c7333eca31e2cd04b736d6274b9cbf
https://github.com/e0ipso/drupal-unit-autoload/blob/7ce147b269c7333eca31e2cd04b736d6274b9cbf/src/AutoloaderBootstrap.php#L116-L132
15,547
gintonicweb/GintonicCMS
src/Controller/Admin/UsersController.php
UsersController.index
public function index() { $action = $this->Crud->action(); $action->config('scaffold.fields_blacklist', ['created', 'modified']); $this->Crud->execute(); }
php
public function index() { $action = $this->Crud->action(); $action->config('scaffold.fields_blacklist', ['created', 'modified']); $this->Crud->execute(); }
[ "public", "function", "index", "(", ")", "{", "$", "action", "=", "$", "this", "->", "Crud", "->", "action", "(", ")", ";", "$", "action", "->", "config", "(", "'scaffold.fields_blacklist'", ",", "[", "'created'", ",", "'modified'", "]", ")", ";", "$", "this", "->", "Crud", "->", "execute", "(", ")", ";", "}" ]
Index method Don't show created and modified fields @return void
[ "Index", "method", "Don", "t", "show", "created", "and", "modified", "fields" ]
b34445fecea56a7d432d0f3e2f988cde8ead746b
https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Controller/Admin/UsersController.php#L57-L62
15,548
gintonicweb/GintonicCMS
src/Controller/Admin/UsersController.php
UsersController.view
public function view() { $action = $this->Crud->action(); $action->config('scaffold.relations', false); $this->Crud->execute(); }
php
public function view() { $action = $this->Crud->action(); $action->config('scaffold.relations', false); $this->Crud->execute(); }
[ "public", "function", "view", "(", ")", "{", "$", "action", "=", "$", "this", "->", "Crud", "->", "action", "(", ")", ";", "$", "action", "->", "config", "(", "'scaffold.relations'", ",", "false", ")", ";", "$", "this", "->", "Crud", "->", "execute", "(", ")", ";", "}" ]
View method Related models are blacklisted because the role is already present in the main user panel @return void
[ "View", "method", "Related", "models", "are", "blacklisted", "because", "the", "role", "is", "already", "present", "in", "the", "main", "user", "panel" ]
b34445fecea56a7d432d0f3e2f988cde8ead746b
https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Controller/Admin/UsersController.php#L71-L76
15,549
bestit/commercetools-order-export-bundle
src/OrderVisitor.php
OrderVisitor.getNextOrderCollection
private function getNextOrderCollection(int $renderedArticleCount) { $count = $this->count(); $logger = $this->getLogger(); $orderCollection = null; $withPagination = $this->withPagination(); $logger->debug( 'Tries to load the next order collection', ['count' => $count, 'withPagination' => $withPagination] ); if ((!$withPagination) || ($renderedArticleCount < $count)) { if ($withPagination) { $this->getOrderQuery()->offset($renderedArticleCount); } $this->loadOrderCollection(); $orderCollection = $this->getOrderCollection(); } return $orderCollection; }
php
private function getNextOrderCollection(int $renderedArticleCount) { $count = $this->count(); $logger = $this->getLogger(); $orderCollection = null; $withPagination = $this->withPagination(); $logger->debug( 'Tries to load the next order collection', ['count' => $count, 'withPagination' => $withPagination] ); if ((!$withPagination) || ($renderedArticleCount < $count)) { if ($withPagination) { $this->getOrderQuery()->offset($renderedArticleCount); } $this->loadOrderCollection(); $orderCollection = $this->getOrderCollection(); } return $orderCollection; }
[ "private", "function", "getNextOrderCollection", "(", "int", "$", "renderedArticleCount", ")", "{", "$", "count", "=", "$", "this", "->", "count", "(", ")", ";", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "$", "orderCollection", "=", "null", ";", "$", "withPagination", "=", "$", "this", "->", "withPagination", "(", ")", ";", "$", "logger", "->", "debug", "(", "'Tries to load the next order collection'", ",", "[", "'count'", "=>", "$", "count", ",", "'withPagination'", "=>", "$", "withPagination", "]", ")", ";", "if", "(", "(", "!", "$", "withPagination", ")", "||", "(", "$", "renderedArticleCount", "<", "$", "count", ")", ")", "{", "if", "(", "$", "withPagination", ")", "{", "$", "this", "->", "getOrderQuery", "(", ")", "->", "offset", "(", "$", "renderedArticleCount", ")", ";", "}", "$", "this", "->", "loadOrderCollection", "(", ")", ";", "$", "orderCollection", "=", "$", "this", "->", "getOrderCollection", "(", ")", ";", "}", "return", "$", "orderCollection", ";", "}" ]
Returns the next order collection or void. @param int $renderedArticleCount How many articles are rendered allready. @return OrderCollection|void
[ "Returns", "the", "next", "order", "collection", "or", "void", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L151-L174
15,550
bestit/commercetools-order-export-bundle
src/OrderVisitor.php
OrderVisitor.getTotalCount
private function getTotalCount(): int { if ($this->totalCount === -1) { $this->setTotalCount($this->getLastResponse()->getTotal()); } return $this->totalCount; }
php
private function getTotalCount(): int { if ($this->totalCount === -1) { $this->setTotalCount($this->getLastResponse()->getTotal()); } return $this->totalCount; }
[ "private", "function", "getTotalCount", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "totalCount", "===", "-", "1", ")", "{", "$", "this", "->", "setTotalCount", "(", "$", "this", "->", "getLastResponse", "(", ")", "->", "getTotal", "(", ")", ")", ";", "}", "return", "$", "this", "->", "totalCount", ";", "}" ]
Returns the total count of found orders. @return int
[ "Returns", "the", "total", "count", "of", "found", "orders", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L206-L213
15,551
bestit/commercetools-order-export-bundle
src/OrderVisitor.php
OrderVisitor.loadOrderCollection
private function loadOrderCollection(): OrderVisitor { $logger = $this->getLogger(); /** @var PagedQueryResponse $response */ $response = $this->getClient()->execute($this->getOrderQuery()); if ($response instanceof ErrorResponse) { $logger->error('Got error response loading the orders.', ['response' => $response]); throw new RuntimeException($response->getMessage()); } else { $logger->debug('Found some orders.', ['response' => $response]); } $this->setLastResponse($response); $this->setOrderCollection($this->getLastResponse()->toObject()); return $this; }
php
private function loadOrderCollection(): OrderVisitor { $logger = $this->getLogger(); /** @var PagedQueryResponse $response */ $response = $this->getClient()->execute($this->getOrderQuery()); if ($response instanceof ErrorResponse) { $logger->error('Got error response loading the orders.', ['response' => $response]); throw new RuntimeException($response->getMessage()); } else { $logger->debug('Found some orders.', ['response' => $response]); } $this->setLastResponse($response); $this->setOrderCollection($this->getLastResponse()->toObject()); return $this; }
[ "private", "function", "loadOrderCollection", "(", ")", ":", "OrderVisitor", "{", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "/** @var PagedQueryResponse $response */", "$", "response", "=", "$", "this", "->", "getClient", "(", ")", "->", "execute", "(", "$", "this", "->", "getOrderQuery", "(", ")", ")", ";", "if", "(", "$", "response", "instanceof", "ErrorResponse", ")", "{", "$", "logger", "->", "error", "(", "'Got error response loading the orders.'", ",", "[", "'response'", "=>", "$", "response", "]", ")", ";", "throw", "new", "RuntimeException", "(", "$", "response", "->", "getMessage", "(", ")", ")", ";", "}", "else", "{", "$", "logger", "->", "debug", "(", "'Found some orders.'", ",", "[", "'response'", "=>", "$", "response", "]", ")", ";", "}", "$", "this", "->", "setLastResponse", "(", "$", "response", ")", ";", "$", "this", "->", "setOrderCollection", "(", "$", "this", "->", "getLastResponse", "(", ")", "->", "toObject", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Loads the order collection. @return OrderVisitor
[ "Loads", "the", "order", "collection", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L219-L239
15,552
bestit/commercetools-order-export-bundle
src/OrderVisitor.php
OrderVisitor.loadOrderQuery
private function loadOrderQuery(): OrderVisitor { $logger = $this->getLogger(); $query = new OrderQueryRequest(); if ($wheres = $this->getDefaultWhere()) { $logger->debug('Added where-clause to fech orders.', ['predicates' => $wheres]); array_walk($wheres, function (string $where) use ($logger, $query) { $query->where($where); }); } else { $logger->debug('No where-clause to fetch orders.'); } $this->setOrderQuery($query); return $this; }
php
private function loadOrderQuery(): OrderVisitor { $logger = $this->getLogger(); $query = new OrderQueryRequest(); if ($wheres = $this->getDefaultWhere()) { $logger->debug('Added where-clause to fech orders.', ['predicates' => $wheres]); array_walk($wheres, function (string $where) use ($logger, $query) { $query->where($where); }); } else { $logger->debug('No where-clause to fetch orders.'); } $this->setOrderQuery($query); return $this; }
[ "private", "function", "loadOrderQuery", "(", ")", ":", "OrderVisitor", "{", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "$", "query", "=", "new", "OrderQueryRequest", "(", ")", ";", "if", "(", "$", "wheres", "=", "$", "this", "->", "getDefaultWhere", "(", ")", ")", "{", "$", "logger", "->", "debug", "(", "'Added where-clause to fech orders.'", ",", "[", "'predicates'", "=>", "$", "wheres", "]", ")", ";", "array_walk", "(", "$", "wheres", ",", "function", "(", "string", "$", "where", ")", "use", "(", "$", "logger", ",", "$", "query", ")", "{", "$", "query", "->", "where", "(", "$", "where", ")", ";", "}", ")", ";", "}", "else", "{", "$", "logger", "->", "debug", "(", "'No where-clause to fetch orders.'", ")", ";", "}", "$", "this", "->", "setOrderQuery", "(", "$", "query", ")", ";", "return", "$", "this", ";", "}" ]
Returns the order query request. @return OrderVisitor
[ "Returns", "the", "order", "query", "request", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L245-L263
15,553
bestit/commercetools-order-export-bundle
src/OrderVisitor.php
OrderVisitor.withPagination
private function withPagination(bool $newStatus = true): bool { $oldStatus = $this->withPagination; if (func_num_args()) { $this->withPagination = $newStatus; } return $oldStatus; }
php
private function withPagination(bool $newStatus = true): bool { $oldStatus = $this->withPagination; if (func_num_args()) { $this->withPagination = $newStatus; } return $oldStatus; }
[ "private", "function", "withPagination", "(", "bool", "$", "newStatus", "=", "true", ")", ":", "bool", "{", "$", "oldStatus", "=", "$", "this", "->", "withPagination", ";", "if", "(", "func_num_args", "(", ")", ")", "{", "$", "this", "->", "withPagination", "=", "$", "newStatus", ";", "}", "return", "$", "oldStatus", ";", "}" ]
Sets the pagination status for this list. @param bool $newStatus @return bool
[ "Sets", "the", "pagination", "status", "for", "this", "list", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L342-L351
15,554
bestit/commercetools-order-export-bundle
src/OrderVisitor.php
OrderVisitor.yieldOrders
public function yieldOrders() { $usedIndex = 0; $orderCollection = $this->getOrderCollection(); while ($orderCollection && count($orderCollection)) { foreach ($orderCollection as $order) { set_time_limit(0); yield $usedIndex++ => $order; } $orderCollection = $this->getNextOrderCollection($usedIndex); } }
php
public function yieldOrders() { $usedIndex = 0; $orderCollection = $this->getOrderCollection(); while ($orderCollection && count($orderCollection)) { foreach ($orderCollection as $order) { set_time_limit(0); yield $usedIndex++ => $order; } $orderCollection = $this->getNextOrderCollection($usedIndex); } }
[ "public", "function", "yieldOrders", "(", ")", "{", "$", "usedIndex", "=", "0", ";", "$", "orderCollection", "=", "$", "this", "->", "getOrderCollection", "(", ")", ";", "while", "(", "$", "orderCollection", "&&", "count", "(", "$", "orderCollection", ")", ")", "{", "foreach", "(", "$", "orderCollection", "as", "$", "order", ")", "{", "set_time_limit", "(", "0", ")", ";", "yield", "$", "usedIndex", "++", "=>", "$", "order", ";", "}", "$", "orderCollection", "=", "$", "this", "->", "getNextOrderCollection", "(", "$", "usedIndex", ")", ";", "}", "}" ]
Yields all found orders. @return Generator
[ "Yields", "all", "found", "orders", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L357-L371
15,555
ua1-labs/firebug
Fire/Bug.php
Bug.addPanel
public function addPanel(Panel $panel) { $id = $panel->getId(); if (!empty($this->_panels[$id])) { throw new BugException('[FireBug] No panels exist with ID "' . $id . '".'); } $this->_panels[$id] = $panel; }
php
public function addPanel(Panel $panel) { $id = $panel->getId(); if (!empty($this->_panels[$id])) { throw new BugException('[FireBug] No panels exist with ID "' . $id . '".'); } $this->_panels[$id] = $panel; }
[ "public", "function", "addPanel", "(", "Panel", "$", "panel", ")", "{", "$", "id", "=", "$", "panel", "->", "getId", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "_panels", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "BugException", "(", "'[FireBug] No panels exist with ID \"'", ".", "$", "id", ".", "'\".'", ")", ";", "}", "$", "this", "->", "_panels", "[", "$", "id", "]", "=", "$", "panel", ";", "}" ]
Adds a Fire\Bug\Panel object to the the array of panels. @param \Fire\Bug\Panel $panel The panel you are adding to FireBug @return void
[ "Adds", "a", "Fire", "\\", "Bug", "\\", "Panel", "object", "to", "the", "the", "array", "of", "panels", "." ]
70a45b2c0bbf64978641eb07e5f3cddfc1951162
https://github.com/ua1-labs/firebug/blob/70a45b2c0bbf64978641eb07e5f3cddfc1951162/Fire/Bug.php#L113-L120
15,556
ua1-labs/firebug
Fire/Bug.php
Bug.render
public function render() { if ($this->_enabled) { if (php_sapi_name() === 'cli') { echo 'FireBug: ' . $this->getLoadTime() . ' milliseconds' . "\n"; } else { ob_start(); include $this->_template; $debugPanel = ob_get_contents(); ob_end_clean(); return $debugPanel; } } }
php
public function render() { if ($this->_enabled) { if (php_sapi_name() === 'cli') { echo 'FireBug: ' . $this->getLoadTime() . ' milliseconds' . "\n"; } else { ob_start(); include $this->_template; $debugPanel = ob_get_contents(); ob_end_clean(); return $debugPanel; } } }
[ "public", "function", "render", "(", ")", "{", "if", "(", "$", "this", "->", "_enabled", ")", "{", "if", "(", "php_sapi_name", "(", ")", "===", "'cli'", ")", "{", "echo", "'FireBug: '", ".", "$", "this", "->", "getLoadTime", "(", ")", ".", "' milliseconds'", ".", "\"\\n\"", ";", "}", "else", "{", "ob_start", "(", ")", ";", "include", "$", "this", "->", "_template", ";", "$", "debugPanel", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "return", "$", "debugPanel", ";", "}", "}", "}" ]
Method used to render FireBug. @return void
[ "Method", "used", "to", "render", "FireBug", "." ]
70a45b2c0bbf64978641eb07e5f3cddfc1951162
https://github.com/ua1-labs/firebug/blob/70a45b2c0bbf64978641eb07e5f3cddfc1951162/Fire/Bug.php#L174-L188
15,557
comelyio/comely
src/Comely/IO/DependencyInjection/DependencyInjectionContainer.php
DependencyInjectionContainer.add
public function add(string $key, $object) { $key = self::ProcessKey(__METHOD__, $key); $objectType = gettype($object); switch ($objectType) { case "object": $this->repository->push($object, $key); return true; case "string": return $this->service($key)->class($object); default: throw new DependencyInjectionException( sprintf('Cannot store "%s" in Dependency Injection container', $objectType) ); } }
php
public function add(string $key, $object) { $key = self::ProcessKey(__METHOD__, $key); $objectType = gettype($object); switch ($objectType) { case "object": $this->repository->push($object, $key); return true; case "string": return $this->service($key)->class($object); default: throw new DependencyInjectionException( sprintf('Cannot store "%s" in Dependency Injection container', $objectType) ); } }
[ "public", "function", "add", "(", "string", "$", "key", ",", "$", "object", ")", "{", "$", "key", "=", "self", "::", "ProcessKey", "(", "__METHOD__", ",", "$", "key", ")", ";", "$", "objectType", "=", "gettype", "(", "$", "object", ")", ";", "switch", "(", "$", "objectType", ")", "{", "case", "\"object\"", ":", "$", "this", "->", "repository", "->", "push", "(", "$", "object", ",", "$", "key", ")", ";", "return", "true", ";", "case", "\"string\"", ":", "return", "$", "this", "->", "service", "(", "$", "key", ")", "->", "class", "(", "$", "object", ")", ";", "default", ":", "throw", "new", "DependencyInjectionException", "(", "sprintf", "(", "'Cannot store \"%s\" in Dependency Injection container'", ",", "$", "objectType", ")", ")", ";", "}", "}" ]
Store an instance or add new server If second argument is an instance, it will be stored as-is. If second argument is a class name (string), it will be added as service and instance to Service will be returned @param string $key @param $object @return Service|bool @throws DependencyInjectionException @throws Exception\RepositoryException @throws Exception\ServicesException
[ "Store", "an", "instance", "or", "add", "new", "server" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/DependencyInjection/DependencyInjectionContainer.php#L75-L90
15,558
nicoSWD/put.io-api-v2
src/PutIO/Engines/HTTP/NativeEngine.php
NativeEngine.request
public function request( $method, $url, array $params = [], $outFile = '', $returnBool = \false, $arrayKey = '', $verifyPeer = \true ) { list($url, $contextOptions) = $this->configureRequestOptions($url, $method, $params, $verifyPeer); $fp = @fopen($url, 'rb', \false, stream_context_create($contextOptions)); $headers = stream_get_meta_data($fp)['wrapper_data']; return $this->handleRequest($fp, $headers, $outFile, $returnBool, $arrayKey); }
php
public function request( $method, $url, array $params = [], $outFile = '', $returnBool = \false, $arrayKey = '', $verifyPeer = \true ) { list($url, $contextOptions) = $this->configureRequestOptions($url, $method, $params, $verifyPeer); $fp = @fopen($url, 'rb', \false, stream_context_create($contextOptions)); $headers = stream_get_meta_data($fp)['wrapper_data']; return $this->handleRequest($fp, $headers, $outFile, $returnBool, $arrayKey); }
[ "public", "function", "request", "(", "$", "method", ",", "$", "url", ",", "array", "$", "params", "=", "[", "]", ",", "$", "outFile", "=", "''", ",", "$", "returnBool", "=", "\\", "false", ",", "$", "arrayKey", "=", "''", ",", "$", "verifyPeer", "=", "\\", "true", ")", "{", "list", "(", "$", "url", ",", "$", "contextOptions", ")", "=", "$", "this", "->", "configureRequestOptions", "(", "$", "url", ",", "$", "method", ",", "$", "params", ",", "$", "verifyPeer", ")", ";", "$", "fp", "=", "@", "fopen", "(", "$", "url", ",", "'rb'", ",", "\\", "false", ",", "stream_context_create", "(", "$", "contextOptions", ")", ")", ";", "$", "headers", "=", "stream_get_meta_data", "(", "$", "fp", ")", "[", "'wrapper_data'", "]", ";", "return", "$", "this", "->", "handleRequest", "(", "$", "fp", ",", "$", "headers", ",", "$", "outFile", ",", "$", "returnBool", ",", "$", "arrayKey", ")", ";", "}" ]
Makes an HTTP request to put.io's API and returns the response. Relies on native PHP functions. NOTE!! Due to restrictions, files must be loaded into the memory when uploading. I don't recommend uploading large files using native functions. Only use this if you absolutely must! Otherwise, the cURL engine is much better! Downloading is no issue as long as you're saving the file somewhere on the file system rather than the memory. Set $outFile and you're all set! Returns false if a file was not found. @param string $method HTTP request method. Only POST and GET are supported. @param string $url Remote path to API module. @param array $params Variables to be sent. @param string $outFile If $outFile is set, the response will be written to this file instead of StdOut. @param bool $returnBool @param string $arrayKey Will return all data on a specific array key of the response. @param bool $verifyPeer If true, will use proper SSL peer/host verification. @return mixed @throws \PutIO\Exceptions\LocalStorageException @throws \PutIO\Exceptions\RemoteConnectionException
[ "Makes", "an", "HTTP", "request", "to", "put", ".", "io", "s", "API", "and", "returns", "the", "response", ".", "Relies", "on", "native", "PHP", "functions", "." ]
d91bedd91ea75793512a921bfd9aa83e86a6f0a7
https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/HTTP/NativeEngine.php#L57-L72
15,559
codeburnerframework/router
src/Matcher.php
Matcher.match
public function match($httpMethod, $path) { $path = $this->parsePath($path); if (($route = $this->collector->findStaticRoute($httpMethod, $path)) || ($route = $this->matchDynamicRoute($httpMethod, $path))) { $route->setMatcher($this); return $route; } $this->matchSimilarRoute($httpMethod, $path); }
php
public function match($httpMethod, $path) { $path = $this->parsePath($path); if (($route = $this->collector->findStaticRoute($httpMethod, $path)) || ($route = $this->matchDynamicRoute($httpMethod, $path))) { $route->setMatcher($this); return $route; } $this->matchSimilarRoute($httpMethod, $path); }
[ "public", "function", "match", "(", "$", "httpMethod", ",", "$", "path", ")", "{", "$", "path", "=", "$", "this", "->", "parsePath", "(", "$", "path", ")", ";", "if", "(", "(", "$", "route", "=", "$", "this", "->", "collector", "->", "findStaticRoute", "(", "$", "httpMethod", ",", "$", "path", ")", ")", "||", "(", "$", "route", "=", "$", "this", "->", "matchDynamicRoute", "(", "$", "httpMethod", ",", "$", "path", ")", ")", ")", "{", "$", "route", "->", "setMatcher", "(", "$", "this", ")", ";", "return", "$", "route", ";", "}", "$", "this", "->", "matchSimilarRoute", "(", "$", "httpMethod", ",", "$", "path", ")", ";", "}" ]
Find a route that matches the given arguments. @param string $httpMethod @param string $path @throws NotFoundException @throws MethodNotAllowedException @return Route
[ "Find", "a", "route", "that", "matches", "the", "given", "arguments", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L71-L83
15,560
codeburnerframework/router
src/Matcher.php
Matcher.matchDynamicRoute
protected function matchDynamicRoute($httpMethod, $path) { if ($routes = $this->collector->findDynamicRoutes($httpMethod, $path)) { // cache the parser reference $this->parser = $this->collector->getParser(); // chunk routes for smaller regex groups using the Sturges' Formula foreach (array_chunk($routes, round(1 + 3.3 * log(count($routes))), true) as $chunk) { array_map([$this, "buildRoute"], $chunk); list($pattern, $map) = $this->buildGroup($chunk); if (!preg_match($pattern, $path, $matches)) { continue; } /** @var Route $route */ $route = $map[count($matches)]; unset($matches[0]); $route->setParams(array_combine($route->getParams(), array_filter($matches))); return $route; } } return false; }
php
protected function matchDynamicRoute($httpMethod, $path) { if ($routes = $this->collector->findDynamicRoutes($httpMethod, $path)) { // cache the parser reference $this->parser = $this->collector->getParser(); // chunk routes for smaller regex groups using the Sturges' Formula foreach (array_chunk($routes, round(1 + 3.3 * log(count($routes))), true) as $chunk) { array_map([$this, "buildRoute"], $chunk); list($pattern, $map) = $this->buildGroup($chunk); if (!preg_match($pattern, $path, $matches)) { continue; } /** @var Route $route */ $route = $map[count($matches)]; unset($matches[0]); $route->setParams(array_combine($route->getParams(), array_filter($matches))); return $route; } } return false; }
[ "protected", "function", "matchDynamicRoute", "(", "$", "httpMethod", ",", "$", "path", ")", "{", "if", "(", "$", "routes", "=", "$", "this", "->", "collector", "->", "findDynamicRoutes", "(", "$", "httpMethod", ",", "$", "path", ")", ")", "{", "// cache the parser reference", "$", "this", "->", "parser", "=", "$", "this", "->", "collector", "->", "getParser", "(", ")", ";", "// chunk routes for smaller regex groups using the Sturges' Formula", "foreach", "(", "array_chunk", "(", "$", "routes", ",", "round", "(", "1", "+", "3.3", "*", "log", "(", "count", "(", "$", "routes", ")", ")", ")", ",", "true", ")", "as", "$", "chunk", ")", "{", "array_map", "(", "[", "$", "this", ",", "\"buildRoute\"", "]", ",", "$", "chunk", ")", ";", "list", "(", "$", "pattern", ",", "$", "map", ")", "=", "$", "this", "->", "buildGroup", "(", "$", "chunk", ")", ";", "if", "(", "!", "preg_match", "(", "$", "pattern", ",", "$", "path", ",", "$", "matches", ")", ")", "{", "continue", ";", "}", "/** @var Route $route */", "$", "route", "=", "$", "map", "[", "count", "(", "$", "matches", ")", "]", ";", "unset", "(", "$", "matches", "[", "0", "]", ")", ";", "$", "route", "->", "setParams", "(", "array_combine", "(", "$", "route", "->", "getParams", "(", ")", ",", "array_filter", "(", "$", "matches", ")", ")", ")", ";", "return", "$", "route", ";", "}", "}", "return", "false", ";", "}" ]
Find and return the request dynamic route based on the compiled data and Path. @param string $httpMethod @param string $path @return Route|false If the request match an array with the action and parameters will be returned otherwise a false will.
[ "Find", "and", "return", "the", "request", "dynamic", "route", "based", "on", "the", "compiled", "data", "and", "Path", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L95-L120
15,561
codeburnerframework/router
src/Matcher.php
Matcher.buildRoute
protected function buildRoute(Route $route) { if ($route->getBlock()) { return $route; } list($pattern, $params) = $this->parsePlaceholders($route->getPattern()); return $route->setPatternWithoutReset($pattern)->setParams($params)->setBlock(true); }
php
protected function buildRoute(Route $route) { if ($route->getBlock()) { return $route; } list($pattern, $params) = $this->parsePlaceholders($route->getPattern()); return $route->setPatternWithoutReset($pattern)->setParams($params)->setBlock(true); }
[ "protected", "function", "buildRoute", "(", "Route", "$", "route", ")", "{", "if", "(", "$", "route", "->", "getBlock", "(", ")", ")", "{", "return", "$", "route", ";", "}", "list", "(", "$", "pattern", ",", "$", "params", ")", "=", "$", "this", "->", "parsePlaceholders", "(", "$", "route", "->", "getPattern", "(", ")", ")", ";", "return", "$", "route", "->", "setPatternWithoutReset", "(", "$", "pattern", ")", "->", "setParams", "(", "$", "params", ")", "->", "setBlock", "(", "true", ")", ";", "}" ]
Parse the dynamic segments of the pattern and replace then for corresponding regex. @param Route $route @return Route
[ "Parse", "the", "dynamic", "segments", "of", "the", "pattern", "and", "replace", "then", "for", "corresponding", "regex", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L130-L138
15,562
codeburnerframework/router
src/Matcher.php
Matcher.buildGroup
protected function buildGroup(array $routes) { $groupCount = (int) $map = $regex = []; foreach ($routes as $route) { $params = $route->getParams(); $paramsCount = count($params); $groupCount = max($groupCount, $paramsCount) + 1; $regex[] = $route->getPattern() . str_repeat("()", $groupCount - $paramsCount - 1); $map[$groupCount] = $route; } return ["~^(?|" . implode("|", $regex) . ")$~", $map]; }
php
protected function buildGroup(array $routes) { $groupCount = (int) $map = $regex = []; foreach ($routes as $route) { $params = $route->getParams(); $paramsCount = count($params); $groupCount = max($groupCount, $paramsCount) + 1; $regex[] = $route->getPattern() . str_repeat("()", $groupCount - $paramsCount - 1); $map[$groupCount] = $route; } return ["~^(?|" . implode("|", $regex) . ")$~", $map]; }
[ "protected", "function", "buildGroup", "(", "array", "$", "routes", ")", "{", "$", "groupCount", "=", "(", "int", ")", "$", "map", "=", "$", "regex", "=", "[", "]", ";", "foreach", "(", "$", "routes", "as", "$", "route", ")", "{", "$", "params", "=", "$", "route", "->", "getParams", "(", ")", ";", "$", "paramsCount", "=", "count", "(", "$", "params", ")", ";", "$", "groupCount", "=", "max", "(", "$", "groupCount", ",", "$", "paramsCount", ")", "+", "1", ";", "$", "regex", "[", "]", "=", "$", "route", "->", "getPattern", "(", ")", ".", "str_repeat", "(", "\"()\"", ",", "$", "groupCount", "-", "$", "paramsCount", "-", "1", ")", ";", "$", "map", "[", "$", "groupCount", "]", "=", "$", "route", ";", "}", "return", "[", "\"~^(?|\"", ".", "implode", "(", "\"|\"", ",", "$", "regex", ")", ".", "\")$~\"", ",", "$", "map", "]", ";", "}" ]
Group several dynamic routes patterns into one big regex and maps the routes to the pattern positions in the big regex. @param Route[] $routes @return array
[ "Group", "several", "dynamic", "routes", "patterns", "into", "one", "big", "regex", "and", "maps", "the", "routes", "to", "the", "pattern", "positions", "in", "the", "big", "regex", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L148-L161
15,563
codeburnerframework/router
src/Matcher.php
Matcher.parsePlaceholders
protected function parsePlaceholders($pattern) { $params = []; $parser = $this->parser; preg_match_all("~" . $parser::DYNAMIC_REGEX . "~x", $pattern, $matches, PREG_SET_ORDER); foreach ((array) $matches as $key => $match) { $pattern = str_replace($match[0], isset($match[2]) ? "({$match[2]})" : "([^/]+)", $pattern); $params[$key] = $match[1]; } return [$pattern, $params]; }
php
protected function parsePlaceholders($pattern) { $params = []; $parser = $this->parser; preg_match_all("~" . $parser::DYNAMIC_REGEX . "~x", $pattern, $matches, PREG_SET_ORDER); foreach ((array) $matches as $key => $match) { $pattern = str_replace($match[0], isset($match[2]) ? "({$match[2]})" : "([^/]+)", $pattern); $params[$key] = $match[1]; } return [$pattern, $params]; }
[ "protected", "function", "parsePlaceholders", "(", "$", "pattern", ")", "{", "$", "params", "=", "[", "]", ";", "$", "parser", "=", "$", "this", "->", "parser", ";", "preg_match_all", "(", "\"~\"", ".", "$", "parser", "::", "DYNAMIC_REGEX", ".", "\"~x\"", ",", "$", "pattern", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "foreach", "(", "(", "array", ")", "$", "matches", "as", "$", "key", "=>", "$", "match", ")", "{", "$", "pattern", "=", "str_replace", "(", "$", "match", "[", "0", "]", ",", "isset", "(", "$", "match", "[", "2", "]", ")", "?", "\"({$match[2]})\"", ":", "\"([^/]+)\"", ",", "$", "pattern", ")", ";", "$", "params", "[", "$", "key", "]", "=", "$", "match", "[", "1", "]", ";", "}", "return", "[", "$", "pattern", ",", "$", "params", "]", ";", "}" ]
Parse an route pattern seeking for parameters and build the route regex. @param string $pattern @return array 0 => new route regex, 1 => map of parameter names
[ "Parse", "an", "route", "pattern", "seeking", "for", "parameters", "and", "build", "the", "route", "regex", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L170-L183
15,564
codeburnerframework/router
src/Matcher.php
Matcher.parsePath
protected function parsePath($path) { $path = parse_url(substr(strstr(";" . $path, ";" . $this->basepath), strlen(";" . $this->basepath)), PHP_URL_PATH); if ($path === false) { throw new Exception("Seriously malformed URL passed to route matcher."); } return $path; }
php
protected function parsePath($path) { $path = parse_url(substr(strstr(";" . $path, ";" . $this->basepath), strlen(";" . $this->basepath)), PHP_URL_PATH); if ($path === false) { throw new Exception("Seriously malformed URL passed to route matcher."); } return $path; }
[ "protected", "function", "parsePath", "(", "$", "path", ")", "{", "$", "path", "=", "parse_url", "(", "substr", "(", "strstr", "(", "\";\"", ".", "$", "path", ",", "\";\"", ".", "$", "this", "->", "basepath", ")", ",", "strlen", "(", "\";\"", ".", "$", "this", "->", "basepath", ")", ")", ",", "PHP_URL_PATH", ")", ";", "if", "(", "$", "path", "===", "false", ")", "{", "throw", "new", "Exception", "(", "\"Seriously malformed URL passed to route matcher.\"", ")", ";", "}", "return", "$", "path", ";", "}" ]
Get only the path of a given url. @param string $path The given URL @throws Exception @return string
[ "Get", "only", "the", "path", "of", "a", "given", "url", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L194-L203
15,565
codeburnerframework/router
src/Matcher.php
Matcher.matchSimilarRoute
protected function matchSimilarRoute($httpMethod, $path) { $dm = []; if (($sm = $this->checkStaticRouteInOtherMethods($httpMethod, $path)) || ($dm = $this->checkDynamicRouteInOtherMethods($httpMethod, $path))) { throw new MethodNotAllowedException($httpMethod, $path, array_merge((array) $sm, (array) $dm)); } throw new NotFoundException; }
php
protected function matchSimilarRoute($httpMethod, $path) { $dm = []; if (($sm = $this->checkStaticRouteInOtherMethods($httpMethod, $path)) || ($dm = $this->checkDynamicRouteInOtherMethods($httpMethod, $path))) { throw new MethodNotAllowedException($httpMethod, $path, array_merge((array) $sm, (array) $dm)); } throw new NotFoundException; }
[ "protected", "function", "matchSimilarRoute", "(", "$", "httpMethod", ",", "$", "path", ")", "{", "$", "dm", "=", "[", "]", ";", "if", "(", "(", "$", "sm", "=", "$", "this", "->", "checkStaticRouteInOtherMethods", "(", "$", "httpMethod", ",", "$", "path", ")", ")", "||", "(", "$", "dm", "=", "$", "this", "->", "checkDynamicRouteInOtherMethods", "(", "$", "httpMethod", ",", "$", "path", ")", ")", ")", "{", "throw", "new", "MethodNotAllowedException", "(", "$", "httpMethod", ",", "$", "path", ",", "array_merge", "(", "(", "array", ")", "$", "sm", ",", "(", "array", ")", "$", "dm", ")", ")", ";", "}", "throw", "new", "NotFoundException", ";", "}" ]
Generate an HTTP error request with method not allowed or not found. @param string $httpMethod @param string $path @throws NotFoundException @throws MethodNotAllowedException
[ "Generate", "an", "HTTP", "error", "request", "with", "method", "not", "allowed", "or", "not", "found", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L215-L225
15,566
codeburnerframework/router
src/Matcher.php
Matcher.checkStaticRouteInOtherMethods
protected function checkStaticRouteInOtherMethods($targetHttpMethod, $path) { return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) { return (bool) $this->collector->findStaticRoute($httpMethod, $path); }); }
php
protected function checkStaticRouteInOtherMethods($targetHttpMethod, $path) { return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) { return (bool) $this->collector->findStaticRoute($httpMethod, $path); }); }
[ "protected", "function", "checkStaticRouteInOtherMethods", "(", "$", "targetHttpMethod", ",", "$", "path", ")", "{", "return", "array_filter", "(", "$", "this", "->", "getHttpMethodsBut", "(", "$", "targetHttpMethod", ")", ",", "function", "(", "$", "httpMethod", ")", "use", "(", "$", "path", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "collector", "->", "findStaticRoute", "(", "$", "httpMethod", ",", "$", "path", ")", ";", "}", ")", ";", "}" ]
Verify if a static route match in another method than the requested. @param string $targetHttpMethod The HTTP method that must not be checked @param string $path The Path that must be matched. @return array
[ "Verify", "if", "a", "static", "route", "match", "in", "another", "method", "than", "the", "requested", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L236-L241
15,567
codeburnerframework/router
src/Matcher.php
Matcher.checkDynamicRouteInOtherMethods
protected function checkDynamicRouteInOtherMethods($targetHttpMethod, $path) { return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) { return (bool) $this->matchDynamicRoute($httpMethod, $path); }); }
php
protected function checkDynamicRouteInOtherMethods($targetHttpMethod, $path) { return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) { return (bool) $this->matchDynamicRoute($httpMethod, $path); }); }
[ "protected", "function", "checkDynamicRouteInOtherMethods", "(", "$", "targetHttpMethod", ",", "$", "path", ")", "{", "return", "array_filter", "(", "$", "this", "->", "getHttpMethodsBut", "(", "$", "targetHttpMethod", ")", ",", "function", "(", "$", "httpMethod", ")", "use", "(", "$", "path", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "matchDynamicRoute", "(", "$", "httpMethod", ",", "$", "path", ")", ";", "}", ")", ";", "}" ]
Verify if a dynamic route match in another method than the requested. @param string $targetHttpMethod The HTTP method that must not be checked @param string $path The Path that must be matched. @return array
[ "Verify", "if", "a", "dynamic", "route", "match", "in", "another", "method", "than", "the", "requested", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L252-L257
15,568
JustBlackBird/jms-serializer-strict-json
src/Exception/TypeMismatchException.php
TypeMismatchException.fromValue
public static function fromValue( $expected_type, $actual_value, DeserializationContext $context = null ) { if (null !== $context && count($context->getCurrentPath()) > 0) { $property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath())); } else { $property = ''; } return new static(sprintf( 'Expected %s%s, but got %s: %s', $property, $expected_type, gettype($actual_value), json_encode($actual_value) )); }
php
public static function fromValue( $expected_type, $actual_value, DeserializationContext $context = null ) { if (null !== $context && count($context->getCurrentPath()) > 0) { $property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath())); } else { $property = ''; } return new static(sprintf( 'Expected %s%s, but got %s: %s', $property, $expected_type, gettype($actual_value), json_encode($actual_value) )); }
[ "public", "static", "function", "fromValue", "(", "$", "expected_type", ",", "$", "actual_value", ",", "DeserializationContext", "$", "context", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "context", "&&", "count", "(", "$", "context", "->", "getCurrentPath", "(", ")", ")", ">", "0", ")", "{", "$", "property", "=", "sprintf", "(", "'property \"%s\" to be '", ",", "implode", "(", "'.'", ",", "$", "context", "->", "getCurrentPath", "(", ")", ")", ")", ";", "}", "else", "{", "$", "property", "=", "''", ";", "}", "return", "new", "static", "(", "sprintf", "(", "'Expected %s%s, but got %s: %s'", ",", "$", "property", ",", "$", "expected_type", ",", "gettype", "(", "$", "actual_value", ")", ",", "json_encode", "(", "$", "actual_value", ")", ")", ")", ";", "}" ]
A handy method for building exception instance. @param string $expected_type @param mixed $actual_value @param DeserializationContext|null $context @return TypeMismatchException
[ "A", "handy", "method", "for", "building", "exception", "instance", "." ]
db1d1473ccb0de32dfb12ec89c89e028a515d61e
https://github.com/JustBlackBird/jms-serializer-strict-json/blob/db1d1473ccb0de32dfb12ec89c89e028a515d61e/src/Exception/TypeMismatchException.php#L33-L51
15,569
avto-dev/app-version-laravel
src/AppVersionServiceProvider.php
AppVersionServiceProvider.registerAppVersionManager
protected function registerAppVersionManager() { $this->app->singleton(AppVersionManager::class, function (Application $app) { $config = (array) $app ->make('config') ->get(static::getConfigRootKeyName()); return new AppVersionManager($config); }); $this->app->bind(AppVersionManagerContract::class, AppVersionManager::class); $this->app->bind(static::VERSION_MANAGER_ALIAS, AppVersionManagerContract::class); }
php
protected function registerAppVersionManager() { $this->app->singleton(AppVersionManager::class, function (Application $app) { $config = (array) $app ->make('config') ->get(static::getConfigRootKeyName()); return new AppVersionManager($config); }); $this->app->bind(AppVersionManagerContract::class, AppVersionManager::class); $this->app->bind(static::VERSION_MANAGER_ALIAS, AppVersionManagerContract::class); }
[ "protected", "function", "registerAppVersionManager", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "AppVersionManager", "::", "class", ",", "function", "(", "Application", "$", "app", ")", "{", "$", "config", "=", "(", "array", ")", "$", "app", "->", "make", "(", "'config'", ")", "->", "get", "(", "static", "::", "getConfigRootKeyName", "(", ")", ")", ";", "return", "new", "AppVersionManager", "(", "$", "config", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "AppVersionManagerContract", "::", "class", ",", "AppVersionManager", "::", "class", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "static", "::", "VERSION_MANAGER_ALIAS", ",", "AppVersionManagerContract", "::", "class", ")", ";", "}" ]
Register version manager instance. @return void
[ "Register", "version", "manager", "instance", "." ]
5cbf9df5981cadd2d5148c49c834cc17fb903c3f
https://github.com/avto-dev/app-version-laravel/blob/5cbf9df5981cadd2d5148c49c834cc17fb903c3f/src/AppVersionServiceProvider.php#L64-L76
15,570
avto-dev/app-version-laravel
src/AppVersionServiceProvider.php
AppVersionServiceProvider.initializeConfigs
protected function initializeConfigs() { $this->mergeConfigFrom(static::getConfigPath(), static::getConfigRootKeyName()); $this->publishes([ realpath(static::getConfigPath()) => config_path(basename(static::getConfigPath())), ], 'config'); }
php
protected function initializeConfigs() { $this->mergeConfigFrom(static::getConfigPath(), static::getConfigRootKeyName()); $this->publishes([ realpath(static::getConfigPath()) => config_path(basename(static::getConfigPath())), ], 'config'); }
[ "protected", "function", "initializeConfigs", "(", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "static", "::", "getConfigPath", "(", ")", ",", "static", "::", "getConfigRootKeyName", "(", ")", ")", ";", "$", "this", "->", "publishes", "(", "[", "realpath", "(", "static", "::", "getConfigPath", "(", ")", ")", "=>", "config_path", "(", "basename", "(", "static", "::", "getConfigPath", "(", ")", ")", ")", ",", "]", ",", "'config'", ")", ";", "}" ]
Initialize configs. @return void
[ "Initialize", "configs", "." ]
5cbf9df5981cadd2d5148c49c834cc17fb903c3f
https://github.com/avto-dev/app-version-laravel/blob/5cbf9df5981cadd2d5148c49c834cc17fb903c3f/src/AppVersionServiceProvider.php#L113-L120
15,571
contao-bootstrap/buttons
src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonsElement.php
ButtonsElement.compile
protected function compile() { if (!$this->bootstrap_buttonStyle) { $this->bootstrap_buttonStyle = 'btn-default'; } $buttons = Factory::createFromFieldset($this->bootstrap_buttons); $buttons->eachChild(array($this, 'addButtonStyle')); $this->Template->buttons = $buttons; }
php
protected function compile() { if (!$this->bootstrap_buttonStyle) { $this->bootstrap_buttonStyle = 'btn-default'; } $buttons = Factory::createFromFieldset($this->bootstrap_buttons); $buttons->eachChild(array($this, 'addButtonStyle')); $this->Template->buttons = $buttons; }
[ "protected", "function", "compile", "(", ")", "{", "if", "(", "!", "$", "this", "->", "bootstrap_buttonStyle", ")", "{", "$", "this", "->", "bootstrap_buttonStyle", "=", "'btn-default'", ";", "}", "$", "buttons", "=", "Factory", "::", "createFromFieldset", "(", "$", "this", "->", "bootstrap_buttons", ")", ";", "$", "buttons", "->", "eachChild", "(", "array", "(", "$", "this", ",", "'addButtonStyle'", ")", ")", ";", "$", "this", "->", "Template", "->", "buttons", "=", "$", "buttons", ";", "}" ]
Compile the button toolbar. @return void
[ "Compile", "the", "button", "toolbar", "." ]
f573a24c19ec059aae528a12ba46dfc993844201
https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonsElement.php#L35-L45
15,572
contao-bootstrap/buttons
src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonsElement.php
ButtonsElement.addButtonStyle
public function addButtonStyle($child) { if ($child instanceof Group || $child instanceof Toolbar) { $child->eachChild(array($this, 'addButtonStyle')); } else { $class = $child->getAttribute('class'); $class = array_filter($class, function ($item) { return strpos($item, 'btn-') !== false; }); if (!$class && $this->bootstrap_buttonStyle) { $child->addClass($this->bootstrap_buttonStyle); } } }
php
public function addButtonStyle($child) { if ($child instanceof Group || $child instanceof Toolbar) { $child->eachChild(array($this, 'addButtonStyle')); } else { $class = $child->getAttribute('class'); $class = array_filter($class, function ($item) { return strpos($item, 'btn-') !== false; }); if (!$class && $this->bootstrap_buttonStyle) { $child->addClass($this->bootstrap_buttonStyle); } } }
[ "public", "function", "addButtonStyle", "(", "$", "child", ")", "{", "if", "(", "$", "child", "instanceof", "Group", "||", "$", "child", "instanceof", "Toolbar", ")", "{", "$", "child", "->", "eachChild", "(", "array", "(", "$", "this", ",", "'addButtonStyle'", ")", ")", ";", "}", "else", "{", "$", "class", "=", "$", "child", "->", "getAttribute", "(", "'class'", ")", ";", "$", "class", "=", "array_filter", "(", "$", "class", ",", "function", "(", "$", "item", ")", "{", "return", "strpos", "(", "$", "item", ",", "'btn-'", ")", "!==", "false", ";", "}", ")", ";", "if", "(", "!", "$", "class", "&&", "$", "this", "->", "bootstrap_buttonStyle", ")", "{", "$", "child", "->", "addClass", "(", "$", "this", "->", "bootstrap_buttonStyle", ")", ";", "}", "}", "}" ]
Add button style. @param mixed $child Current child. @return void
[ "Add", "button", "style", "." ]
f573a24c19ec059aae528a12ba46dfc993844201
https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonsElement.php#L54-L68
15,573
nathancox/silverstripe-hasoneautocompletefield
src/forms/HasOneAutocompleteField.php
HasOneAutocompleteField.search
public function search(HTTPRequest $request) { // Check form field state if($this->isDisabled() || $this->isReadonly()) { return $this->httpError(403); } $query = $request->getVar('query'); // use callbacks if they're set, otherwise used this class's methods for search and processing if ($this->getSearchCallback()) { $results = call_user_func($this->getSearchCallback(), $query, $this); } else { $results = $this->getResults($query); } if ($this->getProcessCallback()) { $json = call_user_func($this->getProcessCallback(), $results, $this); } else { $json = $this->processResults($results); } return Convert::array2json($json); }
php
public function search(HTTPRequest $request) { // Check form field state if($this->isDisabled() || $this->isReadonly()) { return $this->httpError(403); } $query = $request->getVar('query'); // use callbacks if they're set, otherwise used this class's methods for search and processing if ($this->getSearchCallback()) { $results = call_user_func($this->getSearchCallback(), $query, $this); } else { $results = $this->getResults($query); } if ($this->getProcessCallback()) { $json = call_user_func($this->getProcessCallback(), $results, $this); } else { $json = $this->processResults($results); } return Convert::array2json($json); }
[ "public", "function", "search", "(", "HTTPRequest", "$", "request", ")", "{", "// Check form field state", "if", "(", "$", "this", "->", "isDisabled", "(", ")", "||", "$", "this", "->", "isReadonly", "(", ")", ")", "{", "return", "$", "this", "->", "httpError", "(", "403", ")", ";", "}", "$", "query", "=", "$", "request", "->", "getVar", "(", "'query'", ")", ";", "// use callbacks if they're set, otherwise used this class's methods for search and processing", "if", "(", "$", "this", "->", "getSearchCallback", "(", ")", ")", "{", "$", "results", "=", "call_user_func", "(", "$", "this", "->", "getSearchCallback", "(", ")", ",", "$", "query", ",", "$", "this", ")", ";", "}", "else", "{", "$", "results", "=", "$", "this", "->", "getResults", "(", "$", "query", ")", ";", "}", "if", "(", "$", "this", "->", "getProcessCallback", "(", ")", ")", "{", "$", "json", "=", "call_user_func", "(", "$", "this", "->", "getProcessCallback", "(", ")", ",", "$", "results", ",", "$", "this", ")", ";", "}", "else", "{", "$", "json", "=", "$", "this", "->", "processResults", "(", "$", "results", ")", ";", "}", "return", "Convert", "::", "array2json", "(", "$", "json", ")", ";", "}" ]
The action that handles AJAX search requests @param SS_HTTPRequest $request @return json
[ "The", "action", "that", "handles", "AJAX", "search", "requests" ]
862a971723dfc053ddb9c155defa32ab2bcd870e
https://github.com/nathancox/silverstripe-hasoneautocompletefield/blob/862a971723dfc053ddb9c155defa32ab2bcd870e/src/forms/HasOneAutocompleteField.php#L83-L106
15,574
nathancox/silverstripe-hasoneautocompletefield
src/forms/HasOneAutocompleteField.php
HasOneAutocompleteField.getResults
protected function getResults($query) { $searchFields = ($this->getSearchFields() ?: singleton($this->sourceObject)->stat('searchable_fields')); if(!$searchFields) { throw new Exception( sprintf('HasOneAutocompleteField: No searchable fields could be found for class "%s"', $this->sourceObject)); } $params = []; $sort = []; foreach($searchFields as $searchField) { $name = (strpos($searchField, ':') !== FALSE) ? $searchField : "$searchField:PartialMatch:nocase"; $params[$name] = $query; $sort[$searchField] = "ASC"; } $results = DataList::create($this->sourceObject) ->filterAny($params) ->sort($sort) ->limit($this->getResultsLimit()); return $results; }
php
protected function getResults($query) { $searchFields = ($this->getSearchFields() ?: singleton($this->sourceObject)->stat('searchable_fields')); if(!$searchFields) { throw new Exception( sprintf('HasOneAutocompleteField: No searchable fields could be found for class "%s"', $this->sourceObject)); } $params = []; $sort = []; foreach($searchFields as $searchField) { $name = (strpos($searchField, ':') !== FALSE) ? $searchField : "$searchField:PartialMatch:nocase"; $params[$name] = $query; $sort[$searchField] = "ASC"; } $results = DataList::create($this->sourceObject) ->filterAny($params) ->sort($sort) ->limit($this->getResultsLimit()); return $results; }
[ "protected", "function", "getResults", "(", "$", "query", ")", "{", "$", "searchFields", "=", "(", "$", "this", "->", "getSearchFields", "(", ")", "?", ":", "singleton", "(", "$", "this", "->", "sourceObject", ")", "->", "stat", "(", "'searchable_fields'", ")", ")", ";", "if", "(", "!", "$", "searchFields", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'HasOneAutocompleteField: No searchable fields could be found for class \"%s\"'", ",", "$", "this", "->", "sourceObject", ")", ")", ";", "}", "$", "params", "=", "[", "]", ";", "$", "sort", "=", "[", "]", ";", "foreach", "(", "$", "searchFields", "as", "$", "searchField", ")", "{", "$", "name", "=", "(", "strpos", "(", "$", "searchField", ",", "':'", ")", "!==", "FALSE", ")", "?", "$", "searchField", ":", "\"$searchField:PartialMatch:nocase\"", ";", "$", "params", "[", "$", "name", "]", "=", "$", "query", ";", "$", "sort", "[", "$", "searchField", "]", "=", "\"ASC\"", ";", "}", "$", "results", "=", "DataList", "::", "create", "(", "$", "this", "->", "sourceObject", ")", "->", "filterAny", "(", "$", "params", ")", "->", "sort", "(", "$", "sort", ")", "->", "limit", "(", "$", "this", "->", "getResultsLimit", "(", ")", ")", ";", "return", "$", "results", ";", "}" ]
Takes the search term and returns a DataList @param string $query @return DataList
[ "Takes", "the", "search", "term", "and", "returns", "a", "DataList" ]
862a971723dfc053ddb9c155defa32ab2bcd870e
https://github.com/nathancox/silverstripe-hasoneautocompletefield/blob/862a971723dfc053ddb9c155defa32ab2bcd870e/src/forms/HasOneAutocompleteField.php#L113-L138
15,575
nathancox/silverstripe-hasoneautocompletefield
src/forms/HasOneAutocompleteField.php
HasOneAutocompleteField.processResults
protected function processResults($results) { $json = array(); foreach($results as $result) { $name = $result->{$this->labelField}; $json[$result->ID] = array( 'name' => $name, 'currentString' => $this->getCurrentItemText($result) ); } return $json; }
php
protected function processResults($results) { $json = array(); foreach($results as $result) { $name = $result->{$this->labelField}; $json[$result->ID] = array( 'name' => $name, 'currentString' => $this->getCurrentItemText($result) ); } return $json; }
[ "protected", "function", "processResults", "(", "$", "results", ")", "{", "$", "json", "=", "array", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "result", ")", "{", "$", "name", "=", "$", "result", "->", "{", "$", "this", "->", "labelField", "}", ";", "$", "json", "[", "$", "result", "->", "ID", "]", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'currentString'", "=>", "$", "this", "->", "getCurrentItemText", "(", "$", "result", ")", ")", ";", "}", "return", "$", "json", ";", "}" ]
Takes the DataList of search results and returns the json to be sent to the front end. @param DataList @return json
[ "Takes", "the", "DataList", "of", "search", "results", "and", "returns", "the", "json", "to", "be", "sent", "to", "the", "front", "end", "." ]
862a971723dfc053ddb9c155defa32ab2bcd870e
https://github.com/nathancox/silverstripe-hasoneautocompletefield/blob/862a971723dfc053ddb9c155defa32ab2bcd870e/src/forms/HasOneAutocompleteField.php#L145-L158
15,576
nathancox/silverstripe-hasoneautocompletefield
src/forms/HasOneAutocompleteField.php
HasOneAutocompleteField.getItem
function getItem() { $sourceObject = $this->sourceObject; if ($this->value !== null) { $item = $sourceObject::get()->byID($this->value); } else { $item = $sourceObject::create(); } return $item; }
php
function getItem() { $sourceObject = $this->sourceObject; if ($this->value !== null) { $item = $sourceObject::get()->byID($this->value); } else { $item = $sourceObject::create(); } return $item; }
[ "function", "getItem", "(", ")", "{", "$", "sourceObject", "=", "$", "this", "->", "sourceObject", ";", "if", "(", "$", "this", "->", "value", "!==", "null", ")", "{", "$", "item", "=", "$", "sourceObject", "::", "get", "(", ")", "->", "byID", "(", "$", "this", "->", "value", ")", ";", "}", "else", "{", "$", "item", "=", "$", "sourceObject", "::", "create", "(", ")", ";", "}", "return", "$", "item", ";", "}" ]
Get the currently selected object @return DataObject
[ "Get", "the", "currently", "selected", "object" ]
862a971723dfc053ddb9c155defa32ab2bcd870e
https://github.com/nathancox/silverstripe-hasoneautocompletefield/blob/862a971723dfc053ddb9c155defa32ab2bcd870e/src/forms/HasOneAutocompleteField.php#L302-L311
15,577
dragosprotung/stc-core
src/Workout/SportGuesser.php
SportGuesser.guess
public static function guess(string $code) : string { switch (strtolower(trim($code))) { case SportMapperInterface::RUNNING: case 'run': return SportMapperInterface::RUNNING; case SportMapperInterface::CYCLING_SPORT: case 'cycling': return SportMapperInterface::CYCLING_SPORT; case SportMapperInterface::CYCLING_TRANSPORT: return SportMapperInterface::CYCLING_TRANSPORT; case SportMapperInterface::SWIMMING: return SportMapperInterface::SWIMMING; default: return SportMapperInterface::OTHER; } }
php
public static function guess(string $code) : string { switch (strtolower(trim($code))) { case SportMapperInterface::RUNNING: case 'run': return SportMapperInterface::RUNNING; case SportMapperInterface::CYCLING_SPORT: case 'cycling': return SportMapperInterface::CYCLING_SPORT; case SportMapperInterface::CYCLING_TRANSPORT: return SportMapperInterface::CYCLING_TRANSPORT; case SportMapperInterface::SWIMMING: return SportMapperInterface::SWIMMING; default: return SportMapperInterface::OTHER; } }
[ "public", "static", "function", "guess", "(", "string", "$", "code", ")", ":", "string", "{", "switch", "(", "strtolower", "(", "trim", "(", "$", "code", ")", ")", ")", "{", "case", "SportMapperInterface", "::", "RUNNING", ":", "case", "'run'", ":", "return", "SportMapperInterface", "::", "RUNNING", ";", "case", "SportMapperInterface", "::", "CYCLING_SPORT", ":", "case", "'cycling'", ":", "return", "SportMapperInterface", "::", "CYCLING_SPORT", ";", "case", "SportMapperInterface", "::", "CYCLING_TRANSPORT", ":", "return", "SportMapperInterface", "::", "CYCLING_TRANSPORT", ";", "case", "SportMapperInterface", "::", "SWIMMING", ":", "return", "SportMapperInterface", "::", "SWIMMING", ";", "default", ":", "return", "SportMapperInterface", "::", "OTHER", ";", "}", "}" ]
Get the sport code from the tracker sport code. @param string $code The code from the tracker. @return string
[ "Get", "the", "sport", "code", "from", "the", "tracker", "sport", "code", "." ]
9783e3414294f4ee555a1d538d2807269deeb9e7
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/SportGuesser.php#L18-L34
15,578
czim/laravel-pxlcms
src/Sluggable/SluggableTrait.php
SluggableTrait.bootSluggableTrait
public static function bootSluggableTrait() { // cache config for this model static::$slugsTable = config('pxlcms.slugs.table', 'cms_slugs'); static::$slugsColumn = config('pxlcms.slugs.column', 'slug'); static::$slugsEntryKey = config('pxlcms.slugs.keys.entry', 'entry_id'); static::$slugsModuleKey = config('pxlcms.slugs.keys.module', 'module_id'); static::$slugsLanguageKey = config('pxlcms.slugs.keys.language', 'language_id'); static::$slugsActiveColumn = config('pxlcms.slugs.active_column', false); }
php
public static function bootSluggableTrait() { // cache config for this model static::$slugsTable = config('pxlcms.slugs.table', 'cms_slugs'); static::$slugsColumn = config('pxlcms.slugs.column', 'slug'); static::$slugsEntryKey = config('pxlcms.slugs.keys.entry', 'entry_id'); static::$slugsModuleKey = config('pxlcms.slugs.keys.module', 'module_id'); static::$slugsLanguageKey = config('pxlcms.slugs.keys.language', 'language_id'); static::$slugsActiveColumn = config('pxlcms.slugs.active_column', false); }
[ "public", "static", "function", "bootSluggableTrait", "(", ")", "{", "// cache config for this model", "static", "::", "$", "slugsTable", "=", "config", "(", "'pxlcms.slugs.table'", ",", "'cms_slugs'", ")", ";", "static", "::", "$", "slugsColumn", "=", "config", "(", "'pxlcms.slugs.column'", ",", "'slug'", ")", ";", "static", "::", "$", "slugsEntryKey", "=", "config", "(", "'pxlcms.slugs.keys.entry'", ",", "'entry_id'", ")", ";", "static", "::", "$", "slugsModuleKey", "=", "config", "(", "'pxlcms.slugs.keys.module'", ",", "'module_id'", ")", ";", "static", "::", "$", "slugsLanguageKey", "=", "config", "(", "'pxlcms.slugs.keys.language'", ",", "'language_id'", ")", ";", "static", "::", "$", "slugsActiveColumn", "=", "config", "(", "'pxlcms.slugs.active_column'", ",", "false", ")", ";", "}" ]
Caches config on model boot
[ "Caches", "config", "on", "model", "boot" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L32-L41
15,579
czim/laravel-pxlcms
src/Sluggable/SluggableTrait.php
SluggableTrait.scopeWhereSlug
public function scopeWhereSlug($scope, $slug, $locale = null, $forHasQuery = false) { /** @var CmsModel|SluggableTrait $model */ $model = new static; if ($model->storeSlugLocally()) { return $this->CviebrockScopeWhereSlug($scope, $slug); } // build scope with join to slugs table .. $scope = $scope->join( static::$slugsTable, function($join) use ($model, $locale) { $idKey = $this->isTranslationModel() ? config('pxlcms.translatable.translation_foreign_key') : $this->getKeyName(); $join->on($model->getTable() . '.' . $idKey, '=', static::$slugsTable . '.' . static::$slugsEntryKey); $join->on(static::$slugsTable . '.' . static::$slugsModuleKey, '=', DB::raw( (int) $model->getModuleNumber())); if ( ! empty($locale) && $model->isTranslationModel()) { $languageId = $model->lookUpLanguageIdForLocale($locale); $join->on(static::$slugsTable . '.' . static::$slugsLanguageKey, '=', DB::raw( (int) $languageId)); } } ); return $scope->where(static::$slugsTable . '.' . static::$slugsColumn, $slug) ->select($this->getTable() . '.' . ($forHasQuery ? 'id' : '*')); }
php
public function scopeWhereSlug($scope, $slug, $locale = null, $forHasQuery = false) { /** @var CmsModel|SluggableTrait $model */ $model = new static; if ($model->storeSlugLocally()) { return $this->CviebrockScopeWhereSlug($scope, $slug); } // build scope with join to slugs table .. $scope = $scope->join( static::$slugsTable, function($join) use ($model, $locale) { $idKey = $this->isTranslationModel() ? config('pxlcms.translatable.translation_foreign_key') : $this->getKeyName(); $join->on($model->getTable() . '.' . $idKey, '=', static::$slugsTable . '.' . static::$slugsEntryKey); $join->on(static::$slugsTable . '.' . static::$slugsModuleKey, '=', DB::raw( (int) $model->getModuleNumber())); if ( ! empty($locale) && $model->isTranslationModel()) { $languageId = $model->lookUpLanguageIdForLocale($locale); $join->on(static::$slugsTable . '.' . static::$slugsLanguageKey, '=', DB::raw( (int) $languageId)); } } ); return $scope->where(static::$slugsTable . '.' . static::$slugsColumn, $slug) ->select($this->getTable() . '.' . ($forHasQuery ? 'id' : '*')); }
[ "public", "function", "scopeWhereSlug", "(", "$", "scope", ",", "$", "slug", ",", "$", "locale", "=", "null", ",", "$", "forHasQuery", "=", "false", ")", "{", "/** @var CmsModel|SluggableTrait $model */", "$", "model", "=", "new", "static", ";", "if", "(", "$", "model", "->", "storeSlugLocally", "(", ")", ")", "{", "return", "$", "this", "->", "CviebrockScopeWhereSlug", "(", "$", "scope", ",", "$", "slug", ")", ";", "}", "// build scope with join to slugs table ..", "$", "scope", "=", "$", "scope", "->", "join", "(", "static", "::", "$", "slugsTable", ",", "function", "(", "$", "join", ")", "use", "(", "$", "model", ",", "$", "locale", ")", "{", "$", "idKey", "=", "$", "this", "->", "isTranslationModel", "(", ")", "?", "config", "(", "'pxlcms.translatable.translation_foreign_key'", ")", ":", "$", "this", "->", "getKeyName", "(", ")", ";", "$", "join", "->", "on", "(", "$", "model", "->", "getTable", "(", ")", ".", "'.'", ".", "$", "idKey", ",", "'='", ",", "static", "::", "$", "slugsTable", ".", "'.'", ".", "static", "::", "$", "slugsEntryKey", ")", ";", "$", "join", "->", "on", "(", "static", "::", "$", "slugsTable", ".", "'.'", ".", "static", "::", "$", "slugsModuleKey", ",", "'='", ",", "DB", "::", "raw", "(", "(", "int", ")", "$", "model", "->", "getModuleNumber", "(", ")", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "locale", ")", "&&", "$", "model", "->", "isTranslationModel", "(", ")", ")", "{", "$", "languageId", "=", "$", "model", "->", "lookUpLanguageIdForLocale", "(", "$", "locale", ")", ";", "$", "join", "->", "on", "(", "static", "::", "$", "slugsTable", ".", "'.'", ".", "static", "::", "$", "slugsLanguageKey", ",", "'='", ",", "DB", "::", "raw", "(", "(", "int", ")", "$", "languageId", ")", ")", ";", "}", "}", ")", ";", "return", "$", "scope", "->", "where", "(", "static", "::", "$", "slugsTable", ".", "'.'", ".", "static", "::", "$", "slugsColumn", ",", "$", "slug", ")", "->", "select", "(", "$", "this", "->", "getTable", "(", ")", ".", "'.'", ".", "(", "$", "forHasQuery", "?", "'id'", ":", "'*'", ")", ")", ";", "}" ]
Query scope for finding a model by its slug. @param Builder $scope @param string $slug @param string $locale if not set, matches for any locale @param bool $forHasQuery if true, the scope is part of a has relation subquery @return mixed
[ "Query", "scope", "for", "finding", "a", "model", "by", "its", "slug", "." ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L91-L122
15,580
czim/laravel-pxlcms
src/Sluggable/SluggableTrait.php
SluggableTrait.setSlug
protected function setSlug($slug) { $config = $this->getSluggableConfig(); $save_to = $config['save_to']; if ($this->storeSlugLocally()) { $this->setAttribute($save_to, $slug); return; } $this->setSlugInCmsTable($slug); }
php
protected function setSlug($slug) { $config = $this->getSluggableConfig(); $save_to = $config['save_to']; if ($this->storeSlugLocally()) { $this->setAttribute($save_to, $slug); return; } $this->setSlugInCmsTable($slug); }
[ "protected", "function", "setSlug", "(", "$", "slug", ")", "{", "$", "config", "=", "$", "this", "->", "getSluggableConfig", "(", ")", ";", "$", "save_to", "=", "$", "config", "[", "'save_to'", "]", ";", "if", "(", "$", "this", "->", "storeSlugLocally", "(", ")", ")", "{", "$", "this", "->", "setAttribute", "(", "$", "save_to", ",", "$", "slug", ")", ";", "return", ";", "}", "$", "this", "->", "setSlugInCmsTable", "(", "$", "slug", ")", ";", "}" ]
Set the slug manually. @param string $slug
[ "Set", "the", "slug", "manually", "." ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L130-L141
15,581
czim/laravel-pxlcms
src/Sluggable/SluggableTrait.php
SluggableTrait.getSlugRecordFromCmsTable
protected function getSlugRecordFromCmsTable() { /** @var CmsModel|SluggableTrait $this */ $languageId = $this->storeSlugForLanguageId(); $entryId = $this->isTranslationModel() ? $this->getAttribute(config('pxlcms.translatable.translation_foreign_key')) : $this->getKey(); $existing = DB::table(static::$slugsTable) ->select([ 'id', static::$slugsColumn . ' as slug' ]) ->where(static::$slugsModuleKey, $this->getModuleNumber()) ->where(static::$slugsEntryKey, $entryId); // if language is null, we need to take into account that some weird // cms hook setups will use '0' or '' (and do not have nullable language columns) if (is_null($languageId)) { $existing = $existing->where(function($query) { return $query->whereNull(static::$slugsLanguageKey) ->orWhere(static::$slugsLanguageKey, 0) ->orWhere(static::$slugsLanguageKey, ''); }); } else { $existing = $existing->where(static::$slugsLanguageKey, $languageId); } $existing = $existing->limit(1) ->first(); if (empty($existing)) return null; return $existing; }
php
protected function getSlugRecordFromCmsTable() { /** @var CmsModel|SluggableTrait $this */ $languageId = $this->storeSlugForLanguageId(); $entryId = $this->isTranslationModel() ? $this->getAttribute(config('pxlcms.translatable.translation_foreign_key')) : $this->getKey(); $existing = DB::table(static::$slugsTable) ->select([ 'id', static::$slugsColumn . ' as slug' ]) ->where(static::$slugsModuleKey, $this->getModuleNumber()) ->where(static::$slugsEntryKey, $entryId); // if language is null, we need to take into account that some weird // cms hook setups will use '0' or '' (and do not have nullable language columns) if (is_null($languageId)) { $existing = $existing->where(function($query) { return $query->whereNull(static::$slugsLanguageKey) ->orWhere(static::$slugsLanguageKey, 0) ->orWhere(static::$slugsLanguageKey, ''); }); } else { $existing = $existing->where(static::$slugsLanguageKey, $languageId); } $existing = $existing->limit(1) ->first(); if (empty($existing)) return null; return $existing; }
[ "protected", "function", "getSlugRecordFromCmsTable", "(", ")", "{", "/** @var CmsModel|SluggableTrait $this */", "$", "languageId", "=", "$", "this", "->", "storeSlugForLanguageId", "(", ")", ";", "$", "entryId", "=", "$", "this", "->", "isTranslationModel", "(", ")", "?", "$", "this", "->", "getAttribute", "(", "config", "(", "'pxlcms.translatable.translation_foreign_key'", ")", ")", ":", "$", "this", "->", "getKey", "(", ")", ";", "$", "existing", "=", "DB", "::", "table", "(", "static", "::", "$", "slugsTable", ")", "->", "select", "(", "[", "'id'", ",", "static", "::", "$", "slugsColumn", ".", "' as slug'", "]", ")", "->", "where", "(", "static", "::", "$", "slugsModuleKey", ",", "$", "this", "->", "getModuleNumber", "(", ")", ")", "->", "where", "(", "static", "::", "$", "slugsEntryKey", ",", "$", "entryId", ")", ";", "// if language is null, we need to take into account that some weird", "// cms hook setups will use '0' or '' (and do not have nullable language columns)", "if", "(", "is_null", "(", "$", "languageId", ")", ")", "{", "$", "existing", "=", "$", "existing", "->", "where", "(", "function", "(", "$", "query", ")", "{", "return", "$", "query", "->", "whereNull", "(", "static", "::", "$", "slugsLanguageKey", ")", "->", "orWhere", "(", "static", "::", "$", "slugsLanguageKey", ",", "0", ")", "->", "orWhere", "(", "static", "::", "$", "slugsLanguageKey", ",", "''", ")", ";", "}", ")", ";", "}", "else", "{", "$", "existing", "=", "$", "existing", "->", "where", "(", "static", "::", "$", "slugsLanguageKey", ",", "$", "languageId", ")", ";", "}", "$", "existing", "=", "$", "existing", "->", "limit", "(", "1", ")", "->", "first", "(", ")", ";", "if", "(", "empty", "(", "$", "existing", ")", ")", "return", "null", ";", "return", "$", "existing", ";", "}" ]
Returns current slug from CMS slugs table @return object|null
[ "Returns", "current", "slug", "from", "CMS", "slugs", "table" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L186-L222
15,582
czim/laravel-pxlcms
src/Sluggable/SluggableTrait.php
SluggableTrait.getAllSlugsForModuleFromCmsTable
protected function getAllSlugsForModuleFromCmsTable($likeSlug = null, $limitToLanguage = true) { /** @var CmsModel|SluggableTrait $this */ $config = $this->getSluggableConfig(); $includeTrashed = $config['include_trashed']; $separator = $config['separator']; $existing = DB::table(static::$slugsTable) ->select([ 'id', static::$slugsColumn . ' as slug' ]) ->where(static::$slugsModuleKey, $this->getModuleNumber()) ->where(function ($query) use ($likeSlug, $separator) { $query->where(static::$slugsColumn, $likeSlug); $query->orWhere(static::$slugsColumn, 'LIKE', $likeSlug . $separator . '%'); }); if ( ! $includeTrashed && static::$slugsActiveColumn) { $existing->where(static::$slugsActiveColumn, true); } if ($limitToLanguage) { $existing->where(static::$slugsLanguageKey, $this->storeSlugForLanguageId()); } $list = $existing->lists(static::$slugsColumn, static::$slugsEntryKey); // Laravel 5.0/5.1 check return $list instanceof Collection ? $list->all() : $list; }
php
protected function getAllSlugsForModuleFromCmsTable($likeSlug = null, $limitToLanguage = true) { /** @var CmsModel|SluggableTrait $this */ $config = $this->getSluggableConfig(); $includeTrashed = $config['include_trashed']; $separator = $config['separator']; $existing = DB::table(static::$slugsTable) ->select([ 'id', static::$slugsColumn . ' as slug' ]) ->where(static::$slugsModuleKey, $this->getModuleNumber()) ->where(function ($query) use ($likeSlug, $separator) { $query->where(static::$slugsColumn, $likeSlug); $query->orWhere(static::$slugsColumn, 'LIKE', $likeSlug . $separator . '%'); }); if ( ! $includeTrashed && static::$slugsActiveColumn) { $existing->where(static::$slugsActiveColumn, true); } if ($limitToLanguage) { $existing->where(static::$slugsLanguageKey, $this->storeSlugForLanguageId()); } $list = $existing->lists(static::$slugsColumn, static::$slugsEntryKey); // Laravel 5.0/5.1 check return $list instanceof Collection ? $list->all() : $list; }
[ "protected", "function", "getAllSlugsForModuleFromCmsTable", "(", "$", "likeSlug", "=", "null", ",", "$", "limitToLanguage", "=", "true", ")", "{", "/** @var CmsModel|SluggableTrait $this */", "$", "config", "=", "$", "this", "->", "getSluggableConfig", "(", ")", ";", "$", "includeTrashed", "=", "$", "config", "[", "'include_trashed'", "]", ";", "$", "separator", "=", "$", "config", "[", "'separator'", "]", ";", "$", "existing", "=", "DB", "::", "table", "(", "static", "::", "$", "slugsTable", ")", "->", "select", "(", "[", "'id'", ",", "static", "::", "$", "slugsColumn", ".", "' as slug'", "]", ")", "->", "where", "(", "static", "::", "$", "slugsModuleKey", ",", "$", "this", "->", "getModuleNumber", "(", ")", ")", "->", "where", "(", "function", "(", "$", "query", ")", "use", "(", "$", "likeSlug", ",", "$", "separator", ")", "{", "$", "query", "->", "where", "(", "static", "::", "$", "slugsColumn", ",", "$", "likeSlug", ")", ";", "$", "query", "->", "orWhere", "(", "static", "::", "$", "slugsColumn", ",", "'LIKE'", ",", "$", "likeSlug", ".", "$", "separator", ".", "'%'", ")", ";", "}", ")", ";", "if", "(", "!", "$", "includeTrashed", "&&", "static", "::", "$", "slugsActiveColumn", ")", "{", "$", "existing", "->", "where", "(", "static", "::", "$", "slugsActiveColumn", ",", "true", ")", ";", "}", "if", "(", "$", "limitToLanguage", ")", "{", "$", "existing", "->", "where", "(", "static", "::", "$", "slugsLanguageKey", ",", "$", "this", "->", "storeSlugForLanguageId", "(", ")", ")", ";", "}", "$", "list", "=", "$", "existing", "->", "lists", "(", "static", "::", "$", "slugsColumn", ",", "static", "::", "$", "slugsEntryKey", ")", ";", "// Laravel 5.0/5.1 check", "return", "$", "list", "instanceof", "Collection", "?", "$", "list", "->", "all", "(", ")", ":", "$", "list", ";", "}" ]
Returns current slugs for this module from CMS slugs table @param string $likeSlug if set, only returns slugs that are like the string @param bool $limitToLanguage if true, only returns matches within the language @return null|object
[ "Returns", "current", "slugs", "for", "this", "module", "from", "CMS", "slugs", "table" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L266-L297
15,583
czim/laravel-pxlcms
src/Sluggable/SluggableTrait.php
SluggableTrait.storeSlugForLanguageId
protected function storeSlugForLanguageId() { /** @var CmsModel|SluggableTrait $this */ $config = $this->getSluggableConfig(); $languageKey = array_get($config, 'language_key'); $localeKey = array_get($config, 'locale_key'); if ($languageKey) { return $this->getAttribute($languageKey); } if ($localeKey) { return $this->lookupLanguageIdForLocale( $this->getAttribute($localeKey) ); } return null; }
php
protected function storeSlugForLanguageId() { /** @var CmsModel|SluggableTrait $this */ $config = $this->getSluggableConfig(); $languageKey = array_get($config, 'language_key'); $localeKey = array_get($config, 'locale_key'); if ($languageKey) { return $this->getAttribute($languageKey); } if ($localeKey) { return $this->lookupLanguageIdForLocale( $this->getAttribute($localeKey) ); } return null; }
[ "protected", "function", "storeSlugForLanguageId", "(", ")", "{", "/** @var CmsModel|SluggableTrait $this */", "$", "config", "=", "$", "this", "->", "getSluggableConfig", "(", ")", ";", "$", "languageKey", "=", "array_get", "(", "$", "config", ",", "'language_key'", ")", ";", "$", "localeKey", "=", "array_get", "(", "$", "config", ",", "'locale_key'", ")", ";", "if", "(", "$", "languageKey", ")", "{", "return", "$", "this", "->", "getAttribute", "(", "$", "languageKey", ")", ";", "}", "if", "(", "$", "localeKey", ")", "{", "return", "$", "this", "->", "lookupLanguageIdForLocale", "(", "$", "this", "->", "getAttribute", "(", "$", "localeKey", ")", ")", ";", "}", "return", "null", ";", "}" ]
Returns the language_id to store slugs for @return string
[ "Returns", "the", "language_id", "to", "store", "slugs", "for" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L365-L382
15,584
Wonail/wocenter
actions/FlushCache.php
FlushCache.flushCache
protected function flushCache(Module $current = null) { $message = ''; if ($current === null) { $current = Yii::$app; } $modules = $current->getModules(); foreach ($modules as $moduleName => $module) { if (is_array($module)) { $module = $current->getModule($moduleName, true); } if ($module instanceof Module) { $message .= $this->flushCache($module); } } $components = $current->getComponents(); foreach ($components as $componentName => $component) { if (is_array($component) && $componentName != 'user') { $component = $current->get($componentName); } if ($component instanceof Cache) { $message .= $component->flush() ? '<p>' . Yii::t( 'wocenter/app', '{currentModuleName}: {componentName} is flushed.', [ 'currentModuleName' => $current->className(), 'componentName' => $component->className(), ] ) . '</p>' : ''; } } return $message; }
php
protected function flushCache(Module $current = null) { $message = ''; if ($current === null) { $current = Yii::$app; } $modules = $current->getModules(); foreach ($modules as $moduleName => $module) { if (is_array($module)) { $module = $current->getModule($moduleName, true); } if ($module instanceof Module) { $message .= $this->flushCache($module); } } $components = $current->getComponents(); foreach ($components as $componentName => $component) { if (is_array($component) && $componentName != 'user') { $component = $current->get($componentName); } if ($component instanceof Cache) { $message .= $component->flush() ? '<p>' . Yii::t( 'wocenter/app', '{currentModuleName}: {componentName} is flushed.', [ 'currentModuleName' => $current->className(), 'componentName' => $component->className(), ] ) . '</p>' : ''; } } return $message; }
[ "protected", "function", "flushCache", "(", "Module", "$", "current", "=", "null", ")", "{", "$", "message", "=", "''", ";", "if", "(", "$", "current", "===", "null", ")", "{", "$", "current", "=", "Yii", "::", "$", "app", ";", "}", "$", "modules", "=", "$", "current", "->", "getModules", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "moduleName", "=>", "$", "module", ")", "{", "if", "(", "is_array", "(", "$", "module", ")", ")", "{", "$", "module", "=", "$", "current", "->", "getModule", "(", "$", "moduleName", ",", "true", ")", ";", "}", "if", "(", "$", "module", "instanceof", "Module", ")", "{", "$", "message", ".=", "$", "this", "->", "flushCache", "(", "$", "module", ")", ";", "}", "}", "$", "components", "=", "$", "current", "->", "getComponents", "(", ")", ";", "foreach", "(", "$", "components", "as", "$", "componentName", "=>", "$", "component", ")", "{", "if", "(", "is_array", "(", "$", "component", ")", "&&", "$", "componentName", "!=", "'user'", ")", "{", "$", "component", "=", "$", "current", "->", "get", "(", "$", "componentName", ")", ";", "}", "if", "(", "$", "component", "instanceof", "Cache", ")", "{", "$", "message", ".=", "$", "component", "->", "flush", "(", ")", "?", "'<p>'", ".", "Yii", "::", "t", "(", "'wocenter/app'", ",", "'{currentModuleName}: {componentName} is flushed.'", ",", "[", "'currentModuleName'", "=>", "$", "current", "->", "className", "(", ")", ",", "'componentName'", "=>", "$", "component", "->", "className", "(", ")", ",", "]", ")", ".", "'</p>'", ":", "''", ";", "}", "}", "return", "$", "message", ";", "}" ]
Recursive flush all app cache @param null|Module $current Current Module @return string execute message
[ "Recursive", "flush", "all", "app", "cache" ]
186c15aad008d32fbf5ad75256cf01581dccf9e6
https://github.com/Wonail/wocenter/blob/186c15aad008d32fbf5ad75256cf01581dccf9e6/actions/FlushCache.php#L40-L73
15,585
JoffreyPoreeCoding/MongoDB-ODM
src/Tools/ArrayModifier.php
ArrayModifier.aggregate
public static function aggregate($array, $specialKeys = self::SPECIALS_KEYS, $prefix = '') { $new = []; foreach ($array as $key => $value) { $newKey = (!empty($prefix)) ? $prefix . '.' . $key : $key; if (!in_array($key, $specialKeys, true) && !in_array($key, array_keys($specialKeys), true)) { if (is_a($value, "stdClass")) { $value = (array) $value; } if (is_array($value)) { $new += self::aggregate($value, $specialKeys, $newKey); } else { $new[$newKey] = $value; } } else { if (array_key_exists($key, $specialKeys) && is_callable($specialKeys[$key])) { $new = call_user_func($specialKeys[$key], $prefix, $key, $value, $new); } } } return $new; }
php
public static function aggregate($array, $specialKeys = self::SPECIALS_KEYS, $prefix = '') { $new = []; foreach ($array as $key => $value) { $newKey = (!empty($prefix)) ? $prefix . '.' . $key : $key; if (!in_array($key, $specialKeys, true) && !in_array($key, array_keys($specialKeys), true)) { if (is_a($value, "stdClass")) { $value = (array) $value; } if (is_array($value)) { $new += self::aggregate($value, $specialKeys, $newKey); } else { $new[$newKey] = $value; } } else { if (array_key_exists($key, $specialKeys) && is_callable($specialKeys[$key])) { $new = call_user_func($specialKeys[$key], $prefix, $key, $value, $new); } } } return $new; }
[ "public", "static", "function", "aggregate", "(", "$", "array", ",", "$", "specialKeys", "=", "self", "::", "SPECIALS_KEYS", ",", "$", "prefix", "=", "''", ")", "{", "$", "new", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "newKey", "=", "(", "!", "empty", "(", "$", "prefix", ")", ")", "?", "$", "prefix", ".", "'.'", ".", "$", "key", ":", "$", "key", ";", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "specialKeys", ",", "true", ")", "&&", "!", "in_array", "(", "$", "key", ",", "array_keys", "(", "$", "specialKeys", ")", ",", "true", ")", ")", "{", "if", "(", "is_a", "(", "$", "value", ",", "\"stdClass\"", ")", ")", "{", "$", "value", "=", "(", "array", ")", "$", "value", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "new", "+=", "self", "::", "aggregate", "(", "$", "value", ",", "$", "specialKeys", ",", "$", "newKey", ")", ";", "}", "else", "{", "$", "new", "[", "$", "newKey", "]", "=", "$", "value", ";", "}", "}", "else", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "specialKeys", ")", "&&", "is_callable", "(", "$", "specialKeys", "[", "$", "key", "]", ")", ")", "{", "$", "new", "=", "call_user_func", "(", "$", "specialKeys", "[", "$", "key", "]", ",", "$", "prefix", ",", "$", "key", ",", "$", "value", ",", "$", "new", ")", ";", "}", "}", "}", "return", "$", "new", ";", "}" ]
Aggregate an array to dot notation @param array $array Input array @param array $specialKeys array of key to not aggregate @param string $prefix prefix @return array
[ "Aggregate", "an", "array", "to", "dot", "notation" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Tools/ArrayModifier.php#L44-L67
15,586
JoffreyPoreeCoding/MongoDB-ODM
src/Tools/ArrayModifier.php
ArrayModifier.disaggregate
public static function disaggregate($array) { $new = []; foreach ($array as $key => $val) { if (false !== strpos($key, ".")) { list($realKey, $aggregated) = explode(".", $key, 2); $values = self::getDisaggregatedValues(preg_grep("/^$realKey/", array_keys($array)), $array); $new[$realKey] = self::disaggregate($values); } else { $new[$key] = $val; } } return $new; }
php
public static function disaggregate($array) { $new = []; foreach ($array as $key => $val) { if (false !== strpos($key, ".")) { list($realKey, $aggregated) = explode(".", $key, 2); $values = self::getDisaggregatedValues(preg_grep("/^$realKey/", array_keys($array)), $array); $new[$realKey] = self::disaggregate($values); } else { $new[$key] = $val; } } return $new; }
[ "public", "static", "function", "disaggregate", "(", "$", "array", ")", "{", "$", "new", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "false", "!==", "strpos", "(", "$", "key", ",", "\".\"", ")", ")", "{", "list", "(", "$", "realKey", ",", "$", "aggregated", ")", "=", "explode", "(", "\".\"", ",", "$", "key", ",", "2", ")", ";", "$", "values", "=", "self", "::", "getDisaggregatedValues", "(", "preg_grep", "(", "\"/^$realKey/\"", ",", "array_keys", "(", "$", "array", ")", ")", ",", "$", "array", ")", ";", "$", "new", "[", "$", "realKey", "]", "=", "self", "::", "disaggregate", "(", "$", "values", ")", ";", "}", "else", "{", "$", "new", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "return", "$", "new", ";", "}" ]
Disaggreate a dot notation array to an multi-dimensionnal array @param array $array Dot notation array @return void
[ "Disaggreate", "a", "dot", "notation", "array", "to", "an", "multi", "-", "dimensionnal", "array" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Tools/ArrayModifier.php#L75-L89
15,587
JoffreyPoreeCoding/MongoDB-ODM
src/Tools/ArrayModifier.php
ArrayModifier.getDisaggregatedValues
private static function getDisaggregatedValues($keys, $array) { $values = []; foreach ($keys as $key) { $realKey = explode(".", $key, 2)[1]; $values[$realKey] = $array[$key]; } return $values; }
php
private static function getDisaggregatedValues($keys, $array) { $values = []; foreach ($keys as $key) { $realKey = explode(".", $key, 2)[1]; $values[$realKey] = $array[$key]; } return $values; }
[ "private", "static", "function", "getDisaggregatedValues", "(", "$", "keys", ",", "$", "array", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "realKey", "=", "explode", "(", "\".\"", ",", "$", "key", ",", "2", ")", "[", "1", "]", ";", "$", "values", "[", "$", "realKey", "]", "=", "$", "array", "[", "$", "key", "]", ";", "}", "return", "$", "values", ";", "}" ]
Get values of disaggregated array @param array $keys Key @param array $array Array to disaggegate @return array
[ "Get", "values", "of", "disaggregated", "array" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Tools/ArrayModifier.php#L98-L106
15,588
acasademont/wurfl
WURFL/Handlers/Handler.php
WURFL_Handlers_Handler.match
public function match(WURFL_Request_GenericRequest $request) { if ($this->canHandle($request->userAgentNormalized)) { return $this->applyMatch($request); } if (isset($this->nextHandler)) { return $this->nextHandler->match($request); } return WURFL_Constants::GENERIC; }
php
public function match(WURFL_Request_GenericRequest $request) { if ($this->canHandle($request->userAgentNormalized)) { return $this->applyMatch($request); } if (isset($this->nextHandler)) { return $this->nextHandler->match($request); } return WURFL_Constants::GENERIC; }
[ "public", "function", "match", "(", "WURFL_Request_GenericRequest", "$", "request", ")", "{", "if", "(", "$", "this", "->", "canHandle", "(", "$", "request", "->", "userAgentNormalized", ")", ")", "{", "return", "$", "this", "->", "applyMatch", "(", "$", "request", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "nextHandler", ")", ")", "{", "return", "$", "this", "->", "nextHandler", "->", "match", "(", "$", "request", ")", ";", "}", "return", "WURFL_Constants", "::", "GENERIC", ";", "}" ]
Finds the device id for the given request - if it is not found it delegates to the next available handler @param WURFL_Request_GenericRequest $request @return string WURFL Device ID for matching device
[ "Finds", "the", "device", "id", "for", "the", "given", "request", "-", "if", "it", "is", "not", "found", "it", "delegates", "to", "the", "next", "available", "handler" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Handlers/Handler.php#L211-L222
15,589
AbuseIO/parser-spamcop
src/Spamcop.php
Spamcop.parseSummaryReport
public function parseSummaryReport() { $reports = [ ]; preg_match_all( "/^\s*". "(?<ip>[a-f0-9:\.]+)\s+". "(?<date>\w+\s+\d+\s\d+)h\/". "(?<days>\d+)\s+". "(?<trap>\d+)\s+". "(?<user>\d+)\s+". "(?<mole>\d+)\s+". "(?<simp>\d+)". "/m", $this->parsedMail->getMessageBody(), $matches, PREG_SET_ORDER ); if (is_array($matches) && count($matches) > 0) { foreach ($matches as $match) { $report = [ 'Source-IP' => $match['ip'], 'Received-Date' => $match['date'] . ':00', 'Duration-Days' => $match['days'], ]; foreach (['trap', 'user', 'mole', 'simp'] as $field) { $report[ucfirst($field) ."-Report"] = $match[$field]; } $reports[] = $report; } } return $reports; }
php
public function parseSummaryReport() { $reports = [ ]; preg_match_all( "/^\s*". "(?<ip>[a-f0-9:\.]+)\s+". "(?<date>\w+\s+\d+\s\d+)h\/". "(?<days>\d+)\s+". "(?<trap>\d+)\s+". "(?<user>\d+)\s+". "(?<mole>\d+)\s+". "(?<simp>\d+)". "/m", $this->parsedMail->getMessageBody(), $matches, PREG_SET_ORDER ); if (is_array($matches) && count($matches) > 0) { foreach ($matches as $match) { $report = [ 'Source-IP' => $match['ip'], 'Received-Date' => $match['date'] . ':00', 'Duration-Days' => $match['days'], ]; foreach (['trap', 'user', 'mole', 'simp'] as $field) { $report[ucfirst($field) ."-Report"] = $match[$field]; } $reports[] = $report; } } return $reports; }
[ "public", "function", "parseSummaryReport", "(", ")", "{", "$", "reports", "=", "[", "]", ";", "preg_match_all", "(", "\"/^\\s*\"", ".", "\"(?<ip>[a-f0-9:\\.]+)\\s+\"", ".", "\"(?<date>\\w+\\s+\\d+\\s\\d+)h\\/\"", ".", "\"(?<days>\\d+)\\s+\"", ".", "\"(?<trap>\\d+)\\s+\"", ".", "\"(?<user>\\d+)\\s+\"", ".", "\"(?<mole>\\d+)\\s+\"", ".", "\"(?<simp>\\d+)\"", ".", "\"/m\"", ",", "$", "this", "->", "parsedMail", "->", "getMessageBody", "(", ")", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "if", "(", "is_array", "(", "$", "matches", ")", "&&", "count", "(", "$", "matches", ")", ">", "0", ")", "{", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "$", "report", "=", "[", "'Source-IP'", "=>", "$", "match", "[", "'ip'", "]", ",", "'Received-Date'", "=>", "$", "match", "[", "'date'", "]", ".", "':00'", ",", "'Duration-Days'", "=>", "$", "match", "[", "'days'", "]", ",", "]", ";", "foreach", "(", "[", "'trap'", ",", "'user'", ",", "'mole'", ",", "'simp'", "]", "as", "$", "field", ")", "{", "$", "report", "[", "ucfirst", "(", "$", "field", ")", ".", "\"-Report\"", "]", "=", "$", "match", "[", "$", "field", "]", ";", "}", "$", "reports", "[", "]", "=", "$", "report", ";", "}", "}", "return", "$", "reports", ";", "}" ]
This is a spamcop formatted summery with a multiple incidents @return array $reports
[ "This", "is", "a", "spamcop", "formatted", "summery", "with", "a", "multiple", "incidents" ]
6745d54bfee747b66af6e7332a59d554de3d8253
https://github.com/AbuseIO/parser-spamcop/blob/6745d54bfee747b66af6e7332a59d554de3d8253/src/Spamcop.php#L105-L141
15,590
AbuseIO/parser-spamcop
src/Spamcop.php
Spamcop.parseAlerts
public function parseAlerts() { $reports = [ ]; preg_match_all( '/\s*(?<ip>[a-f0-9:\.]+)/', // Someone from spamcop found it funny to prefix IPv6 addresses, so lets strip that off str_replace('IPv6 ', '', $this->parsedMail->getMessageBody()), $matches ); $received = $this->parsedMail->getHeaders()['date']; if (strtotime(date('d-m-Y H:i:s', strtotime($received))) !== (int)strtotime($received)) { $received = date('d-m-Y H:i:s'); } if (is_array($matches) && !empty($matches['ip']) && count($matches['ip']) > 0) { foreach ($matches['ip'] as $ip) { $reports[] = [ 'Source-IP' => $ip, 'Received-Date' => $received, 'Note' => 'A spamtrap hit notification was received.'. ' These notifications do not provide any evidence.' ]; } } return $reports; }
php
public function parseAlerts() { $reports = [ ]; preg_match_all( '/\s*(?<ip>[a-f0-9:\.]+)/', // Someone from spamcop found it funny to prefix IPv6 addresses, so lets strip that off str_replace('IPv6 ', '', $this->parsedMail->getMessageBody()), $matches ); $received = $this->parsedMail->getHeaders()['date']; if (strtotime(date('d-m-Y H:i:s', strtotime($received))) !== (int)strtotime($received)) { $received = date('d-m-Y H:i:s'); } if (is_array($matches) && !empty($matches['ip']) && count($matches['ip']) > 0) { foreach ($matches['ip'] as $ip) { $reports[] = [ 'Source-IP' => $ip, 'Received-Date' => $received, 'Note' => 'A spamtrap hit notification was received.'. ' These notifications do not provide any evidence.' ]; } } return $reports; }
[ "public", "function", "parseAlerts", "(", ")", "{", "$", "reports", "=", "[", "]", ";", "preg_match_all", "(", "'/\\s*(?<ip>[a-f0-9:\\.]+)/'", ",", "// Someone from spamcop found it funny to prefix IPv6 addresses, so lets strip that off", "str_replace", "(", "'IPv6 '", ",", "''", ",", "$", "this", "->", "parsedMail", "->", "getMessageBody", "(", ")", ")", ",", "$", "matches", ")", ";", "$", "received", "=", "$", "this", "->", "parsedMail", "->", "getHeaders", "(", ")", "[", "'date'", "]", ";", "if", "(", "strtotime", "(", "date", "(", "'d-m-Y H:i:s'", ",", "strtotime", "(", "$", "received", ")", ")", ")", "!==", "(", "int", ")", "strtotime", "(", "$", "received", ")", ")", "{", "$", "received", "=", "date", "(", "'d-m-Y H:i:s'", ")", ";", "}", "if", "(", "is_array", "(", "$", "matches", ")", "&&", "!", "empty", "(", "$", "matches", "[", "'ip'", "]", ")", "&&", "count", "(", "$", "matches", "[", "'ip'", "]", ")", ">", "0", ")", "{", "foreach", "(", "$", "matches", "[", "'ip'", "]", "as", "$", "ip", ")", "{", "$", "reports", "[", "]", "=", "[", "'Source-IP'", "=>", "$", "ip", ",", "'Received-Date'", "=>", "$", "received", ",", "'Note'", "=>", "'A spamtrap hit notification was received.'", ".", "' These notifications do not provide any evidence.'", "]", ";", "}", "}", "return", "$", "reports", ";", "}" ]
This is a spamcop formatted alert with a multiple incidents @return array $reports
[ "This", "is", "a", "spamcop", "formatted", "alert", "with", "a", "multiple", "incidents" ]
6745d54bfee747b66af6e7332a59d554de3d8253
https://github.com/AbuseIO/parser-spamcop/blob/6745d54bfee747b66af6e7332a59d554de3d8253/src/Spamcop.php#L149-L179
15,591
AbuseIO/parser-spamcop
src/Spamcop.php
Spamcop.parseSpamReportCustom
public function parseSpamReportCustom() { $reports = [ ]; $body = $this->parsedMail->getMessageBody(); // Grab the message part from the body preg_match( '/(\[ SpamCop V[0-9\.\]\ ]*+)\r?\n(?<message>.*)\r?\n\[ Offending message \]/s', $body, $matches ); if (!empty($matches['message'])) { $report['message'] = $matches['message']; } // Grab the Evidence from the body preg_match( '/(\[ Offending message \]*+)\r?\n(?<evidence>.*)/s', $body, $matches ); if (!empty($matches['evidence'])) { $parsedEvidence = new MimeParser(); $parsedEvidence->setText($matches['evidence']); $report['evidence'] = $parsedEvidence->getHeaders(); } // Now parse the data from both extracts if (!empty($report['message']) && !empty($report['evidence'])) { preg_match( '/Email from (?<ip>[a-f0-9:\.]+) \/ (?<date>.*)/', $report['message'], $matches ); if (!empty($matches['ip']) && !empty($matches['date'])) { $report['Source-IP'] = $matches['ip']; $report['Received-Date'] = $matches['date']; $reports[] = $report; } /* * Why would you use a single format while you can use different formats huh Spamcop? * For spamvertized we need to do some magic to build the report correctly * "(?<mole>\d+)\s+". */ $report['message'] = str_replace('\r', '', $report['message']); preg_match( '/Spamvertised web site:\s'. '(?<url>.*)\\n'. '(?<reply>.*)\n'. '(?<resolved>.*) is (?<ip>.*); (?<date>.*)\n'. '/', $report['message'], $matches ); if (!empty($matches['ip']) && !empty($matches['date']) && !empty($matches['url'])) { $report['Source-IP'] = $matches['ip']; $report['Received-Date'] = $matches['date']; $report['Report-URL'] = $matches['reply']; $report['Spam-URL'] = $matches['url']; $reports[] = $report; } } else { $this->warningCount++; } return $reports; }
php
public function parseSpamReportCustom() { $reports = [ ]; $body = $this->parsedMail->getMessageBody(); // Grab the message part from the body preg_match( '/(\[ SpamCop V[0-9\.\]\ ]*+)\r?\n(?<message>.*)\r?\n\[ Offending message \]/s', $body, $matches ); if (!empty($matches['message'])) { $report['message'] = $matches['message']; } // Grab the Evidence from the body preg_match( '/(\[ Offending message \]*+)\r?\n(?<evidence>.*)/s', $body, $matches ); if (!empty($matches['evidence'])) { $parsedEvidence = new MimeParser(); $parsedEvidence->setText($matches['evidence']); $report['evidence'] = $parsedEvidence->getHeaders(); } // Now parse the data from both extracts if (!empty($report['message']) && !empty($report['evidence'])) { preg_match( '/Email from (?<ip>[a-f0-9:\.]+) \/ (?<date>.*)/', $report['message'], $matches ); if (!empty($matches['ip']) && !empty($matches['date'])) { $report['Source-IP'] = $matches['ip']; $report['Received-Date'] = $matches['date']; $reports[] = $report; } /* * Why would you use a single format while you can use different formats huh Spamcop? * For spamvertized we need to do some magic to build the report correctly * "(?<mole>\d+)\s+". */ $report['message'] = str_replace('\r', '', $report['message']); preg_match( '/Spamvertised web site:\s'. '(?<url>.*)\\n'. '(?<reply>.*)\n'. '(?<resolved>.*) is (?<ip>.*); (?<date>.*)\n'. '/', $report['message'], $matches ); if (!empty($matches['ip']) && !empty($matches['date']) && !empty($matches['url'])) { $report['Source-IP'] = $matches['ip']; $report['Received-Date'] = $matches['date']; $report['Report-URL'] = $matches['reply']; $report['Spam-URL'] = $matches['url']; $reports[] = $report; } } else { $this->warningCount++; } return $reports; }
[ "public", "function", "parseSpamReportCustom", "(", ")", "{", "$", "reports", "=", "[", "]", ";", "$", "body", "=", "$", "this", "->", "parsedMail", "->", "getMessageBody", "(", ")", ";", "// Grab the message part from the body", "preg_match", "(", "'/(\\[ SpamCop V[0-9\\.\\]\\ ]*+)\\r?\\n(?<message>.*)\\r?\\n\\[ Offending message \\]/s'", ",", "$", "body", ",", "$", "matches", ")", ";", "if", "(", "!", "empty", "(", "$", "matches", "[", "'message'", "]", ")", ")", "{", "$", "report", "[", "'message'", "]", "=", "$", "matches", "[", "'message'", "]", ";", "}", "// Grab the Evidence from the body", "preg_match", "(", "'/(\\[ Offending message \\]*+)\\r?\\n(?<evidence>.*)/s'", ",", "$", "body", ",", "$", "matches", ")", ";", "if", "(", "!", "empty", "(", "$", "matches", "[", "'evidence'", "]", ")", ")", "{", "$", "parsedEvidence", "=", "new", "MimeParser", "(", ")", ";", "$", "parsedEvidence", "->", "setText", "(", "$", "matches", "[", "'evidence'", "]", ")", ";", "$", "report", "[", "'evidence'", "]", "=", "$", "parsedEvidence", "->", "getHeaders", "(", ")", ";", "}", "// Now parse the data from both extracts", "if", "(", "!", "empty", "(", "$", "report", "[", "'message'", "]", ")", "&&", "!", "empty", "(", "$", "report", "[", "'evidence'", "]", ")", ")", "{", "preg_match", "(", "'/Email from (?<ip>[a-f0-9:\\.]+) \\/ (?<date>.*)/'", ",", "$", "report", "[", "'message'", "]", ",", "$", "matches", ")", ";", "if", "(", "!", "empty", "(", "$", "matches", "[", "'ip'", "]", ")", "&&", "!", "empty", "(", "$", "matches", "[", "'date'", "]", ")", ")", "{", "$", "report", "[", "'Source-IP'", "]", "=", "$", "matches", "[", "'ip'", "]", ";", "$", "report", "[", "'Received-Date'", "]", "=", "$", "matches", "[", "'date'", "]", ";", "$", "reports", "[", "]", "=", "$", "report", ";", "}", "/*\n * Why would you use a single format while you can use different formats huh Spamcop?\n * For spamvertized we need to do some magic to build the report correctly\n * \"(?<mole>\\d+)\\s+\".\n */", "$", "report", "[", "'message'", "]", "=", "str_replace", "(", "'\\r'", ",", "''", ",", "$", "report", "[", "'message'", "]", ")", ";", "preg_match", "(", "'/Spamvertised web site:\\s'", ".", "'(?<url>.*)\\\\n'", ".", "'(?<reply>.*)\\n'", ".", "'(?<resolved>.*) is (?<ip>.*); (?<date>.*)\\n'", ".", "'/'", ",", "$", "report", "[", "'message'", "]", ",", "$", "matches", ")", ";", "if", "(", "!", "empty", "(", "$", "matches", "[", "'ip'", "]", ")", "&&", "!", "empty", "(", "$", "matches", "[", "'date'", "]", ")", "&&", "!", "empty", "(", "$", "matches", "[", "'url'", "]", ")", ")", "{", "$", "report", "[", "'Source-IP'", "]", "=", "$", "matches", "[", "'ip'", "]", ";", "$", "report", "[", "'Received-Date'", "]", "=", "$", "matches", "[", "'date'", "]", ";", "$", "report", "[", "'Report-URL'", "]", "=", "$", "matches", "[", "'reply'", "]", ";", "$", "report", "[", "'Spam-URL'", "]", "=", "$", "matches", "[", "'url'", "]", ";", "$", "reports", "[", "]", "=", "$", "report", ";", "}", "}", "else", "{", "$", "this", "->", "warningCount", "++", ";", "}", "return", "$", "reports", ";", "}" ]
This is a spamcop formatted mail with a single incident @return array $reports
[ "This", "is", "a", "spamcop", "formatted", "mail", "with", "a", "single", "incident" ]
6745d54bfee747b66af6e7332a59d554de3d8253
https://github.com/AbuseIO/parser-spamcop/blob/6745d54bfee747b66af6e7332a59d554de3d8253/src/Spamcop.php#L187-L261
15,592
AbuseIO/parser-spamcop
src/Spamcop.php
Spamcop.parseSpamReportArf
public function parseSpamReportArf() { $reports = [ ]; //Seriously spamcop? Newlines arent in the CL specifications $this->arfMail['report'] = str_replace("\r", "", $this->arfMail['report']); preg_match_all('/([\w\-]+): (.*)[ ]*\r?\n/', $this->arfMail['report'], $regs); $report = array_combine($regs[1], $regs[2]); //Valueable information put in the body instead of the report, thnx for that Spamcop if (strpos($this->arfMail['message'], 'Comments from recipient') !== false) { preg_match( "/Comments from recipient.*\s]\n(.*)\n\n\nThis/s", str_replace(array("\r", "> "), "", $this->arfMail['message']), $match ); $report['recipient_comment'] = str_replace("\n", " ", $match[1]); } // Add the headers from evidence into infoblob $parsedEvidence = new MimeParser(); $parsedEvidence->setText($this->arfMail['evidence']); $headers = $parsedEvidence->getHeaders(); foreach ($headers as $key => $value) { if (is_array($value) || is_object(($value))) { foreach ($value as $index => $subvalue) { $report['headers']["${key}${index}"] = "$subvalue"; } } else { $report['headers']["$key"] = $value; } } /* * Sometimes Spamcop has a trouble adding the correct fields. The IP is pretty * normal to add. In a last attempt we will try to fetch the IP from the body ourselves */ if (empty($report['Source-IP'])) { preg_match( "/Email from (?<ip>[a-f0-9:\.]+) \/ " . preg_quote($report['Received-Date']) . "/s", $this->arfMail['message'], $regs ); if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) { $report['Source-IP'] = $regs['ip']; } preg_match( "/from: (?<ip>[a-f0-9:\.]+)\r?\n?\r\n/s", $this->parsedMail->getMessageBody(), $regs ); if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) { $report['Source-IP'] = $regs['ip']; } } $reports[] = $report; return $reports; }
php
public function parseSpamReportArf() { $reports = [ ]; //Seriously spamcop? Newlines arent in the CL specifications $this->arfMail['report'] = str_replace("\r", "", $this->arfMail['report']); preg_match_all('/([\w\-]+): (.*)[ ]*\r?\n/', $this->arfMail['report'], $regs); $report = array_combine($regs[1], $regs[2]); //Valueable information put in the body instead of the report, thnx for that Spamcop if (strpos($this->arfMail['message'], 'Comments from recipient') !== false) { preg_match( "/Comments from recipient.*\s]\n(.*)\n\n\nThis/s", str_replace(array("\r", "> "), "", $this->arfMail['message']), $match ); $report['recipient_comment'] = str_replace("\n", " ", $match[1]); } // Add the headers from evidence into infoblob $parsedEvidence = new MimeParser(); $parsedEvidence->setText($this->arfMail['evidence']); $headers = $parsedEvidence->getHeaders(); foreach ($headers as $key => $value) { if (is_array($value) || is_object(($value))) { foreach ($value as $index => $subvalue) { $report['headers']["${key}${index}"] = "$subvalue"; } } else { $report['headers']["$key"] = $value; } } /* * Sometimes Spamcop has a trouble adding the correct fields. The IP is pretty * normal to add. In a last attempt we will try to fetch the IP from the body ourselves */ if (empty($report['Source-IP'])) { preg_match( "/Email from (?<ip>[a-f0-9:\.]+) \/ " . preg_quote($report['Received-Date']) . "/s", $this->arfMail['message'], $regs ); if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) { $report['Source-IP'] = $regs['ip']; } preg_match( "/from: (?<ip>[a-f0-9:\.]+)\r?\n?\r\n/s", $this->parsedMail->getMessageBody(), $regs ); if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) { $report['Source-IP'] = $regs['ip']; } } $reports[] = $report; return $reports; }
[ "public", "function", "parseSpamReportArf", "(", ")", "{", "$", "reports", "=", "[", "]", ";", "//Seriously spamcop? Newlines arent in the CL specifications", "$", "this", "->", "arfMail", "[", "'report'", "]", "=", "str_replace", "(", "\"\\r\"", ",", "\"\"", ",", "$", "this", "->", "arfMail", "[", "'report'", "]", ")", ";", "preg_match_all", "(", "'/([\\w\\-]+): (.*)[ ]*\\r?\\n/'", ",", "$", "this", "->", "arfMail", "[", "'report'", "]", ",", "$", "regs", ")", ";", "$", "report", "=", "array_combine", "(", "$", "regs", "[", "1", "]", ",", "$", "regs", "[", "2", "]", ")", ";", "//Valueable information put in the body instead of the report, thnx for that Spamcop", "if", "(", "strpos", "(", "$", "this", "->", "arfMail", "[", "'message'", "]", ",", "'Comments from recipient'", ")", "!==", "false", ")", "{", "preg_match", "(", "\"/Comments from recipient.*\\s]\\n(.*)\\n\\n\\nThis/s\"", ",", "str_replace", "(", "array", "(", "\"\\r\"", ",", "\"> \"", ")", ",", "\"\"", ",", "$", "this", "->", "arfMail", "[", "'message'", "]", ")", ",", "$", "match", ")", ";", "$", "report", "[", "'recipient_comment'", "]", "=", "str_replace", "(", "\"\\n\"", ",", "\" \"", ",", "$", "match", "[", "1", "]", ")", ";", "}", "// Add the headers from evidence into infoblob", "$", "parsedEvidence", "=", "new", "MimeParser", "(", ")", ";", "$", "parsedEvidence", "->", "setText", "(", "$", "this", "->", "arfMail", "[", "'evidence'", "]", ")", ";", "$", "headers", "=", "$", "parsedEvidence", "->", "getHeaders", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "||", "is_object", "(", "(", "$", "value", ")", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "index", "=>", "$", "subvalue", ")", "{", "$", "report", "[", "'headers'", "]", "[", "\"${key}${index}\"", "]", "=", "\"$subvalue\"", ";", "}", "}", "else", "{", "$", "report", "[", "'headers'", "]", "[", "\"$key\"", "]", "=", "$", "value", ";", "}", "}", "/*\n * Sometimes Spamcop has a trouble adding the correct fields. The IP is pretty\n * normal to add. In a last attempt we will try to fetch the IP from the body ourselves\n */", "if", "(", "empty", "(", "$", "report", "[", "'Source-IP'", "]", ")", ")", "{", "preg_match", "(", "\"/Email from (?<ip>[a-f0-9:\\.]+) \\/ \"", ".", "preg_quote", "(", "$", "report", "[", "'Received-Date'", "]", ")", ".", "\"/s\"", ",", "$", "this", "->", "arfMail", "[", "'message'", "]", ",", "$", "regs", ")", ";", "if", "(", "!", "empty", "(", "$", "regs", "[", "'ip'", "]", ")", "&&", "!", "filter_var", "(", "$", "regs", "[", "'ip'", "]", ",", "FILTER_VALIDATE_IP", ")", "===", "false", ")", "{", "$", "report", "[", "'Source-IP'", "]", "=", "$", "regs", "[", "'ip'", "]", ";", "}", "preg_match", "(", "\"/from: (?<ip>[a-f0-9:\\.]+)\\r?\\n?\\r\\n/s\"", ",", "$", "this", "->", "parsedMail", "->", "getMessageBody", "(", ")", ",", "$", "regs", ")", ";", "if", "(", "!", "empty", "(", "$", "regs", "[", "'ip'", "]", ")", "&&", "!", "filter_var", "(", "$", "regs", "[", "'ip'", "]", ",", "FILTER_VALIDATE_IP", ")", "===", "false", ")", "{", "$", "report", "[", "'Source-IP'", "]", "=", "$", "regs", "[", "'ip'", "]", ";", "}", "}", "$", "reports", "[", "]", "=", "$", "report", ";", "return", "$", "reports", ";", "}" ]
This is a ARF mail with a single incident @return array $reports
[ "This", "is", "a", "ARF", "mail", "with", "a", "single", "incident" ]
6745d54bfee747b66af6e7332a59d554de3d8253
https://github.com/AbuseIO/parser-spamcop/blob/6745d54bfee747b66af6e7332a59d554de3d8253/src/Spamcop.php#L269-L333
15,593
vincentchalamon/VinceCmsSonataAdminBundle
Controller/MenuController.php
MenuController.upAction
public function upAction(Request $request) { /** @var MenuRepository $repo */ $repo = $this->get('vince_cms.repository.menu'); /** @var Menu $menu */ $menu = $repo->find($request->get('id')); if ($menu->getParent()) { $repo->moveUp($menu); } return $this->redirect($this->generateUrl('admin_my_cms_menu_list')); }
php
public function upAction(Request $request) { /** @var MenuRepository $repo */ $repo = $this->get('vince_cms.repository.menu'); /** @var Menu $menu */ $menu = $repo->find($request->get('id')); if ($menu->getParent()) { $repo->moveUp($menu); } return $this->redirect($this->generateUrl('admin_my_cms_menu_list')); }
[ "public", "function", "upAction", "(", "Request", "$", "request", ")", "{", "/** @var MenuRepository $repo */", "$", "repo", "=", "$", "this", "->", "get", "(", "'vince_cms.repository.menu'", ")", ";", "/** @var Menu $menu */", "$", "menu", "=", "$", "repo", "->", "find", "(", "$", "request", "->", "get", "(", "'id'", ")", ")", ";", "if", "(", "$", "menu", "->", "getParent", "(", ")", ")", "{", "$", "repo", "->", "moveUp", "(", "$", "menu", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_my_cms_menu_list'", ")", ")", ";", "}" ]
Move menu up @author Vincent Chalamon <[email protected]> @param Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Move", "menu", "up" ]
edc768061734a92ba116488dd7b61ad40af21ceb
https://github.com/vincentchalamon/VinceCmsSonataAdminBundle/blob/edc768061734a92ba116488dd7b61ad40af21ceb/Controller/MenuController.php#L31-L42
15,594
vincentchalamon/VinceCmsSonataAdminBundle
Controller/MenuController.php
MenuController.downAction
public function downAction(Request $request) { /** @var MenuRepository $repo */ $repo = $this->get('vince_cms.repository.menu'); /** @var Menu $menu */ $menu = $repo->find($request->get('id')); if ($menu->getParent()) { $repo->moveDown($menu); } return $this->redirect($this->generateUrl('admin_my_cms_menu_list')); }
php
public function downAction(Request $request) { /** @var MenuRepository $repo */ $repo = $this->get('vince_cms.repository.menu'); /** @var Menu $menu */ $menu = $repo->find($request->get('id')); if ($menu->getParent()) { $repo->moveDown($menu); } return $this->redirect($this->generateUrl('admin_my_cms_menu_list')); }
[ "public", "function", "downAction", "(", "Request", "$", "request", ")", "{", "/** @var MenuRepository $repo */", "$", "repo", "=", "$", "this", "->", "get", "(", "'vince_cms.repository.menu'", ")", ";", "/** @var Menu $menu */", "$", "menu", "=", "$", "repo", "->", "find", "(", "$", "request", "->", "get", "(", "'id'", ")", ")", ";", "if", "(", "$", "menu", "->", "getParent", "(", ")", ")", "{", "$", "repo", "->", "moveDown", "(", "$", "menu", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_my_cms_menu_list'", ")", ")", ";", "}" ]
Move menu down @author Vincent Chalamon <[email protected]> @param Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Move", "menu", "down" ]
edc768061734a92ba116488dd7b61ad40af21ceb
https://github.com/vincentchalamon/VinceCmsSonataAdminBundle/blob/edc768061734a92ba116488dd7b61ad40af21ceb/Controller/MenuController.php#L53-L64
15,595
crossjoin/Css
src/Crossjoin/Css/Format/Rule/TraitIsValid.php
TraitIsValid.setIsValid
public function setIsValid($isValid) { if (is_bool($isValid)) { $this->isValid = $isValid; } else { throw new \InvalidArgumentException( "Invalid value '" . $isValid . "' for argument 'isValid' given." ); } return $this; }
php
public function setIsValid($isValid) { if (is_bool($isValid)) { $this->isValid = $isValid; } else { throw new \InvalidArgumentException( "Invalid value '" . $isValid . "' for argument 'isValid' given." ); } return $this; }
[ "public", "function", "setIsValid", "(", "$", "isValid", ")", "{", "if", "(", "is_bool", "(", "$", "isValid", ")", ")", "{", "$", "this", "->", "isValid", "=", "$", "isValid", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid value '\"", ".", "$", "isValid", ".", "\"' for argument 'isValid' given.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the validation status. @param bool $isValid @return $this
[ "Sets", "the", "validation", "status", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/TraitIsValid.php#L22-L33
15,596
crossjoin/Css
src/Crossjoin/Css/Format/Rule/TraitIsValid.php
TraitIsValid.addValidationError
public function addValidationError($errorMessage) { if (is_string($errorMessage)) { $this->validationErrors[] = $errorMessage; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($errorMessage). "' for argument 'errorMessage' given." ); } return $this; }
php
public function addValidationError($errorMessage) { if (is_string($errorMessage)) { $this->validationErrors[] = $errorMessage; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($errorMessage). "' for argument 'errorMessage' given." ); } return $this; }
[ "public", "function", "addValidationError", "(", "$", "errorMessage", ")", "{", "if", "(", "is_string", "(", "$", "errorMessage", ")", ")", "{", "$", "this", "->", "validationErrors", "[", "]", "=", "$", "errorMessage", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "errorMessage", ")", ".", "\"' for argument 'errorMessage' given.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a validation error message. @param string $errorMessage @return $this
[ "Adds", "a", "validation", "error", "message", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/TraitIsValid.php#L51-L62
15,597
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
LogQuery.filterByDateTime
public function filterByDateTime($dateTime = null, $comparison = null) { if (is_array($dateTime)) { $useMinMax = false; if (isset($dateTime['min'])) { $this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($dateTime['max'])) { $this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime, $comparison); }
php
public function filterByDateTime($dateTime = null, $comparison = null) { if (is_array($dateTime)) { $useMinMax = false; if (isset($dateTime['min'])) { $this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($dateTime['max'])) { $this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime, $comparison); }
[ "public", "function", "filterByDateTime", "(", "$", "dateTime", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "dateTime", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "dateTime", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "LogTableMap", "::", "COL_DATE_TIME", ",", "$", "dateTime", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "dateTime", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "LogTableMap", "::", "COL_DATE_TIME", ",", "$", "dateTime", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LogTableMap", "::", "COL_DATE_TIME", ",", "$", "dateTime", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the date_time column Example usage: <code> $query->filterByDateTime('2011-03-14'); // WHERE date_time = '2011-03-14' $query->filterByDateTime('now'); // WHERE date_time = '2011-03-14' $query->filterByDateTime(array('max' => 'yesterday')); // WHERE date_time > '2011-03-13' </code> @param mixed $dateTime The value to use as filter. Values can be integers (unix timestamps), DateTime objects, or strings. Empty strings are treated as NULL. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "date_time", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L346-L367
15,598
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
LogQuery.filterByLogText
public function filterByLogText($logText = null, $comparison = null) { if (null === $comparison) { if (is_array($logText)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $logText)) { $logText = str_replace('*', '%', $logText); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LogTableMap::COL_LOG_TEXT, $logText, $comparison); }
php
public function filterByLogText($logText = null, $comparison = null) { if (null === $comparison) { if (is_array($logText)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $logText)) { $logText = str_replace('*', '%', $logText); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LogTableMap::COL_LOG_TEXT, $logText, $comparison); }
[ "public", "function", "filterByLogText", "(", "$", "logText", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "logText", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "logText", ")", ")", "{", "$", "logText", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "logText", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LogTableMap", "::", "COL_LOG_TEXT", ",", "$", "logText", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the log_text column Example usage: <code> $query->filterByLogText('fooValue'); // WHERE log_text = 'fooValue' $query->filterByLogText('%fooValue%'); // WHERE log_text LIKE '%fooValue%' </code> @param string $logText The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "log_text", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L384-L396
15,599
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
LogQuery.filterBySessionId
public function filterBySessionId($sessionId = null, $comparison = null) { if (null === $comparison) { if (is_array($sessionId)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $sessionId)) { $sessionId = str_replace('*', '%', $sessionId); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LogTableMap::COL_SESSION_ID, $sessionId, $comparison); }
php
public function filterBySessionId($sessionId = null, $comparison = null) { if (null === $comparison) { if (is_array($sessionId)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $sessionId)) { $sessionId = str_replace('*', '%', $sessionId); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LogTableMap::COL_SESSION_ID, $sessionId, $comparison); }
[ "public", "function", "filterBySessionId", "(", "$", "sessionId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "sessionId", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "sessionId", ")", ")", "{", "$", "sessionId", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "sessionId", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LogTableMap", "::", "COL_SESSION_ID", ",", "$", "sessionId", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the session_id column Example usage: <code> $query->filterBySessionId('fooValue'); // WHERE session_id = 'fooValue' $query->filterBySessionId('%fooValue%'); // WHERE session_id LIKE '%fooValue%' </code> @param string $sessionId The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "session_id", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L471-L483