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,300
FrenchFrogs/framework
src/Filterer/Filterer.php
Filterer.setFilters
public function setFilters($filters) { if (!is_array($filters)) { $this->clearFilters(); foreach(explode('|', $filters) as $filter) { // searching for optional params $params = []; if (strpos($filter, ':')) { list($filter, $params) = explode(':', $filter); $params = (array) explode(',', $params); } $this->addFilter($filter, null, ...$params); } } else { $this->filters = $filters; } return $this; }
php
public function setFilters($filters) { if (!is_array($filters)) { $this->clearFilters(); foreach(explode('|', $filters) as $filter) { // searching for optional params $params = []; if (strpos($filter, ':')) { list($filter, $params) = explode(':', $filter); $params = (array) explode(',', $params); } $this->addFilter($filter, null, ...$params); } } else { $this->filters = $filters; } return $this; }
[ "public", "function", "setFilters", "(", "$", "filters", ")", "{", "if", "(", "!", "is_array", "(", "$", "filters", ")", ")", "{", "$", "this", "->", "clearFilters", "(", ")", ";", "foreach", "(", "explode", "(", "'|'", ",", "$", "filters", ")", "as", "$", "filter", ")", "{", "// searching for optional params", "$", "params", "=", "[", "]", ";", "if", "(", "strpos", "(", "$", "filter", ",", "':'", ")", ")", "{", "list", "(", "$", "filter", ",", "$", "params", ")", "=", "explode", "(", "':'", ",", "$", "filter", ")", ";", "$", "params", "=", "(", "array", ")", "explode", "(", "','", ",", "$", "params", ")", ";", "}", "$", "this", "->", "addFilter", "(", "$", "filter", ",", "null", ",", "...", "$", "params", ")", ";", "}", "}", "else", "{", "$", "this", "->", "filters", "=", "$", "filters", ";", "}", "return", "$", "this", ";", "}" ]
Set all filter as an array @param $filters @return $this
[ "Set", "all", "filter", "as", "an", "array" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Filterer/Filterer.php#L43-L64
15,301
FrenchFrogs/framework
src/Filterer/Filterer.php
Filterer.addFilter
public function addFilter($index, $method = null, ...$params) { $this->filters[$index] = [$method, $params]; return $this; }
php
public function addFilter($index, $method = null, ...$params) { $this->filters[$index] = [$method, $params]; return $this; }
[ "public", "function", "addFilter", "(", "$", "index", ",", "$", "method", "=", "null", ",", "...", "$", "params", ")", "{", "$", "this", "->", "filters", "[", "$", "index", "]", "=", "[", "$", "method", ",", "$", "params", "]", ";", "return", "$", "this", ";", "}" ]
Add a single filter to the filters container @param $index @param null $method @param ...$params @return $this
[ "Add", "a", "single", "filter", "to", "the", "filters", "container" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Filterer/Filterer.php#L74-L78
15,302
FrenchFrogs/framework
src/Filterer/Filterer.php
Filterer.getFilter
public function getFilter($index) { if (!$this->hasFilter($index)) { throw new \Exception('Impossible de trouver le filtre : ' . $index); } return $this->filters[$index]; }
php
public function getFilter($index) { if (!$this->hasFilter($index)) { throw new \Exception('Impossible de trouver le filtre : ' . $index); } return $this->filters[$index]; }
[ "public", "function", "getFilter", "(", "$", "index", ")", "{", "if", "(", "!", "$", "this", "->", "hasFilter", "(", "$", "index", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Impossible de trouver le filtre : '", ".", "$", "index", ")", ";", "}", "return", "$", "this", "->", "filters", "[", "$", "index", "]", ";", "}" ]
Return the filter from the filters container from the filter container @param $index @return mixed @throws \Exception
[ "Return", "the", "filter", "from", "the", "filters", "container", "from", "the", "filter", "container" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Filterer/Filterer.php#L129-L136
15,303
FrenchFrogs/framework
src/Filterer/Filterer.php
Filterer.filter
public function filter($value) { foreach($this->getFilters() as $index => $filter) { // Extract the params list($method, $params) = $filter; // If method is null, we use the index as the method name $method = is_null($method) ? $index : $method; // Build the params for the filter array_unshift($params, $value); // If it's a anonymous function if (!is_string($method) && is_callable($method)) { $value = call_user_func_array($method, $params); // if it's a local method } else { if (!method_exists($this, $method)) { throw new \Exception('Method "'. $method .'" not found for filter : ' . $index); } $value = call_user_func_array([$this, $method], $params); } } return $value; }
php
public function filter($value) { foreach($this->getFilters() as $index => $filter) { // Extract the params list($method, $params) = $filter; // If method is null, we use the index as the method name $method = is_null($method) ? $index : $method; // Build the params for the filter array_unshift($params, $value); // If it's a anonymous function if (!is_string($method) && is_callable($method)) { $value = call_user_func_array($method, $params); // if it's a local method } else { if (!method_exists($this, $method)) { throw new \Exception('Method "'. $method .'" not found for filter : ' . $index); } $value = call_user_func_array([$this, $method], $params); } } return $value; }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "getFilters", "(", ")", "as", "$", "index", "=>", "$", "filter", ")", "{", "// Extract the params", "list", "(", "$", "method", ",", "$", "params", ")", "=", "$", "filter", ";", "// If method is null, we use the index as the method name", "$", "method", "=", "is_null", "(", "$", "method", ")", "?", "$", "index", ":", "$", "method", ";", "// Build the params for the filter", "array_unshift", "(", "$", "params", ",", "$", "value", ")", ";", "// If it's a anonymous function", "if", "(", "!", "is_string", "(", "$", "method", ")", "&&", "is_callable", "(", "$", "method", ")", ")", "{", "$", "value", "=", "call_user_func_array", "(", "$", "method", ",", "$", "params", ")", ";", "// if it's a local method", "}", "else", "{", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Method \"'", ".", "$", "method", ".", "'\" not found for filter : '", ".", "$", "index", ")", ";", "}", "$", "value", "=", "call_user_func_array", "(", "[", "$", "this", ",", "$", "method", "]", ",", "$", "params", ")", ";", "}", "}", "return", "$", "value", ";", "}" ]
Filter de value Main method of the class @param $value @return mixed @throws \Exception
[ "Filter", "de", "value" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Filterer/Filterer.php#L159-L188
15,304
FrenchFrogs/framework
src/Filterer/Filterer.php
Filterer.dateFormat
public function dateFormat($value, $format = 'd/m/Y') { if (!empty($value)) { // passage de la date en datetime if (strlen($value) == 10) { $value .= ' 00:00:00'; } // gestion d'une date vide if ($value == '0000-00-00 00:00:00') { $value = ''; } else { $date = \DateTime::createFromFormat('Y-m-d H:i:s',$value); //Check que la value est compatible avec le format if($date !== false && !array_sum($date->getLastErrors())){ $value = $date->format($format); } } } return $value; }
php
public function dateFormat($value, $format = 'd/m/Y') { if (!empty($value)) { // passage de la date en datetime if (strlen($value) == 10) { $value .= ' 00:00:00'; } // gestion d'une date vide if ($value == '0000-00-00 00:00:00') { $value = ''; } else { $date = \DateTime::createFromFormat('Y-m-d H:i:s',$value); //Check que la value est compatible avec le format if($date !== false && !array_sum($date->getLastErrors())){ $value = $date->format($format); } } } return $value; }
[ "public", "function", "dateFormat", "(", "$", "value", ",", "$", "format", "=", "'d/m/Y'", ")", "{", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "// passage de la date en datetime", "if", "(", "strlen", "(", "$", "value", ")", "==", "10", ")", "{", "$", "value", ".=", "' 00:00:00'", ";", "}", "// gestion d'une date vide", "if", "(", "$", "value", "==", "'0000-00-00 00:00:00'", ")", "{", "$", "value", "=", "''", ";", "}", "else", "{", "$", "date", "=", "\\", "DateTime", "::", "createFromFormat", "(", "'Y-m-d H:i:s'", ",", "$", "value", ")", ";", "//Check que la value est compatible avec le format", "if", "(", "$", "date", "!==", "false", "&&", "!", "array_sum", "(", "$", "date", "->", "getLastErrors", "(", ")", ")", ")", "{", "$", "value", "=", "$", "date", "->", "format", "(", "$", "format", ")", ";", "}", "}", "}", "return", "$", "value", ";", "}" ]
Format a date @param $value @param string $format @return string
[ "Format", "a", "date" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Filterer/Filterer.php#L232-L254
15,305
comelyio/comely
src/Comely/IO/Cache/Cache.php
Cache.addServer
public function addServer(int $engine, string $host = "127.0.0.1", int $port = 0): Server { $this->servers[] = new Server($engine, $host, $port); return end($this->servers); }
php
public function addServer(int $engine, string $host = "127.0.0.1", int $port = 0): Server { $this->servers[] = new Server($engine, $host, $port); return end($this->servers); }
[ "public", "function", "addServer", "(", "int", "$", "engine", ",", "string", "$", "host", "=", "\"127.0.0.1\"", ",", "int", "$", "port", "=", "0", ")", ":", "Server", "{", "$", "this", "->", "servers", "[", "]", "=", "new", "Server", "(", "$", "engine", ",", "$", "host", ",", "$", "port", ")", ";", "return", "end", "(", "$", "this", "->", "servers", ")", ";", "}" ]
Add a server to connection queue Multiple cache servers may be added before connection, if connection fails with first server then Comely Cache component will try to connect to next server. @param int $engine @param string $host @param int $port @return Server @throws ConnectionException
[ "Add", "a", "server", "to", "connection", "queue" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Cache.php#L84-L88
15,306
comelyio/comely
src/Comely/IO/Cache/Cache.php
Cache.isConnected
public function isConnected(): bool { if ($this->engine) { $connected = $this->engine->isConnected(); if (!$connected) { $this->engine = null; } return $connected; } return false; }
php
public function isConnected(): bool { if ($this->engine) { $connected = $this->engine->isConnected(); if (!$connected) { $this->engine = null; } return $connected; } return false; }
[ "public", "function", "isConnected", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "engine", ")", "{", "$", "connected", "=", "$", "this", "->", "engine", "->", "isConnected", "(", ")", ";", "if", "(", "!", "$", "connected", ")", "{", "$", "this", "->", "engine", "=", "null", ";", "}", "return", "$", "connected", ";", "}", "return", "false", ";", "}" ]
Check connection status @return bool
[ "Check", "connection", "status" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Cache.php#L154-L166
15,307
comelyio/comely
src/Comely/IO/Cache/Cache.php
Cache.ping
public function ping(bool $reconnect = false): bool { if ($this->engine) { $ping = $this->engine->ping(); if (!$ping) { $this->engine = null; if ($reconnect) { $this->connect(); } } return $ping; } return false; }
php
public function ping(bool $reconnect = false): bool { if ($this->engine) { $ping = $this->engine->ping(); if (!$ping) { $this->engine = null; if ($reconnect) { $this->connect(); } } return $ping; } return false; }
[ "public", "function", "ping", "(", "bool", "$", "reconnect", "=", "false", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "engine", ")", "{", "$", "ping", "=", "$", "this", "->", "engine", "->", "ping", "(", ")", ";", "if", "(", "!", "$", "ping", ")", "{", "$", "this", "->", "engine", "=", "null", ";", "if", "(", "$", "reconnect", ")", "{", "$", "this", "->", "connect", "(", ")", ";", "}", "}", "return", "$", "ping", ";", "}", "return", "false", ";", "}" ]
Ping Cache Server This method will not only check the connection status, but also attempt to ping cache server. On failure, cache component will be disconnected with cache server/engine. Optional $reconnect param. may be passed to attempt reconnection on failure. @param bool $reconnect @return bool @throws ConnectionException @throws EngineException
[ "Ping", "Cache", "Server" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Cache.php#L180-L195
15,308
comelyio/comely
src/Comely/IO/Cache/Cache.php
Cache.has
public function has(string $key): bool { $this->checkConnection(__METHOD__); return $this->engine->has($key); }
php
public function has(string $key): bool { $this->checkConnection(__METHOD__); return $this->engine->has($key); }
[ "public", "function", "has", "(", "string", "$", "key", ")", ":", "bool", "{", "$", "this", "->", "checkConnection", "(", "__METHOD__", ")", ";", "return", "$", "this", "->", "engine", "->", "has", "(", "$", "key", ")", ";", "}" ]
Checks if a data exists on cache server corresponding to provided key @param string $key @return bool @throws CacheException @throws EngineException
[ "Checks", "if", "a", "data", "exists", "on", "cache", "server", "corresponding", "to", "provided", "key" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Cache.php#L295-L299
15,309
comelyio/comely
src/Comely/IO/Cache/Cache.php
Cache.delete
public function delete(string $key): bool { $this->checkConnection(__METHOD__); $delete = $this->engine->delete($key); if ($delete && $this->index) { $this->index->events() ->trigger(Indexing::EVENT_ON_DELETE) ->params($key) ->fire(); } return $delete; }
php
public function delete(string $key): bool { $this->checkConnection(__METHOD__); $delete = $this->engine->delete($key); if ($delete && $this->index) { $this->index->events() ->trigger(Indexing::EVENT_ON_DELETE) ->params($key) ->fire(); } return $delete; }
[ "public", "function", "delete", "(", "string", "$", "key", ")", ":", "bool", "{", "$", "this", "->", "checkConnection", "(", "__METHOD__", ")", ";", "$", "delete", "=", "$", "this", "->", "engine", "->", "delete", "(", "$", "key", ")", ";", "if", "(", "$", "delete", "&&", "$", "this", "->", "index", ")", "{", "$", "this", "->", "index", "->", "events", "(", ")", "->", "trigger", "(", "Indexing", "::", "EVENT_ON_DELETE", ")", "->", "params", "(", "$", "key", ")", "->", "fire", "(", ")", ";", "}", "return", "$", "delete", ";", "}" ]
Delete an stored item with provided key on cache server @param string $key @return bool @throws CacheException @throws EngineException
[ "Delete", "an", "stored", "item", "with", "provided", "key", "on", "cache", "server" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Cache.php#L309-L321
15,310
comelyio/comely
src/Comely/IO/Cache/Cache.php
Cache.flush
public function flush(): bool { $this->checkConnection(__METHOD__); $flush = $this->engine->flush(); if ($flush && $this->index) { $this->index->events()->trigger(Indexing::EVENT_ON_FLUSH) ->fire(); } return $flush; }
php
public function flush(): bool { $this->checkConnection(__METHOD__); $flush = $this->engine->flush(); if ($flush && $this->index) { $this->index->events()->trigger(Indexing::EVENT_ON_FLUSH) ->fire(); } return $flush; }
[ "public", "function", "flush", "(", ")", ":", "bool", "{", "$", "this", "->", "checkConnection", "(", "__METHOD__", ")", ";", "$", "flush", "=", "$", "this", "->", "engine", "->", "flush", "(", ")", ";", "if", "(", "$", "flush", "&&", "$", "this", "->", "index", ")", "{", "$", "this", "->", "index", "->", "events", "(", ")", "->", "trigger", "(", "Indexing", "::", "EVENT_ON_FLUSH", ")", "->", "fire", "(", ")", ";", "}", "return", "$", "flush", ";", "}" ]
Flushes all stored data from cache server @return bool @throws CacheException @throws EngineException
[ "Flushes", "all", "stored", "data", "from", "cache", "server" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Cache.php#L330-L340
15,311
comelyio/comely
src/Comely/IO/Cache/Cache.php
Cache.countUp
public function countUp(string $key, int $inc = 1): int { $this->checkConnection(__METHOD__); return $this->engine->countUp($key, $inc); }
php
public function countUp(string $key, int $inc = 1): int { $this->checkConnection(__METHOD__); return $this->engine->countUp($key, $inc); }
[ "public", "function", "countUp", "(", "string", "$", "key", ",", "int", "$", "inc", "=", "1", ")", ":", "int", "{", "$", "this", "->", "checkConnection", "(", "__METHOD__", ")", ";", "return", "$", "this", "->", "engine", "->", "countUp", "(", "$", "key", ",", "$", "inc", ")", ";", "}" ]
Increase stored integer value If key doesn't already exist, a new key will be created with value 0 before increment @param string $key @param int $inc @return int @throws CacheException @throws EngineException
[ "Increase", "stored", "integer", "value", "If", "key", "doesn", "t", "already", "exist", "a", "new", "key", "will", "be", "created", "with", "value", "0", "before", "increment" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Cache.php#L352-L356
15,312
comelyio/comely
src/Comely/IO/Cache/Cache.php
Cache.countDown
public function countDown(string $key, int $dec = 1): int { $this->checkConnection(__METHOD__); return $this->engine->countDown($key, $dec); }
php
public function countDown(string $key, int $dec = 1): int { $this->checkConnection(__METHOD__); return $this->engine->countDown($key, $dec); }
[ "public", "function", "countDown", "(", "string", "$", "key", ",", "int", "$", "dec", "=", "1", ")", ":", "int", "{", "$", "this", "->", "checkConnection", "(", "__METHOD__", ")", ";", "return", "$", "this", "->", "engine", "->", "countDown", "(", "$", "key", ",", "$", "dec", ")", ";", "}" ]
Decrease stored integer value If key doesn't already exist, a new key will be created with value 0 before decrement @param string $key @param int $dec @return int @throws CacheException @throws EngineException
[ "Decrease", "stored", "integer", "value", "If", "key", "doesn", "t", "already", "exist", "a", "new", "key", "will", "be", "created", "with", "value", "0", "before", "decrement" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Cache.php#L368-L372
15,313
comelyio/comely
src/Comely/IO/Cache/Cache.php
Cache.setCacheableIdentifier
public function setCacheableIdentifier(string $id = null, int $length = null): self { if ($id) { if (!preg_match('/^[a-zA-Z0-9\_\-\~\.]{8,32}$/', $id)) { throw new CacheException('Invalid value passed to "setCacheableIdentifier" method'); } $this->cacheableId = $id; $this->cacheableIdLength = strlen($id); } if ($length) { if ($length < 100 || $length <= $this->cacheableIdLength) { throw new CacheException('Length of encoded Cacheable objects must start from at least 100'); } $this->cacheableLengthFrom = $length; } return $this; }
php
public function setCacheableIdentifier(string $id = null, int $length = null): self { if ($id) { if (!preg_match('/^[a-zA-Z0-9\_\-\~\.]{8,32}$/', $id)) { throw new CacheException('Invalid value passed to "setCacheableIdentifier" method'); } $this->cacheableId = $id; $this->cacheableIdLength = strlen($id); } if ($length) { if ($length < 100 || $length <= $this->cacheableIdLength) { throw new CacheException('Length of encoded Cacheable objects must start from at least 100'); } $this->cacheableLengthFrom = $length; } return $this; }
[ "public", "function", "setCacheableIdentifier", "(", "string", "$", "id", "=", "null", ",", "int", "$", "length", "=", "null", ")", ":", "self", "{", "if", "(", "$", "id", ")", "{", "if", "(", "!", "preg_match", "(", "'/^[a-zA-Z0-9\\_\\-\\~\\.]{8,32}$/'", ",", "$", "id", ")", ")", "{", "throw", "new", "CacheException", "(", "'Invalid value passed to \"setCacheableIdentifier\" method'", ")", ";", "}", "$", "this", "->", "cacheableId", "=", "$", "id", ";", "$", "this", "->", "cacheableIdLength", "=", "strlen", "(", "$", "id", ")", ";", "}", "if", "(", "$", "length", ")", "{", "if", "(", "$", "length", "<", "100", "||", "$", "length", "<=", "$", "this", "->", "cacheableIdLength", ")", "{", "throw", "new", "CacheException", "(", "'Length of encoded Cacheable objects must start from at least 100'", ")", ";", "}", "$", "this", "->", "cacheableLengthFrom", "=", "$", "length", ";", "}", "return", "$", "this", ";", "}" ]
Set custom identifier for objects extending CacheableInterface @param string|null $id @param int|null $length @return Cache @throws CacheException
[ "Set", "custom", "identifier", "for", "objects", "extending", "CacheableInterface" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Cache.php#L431-L451
15,314
blackprism/serializer
src/Blackprism/Serializer/Json/Deserialize.php
Deserialize.setObject
private function setObject(array $data) { $identifierAttribute = $this->configuration->getIdentifierAttribute(); if ($identifierAttribute === null) { throw new UndefinedIdentifierAttribute(); } // We found an identifier attribute, $data is a json object if (isset($data[$identifierAttribute]) === true) { return $this->setObjectForObjectData($identifierAttribute, $data); } // We don't found an identifier attribute, $data is a collection return $this->setObjectForCollectionData($data); }
php
private function setObject(array $data) { $identifierAttribute = $this->configuration->getIdentifierAttribute(); if ($identifierAttribute === null) { throw new UndefinedIdentifierAttribute(); } // We found an identifier attribute, $data is a json object if (isset($data[$identifierAttribute]) === true) { return $this->setObjectForObjectData($identifierAttribute, $data); } // We don't found an identifier attribute, $data is a collection return $this->setObjectForCollectionData($data); }
[ "private", "function", "setObject", "(", "array", "$", "data", ")", "{", "$", "identifierAttribute", "=", "$", "this", "->", "configuration", "->", "getIdentifierAttribute", "(", ")", ";", "if", "(", "$", "identifierAttribute", "===", "null", ")", "{", "throw", "new", "UndefinedIdentifierAttribute", "(", ")", ";", "}", "// We found an identifier attribute, $data is a json object", "if", "(", "isset", "(", "$", "data", "[", "$", "identifierAttribute", "]", ")", "===", "true", ")", "{", "return", "$", "this", "->", "setObjectForObjectData", "(", "$", "identifierAttribute", ",", "$", "data", ")", ";", "}", "// We don't found an identifier attribute, $data is a collection", "return", "$", "this", "->", "setObjectForCollectionData", "(", "$", "data", ")", ";", "}" ]
Create class object with data @param mixed[] $data @return object|object[] @throws UndefinedIdentifierAttribute @throws MissingIdentifierAttribute
[ "Create", "class", "object", "with", "data" ]
f5bd6ebeec802d2ad747daba7c9211b252ee4776
https://github.com/blackprism/serializer/blob/f5bd6ebeec802d2ad747daba7c9211b252ee4776/src/Blackprism/Serializer/Json/Deserialize.php#L107-L122
15,315
FrenchFrogs/framework
src/Html/Element/Button.php
Button.icon
public function icon($icon, $is_icon_only = true) { $this->setIcon($icon); ($is_icon_only) ? $this->enableIconOnly() : $this->disableIconOnly(); return $this; }
php
public function icon($icon, $is_icon_only = true) { $this->setIcon($icon); ($is_icon_only) ? $this->enableIconOnly() : $this->disableIconOnly(); return $this; }
[ "public", "function", "icon", "(", "$", "icon", ",", "$", "is_icon_only", "=", "true", ")", "{", "$", "this", "->", "setIcon", "(", "$", "icon", ")", ";", "(", "$", "is_icon_only", ")", "?", "$", "this", "->", "enableIconOnly", "(", ")", ":", "$", "this", "->", "disableIconOnly", "(", ")", ";", "return", "$", "this", ";", "}" ]
Fast setting for icon @param $icon @param bool|true $is_icon_only @return $this
[ "Fast", "setting", "for", "icon" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Html/Element/Button.php#L48-L53
15,316
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Console/Cerberus.php
Cerberus.createDir
public static function createDir($strPath, $rights = 0777) { $folderPath = array($strPath); $oldumask = umask(0); while (!@is_dir(dirname(end($folderPath))) && dirname(end($folderPath)) != "/" && dirname(end($folderPath)) != "." && dirname(end($folderPath)) != "" ) { array_push($folderPath, dirname(end($folderPath))); } while ($parentFolderPath = array_pop($folderPath)) { if (!@is_dir($parentFolderPath)) { if (!@mkdir($parentFolderPath, $rights)) { throw new \RuntimeException("Runtime Error: Can't create folder: $parentFolderPath"); } } } umask($oldumask); }
php
public static function createDir($strPath, $rights = 0777) { $folderPath = array($strPath); $oldumask = umask(0); while (!@is_dir(dirname(end($folderPath))) && dirname(end($folderPath)) != "/" && dirname(end($folderPath)) != "." && dirname(end($folderPath)) != "" ) { array_push($folderPath, dirname(end($folderPath))); } while ($parentFolderPath = array_pop($folderPath)) { if (!@is_dir($parentFolderPath)) { if (!@mkdir($parentFolderPath, $rights)) { throw new \RuntimeException("Runtime Error: Can't create folder: $parentFolderPath"); } } } umask($oldumask); }
[ "public", "static", "function", "createDir", "(", "$", "strPath", ",", "$", "rights", "=", "0777", ")", "{", "$", "folderPath", "=", "array", "(", "$", "strPath", ")", ";", "$", "oldumask", "=", "umask", "(", "0", ")", ";", "while", "(", "!", "@", "is_dir", "(", "dirname", "(", "end", "(", "$", "folderPath", ")", ")", ")", "&&", "dirname", "(", "end", "(", "$", "folderPath", ")", ")", "!=", "\"/\"", "&&", "dirname", "(", "end", "(", "$", "folderPath", ")", ")", "!=", "\".\"", "&&", "dirname", "(", "end", "(", "$", "folderPath", ")", ")", "!=", "\"\"", ")", "{", "array_push", "(", "$", "folderPath", ",", "dirname", "(", "end", "(", "$", "folderPath", ")", ")", ")", ";", "}", "while", "(", "$", "parentFolderPath", "=", "array_pop", "(", "$", "folderPath", ")", ")", "{", "if", "(", "!", "@", "is_dir", "(", "$", "parentFolderPath", ")", ")", "{", "if", "(", "!", "@", "mkdir", "(", "$", "parentFolderPath", ",", "$", "rights", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Runtime Error: Can't create folder: $parentFolderPath\"", ")", ";", "}", "}", "}", "umask", "(", "$", "oldumask", ")", ";", "}" ]
Creates a directory recursively @param string $strPath path @param integer $rights right for new directory @throws \RuntimeException
[ "Creates", "a", "directory", "recursively" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Console/Cerberus.php#L96-L118
15,317
phramework/validate
src/DatetimeValidator.php
DatetimeValidator.validate
public function validate($value) { //Use string's validator $return = parent::validate($value); //Apply additional rules if ($return->status === true && (preg_match( '/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/', $value, $matches ))) { if (checkdate($matches[2], $matches[3], $matches[1])) { $timestamp = strtotime($value); //validate formatMinimum if ($this->formatMinimum !== null && $timestamp < strtotime($this->formatMinimum) ) { $failure = 'formatMinimum'; goto error; } //validate formatMaximum if ($this->formatMaximum !== null && $timestamp > strtotime($this->formatMaximum) ) { $failure = 'formatMaximum'; goto error; } //Set status to success $return->status = true; return $return; } } $failure = 'failure'; error: $return->status = false; $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => $failure ] ]); return $return; }
php
public function validate($value) { //Use string's validator $return = parent::validate($value); //Apply additional rules if ($return->status === true && (preg_match( '/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/', $value, $matches ))) { if (checkdate($matches[2], $matches[3], $matches[1])) { $timestamp = strtotime($value); //validate formatMinimum if ($this->formatMinimum !== null && $timestamp < strtotime($this->formatMinimum) ) { $failure = 'formatMinimum'; goto error; } //validate formatMaximum if ($this->formatMaximum !== null && $timestamp > strtotime($this->formatMaximum) ) { $failure = 'formatMaximum'; goto error; } //Set status to success $return->status = true; return $return; } } $failure = 'failure'; error: $return->status = false; $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => $failure ] ]); return $return; }
[ "public", "function", "validate", "(", "$", "value", ")", "{", "//Use string's validator", "$", "return", "=", "parent", "::", "validate", "(", "$", "value", ")", ";", "//Apply additional rules", "if", "(", "$", "return", "->", "status", "===", "true", "&&", "(", "preg_match", "(", "'/^(\\d{4})-(\\d{2})-(\\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/'", ",", "$", "value", ",", "$", "matches", ")", ")", ")", "{", "if", "(", "checkdate", "(", "$", "matches", "[", "2", "]", ",", "$", "matches", "[", "3", "]", ",", "$", "matches", "[", "1", "]", ")", ")", "{", "$", "timestamp", "=", "strtotime", "(", "$", "value", ")", ";", "//validate formatMinimum", "if", "(", "$", "this", "->", "formatMinimum", "!==", "null", "&&", "$", "timestamp", "<", "strtotime", "(", "$", "this", "->", "formatMinimum", ")", ")", "{", "$", "failure", "=", "'formatMinimum'", ";", "goto", "error", ";", "}", "//validate formatMaximum", "if", "(", "$", "this", "->", "formatMaximum", "!==", "null", "&&", "$", "timestamp", ">", "strtotime", "(", "$", "this", "->", "formatMaximum", ")", ")", "{", "$", "failure", "=", "'formatMaximum'", ";", "goto", "error", ";", "}", "//Set status to success", "$", "return", "->", "status", "=", "true", ";", "return", "$", "return", ";", "}", "}", "$", "failure", "=", "'failure'", ";", "error", ":", "$", "return", "->", "status", "=", "false", ";", "$", "return", "->", "errorObject", "=", "new", "IncorrectParametersException", "(", "[", "[", "'type'", "=>", "static", "::", "getType", "(", ")", ",", "'failure'", "=>", "$", "failure", "]", "]", ")", ";", "return", "$", "return", ";", "}" ]
Validate value, validates as SQL date or SQL datetime @see \Phramework\Validate\ValidateResult for ValidateResult object @see https://dev.mysql.com/doc/refman/5.1/en/datetime.html @param mixed $value Value to validate @return ValidateResult @todo set errorObject
[ "Validate", "value", "validates", "as", "SQL", "date", "or", "SQL", "datetime" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/DatetimeValidator.php#L71-L120
15,318
activecollab/databasestructure
src/Structure.php
Structure.getType
public function getType($type_name) { if (isset($this->types[$type_name])) { return $this->types[$type_name]; } else { throw new InvalidArgumentException("Type '$type_name' not found"); } }
php
public function getType($type_name) { if (isset($this->types[$type_name])) { return $this->types[$type_name]; } else { throw new InvalidArgumentException("Type '$type_name' not found"); } }
[ "public", "function", "getType", "(", "$", "type_name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "types", "[", "$", "type_name", "]", ")", ")", "{", "return", "$", "this", "->", "types", "[", "$", "type_name", "]", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "\"Type '$type_name' not found\"", ")", ";", "}", "}" ]
Return type by type name. @param string $type_name @return Type
[ "Return", "type", "by", "type", "name", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Structure.php#L70-L77
15,319
activecollab/databasestructure
src/Structure.php
Structure.build
public function build($build_path = null, ConnectionInterface $connection = null, array $event_handlers = []) { $builders = $this->getBuilders($build_path, $connection, $event_handlers); foreach ($builders as $builder) { $builder->preBuild(); } foreach ($this->types as $type) { foreach ($builders as $builder) { $builder->buildType($type); } } foreach ($builders as $builder) { $builder->postBuild(); } }
php
public function build($build_path = null, ConnectionInterface $connection = null, array $event_handlers = []) { $builders = $this->getBuilders($build_path, $connection, $event_handlers); foreach ($builders as $builder) { $builder->preBuild(); } foreach ($this->types as $type) { foreach ($builders as $builder) { $builder->buildType($type); } } foreach ($builders as $builder) { $builder->postBuild(); } }
[ "public", "function", "build", "(", "$", "build_path", "=", "null", ",", "ConnectionInterface", "$", "connection", "=", "null", ",", "array", "$", "event_handlers", "=", "[", "]", ")", "{", "$", "builders", "=", "$", "this", "->", "getBuilders", "(", "$", "build_path", ",", "$", "connection", ",", "$", "event_handlers", ")", ";", "foreach", "(", "$", "builders", "as", "$", "builder", ")", "{", "$", "builder", "->", "preBuild", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "types", "as", "$", "type", ")", "{", "foreach", "(", "$", "builders", "as", "$", "builder", ")", "{", "$", "builder", "->", "buildType", "(", "$", "type", ")", ";", "}", "}", "foreach", "(", "$", "builders", "as", "$", "builder", ")", "{", "$", "builder", "->", "postBuild", "(", ")", ";", "}", "}" ]
Build model at the given path. If $build_path is null, classes will be generated, evaled and loaded into the memory @param string|null $build_path @param ConnectionInterface $connection @param array|null $event_handlers
[ "Build", "model", "at", "the", "given", "path", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Structure.php#L187-L204
15,320
activecollab/databasestructure
src/Structure.php
Structure.getBuilders
private function getBuilders($build_path, ConnectionInterface $connection = null, array $event_handlers) { if (empty($this->builders)) { $this->builders[] = new BaseDirBuilder($this); $this->builders[] = new TypesBuilder($this); $this->builders[] = new BaseTypeClassBuilder($this); $this->builders[] = new TypeClassBuilder($this); $this->builders[] = new TypeTableBuilder($this); $this->builders[] = new AssociationsBuilder($this); $this->builders[] = new TriggersBuilder($this); $this->builders[] = new ManagerDirBuilder($this); $this->builders[] = new BaseManagerDirBuilder($this); $this->builders[] = new BaseTypeManagerBuilder($this); $this->builders[] = new TypeManagerBuilder($this); $this->builders[] = new CollectionDirBuilder($this); $this->builders[] = new BaseCollectionDirBuilder($this); $this->builders[] = new BaseTypeCollectionBuilder($this); $this->builders[] = new TypeCollectionBuilder($this); if ($build_path) { foreach ($this->builders as $k => $v) { if ($v instanceof FileSystemBuilderInterface) { $this->builders[$k]->setBuildPath($build_path); } } } if ($connection) { foreach ($this->builders as $k => $v) { if ($v instanceof DatabaseBuilderInterface) { $this->builders[$k]->setConnection($connection); } } } foreach ($event_handlers as $event => $handler) { foreach ($this->builders as $k => $v) { $v->registerEventHandler($event, $handler); } } } return $this->builders; }
php
private function getBuilders($build_path, ConnectionInterface $connection = null, array $event_handlers) { if (empty($this->builders)) { $this->builders[] = new BaseDirBuilder($this); $this->builders[] = new TypesBuilder($this); $this->builders[] = new BaseTypeClassBuilder($this); $this->builders[] = new TypeClassBuilder($this); $this->builders[] = new TypeTableBuilder($this); $this->builders[] = new AssociationsBuilder($this); $this->builders[] = new TriggersBuilder($this); $this->builders[] = new ManagerDirBuilder($this); $this->builders[] = new BaseManagerDirBuilder($this); $this->builders[] = new BaseTypeManagerBuilder($this); $this->builders[] = new TypeManagerBuilder($this); $this->builders[] = new CollectionDirBuilder($this); $this->builders[] = new BaseCollectionDirBuilder($this); $this->builders[] = new BaseTypeCollectionBuilder($this); $this->builders[] = new TypeCollectionBuilder($this); if ($build_path) { foreach ($this->builders as $k => $v) { if ($v instanceof FileSystemBuilderInterface) { $this->builders[$k]->setBuildPath($build_path); } } } if ($connection) { foreach ($this->builders as $k => $v) { if ($v instanceof DatabaseBuilderInterface) { $this->builders[$k]->setConnection($connection); } } } foreach ($event_handlers as $event => $handler) { foreach ($this->builders as $k => $v) { $v->registerEventHandler($event, $handler); } } } return $this->builders; }
[ "private", "function", "getBuilders", "(", "$", "build_path", ",", "ConnectionInterface", "$", "connection", "=", "null", ",", "array", "$", "event_handlers", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "builders", ")", ")", "{", "$", "this", "->", "builders", "[", "]", "=", "new", "BaseDirBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "TypesBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "BaseTypeClassBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "TypeClassBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "TypeTableBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "AssociationsBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "TriggersBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "ManagerDirBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "BaseManagerDirBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "BaseTypeManagerBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "TypeManagerBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "CollectionDirBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "BaseCollectionDirBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "BaseTypeCollectionBuilder", "(", "$", "this", ")", ";", "$", "this", "->", "builders", "[", "]", "=", "new", "TypeCollectionBuilder", "(", "$", "this", ")", ";", "if", "(", "$", "build_path", ")", "{", "foreach", "(", "$", "this", "->", "builders", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "instanceof", "FileSystemBuilderInterface", ")", "{", "$", "this", "->", "builders", "[", "$", "k", "]", "->", "setBuildPath", "(", "$", "build_path", ")", ";", "}", "}", "}", "if", "(", "$", "connection", ")", "{", "foreach", "(", "$", "this", "->", "builders", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "instanceof", "DatabaseBuilderInterface", ")", "{", "$", "this", "->", "builders", "[", "$", "k", "]", "->", "setConnection", "(", "$", "connection", ")", ";", "}", "}", "}", "foreach", "(", "$", "event_handlers", "as", "$", "event", "=>", "$", "handler", ")", "{", "foreach", "(", "$", "this", "->", "builders", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "v", "->", "registerEventHandler", "(", "$", "event", ",", "$", "handler", ")", ";", "}", "}", "}", "return", "$", "this", "->", "builders", ";", "}" ]
Return a list of prepared builder instances. @param string|null $build_path @param ConnectionInterface $connection @param array $event_handlers @return BuilderInterface[]
[ "Return", "a", "list", "of", "prepared", "builder", "instances", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Structure.php#L219-L266
15,321
WebDevTmas/date-repetition
src/DateRepetition/WeeklyDateRepetition.php
WeeklyDateRepetition.setDay
public function setDay($day) { if(! in_array($day, $this->weekDays)) { throw new InvalidArgumentException('Argument is not a day of the week'); } $this->day = $day; return $this; }
php
public function setDay($day) { if(! in_array($day, $this->weekDays)) { throw new InvalidArgumentException('Argument is not a day of the week'); } $this->day = $day; return $this; }
[ "public", "function", "setDay", "(", "$", "day", ")", "{", "if", "(", "!", "in_array", "(", "$", "day", ",", "$", "this", "->", "weekDays", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Argument is not a day of the week'", ")", ";", "}", "$", "this", "->", "day", "=", "$", "day", ";", "return", "$", "this", ";", "}" ]
Sets weekday of the weekly date repetition @param string day of the week (monday, tuesday, wednesday, thursday, friday, saturday, sunday) @return this
[ "Sets", "weekday", "of", "the", "weekly", "date", "repetition" ]
3ebd59f4ab3aab4b7497ebd767a57fad08277c6d
https://github.com/WebDevTmas/date-repetition/blob/3ebd59f4ab3aab4b7497ebd767a57fad08277c6d/src/DateRepetition/WeeklyDateRepetition.php#L66-L73
15,322
vincentchalamon/VinceCmsSonataAdminBundle
Controller/PublishableController.php
PublishableController.batchActionPublish
public function batchActionPublish(ProxyQueryInterface $query) { try { $objects = $query->select('DISTINCT '.$query->getRootAlias())->getQuery()->iterate(); $i = 0; $em = $this->get('doctrine')->getManager(); foreach ($objects as $object) { $object[0]->publish(); $em->persist($object[0]); if ((++$i % 20) == 0) { $em->flush(); $em->clear(); } } $em->flush(); $em->clear(); $this->addFlash('sonata_flash_success', 'flash.success.batch_publish'); } catch (ModelManagerException $e) { $this->addFlash('sonata_flash_error', 'flash.error.batch_publish'); } return new RedirectResponse($this->admin->generateUrl('list', array('filter' => $this->admin->getFilterParameters()))); }
php
public function batchActionPublish(ProxyQueryInterface $query) { try { $objects = $query->select('DISTINCT '.$query->getRootAlias())->getQuery()->iterate(); $i = 0; $em = $this->get('doctrine')->getManager(); foreach ($objects as $object) { $object[0]->publish(); $em->persist($object[0]); if ((++$i % 20) == 0) { $em->flush(); $em->clear(); } } $em->flush(); $em->clear(); $this->addFlash('sonata_flash_success', 'flash.success.batch_publish'); } catch (ModelManagerException $e) { $this->addFlash('sonata_flash_error', 'flash.error.batch_publish'); } return new RedirectResponse($this->admin->generateUrl('list', array('filter' => $this->admin->getFilterParameters()))); }
[ "public", "function", "batchActionPublish", "(", "ProxyQueryInterface", "$", "query", ")", "{", "try", "{", "$", "objects", "=", "$", "query", "->", "select", "(", "'DISTINCT '", ".", "$", "query", "->", "getRootAlias", "(", ")", ")", "->", "getQuery", "(", ")", "->", "iterate", "(", ")", ";", "$", "i", "=", "0", ";", "$", "em", "=", "$", "this", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "foreach", "(", "$", "objects", "as", "$", "object", ")", "{", "$", "object", "[", "0", "]", "->", "publish", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "object", "[", "0", "]", ")", ";", "if", "(", "(", "++", "$", "i", "%", "20", ")", "==", "0", ")", "{", "$", "em", "->", "flush", "(", ")", ";", "$", "em", "->", "clear", "(", ")", ";", "}", "}", "$", "em", "->", "flush", "(", ")", ";", "$", "em", "->", "clear", "(", ")", ";", "$", "this", "->", "addFlash", "(", "'sonata_flash_success'", ",", "'flash.success.batch_publish'", ")", ";", "}", "catch", "(", "ModelManagerException", "$", "e", ")", "{", "$", "this", "->", "addFlash", "(", "'sonata_flash_error'", ",", "'flash.error.batch_publish'", ")", ";", "}", "return", "new", "RedirectResponse", "(", "$", "this", "->", "admin", "->", "generateUrl", "(", "'list'", ",", "array", "(", "'filter'", "=>", "$", "this", "->", "admin", "->", "getFilterParameters", "(", ")", ")", ")", ")", ";", "}" ]
Execute a batch publish @param ProxyQueryInterface $query @return RedirectResponse
[ "Execute", "a", "batch", "publish" ]
edc768061734a92ba116488dd7b61ad40af21ceb
https://github.com/vincentchalamon/VinceCmsSonataAdminBundle/blob/edc768061734a92ba116488dd7b61ad40af21ceb/Controller/PublishableController.php#L56-L78
15,323
fuelphp/display
src/Parser/Twig.php
Twig.setupTwig
public function setupTwig() { $twigLoader = new TwigLoader($this->viewManager); $config = []; if ($this->viewManager->cachePath) { $config['cache'] = $this->viewManager->cachePath.'twig/'; } $this->twig = new Twig_Environment($twigLoader, $config); }
php
public function setupTwig() { $twigLoader = new TwigLoader($this->viewManager); $config = []; if ($this->viewManager->cachePath) { $config['cache'] = $this->viewManager->cachePath.'twig/'; } $this->twig = new Twig_Environment($twigLoader, $config); }
[ "public", "function", "setupTwig", "(", ")", "{", "$", "twigLoader", "=", "new", "TwigLoader", "(", "$", "this", "->", "viewManager", ")", ";", "$", "config", "=", "[", "]", ";", "if", "(", "$", "this", "->", "viewManager", "->", "cachePath", ")", "{", "$", "config", "[", "'cache'", "]", "=", "$", "this", "->", "viewManager", "->", "cachePath", ".", "'twig/'", ";", "}", "$", "this", "->", "twig", "=", "new", "Twig_Environment", "(", "$", "twigLoader", ",", "$", "config", ")", ";", "}" ]
Sets the Twig Environment up
[ "Sets", "the", "Twig", "Environment", "up" ]
d9a3eddbf80f0fd81beb40d9f4507600ac6611a4
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/Parser/Twig.php#L51-L62
15,324
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/FieldCollection.php
FieldCollection.addItem
public function addItem(BaseField $objItem) { $this->items[] = $objItem; end($this->items); $key = key($this->items); $this->index[$key] = $objItem->get('colName'); }
php
public function addItem(BaseField $objItem) { $this->items[] = $objItem; end($this->items); $key = key($this->items); $this->index[$key] = $objItem->get('colName'); }
[ "public", "function", "addItem", "(", "BaseField", "$", "objItem", ")", "{", "$", "this", "->", "items", "[", "]", "=", "$", "objItem", ";", "end", "(", "$", "this", "->", "items", ")", ";", "$", "key", "=", "key", "(", "$", "this", "->", "items", ")", ";", "$", "this", "->", "index", "[", "$", "key", "]", "=", "$", "objItem", "->", "get", "(", "'colName'", ")", ";", "}" ]
Add an item of type BaseField to the field collection @param BaseField $objItem
[ "Add", "an", "item", "of", "type", "BaseField", "to", "the", "field", "collection" ]
ab92e61c24644f1e61265304b6a35e505007d021
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/FieldCollection.php#L50-L56
15,325
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/FieldCollection.php
FieldCollection.findItemByColName
public function findItemByColName($colName) { if(in_array($colName, $this->index)){ return $this->items[array_search($colName, $this->index)]; } return false; }
php
public function findItemByColName($colName) { if(in_array($colName, $this->index)){ return $this->items[array_search($colName, $this->index)]; } return false; }
[ "public", "function", "findItemByColName", "(", "$", "colName", ")", "{", "if", "(", "in_array", "(", "$", "colName", ",", "$", "this", "->", "index", ")", ")", "{", "return", "$", "this", "->", "items", "[", "array_search", "(", "$", "colName", ",", "$", "this", "->", "index", ")", "]", ";", "}", "return", "false", ";", "}" ]
Get an item by its colName @param string $colName @return BaseField|bool
[ "Get", "an", "item", "by", "its", "colName" ]
ab92e61c24644f1e61265304b6a35e505007d021
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/FieldCollection.php#L63-L72
15,326
FrenchFrogs/framework
src/Table/Column/Button.php
Button.getBindedLabel
public function getBindedLabel($row = []) { $bind = isset($row[$this->getName()]) ? $row[$this->getName()] : false; return sprintf($this->getLabel(), $bind); }
php
public function getBindedLabel($row = []) { $bind = isset($row[$this->getName()]) ? $row[$this->getName()] : false; return sprintf($this->getLabel(), $bind); }
[ "public", "function", "getBindedLabel", "(", "$", "row", "=", "[", "]", ")", "{", "$", "bind", "=", "isset", "(", "$", "row", "[", "$", "this", "->", "getName", "(", ")", "]", ")", "?", "$", "row", "[", "$", "this", "->", "getName", "(", ")", "]", ":", "false", ";", "return", "sprintf", "(", "$", "this", "->", "getLabel", "(", ")", ",", "$", "bind", ")", ";", "}" ]
Return the binded Label @param array $row @return string
[ "Return", "the", "binded", "Label" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Column/Button.php#L31-L35
15,327
prooph/link-app-core
src/Controller/ProcessingSetUpController.php
ProcessingSetUpController.runAction
public function runAction() { try { $this->commandBus->dispatch(CreateDefaultProcessingConfigFile::in(ConfigLocation::fromPath(Definition::getSystemConfigDir()))); $sqliteDbFile = SqliteDbFile::initializeFromDist(Definition::getEventStoreSqliteDbFile()); $esConfigLocation = ConfigLocation::fromPath(Definition::getSystemConfigDir()); $this->commandBus->dispatch(InitializeEventStore::setUpWithSqliteDbAdapter($sqliteDbFile, $esConfigLocation)); } catch (\Exception $ex) { $this->commandBus->dispatch(UndoSystemSetUp::removeConfigs( Definition::getSystemConfigDir(), Definition::getSystemConfigDir(), Definition::getEventStoreSqliteDbFile() )); throw $ex; } return $this->redirect()->toRoute('prooph.link/system_config'); }
php
public function runAction() { try { $this->commandBus->dispatch(CreateDefaultProcessingConfigFile::in(ConfigLocation::fromPath(Definition::getSystemConfigDir()))); $sqliteDbFile = SqliteDbFile::initializeFromDist(Definition::getEventStoreSqliteDbFile()); $esConfigLocation = ConfigLocation::fromPath(Definition::getSystemConfigDir()); $this->commandBus->dispatch(InitializeEventStore::setUpWithSqliteDbAdapter($sqliteDbFile, $esConfigLocation)); } catch (\Exception $ex) { $this->commandBus->dispatch(UndoSystemSetUp::removeConfigs( Definition::getSystemConfigDir(), Definition::getSystemConfigDir(), Definition::getEventStoreSqliteDbFile() )); throw $ex; } return $this->redirect()->toRoute('prooph.link/system_config'); }
[ "public", "function", "runAction", "(", ")", "{", "try", "{", "$", "this", "->", "commandBus", "->", "dispatch", "(", "CreateDefaultProcessingConfigFile", "::", "in", "(", "ConfigLocation", "::", "fromPath", "(", "Definition", "::", "getSystemConfigDir", "(", ")", ")", ")", ")", ";", "$", "sqliteDbFile", "=", "SqliteDbFile", "::", "initializeFromDist", "(", "Definition", "::", "getEventStoreSqliteDbFile", "(", ")", ")", ";", "$", "esConfigLocation", "=", "ConfigLocation", "::", "fromPath", "(", "Definition", "::", "getSystemConfigDir", "(", ")", ")", ";", "$", "this", "->", "commandBus", "->", "dispatch", "(", "InitializeEventStore", "::", "setUpWithSqliteDbAdapter", "(", "$", "sqliteDbFile", ",", "$", "esConfigLocation", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "$", "this", "->", "commandBus", "->", "dispatch", "(", "UndoSystemSetUp", "::", "removeConfigs", "(", "Definition", "::", "getSystemConfigDir", "(", ")", ",", "Definition", "::", "getSystemConfigDir", "(", ")", ",", "Definition", "::", "getEventStoreSqliteDbFile", "(", ")", ")", ")", ";", "throw", "$", "ex", ";", "}", "return", "$", "this", "->", "redirect", "(", ")", "->", "toRoute", "(", "'prooph.link/system_config'", ")", ";", "}" ]
Runs the initial set up of the processing system
[ "Runs", "the", "initial", "set", "up", "of", "the", "processing", "system" ]
835a5945dfa7be7b2cebfa6e84e757ecfd783357
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Controller/ProcessingSetUpController.php#L33-L55
15,328
bestit/commercetools-order-export-bundle
src/DependencyInjection/BestItCtOrderExportExtension.php
BestItCtOrderExportExtension.load
public function load(array $configs, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yml'); $config = $this->processConfiguration(new Configuration(), $configs); $container->setAlias( 'best_it_ct_order_export.export.filesystem', $config['filesystem'] ); $container->setAlias('best_it_ct_order_export.logger', $config['logger']); $container->setParameter( 'best_it_ct_order_export.commercetools.client.id', (string) @ $config['commercetools_client']['id'] ); $container->setParameter( 'best_it_ct_order_export.commercetools.client.secret', (string) @ $config['commercetools_client']['secret'] ); $container->setParameter( 'best_it_ct_order_export.commercetools.client.project', (string) @ $config['commercetools_client']['project'] ); $container->setParameter( 'best_it_ct_order_export.commercetools.client.scope', (string) @ $config['commercetools_client']['scope'] ); $container->setParameter( 'best_it_ct_order_export.orders.with_pagination', (bool) ( $config['orders']['with_pagination'] ?? true ) ); $container->setParameter('best_it_ct_order_export.orders.file_template', $config['orders']['file_template']); $container->setParameter('best_it_ct_order_export.orders.name_scheme', $config['orders']['name_scheme']); $container->setParameter( 'best_it_ct_order_export.orders.default_where', $config['orders']['default_where'] ?? [] ); }
php
public function load(array $configs, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yml'); $config = $this->processConfiguration(new Configuration(), $configs); $container->setAlias( 'best_it_ct_order_export.export.filesystem', $config['filesystem'] ); $container->setAlias('best_it_ct_order_export.logger', $config['logger']); $container->setParameter( 'best_it_ct_order_export.commercetools.client.id', (string) @ $config['commercetools_client']['id'] ); $container->setParameter( 'best_it_ct_order_export.commercetools.client.secret', (string) @ $config['commercetools_client']['secret'] ); $container->setParameter( 'best_it_ct_order_export.commercetools.client.project', (string) @ $config['commercetools_client']['project'] ); $container->setParameter( 'best_it_ct_order_export.commercetools.client.scope', (string) @ $config['commercetools_client']['scope'] ); $container->setParameter( 'best_it_ct_order_export.orders.with_pagination', (bool) ( $config['orders']['with_pagination'] ?? true ) ); $container->setParameter('best_it_ct_order_export.orders.file_template', $config['orders']['file_template']); $container->setParameter('best_it_ct_order_export.orders.name_scheme', $config['orders']['name_scheme']); $container->setParameter( 'best_it_ct_order_export.orders.default_where', $config['orders']['default_where'] ?? [] ); }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "loader", "=", "new", "YamlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "$", "loader", "->", "load", "(", "'services.yml'", ")", ";", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "new", "Configuration", "(", ")", ",", "$", "configs", ")", ";", "$", "container", "->", "setAlias", "(", "'best_it_ct_order_export.export.filesystem'", ",", "$", "config", "[", "'filesystem'", "]", ")", ";", "$", "container", "->", "setAlias", "(", "'best_it_ct_order_export.logger'", ",", "$", "config", "[", "'logger'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'best_it_ct_order_export.commercetools.client.id'", ",", "(", "string", ")", "@", "$", "config", "[", "'commercetools_client'", "]", "[", "'id'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'best_it_ct_order_export.commercetools.client.secret'", ",", "(", "string", ")", "@", "$", "config", "[", "'commercetools_client'", "]", "[", "'secret'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'best_it_ct_order_export.commercetools.client.project'", ",", "(", "string", ")", "@", "$", "config", "[", "'commercetools_client'", "]", "[", "'project'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'best_it_ct_order_export.commercetools.client.scope'", ",", "(", "string", ")", "@", "$", "config", "[", "'commercetools_client'", "]", "[", "'scope'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'best_it_ct_order_export.orders.with_pagination'", ",", "(", "bool", ")", "(", "$", "config", "[", "'orders'", "]", "[", "'with_pagination'", "]", "??", "true", ")", ")", ";", "$", "container", "->", "setParameter", "(", "'best_it_ct_order_export.orders.file_template'", ",", "$", "config", "[", "'orders'", "]", "[", "'file_template'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'best_it_ct_order_export.orders.name_scheme'", ",", "$", "config", "[", "'orders'", "]", "[", "'name_scheme'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'best_it_ct_order_export.orders.default_where'", ",", "$", "config", "[", "'orders'", "]", "[", "'default_where'", "]", "??", "[", "]", ")", ";", "}" ]
Loads the bundle config. @param array $configs @param ContainerBuilder $container @return void
[ "Loads", "the", "bundle", "config", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/DependencyInjection/BestItCtOrderExportExtension.php#L25-L71
15,329
gmazzap/Url_To_Query
UrlToQuery.php
UrlToQuery.resolve
function resolve( $url = '', $query_string_vars = [ ] ) { $url = filter_var( $url, FILTER_SANITIZE_URL ); if ( ! empty( $url ) ) { $id = md5( $url . serialize( $query_string_vars ) ); if ( ! isset( $this->items[$id] ) || ! $this->items[$id] instanceof UrlToQueryItem ) { $this->items[$id] = new UrlToQueryItem( $this ); } $result = $this->items[$id]->resolve( $url, $query_string_vars ); } else { $result = new \WP_Error( 'url-to-query-bad-url' ); } return $result; }
php
function resolve( $url = '', $query_string_vars = [ ] ) { $url = filter_var( $url, FILTER_SANITIZE_URL ); if ( ! empty( $url ) ) { $id = md5( $url . serialize( $query_string_vars ) ); if ( ! isset( $this->items[$id] ) || ! $this->items[$id] instanceof UrlToQueryItem ) { $this->items[$id] = new UrlToQueryItem( $this ); } $result = $this->items[$id]->resolve( $url, $query_string_vars ); } else { $result = new \WP_Error( 'url-to-query-bad-url' ); } return $result; }
[ "function", "resolve", "(", "$", "url", "=", "''", ",", "$", "query_string_vars", "=", "[", "]", ")", "{", "$", "url", "=", "filter_var", "(", "$", "url", ",", "FILTER_SANITIZE_URL", ")", ";", "if", "(", "!", "empty", "(", "$", "url", ")", ")", "{", "$", "id", "=", "md5", "(", "$", "url", ".", "serialize", "(", "$", "query_string_vars", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "$", "id", "]", ")", "||", "!", "$", "this", "->", "items", "[", "$", "id", "]", "instanceof", "UrlToQueryItem", ")", "{", "$", "this", "->", "items", "[", "$", "id", "]", "=", "new", "UrlToQueryItem", "(", "$", "this", ")", ";", "}", "$", "result", "=", "$", "this", "->", "items", "[", "$", "id", "]", "->", "resolve", "(", "$", "url", ",", "$", "query_string_vars", ")", ";", "}", "else", "{", "$", "result", "=", "new", "\\", "WP_Error", "(", "'url-to-query-bad-url'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Resolve an url to an array of WP_Query arguments for main query @param string $url Url to resolve @param type $query_string_vars Query variables to be added to the url @return array|\WP_Error Resolved query or WP_Error is something goes wrong
[ "Resolve", "an", "url", "to", "an", "array", "of", "WP_Query", "arguments", "for", "main", "query" ]
2537affbbb8b9062d46bb2deec1933acab63d007
https://github.com/gmazzap/Url_To_Query/blob/2537affbbb8b9062d46bb2deec1933acab63d007/UrlToQuery.php#L57-L69
15,330
stubbles/stubbles-webapp-core
src/main/php/response/mimetypes/Csv.php
Csv.serializeIterable
private function serializeIterable($resource, OutputStream $out) { $memory = fopen('php://memory', 'wb'); if (is_array($resource) && is_scalar(current($resource))) { if (!is_numeric(key($resource))) { $out->write($this->toCsvLine(array_keys($resource), $memory)); } $out->write($this->toCsvLine($resource, $memory)); } else { $head = true; foreach (Sequence::of($resource)->map('stubbles\sequence\castToArray') as $elements) { if ($head && !is_numeric(key($elements))) { $out->write($this->toCsvLine(array_keys($elements), $memory)); } $head = false; $out->write($this->toCsvLine($elements, $memory)); } } fclose($memory); }
php
private function serializeIterable($resource, OutputStream $out) { $memory = fopen('php://memory', 'wb'); if (is_array($resource) && is_scalar(current($resource))) { if (!is_numeric(key($resource))) { $out->write($this->toCsvLine(array_keys($resource), $memory)); } $out->write($this->toCsvLine($resource, $memory)); } else { $head = true; foreach (Sequence::of($resource)->map('stubbles\sequence\castToArray') as $elements) { if ($head && !is_numeric(key($elements))) { $out->write($this->toCsvLine(array_keys($elements), $memory)); } $head = false; $out->write($this->toCsvLine($elements, $memory)); } } fclose($memory); }
[ "private", "function", "serializeIterable", "(", "$", "resource", ",", "OutputStream", "$", "out", ")", "{", "$", "memory", "=", "fopen", "(", "'php://memory'", ",", "'wb'", ")", ";", "if", "(", "is_array", "(", "$", "resource", ")", "&&", "is_scalar", "(", "current", "(", "$", "resource", ")", ")", ")", "{", "if", "(", "!", "is_numeric", "(", "key", "(", "$", "resource", ")", ")", ")", "{", "$", "out", "->", "write", "(", "$", "this", "->", "toCsvLine", "(", "array_keys", "(", "$", "resource", ")", ",", "$", "memory", ")", ")", ";", "}", "$", "out", "->", "write", "(", "$", "this", "->", "toCsvLine", "(", "$", "resource", ",", "$", "memory", ")", ")", ";", "}", "else", "{", "$", "head", "=", "true", ";", "foreach", "(", "Sequence", "::", "of", "(", "$", "resource", ")", "->", "map", "(", "'stubbles\\sequence\\castToArray'", ")", "as", "$", "elements", ")", "{", "if", "(", "$", "head", "&&", "!", "is_numeric", "(", "key", "(", "$", "elements", ")", ")", ")", "{", "$", "out", "->", "write", "(", "$", "this", "->", "toCsvLine", "(", "array_keys", "(", "$", "elements", ")", ",", "$", "memory", ")", ")", ";", "}", "$", "head", "=", "false", ";", "$", "out", "->", "write", "(", "$", "this", "->", "toCsvLine", "(", "$", "elements", ",", "$", "memory", ")", ")", ";", "}", "}", "fclose", "(", "$", "memory", ")", ";", "}" ]
serializes iterable to csv @param iterable $resource @param \stubbles\streams\OutputStream $out
[ "serializes", "iterable", "to", "csv" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/mimetypes/Csv.php#L102-L124
15,331
stubbles/stubbles-webapp-core
src/main/php/response/mimetypes/Csv.php
Csv.toCsvLine
private function toCsvLine(array $elements, $memory): string { ftruncate($memory, 0); rewind($memory); fputcsv($memory, $elements, $this->delimiter, $this->enclosure); rewind($memory); return stream_get_contents($memory); }
php
private function toCsvLine(array $elements, $memory): string { ftruncate($memory, 0); rewind($memory); fputcsv($memory, $elements, $this->delimiter, $this->enclosure); rewind($memory); return stream_get_contents($memory); }
[ "private", "function", "toCsvLine", "(", "array", "$", "elements", ",", "$", "memory", ")", ":", "string", "{", "ftruncate", "(", "$", "memory", ",", "0", ")", ";", "rewind", "(", "$", "memory", ")", ";", "fputcsv", "(", "$", "memory", ",", "$", "elements", ",", "$", "this", "->", "delimiter", ",", "$", "this", "->", "enclosure", ")", ";", "rewind", "(", "$", "memory", ")", ";", "return", "stream_get_contents", "(", "$", "memory", ")", ";", "}" ]
turns given list of elements into a line suitable for csv @param string[] $elements @param resource $memory @return string
[ "turns", "given", "list", "of", "elements", "into", "a", "line", "suitable", "for", "csv" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/mimetypes/Csv.php#L133-L140
15,332
luyadev/luya-module-styleguide
src/controllers/DefaultController.php
DefaultController.actionIndex
public function actionIndex() { if (!$this->hasAccess()) { return $this->redirect(['login']); } foreach ($this->module->assetFiles as $class) { $this->registerAsset($class); } return $this->render('index', [ 'title' => 'Styleguide', 'showDomain' => true, 'styleguide' => $this->extractElementsFromComponent() ]); }
php
public function actionIndex() { if (!$this->hasAccess()) { return $this->redirect(['login']); } foreach ($this->module->assetFiles as $class) { $this->registerAsset($class); } return $this->render('index', [ 'title' => 'Styleguide', 'showDomain' => true, 'styleguide' => $this->extractElementsFromComponent() ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasAccess", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "[", "'login'", "]", ")", ";", "}", "foreach", "(", "$", "this", "->", "module", "->", "assetFiles", "as", "$", "class", ")", "{", "$", "this", "->", "registerAsset", "(", "$", "class", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'title'", "=>", "'Styleguide'", ",", "'showDomain'", "=>", "true", ",", "'styleguide'", "=>", "$", "this", "->", "extractElementsFromComponent", "(", ")", "]", ")", ";", "}" ]
Render Styleguide. @return \yii\web\Response|string
[ "Render", "Styleguide", "." ]
212ebbd9555ca2e871372b10f3e2399f7ab68e85
https://github.com/luyadev/luya-module-styleguide/blob/212ebbd9555ca2e871372b10f3e2399f7ab68e85/src/controllers/DefaultController.php#L24-L39
15,333
luyadev/luya-module-styleguide
src/controllers/DefaultController.php
DefaultController.actionLogin
public function actionLogin() { $password = Yii::$app->request->post('pass', false); // check password if ($password === $this->module->password || $this->hasAccess()) { Yii::$app->session->set(self::STYLEGUIDE_SESSION_PWNAME, $password); return $this->redirect(['index']); } elseif ($password !== false) { Yii::$app->session->setFlash('wrong.styleguide.password'); } return $this->render('login'); }
php
public function actionLogin() { $password = Yii::$app->request->post('pass', false); // check password if ($password === $this->module->password || $this->hasAccess()) { Yii::$app->session->set(self::STYLEGUIDE_SESSION_PWNAME, $password); return $this->redirect(['index']); } elseif ($password !== false) { Yii::$app->session->setFlash('wrong.styleguide.password'); } return $this->render('login'); }
[ "public", "function", "actionLogin", "(", ")", "{", "$", "password", "=", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'pass'", ",", "false", ")", ";", "// check password", "if", "(", "$", "password", "===", "$", "this", "->", "module", "->", "password", "||", "$", "this", "->", "hasAccess", "(", ")", ")", "{", "Yii", "::", "$", "app", "->", "session", "->", "set", "(", "self", "::", "STYLEGUIDE_SESSION_PWNAME", ",", "$", "password", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'index'", "]", ")", ";", "}", "elseif", "(", "$", "password", "!==", "false", ")", "{", "Yii", "::", "$", "app", "->", "session", "->", "setFlash", "(", "'wrong.styleguide.password'", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'login'", ")", ";", "}" ]
Login action if password is required. @return \yii\web\Response|string
[ "Login", "action", "if", "password", "is", "required", "." ]
212ebbd9555ca2e871372b10f3e2399f7ab68e85
https://github.com/luyadev/luya-module-styleguide/blob/212ebbd9555ca2e871372b10f3e2399f7ab68e85/src/controllers/DefaultController.php#L46-L59
15,334
luyadev/luya-module-styleguide
src/controllers/DefaultController.php
DefaultController.extractElementsFromComponent
protected function extractElementsFromComponent() { $elements = []; foreach (Yii::$app->element->getElements() as $name => $closure) { $reflection = new \ReflectionFunction($closure); $args = $reflection->getParameters(); $params = []; $writtenParams = []; foreach ($args as $k => $v) { $mock = Yii::$app->element->getMockedArgValue($name, $v->name); if ($mock !== false) { $params[] = $mock; if (is_array($mock)) { $writtenParams[] = 'array $'.$v->name; } else { $writtenParams[] = '$'.$v->name; } } else { if ($v->isArray()) { $params[] = ['$'.$v->name]; $writtenParams[] = 'array $'.$v->name; } else { $params[] = '$'.$v->name; $writtenParams[] = '$'.$v->name; } } } $elements[] = $this->defineElement($name, $name, null, $params, [], $writtenParams); } return [ 'groups' => [ [ 'name' => 'Elements', 'description' => 'Basic element overview', 'elements' => $elements, ] ] ]; }
php
protected function extractElementsFromComponent() { $elements = []; foreach (Yii::$app->element->getElements() as $name => $closure) { $reflection = new \ReflectionFunction($closure); $args = $reflection->getParameters(); $params = []; $writtenParams = []; foreach ($args as $k => $v) { $mock = Yii::$app->element->getMockedArgValue($name, $v->name); if ($mock !== false) { $params[] = $mock; if (is_array($mock)) { $writtenParams[] = 'array $'.$v->name; } else { $writtenParams[] = '$'.$v->name; } } else { if ($v->isArray()) { $params[] = ['$'.$v->name]; $writtenParams[] = 'array $'.$v->name; } else { $params[] = '$'.$v->name; $writtenParams[] = '$'.$v->name; } } } $elements[] = $this->defineElement($name, $name, null, $params, [], $writtenParams); } return [ 'groups' => [ [ 'name' => 'Elements', 'description' => 'Basic element overview', 'elements' => $elements, ] ] ]; }
[ "protected", "function", "extractElementsFromComponent", "(", ")", "{", "$", "elements", "=", "[", "]", ";", "foreach", "(", "Yii", "::", "$", "app", "->", "element", "->", "getElements", "(", ")", "as", "$", "name", "=>", "$", "closure", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionFunction", "(", "$", "closure", ")", ";", "$", "args", "=", "$", "reflection", "->", "getParameters", "(", ")", ";", "$", "params", "=", "[", "]", ";", "$", "writtenParams", "=", "[", "]", ";", "foreach", "(", "$", "args", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "mock", "=", "Yii", "::", "$", "app", "->", "element", "->", "getMockedArgValue", "(", "$", "name", ",", "$", "v", "->", "name", ")", ";", "if", "(", "$", "mock", "!==", "false", ")", "{", "$", "params", "[", "]", "=", "$", "mock", ";", "if", "(", "is_array", "(", "$", "mock", ")", ")", "{", "$", "writtenParams", "[", "]", "=", "'array $'", ".", "$", "v", "->", "name", ";", "}", "else", "{", "$", "writtenParams", "[", "]", "=", "'$'", ".", "$", "v", "->", "name", ";", "}", "}", "else", "{", "if", "(", "$", "v", "->", "isArray", "(", ")", ")", "{", "$", "params", "[", "]", "=", "[", "'$'", ".", "$", "v", "->", "name", "]", ";", "$", "writtenParams", "[", "]", "=", "'array $'", ".", "$", "v", "->", "name", ";", "}", "else", "{", "$", "params", "[", "]", "=", "'$'", ".", "$", "v", "->", "name", ";", "$", "writtenParams", "[", "]", "=", "'$'", ".", "$", "v", "->", "name", ";", "}", "}", "}", "$", "elements", "[", "]", "=", "$", "this", "->", "defineElement", "(", "$", "name", ",", "$", "name", ",", "null", ",", "$", "params", ",", "[", "]", ",", "$", "writtenParams", ")", ";", "}", "return", "[", "'groups'", "=>", "[", "[", "'name'", "=>", "'Elements'", ",", "'description'", "=>", "'Basic element overview'", ",", "'elements'", "=>", "$", "elements", ",", "]", "]", "]", ";", "}" ]
Extract the data from the element component @return array
[ "Extract", "the", "data", "from", "the", "element", "component" ]
212ebbd9555ca2e871372b10f3e2399f7ab68e85
https://github.com/luyadev/luya-module-styleguide/blob/212ebbd9555ca2e871372b10f3e2399f7ab68e85/src/controllers/DefaultController.php#L66-L106
15,335
luyadev/luya-module-styleguide
src/controllers/DefaultController.php
DefaultController.defineElement
protected function defineElement($element, $name = null, $description = null, array $values = [], array $options = [], array $params = []) { return [ 'name' => $name ?: $element, 'description' => $description, 'element' => $element, 'values' => $values, 'params' => $params, ]; }
php
protected function defineElement($element, $name = null, $description = null, array $values = [], array $options = [], array $params = []) { return [ 'name' => $name ?: $element, 'description' => $description, 'element' => $element, 'values' => $values, 'params' => $params, ]; }
[ "protected", "function", "defineElement", "(", "$", "element", ",", "$", "name", "=", "null", ",", "$", "description", "=", "null", ",", "array", "$", "values", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ",", "array", "$", "params", "=", "[", "]", ")", "{", "return", "[", "'name'", "=>", "$", "name", "?", ":", "$", "element", ",", "'description'", "=>", "$", "description", ",", "'element'", "=>", "$", "element", ",", "'values'", "=>", "$", "values", ",", "'params'", "=>", "$", "params", ",", "]", ";", "}" ]
Generate the array for a given element. @return array
[ "Generate", "the", "array", "for", "a", "given", "element", "." ]
212ebbd9555ca2e871372b10f3e2399f7ab68e85
https://github.com/luyadev/luya-module-styleguide/blob/212ebbd9555ca2e871372b10f3e2399f7ab68e85/src/controllers/DefaultController.php#L113-L122
15,336
luyadev/luya-module-styleguide
src/controllers/DefaultController.php
DefaultController.hasAccess
protected function hasAccess() { return $this->module->password == Yii::$app->session->get(self::STYLEGUIDE_SESSION_PWNAME, false); }
php
protected function hasAccess() { return $this->module->password == Yii::$app->session->get(self::STYLEGUIDE_SESSION_PWNAME, false); }
[ "protected", "function", "hasAccess", "(", ")", "{", "return", "$", "this", "->", "module", "->", "password", "==", "Yii", "::", "$", "app", "->", "session", "->", "get", "(", "self", "::", "STYLEGUIDE_SESSION_PWNAME", ",", "false", ")", ";", "}" ]
Whether current session contains password or not. @return boolean
[ "Whether", "current", "session", "contains", "password", "or", "not", "." ]
212ebbd9555ca2e871372b10f3e2399f7ab68e85
https://github.com/luyadev/luya-module-styleguide/blob/212ebbd9555ca2e871372b10f3e2399f7ab68e85/src/controllers/DefaultController.php#L129-L132
15,337
Nayjest/Tree
src/NodeCollection.php
NodeCollection.add
public function add($item, $prepend = false) { if (!$item instanceof ChildNodeInterface) { $details = is_object($item) ? get_class($item) : gettype($item); throw new InvalidArgumentException( "NodeCollection accepts only objects implementing ChildNodeInterface, $details given." ); } $old = $item->parent(); if ($old === $this->parentNode) { return $this; } elseif ($old !== null) { $item->detach(); } $this->checkUnlocked($item); parent::add($item, $prepend); $item->internalSetParent($this->parentNode); return $this; }
php
public function add($item, $prepend = false) { if (!$item instanceof ChildNodeInterface) { $details = is_object($item) ? get_class($item) : gettype($item); throw new InvalidArgumentException( "NodeCollection accepts only objects implementing ChildNodeInterface, $details given." ); } $old = $item->parent(); if ($old === $this->parentNode) { return $this; } elseif ($old !== null) { $item->detach(); } $this->checkUnlocked($item); parent::add($item, $prepend); $item->internalSetParent($this->parentNode); return $this; }
[ "public", "function", "add", "(", "$", "item", ",", "$", "prepend", "=", "false", ")", "{", "if", "(", "!", "$", "item", "instanceof", "ChildNodeInterface", ")", "{", "$", "details", "=", "is_object", "(", "$", "item", ")", "?", "get_class", "(", "$", "item", ")", ":", "gettype", "(", "$", "item", ")", ";", "throw", "new", "InvalidArgumentException", "(", "\"NodeCollection accepts only objects implementing ChildNodeInterface, $details given.\"", ")", ";", "}", "$", "old", "=", "$", "item", "->", "parent", "(", ")", ";", "if", "(", "$", "old", "===", "$", "this", "->", "parentNode", ")", "{", "return", "$", "this", ";", "}", "elseif", "(", "$", "old", "!==", "null", ")", "{", "$", "item", "->", "detach", "(", ")", ";", "}", "$", "this", "->", "checkUnlocked", "(", "$", "item", ")", ";", "parent", "::", "add", "(", "$", "item", ",", "$", "prepend", ")", ";", "$", "item", "->", "internalSetParent", "(", "$", "this", "->", "parentNode", ")", ";", "return", "$", "this", ";", "}" ]
Adds component to collection. If component is already in collection, it will not be added twice. @param ChildNodeInterface $item @param bool $prepend Pass true to add component to the beginning of an array. @return $this
[ "Adds", "component", "to", "collection", "." ]
e73da75f939e207b1c25065e9466c28300e7113c
https://github.com/Nayjest/Tree/blob/e73da75f939e207b1c25065e9466c28300e7113c/src/NodeCollection.php#L40-L59
15,338
comodojo/dispatcher.framework
src/Comodojo/Dispatcher/Service/AbstractService.php
AbstractService.getImplementedMethods
public function getImplementedMethods() { $supported_methods = $this->getConfiguration()->get('supported-http-methods'); if ( is_null($supported_methods) ) $supported_methods = self::$supported_methods; if ( method_exists($this, 'any') ) { return $supported_methods; } $implemented_methods = []; foreach ( $supported_methods as $method ) { if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods, $method); } return $implemented_methods; }
php
public function getImplementedMethods() { $supported_methods = $this->getConfiguration()->get('supported-http-methods'); if ( is_null($supported_methods) ) $supported_methods = self::$supported_methods; if ( method_exists($this, 'any') ) { return $supported_methods; } $implemented_methods = []; foreach ( $supported_methods as $method ) { if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods, $method); } return $implemented_methods; }
[ "public", "function", "getImplementedMethods", "(", ")", "{", "$", "supported_methods", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "get", "(", "'supported-http-methods'", ")", ";", "if", "(", "is_null", "(", "$", "supported_methods", ")", ")", "$", "supported_methods", "=", "self", "::", "$", "supported_methods", ";", "if", "(", "method_exists", "(", "$", "this", ",", "'any'", ")", ")", "{", "return", "$", "supported_methods", ";", "}", "$", "implemented_methods", "=", "[", "]", ";", "foreach", "(", "$", "supported_methods", "as", "$", "method", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "strtolower", "(", "$", "method", ")", ")", ")", "array_push", "(", "$", "implemented_methods", ",", "$", "method", ")", ";", "}", "return", "$", "implemented_methods", ";", "}" ]
Get service-implemented HTTP methods @return array Service implemented methods, in uppercase
[ "Get", "service", "-", "implemented", "HTTP", "methods" ]
5093297dcb7441a8d8f79cbb2429c93232e16d1c
https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Service/AbstractService.php#L75-L97
15,339
comodojo/dispatcher.framework
src/Comodojo/Dispatcher/Service/AbstractService.php
AbstractService.getMethod
public function getMethod($method) { $method = strtolower($method); if ( method_exists($this, $method) ) { return $method; } else if ( method_exists($this, 'any') ) { return 'any'; } else { return null; } }
php
public function getMethod($method) { $method = strtolower($method); if ( method_exists($this, $method) ) { return $method; } else if ( method_exists($this, 'any') ) { return 'any'; } else { return null; } }
[ "public", "function", "getMethod", "(", "$", "method", ")", "{", "$", "method", "=", "strtolower", "(", "$", "method", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "return", "$", "method", ";", "}", "else", "if", "(", "method_exists", "(", "$", "this", ",", "'any'", ")", ")", "{", "return", "'any'", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Return the callable class method that reflect the requested one
[ "Return", "the", "callable", "class", "method", "that", "reflect", "the", "requested", "one" ]
5093297dcb7441a8d8f79cbb2429c93232e16d1c
https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Service/AbstractService.php#L103-L121
15,340
czim/laravel-pxlcms
src/Generator/Writer/AbstractProcessStep.php
AbstractProcessStep.stubReplace
protected function stubReplace($placeholder, $replace, $pregReplace = false) { if ($pregReplace) { $this->data->output['content'] = preg_replace( $placeholder, $replace, $this->data->output['content'] ); } else { $this->data->output['content'] = str_replace( $placeholder, $replace, $this->data->output['content'] ); } return $this; }
php
protected function stubReplace($placeholder, $replace, $pregReplace = false) { if ($pregReplace) { $this->data->output['content'] = preg_replace( $placeholder, $replace, $this->data->output['content'] ); } else { $this->data->output['content'] = str_replace( $placeholder, $replace, $this->data->output['content'] ); } return $this; }
[ "protected", "function", "stubReplace", "(", "$", "placeholder", ",", "$", "replace", ",", "$", "pregReplace", "=", "false", ")", "{", "if", "(", "$", "pregReplace", ")", "{", "$", "this", "->", "data", "->", "output", "[", "'content'", "]", "=", "preg_replace", "(", "$", "placeholder", ",", "$", "replace", ",", "$", "this", "->", "data", "->", "output", "[", "'content'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "data", "->", "output", "[", "'content'", "]", "=", "str_replace", "(", "$", "placeholder", ",", "$", "replace", ",", "$", "this", "->", "data", "->", "output", "[", "'content'", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Replaces output stub content placeholders with actual content @param string $placeholder @param string $replace @param bool $pregReplace whether to use preg_replace @return $this
[ "Replaces", "output", "stub", "content", "placeholders", "with", "actual", "content" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/AbstractProcessStep.php#L17-L37
15,341
czim/laravel-pxlcms
src/Generator/Writer/AbstractProcessStep.php
AbstractProcessStep.getLongestKey
protected function getLongestKey(array $array) { $longest = 0; foreach ($array as $key => $value) { if ($longest > strlen($key)) continue; $longest = strlen($key); } return $longest; }
php
protected function getLongestKey(array $array) { $longest = 0; foreach ($array as $key => $value) { if ($longest > strlen($key)) continue; $longest = strlen($key); } return $longest; }
[ "protected", "function", "getLongestKey", "(", "array", "$", "array", ")", "{", "$", "longest", "=", "0", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "longest", ">", "strlen", "(", "$", "key", ")", ")", "continue", ";", "$", "longest", "=", "strlen", "(", "$", "key", ")", ";", "}", "return", "$", "longest", ";", "}" ]
Returns length of longest key in key-value pair array @param array $array @return int
[ "Returns", "length", "of", "longest", "key", "in", "key", "-", "value", "pair", "array" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/AbstractProcessStep.php#L69-L80
15,342
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php
QuiteSimpleXMLElement.attr
public function attr($attribute) { if (strpos($attribute, ':') !== false) { list($ns, $attribute) = explode(':', $attribute, 2); return trim((string) $this->el->attributes($ns, true)->{$attribute}); } return trim((string) $this->el->attributes()->{$attribute}); }
php
public function attr($attribute) { if (strpos($attribute, ':') !== false) { list($ns, $attribute) = explode(':', $attribute, 2); return trim((string) $this->el->attributes($ns, true)->{$attribute}); } return trim((string) $this->el->attributes()->{$attribute}); }
[ "public", "function", "attr", "(", "$", "attribute", ")", "{", "if", "(", "strpos", "(", "$", "attribute", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "ns", ",", "$", "attribute", ")", "=", "explode", "(", "':'", ",", "$", "attribute", ",", "2", ")", ";", "return", "trim", "(", "(", "string", ")", "$", "this", "->", "el", "->", "attributes", "(", "$", "ns", ",", "true", ")", "->", "{", "$", "attribute", "}", ")", ";", "}", "return", "trim", "(", "(", "string", ")", "$", "this", "->", "el", "->", "attributes", "(", ")", "->", "{", "$", "attribute", "}", ")", ";", "}" ]
Get a node attribute value. Namespace prefixes are supported. @param string $attribute @return string
[ "Get", "a", "node", "attribute", "value", ".", "Namespace", "prefixes", "are", "supported", "." ]
566261ac5a789d63fda4ffc328501213772c1b27
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php#L15-L23
15,343
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php
QuiteSimpleXMLElement.first
public function first($path) { // Convenience method $x = $this->xpath($path); return count($x) ? $x[0] : null; }
php
public function first($path) { // Convenience method $x = $this->xpath($path); return count($x) ? $x[0] : null; }
[ "public", "function", "first", "(", "$", "path", ")", "{", "// Convenience method", "$", "x", "=", "$", "this", "->", "xpath", "(", "$", "path", ")", ";", "return", "count", "(", "$", "x", ")", "?", "$", "x", "[", "0", "]", ":", "null", ";", "}" ]
Get the first node matching an XPath query, or null if no match. @param string $path @return QuiteSimpleXMLElement
[ "Get", "the", "first", "node", "matching", "an", "XPath", "query", "or", "null", "if", "no", "match", "." ]
566261ac5a789d63fda4ffc328501213772c1b27
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php#L31-L37
15,344
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php
QuiteSimpleXMLElement.has
public function has($path) { $x = $this->xpath($path); return count($x) ? true : false; }
php
public function has($path) { $x = $this->xpath($path); return count($x) ? true : false; }
[ "public", "function", "has", "(", "$", "path", ")", "{", "$", "x", "=", "$", "this", "->", "xpath", "(", "$", "path", ")", ";", "return", "count", "(", "$", "x", ")", "?", "true", ":", "false", ";", "}" ]
Check if the document has at least one node matching an XPath query. @param string $path @return bool
[ "Check", "if", "the", "document", "has", "at", "least", "one", "node", "matching", "an", "XPath", "query", "." ]
566261ac5a789d63fda4ffc328501213772c1b27
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php#L45-L50
15,345
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php
QuiteSimpleXMLElement.xpath
public function xpath($path) { return array_map(function ($el) { return new QuiteSimpleXMLElement($el, $this); }, $this->el->xpath($path)); }
php
public function xpath($path) { return array_map(function ($el) { return new QuiteSimpleXMLElement($el, $this); }, $this->el->xpath($path)); }
[ "public", "function", "xpath", "(", "$", "path", ")", "{", "return", "array_map", "(", "function", "(", "$", "el", ")", "{", "return", "new", "QuiteSimpleXMLElement", "(", "$", "el", ",", "$", "this", ")", ";", "}", ",", "$", "this", "->", "el", "->", "xpath", "(", "$", "path", ")", ")", ";", "}" ]
Get all nodes matching an XPath query. @param string $path @return QuiteSimpleXMLElement[]
[ "Get", "all", "nodes", "matching", "an", "XPath", "query", "." ]
566261ac5a789d63fda4ffc328501213772c1b27
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php#L58-L63
15,346
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php
QuiteSimpleXMLElement.text
public function text($path = '.', $trim = true) { $text = strval($this->first($path)); return $trim ? trim($text) : $text; }
php
public function text($path = '.', $trim = true) { $text = strval($this->first($path)); return $trim ? trim($text) : $text; }
[ "public", "function", "text", "(", "$", "path", "=", "'.'", ",", "$", "trim", "=", "true", ")", "{", "$", "text", "=", "strval", "(", "$", "this", "->", "first", "(", "$", "path", ")", ")", ";", "return", "$", "trim", "?", "trim", "(", "$", "text", ")", ":", "$", "text", ";", "}" ]
Get the text of the first node matching an XPath query. By default, the text will be trimmed, but if you want the untrimmed text, set the second parameter to False. @param string $path @param bool $trim @return string
[ "Get", "the", "text", "of", "the", "first", "node", "matching", "an", "XPath", "query", ".", "By", "default", "the", "text", "will", "be", "trimmed", "but", "if", "you", "want", "the", "untrimmed", "text", "set", "the", "second", "parameter", "to", "False", "." ]
566261ac5a789d63fda4ffc328501213772c1b27
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php#L85-L90
15,347
ekyna/GlsUniBox
Api/Config.php
Config.validateClientConfig
static public function validateClientConfig(array $config) { $tags = [static::T8700, static::T8915, static::T8914]; foreach ($tags as $tag) { if (!array_key_exists($tag, $config) || empty($config[$tag])) { throw new InvalidArgumentException("Please configure value for tag " . $tag); } } }
php
static public function validateClientConfig(array $config) { $tags = [static::T8700, static::T8915, static::T8914]; foreach ($tags as $tag) { if (!array_key_exists($tag, $config) || empty($config[$tag])) { throw new InvalidArgumentException("Please configure value for tag " . $tag); } } }
[ "static", "public", "function", "validateClientConfig", "(", "array", "$", "config", ")", "{", "$", "tags", "=", "[", "static", "::", "T8700", ",", "static", "::", "T8915", ",", "static", "::", "T8914", "]", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "tag", ",", "$", "config", ")", "||", "empty", "(", "$", "config", "[", "$", "tag", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Please configure value for tag \"", ".", "$", "tag", ")", ";", "}", "}", "}" ]
Validates the client configuration. @param array $config
[ "Validates", "the", "client", "configuration", "." ]
b474271ba355c3917074422306dc64abf09584d0
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Api/Config.php#L379-L388
15,348
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.initRolePermissions
public function initRolePermissions($overrideExisting = true) { if (null !== $this->collRolePermissions && !$overrideExisting) { return; } $this->collRolePermissions = new ObjectCollection(); $this->collRolePermissions->setModel('\Alchemy\Component\Cerberus\Model\RolePermission'); }
php
public function initRolePermissions($overrideExisting = true) { if (null !== $this->collRolePermissions && !$overrideExisting) { return; } $this->collRolePermissions = new ObjectCollection(); $this->collRolePermissions->setModel('\Alchemy\Component\Cerberus\Model\RolePermission'); }
[ "public", "function", "initRolePermissions", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collRolePermissions", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collRolePermissions", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collRolePermissions", "->", "setModel", "(", "'\\Alchemy\\Component\\Cerberus\\Model\\RolePermission'", ")", ";", "}" ]
Initializes the collRolePermissions collection. By default this just sets the collRolePermissions collection to an empty array (like clearcollRolePermissions()); 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", "collRolePermissions", "collection", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L1726-L1733
15,349
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.addRolePermission
public function addRolePermission(ChildRolePermission $l) { if ($this->collRolePermissions === null) { $this->initRolePermissions(); $this->collRolePermissionsPartial = true; } if (!$this->collRolePermissions->contains($l)) { $this->doAddRolePermission($l); } return $this; }
php
public function addRolePermission(ChildRolePermission $l) { if ($this->collRolePermissions === null) { $this->initRolePermissions(); $this->collRolePermissionsPartial = true; } if (!$this->collRolePermissions->contains($l)) { $this->doAddRolePermission($l); } return $this; }
[ "public", "function", "addRolePermission", "(", "ChildRolePermission", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collRolePermissions", "===", "null", ")", "{", "$", "this", "->", "initRolePermissions", "(", ")", ";", "$", "this", "->", "collRolePermissionsPartial", "=", "true", ";", "}", "if", "(", "!", "$", "this", "->", "collRolePermissions", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "doAddRolePermission", "(", "$", "l", ")", ";", "}", "return", "$", "this", ";", "}" ]
Method called to associate a ChildRolePermission object to this object through the ChildRolePermission foreign key attribute. @param ChildRolePermission $l ChildRolePermission @return $this|\Alchemy\Component\Cerberus\Model\Role The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildRolePermission", "object", "to", "this", "object", "through", "the", "ChildRolePermission", "foreign", "key", "attribute", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L1870-L1882
15,350
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.initUsers
public function initUsers() { $this->collUsers = new ObjectCollection(); $this->collUsersPartial = true; $this->collUsers->setModel('\Alchemy\Component\Cerberus\Model\User'); }
php
public function initUsers() { $this->collUsers = new ObjectCollection(); $this->collUsersPartial = true; $this->collUsers->setModel('\Alchemy\Component\Cerberus\Model\User'); }
[ "public", "function", "initUsers", "(", ")", "{", "$", "this", "->", "collUsers", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collUsersPartial", "=", "true", ";", "$", "this", "->", "collUsers", "->", "setModel", "(", "'\\Alchemy\\Component\\Cerberus\\Model\\User'", ")", ";", "}" ]
Initializes the collUsers collection. By default this just sets the collUsers collection to an empty collection (like clearUsers()); 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. @return void
[ "Initializes", "the", "collUsers", "collection", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L1961-L1967
15,351
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.getUsers
public function getUsers(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collUsersPartial && !$this->isNew(); if (null === $this->collUsers || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collUsers) { $this->initUsers(); } } else { $query = ChildUserQuery::create(null, $criteria) ->filterByRole($this); $collUsers = $query->find($con); if (null !== $criteria) { return $collUsers; } if ($partial && $this->collUsers) { //make sure that already added objects gets added to the list of the database. foreach ($this->collUsers as $obj) { if (!$collUsers->contains($obj)) { $collUsers[] = $obj; } } } $this->collUsers = $collUsers; $this->collUsersPartial = false; } } return $this->collUsers; }
php
public function getUsers(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collUsersPartial && !$this->isNew(); if (null === $this->collUsers || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collUsers) { $this->initUsers(); } } else { $query = ChildUserQuery::create(null, $criteria) ->filterByRole($this); $collUsers = $query->find($con); if (null !== $criteria) { return $collUsers; } if ($partial && $this->collUsers) { //make sure that already added objects gets added to the list of the database. foreach ($this->collUsers as $obj) { if (!$collUsers->contains($obj)) { $collUsers[] = $obj; } } } $this->collUsers = $collUsers; $this->collUsersPartial = false; } } return $this->collUsers; }
[ "public", "function", "getUsers", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collUsersPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collUsers", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "// return empty collection", "if", "(", "null", "===", "$", "this", "->", "collUsers", ")", "{", "$", "this", "->", "initUsers", "(", ")", ";", "}", "}", "else", "{", "$", "query", "=", "ChildUserQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByRole", "(", "$", "this", ")", ";", "$", "collUsers", "=", "$", "query", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "return", "$", "collUsers", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collUsers", ")", "{", "//make sure that already added objects gets added to the list of the database.", "foreach", "(", "$", "this", "->", "collUsers", "as", "$", "obj", ")", "{", "if", "(", "!", "$", "collUsers", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "collUsers", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collUsers", "=", "$", "collUsers", ";", "$", "this", "->", "collUsersPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collUsers", ";", "}" ]
Gets a collection of ChildUser objects related by a many-to-many relationship to the current object by way of the user_role 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 ChildRole 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|ChildUser[] List of ChildUser objects
[ "Gets", "a", "collection", "of", "ChildUser", "objects", "related", "by", "a", "many", "-", "to", "-", "many", "relationship", "to", "the", "current", "object", "by", "way", "of", "the", "user_role", "cross", "-", "reference", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L1994-L2027
15,352
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.countUsers
public function countUsers(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collUsersPartial && !$this->isNew(); if (null === $this->collUsers || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collUsers) { return 0; } else { if ($partial && !$criteria) { return count($this->getUsers()); } $query = ChildUserQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByRole($this) ->count($con); } } else { return count($this->collUsers); } }
php
public function countUsers(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collUsersPartial && !$this->isNew(); if (null === $this->collUsers || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collUsers) { return 0; } else { if ($partial && !$criteria) { return count($this->getUsers()); } $query = ChildUserQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByRole($this) ->count($con); } } else { return count($this->collUsers); } }
[ "public", "function", "countUsers", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collUsersPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collUsers", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collUsers", ")", "{", "return", "0", ";", "}", "else", "{", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getUsers", "(", ")", ")", ";", "}", "$", "query", "=", "ChildUserQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByRole", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "}", "else", "{", "return", "count", "(", "$", "this", "->", "collUsers", ")", ";", "}", "}" ]
Gets the number of User objects related by a many-to-many relationship to the current object by way of the user_role 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 User objects
[ "Gets", "the", "number", "of", "User", "objects", "related", "by", "a", "many", "-", "to", "-", "many", "relationship", "to", "the", "current", "object", "by", "way", "of", "the", "user_role", "cross", "-", "reference", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L2072-L2096
15,353
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.addUser
public function addUser(ChildUser $user) { if ($this->collUsers === null) { $this->initUsers(); } if (!$this->getUsers()->contains($user)) { // only add it if the **same** object is not already associated $this->collUsers->push($user); $this->doAddUser($user); } return $this; }
php
public function addUser(ChildUser $user) { if ($this->collUsers === null) { $this->initUsers(); } if (!$this->getUsers()->contains($user)) { // only add it if the **same** object is not already associated $this->collUsers->push($user); $this->doAddUser($user); } return $this; }
[ "public", "function", "addUser", "(", "ChildUser", "$", "user", ")", "{", "if", "(", "$", "this", "->", "collUsers", "===", "null", ")", "{", "$", "this", "->", "initUsers", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "getUsers", "(", ")", "->", "contains", "(", "$", "user", ")", ")", "{", "// only add it if the **same** object is not already associated", "$", "this", "->", "collUsers", "->", "push", "(", "$", "user", ")", ";", "$", "this", "->", "doAddUser", "(", "$", "user", ")", ";", "}", "return", "$", "this", ";", "}" ]
Associate a ChildUser to this object through the user_role cross reference table. @param ChildUser $user @return ChildRole The current object (for fluent API support)
[ "Associate", "a", "ChildUser", "to", "this", "object", "through", "the", "user_role", "cross", "reference", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L2105-L2118
15,354
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.removeUser
public function removeUser(ChildUser $user) { if ($this->getUsers()->contains($user)) { $userRole = new ChildUserRole(); $userRole->setUser($user); if ($user->isRolesLoaded()) { //remove the back reference if available $user->getRoles()->removeObject($this); } $userRole->setRole($this); $this->removeUserRole(clone $userRole); $userRole->clear(); $this->collUsers->remove($this->collUsers->search($user)); if (null === $this->usersScheduledForDeletion) { $this->usersScheduledForDeletion = clone $this->collUsers; $this->usersScheduledForDeletion->clear(); } $this->usersScheduledForDeletion->push($user); } return $this; }
php
public function removeUser(ChildUser $user) { if ($this->getUsers()->contains($user)) { $userRole = new ChildUserRole(); $userRole->setUser($user); if ($user->isRolesLoaded()) { //remove the back reference if available $user->getRoles()->removeObject($this); } $userRole->setRole($this); $this->removeUserRole(clone $userRole); $userRole->clear(); $this->collUsers->remove($this->collUsers->search($user)); if (null === $this->usersScheduledForDeletion) { $this->usersScheduledForDeletion = clone $this->collUsers; $this->usersScheduledForDeletion->clear(); } $this->usersScheduledForDeletion->push($user); } return $this; }
[ "public", "function", "removeUser", "(", "ChildUser", "$", "user", ")", "{", "if", "(", "$", "this", "->", "getUsers", "(", ")", "->", "contains", "(", "$", "user", ")", ")", "{", "$", "userRole", "=", "new", "ChildUserRole", "(", ")", ";", "$", "userRole", "->", "setUser", "(", "$", "user", ")", ";", "if", "(", "$", "user", "->", "isRolesLoaded", "(", ")", ")", "{", "//remove the back reference if available", "$", "user", "->", "getRoles", "(", ")", "->", "removeObject", "(", "$", "this", ")", ";", "}", "$", "userRole", "->", "setRole", "(", "$", "this", ")", ";", "$", "this", "->", "removeUserRole", "(", "clone", "$", "userRole", ")", ";", "$", "userRole", "->", "clear", "(", ")", ";", "$", "this", "->", "collUsers", "->", "remove", "(", "$", "this", "->", "collUsers", "->", "search", "(", "$", "user", ")", ")", ";", "if", "(", "null", "===", "$", "this", "->", "usersScheduledForDeletion", ")", "{", "$", "this", "->", "usersScheduledForDeletion", "=", "clone", "$", "this", "->", "collUsers", ";", "$", "this", "->", "usersScheduledForDeletion", "->", "clear", "(", ")", ";", "}", "$", "this", "->", "usersScheduledForDeletion", "->", "push", "(", "$", "user", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove user of this object through the user_role cross reference table. @param ChildUser $user @return ChildRole The current object (for fluent API support)
[ "Remove", "user", "of", "this", "object", "through", "the", "user_role", "cross", "reference", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L2152-L2178
15,355
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.initPermissions
public function initPermissions() { $this->collPermissions = new ObjectCollection(); $this->collPermissionsPartial = true; $this->collPermissions->setModel('\Alchemy\Component\Cerberus\Model\Permission'); }
php
public function initPermissions() { $this->collPermissions = new ObjectCollection(); $this->collPermissionsPartial = true; $this->collPermissions->setModel('\Alchemy\Component\Cerberus\Model\Permission'); }
[ "public", "function", "initPermissions", "(", ")", "{", "$", "this", "->", "collPermissions", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collPermissionsPartial", "=", "true", ";", "$", "this", "->", "collPermissions", "->", "setModel", "(", "'\\Alchemy\\Component\\Cerberus\\Model\\Permission'", ")", ";", "}" ]
Initializes the collPermissions collection. By default this just sets the collPermissions collection to an empty collection (like clearPermissions()); 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. @return void
[ "Initializes", "the", "collPermissions", "collection", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L2203-L2209
15,356
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.getPermissions
public function getPermissions(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collPermissionsPartial && !$this->isNew(); if (null === $this->collPermissions || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collPermissions) { $this->initPermissions(); } } else { $query = ChildPermissionQuery::create(null, $criteria) ->filterByRole($this); $collPermissions = $query->find($con); if (null !== $criteria) { return $collPermissions; } if ($partial && $this->collPermissions) { //make sure that already added objects gets added to the list of the database. foreach ($this->collPermissions as $obj) { if (!$collPermissions->contains($obj)) { $collPermissions[] = $obj; } } } $this->collPermissions = $collPermissions; $this->collPermissionsPartial = false; } } return $this->collPermissions; }
php
public function getPermissions(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collPermissionsPartial && !$this->isNew(); if (null === $this->collPermissions || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collPermissions) { $this->initPermissions(); } } else { $query = ChildPermissionQuery::create(null, $criteria) ->filterByRole($this); $collPermissions = $query->find($con); if (null !== $criteria) { return $collPermissions; } if ($partial && $this->collPermissions) { //make sure that already added objects gets added to the list of the database. foreach ($this->collPermissions as $obj) { if (!$collPermissions->contains($obj)) { $collPermissions[] = $obj; } } } $this->collPermissions = $collPermissions; $this->collPermissionsPartial = false; } } return $this->collPermissions; }
[ "public", "function", "getPermissions", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collPermissionsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collPermissions", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "// return empty collection", "if", "(", "null", "===", "$", "this", "->", "collPermissions", ")", "{", "$", "this", "->", "initPermissions", "(", ")", ";", "}", "}", "else", "{", "$", "query", "=", "ChildPermissionQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByRole", "(", "$", "this", ")", ";", "$", "collPermissions", "=", "$", "query", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "return", "$", "collPermissions", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collPermissions", ")", "{", "//make sure that already added objects gets added to the list of the database.", "foreach", "(", "$", "this", "->", "collPermissions", "as", "$", "obj", ")", "{", "if", "(", "!", "$", "collPermissions", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "collPermissions", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collPermissions", "=", "$", "collPermissions", ";", "$", "this", "->", "collPermissionsPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collPermissions", ";", "}" ]
Gets a collection of ChildPermission 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 ChildRole 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|ChildPermission[] List of ChildPermission objects
[ "Gets", "a", "collection", "of", "ChildPermission", "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/Role.php#L2236-L2269
15,357
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.countPermissions
public function countPermissions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collPermissionsPartial && !$this->isNew(); if (null === $this->collPermissions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPermissions) { return 0; } else { if ($partial && !$criteria) { return count($this->getPermissions()); } $query = ChildPermissionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByRole($this) ->count($con); } } else { return count($this->collPermissions); } }
php
public function countPermissions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collPermissionsPartial && !$this->isNew(); if (null === $this->collPermissions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPermissions) { return 0; } else { if ($partial && !$criteria) { return count($this->getPermissions()); } $query = ChildPermissionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByRole($this) ->count($con); } } else { return count($this->collPermissions); } }
[ "public", "function", "countPermissions", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collPermissionsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collPermissions", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collPermissions", ")", "{", "return", "0", ";", "}", "else", "{", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getPermissions", "(", ")", ")", ";", "}", "$", "query", "=", "ChildPermissionQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByRole", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "}", "else", "{", "return", "count", "(", "$", "this", "->", "collPermissions", ")", ";", "}", "}" ]
Gets the number of Permission 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 Permission objects
[ "Gets", "the", "number", "of", "Permission", "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/Role.php#L2314-L2338
15,358
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.addPermission
public function addPermission(ChildPermission $permission) { if ($this->collPermissions === null) { $this->initPermissions(); } if (!$this->getPermissions()->contains($permission)) { // only add it if the **same** object is not already associated $this->collPermissions->push($permission); $this->doAddPermission($permission); } return $this; }
php
public function addPermission(ChildPermission $permission) { if ($this->collPermissions === null) { $this->initPermissions(); } if (!$this->getPermissions()->contains($permission)) { // only add it if the **same** object is not already associated $this->collPermissions->push($permission); $this->doAddPermission($permission); } return $this; }
[ "public", "function", "addPermission", "(", "ChildPermission", "$", "permission", ")", "{", "if", "(", "$", "this", "->", "collPermissions", "===", "null", ")", "{", "$", "this", "->", "initPermissions", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "getPermissions", "(", ")", "->", "contains", "(", "$", "permission", ")", ")", "{", "// only add it if the **same** object is not already associated", "$", "this", "->", "collPermissions", "->", "push", "(", "$", "permission", ")", ";", "$", "this", "->", "doAddPermission", "(", "$", "permission", ")", ";", "}", "return", "$", "this", ";", "}" ]
Associate a ChildPermission to this object through the role_permission cross reference table. @param ChildPermission $permission @return ChildRole The current object (for fluent API support)
[ "Associate", "a", "ChildPermission", "to", "this", "object", "through", "the", "role_permission", "cross", "reference", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L2347-L2360
15,359
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Role.php
Role.removePermission
public function removePermission(ChildPermission $permission) { if ($this->getPermissions()->contains($permission)) { $rolePermission = new ChildRolePermission(); $rolePermission->setPermission($permission); if ($permission->isRolesLoaded()) { //remove the back reference if available $permission->getRoles()->removeObject($this); } $rolePermission->setRole($this); $this->removeRolePermission(clone $rolePermission); $rolePermission->clear(); $this->collPermissions->remove($this->collPermissions->search($permission)); if (null === $this->permissionsScheduledForDeletion) { $this->permissionsScheduledForDeletion = clone $this->collPermissions; $this->permissionsScheduledForDeletion->clear(); } $this->permissionsScheduledForDeletion->push($permission); } return $this; }
php
public function removePermission(ChildPermission $permission) { if ($this->getPermissions()->contains($permission)) { $rolePermission = new ChildRolePermission(); $rolePermission->setPermission($permission); if ($permission->isRolesLoaded()) { //remove the back reference if available $permission->getRoles()->removeObject($this); } $rolePermission->setRole($this); $this->removeRolePermission(clone $rolePermission); $rolePermission->clear(); $this->collPermissions->remove($this->collPermissions->search($permission)); if (null === $this->permissionsScheduledForDeletion) { $this->permissionsScheduledForDeletion = clone $this->collPermissions; $this->permissionsScheduledForDeletion->clear(); } $this->permissionsScheduledForDeletion->push($permission); } return $this; }
[ "public", "function", "removePermission", "(", "ChildPermission", "$", "permission", ")", "{", "if", "(", "$", "this", "->", "getPermissions", "(", ")", "->", "contains", "(", "$", "permission", ")", ")", "{", "$", "rolePermission", "=", "new", "ChildRolePermission", "(", ")", ";", "$", "rolePermission", "->", "setPermission", "(", "$", "permission", ")", ";", "if", "(", "$", "permission", "->", "isRolesLoaded", "(", ")", ")", "{", "//remove the back reference if available", "$", "permission", "->", "getRoles", "(", ")", "->", "removeObject", "(", "$", "this", ")", ";", "}", "$", "rolePermission", "->", "setRole", "(", "$", "this", ")", ";", "$", "this", "->", "removeRolePermission", "(", "clone", "$", "rolePermission", ")", ";", "$", "rolePermission", "->", "clear", "(", ")", ";", "$", "this", "->", "collPermissions", "->", "remove", "(", "$", "this", "->", "collPermissions", "->", "search", "(", "$", "permission", ")", ")", ";", "if", "(", "null", "===", "$", "this", "->", "permissionsScheduledForDeletion", ")", "{", "$", "this", "->", "permissionsScheduledForDeletion", "=", "clone", "$", "this", "->", "collPermissions", ";", "$", "this", "->", "permissionsScheduledForDeletion", "->", "clear", "(", ")", ";", "}", "$", "this", "->", "permissionsScheduledForDeletion", "->", "push", "(", "$", "permission", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove permission of this object through the role_permission cross reference table. @param ChildPermission $permission @return ChildRole The current object (for fluent API support)
[ "Remove", "permission", "of", "this", "object", "through", "the", "role_permission", "cross", "reference", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Role.php#L2394-L2420
15,360
Coercive/Xss
XssUrl.php
XssUrl.detect
private function detect() { # Init $this->xss = false; # No data if(!$this->string) { return; } # Detect foreach ($this->list as $item) { if(preg_match("`$item`i", $this->string)) { $this->xss = true; } } }
php
private function detect() { # Init $this->xss = false; # No data if(!$this->string) { return; } # Detect foreach ($this->list as $item) { if(preg_match("`$item`i", $this->string)) { $this->xss = true; } } }
[ "private", "function", "detect", "(", ")", "{", "# Init", "$", "this", "->", "xss", "=", "false", ";", "# No data", "if", "(", "!", "$", "this", "->", "string", ")", "{", "return", ";", "}", "# Detect", "foreach", "(", "$", "this", "->", "list", "as", "$", "item", ")", "{", "if", "(", "preg_match", "(", "\"`$item`i\"", ",", "$", "this", "->", "string", ")", ")", "{", "$", "this", "->", "xss", "=", "true", ";", "}", "}", "}" ]
DETECT XSS URL ATTACK @return void
[ "DETECT", "XSS", "URL", "ATTACK" ]
d47a05347550f7e2c846d7015483a7e91e5a5138
https://github.com/Coercive/Xss/blob/d47a05347550f7e2c846d7015483a7e91e5a5138/XssUrl.php#L94-L108
15,361
avoo/SerializerTranslation
Expression/ExpressionEvaluator.php
ExpressionEvaluator.registerFunction
public function registerFunction(ExpressionFunctionInterface $function) { $this->expressionLanguage->register( $function->getName(), $function->getCompiler(), $function->getEvaluator() ); foreach ($function->getContextVariables() as $name => $value) { $this->setContextVariable($name, $value); } return $this; }
php
public function registerFunction(ExpressionFunctionInterface $function) { $this->expressionLanguage->register( $function->getName(), $function->getCompiler(), $function->getEvaluator() ); foreach ($function->getContextVariables() as $name => $value) { $this->setContextVariable($name, $value); } return $this; }
[ "public", "function", "registerFunction", "(", "ExpressionFunctionInterface", "$", "function", ")", "{", "$", "this", "->", "expressionLanguage", "->", "register", "(", "$", "function", "->", "getName", "(", ")", ",", "$", "function", "->", "getCompiler", "(", ")", ",", "$", "function", "->", "getEvaluator", "(", ")", ")", ";", "foreach", "(", "$", "function", "->", "getContextVariables", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "setContextVariable", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Register a new new ExpressionLanguage function. @param ExpressionFunctionInterface $function @return ExpressionEvaluator
[ "Register", "a", "new", "new", "ExpressionLanguage", "function", "." ]
e66de5482adb944197a36874465ef144b293a157
https://github.com/avoo/SerializerTranslation/blob/e66de5482adb944197a36874465ef144b293a157/Expression/ExpressionEvaluator.php#L84-L97
15,362
datasift/datasift-php
examples/football.php
EventHandler.onInteraction
public function onInteraction($consumer, $interaction, $hash) { echo 'Type: '.$interaction['interaction']['type']."\n"; echo 'Content: '.$interaction['interaction']['content']."\n--\n"; // Stop after 10 if ($this->_num-- == 1) { echo "Stopping consumer...\n"; $consumer->stop(); } }
php
public function onInteraction($consumer, $interaction, $hash) { echo 'Type: '.$interaction['interaction']['type']."\n"; echo 'Content: '.$interaction['interaction']['content']."\n--\n"; // Stop after 10 if ($this->_num-- == 1) { echo "Stopping consumer...\n"; $consumer->stop(); } }
[ "public", "function", "onInteraction", "(", "$", "consumer", ",", "$", "interaction", ",", "$", "hash", ")", "{", "echo", "'Type: '", ".", "$", "interaction", "[", "'interaction'", "]", "[", "'type'", "]", ".", "\"\\n\"", ";", "echo", "'Content: '", ".", "$", "interaction", "[", "'interaction'", "]", "[", "'content'", "]", ".", "\"\\n--\\n\"", ";", "// Stop after 10", "if", "(", "$", "this", "->", "_num", "--", "==", "1", ")", "{", "echo", "\"Stopping consumer...\\n\"", ";", "$", "consumer", "->", "stop", "(", ")", ";", "}", "}" ]
Called for each interaction consumed. @param DataSift_StreamConsumer $consumer The consumer sending the event. @param array $interaction The interaction data. @param string $hash The hash of the stream that matched this interaction. @return void
[ "Called", "for", "each", "interaction", "consumed", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/examples/football.php#L70-L80
15,363
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/OrderBundle/Controller/PdfController.php
PdfController.orderConfirmationAction
public function orderConfirmationAction(Request $request, $id) { $locale = $this->getLocale($request); $this->get('translator')->setLocale($locale); try { $orderApiEntity = $this->getOrderManager()->findByIdAndLocale($id, $locale); $order = $orderApiEntity->getEntity(); } catch (OrderNotFoundException $exc) { throw new OrderNotFoundException($id); } $pdf = $this->getPdfManager()->createOrderConfirmation($orderApiEntity); $pdfName = $this->getPdfManager()->getPdfName($order); return new Response( $pdf, 200, array( 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $pdfName . '"' ) ); }
php
public function orderConfirmationAction(Request $request, $id) { $locale = $this->getLocale($request); $this->get('translator')->setLocale($locale); try { $orderApiEntity = $this->getOrderManager()->findByIdAndLocale($id, $locale); $order = $orderApiEntity->getEntity(); } catch (OrderNotFoundException $exc) { throw new OrderNotFoundException($id); } $pdf = $this->getPdfManager()->createOrderConfirmation($orderApiEntity); $pdfName = $this->getPdfManager()->getPdfName($order); return new Response( $pdf, 200, array( 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $pdfName . '"' ) ); }
[ "public", "function", "orderConfirmationAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "locale", "=", "$", "this", "->", "getLocale", "(", "$", "request", ")", ";", "$", "this", "->", "get", "(", "'translator'", ")", "->", "setLocale", "(", "$", "locale", ")", ";", "try", "{", "$", "orderApiEntity", "=", "$", "this", "->", "getOrderManager", "(", ")", "->", "findByIdAndLocale", "(", "$", "id", ",", "$", "locale", ")", ";", "$", "order", "=", "$", "orderApiEntity", "->", "getEntity", "(", ")", ";", "}", "catch", "(", "OrderNotFoundException", "$", "exc", ")", "{", "throw", "new", "OrderNotFoundException", "(", "$", "id", ")", ";", "}", "$", "pdf", "=", "$", "this", "->", "getPdfManager", "(", ")", "->", "createOrderConfirmation", "(", "$", "orderApiEntity", ")", ";", "$", "pdfName", "=", "$", "this", "->", "getPdfManager", "(", ")", "->", "getPdfName", "(", "$", "order", ")", ";", "return", "new", "Response", "(", "$", "pdf", ",", "200", ",", "array", "(", "'Content-Type'", "=>", "'application/pdf'", ",", "'Content-Disposition'", "=>", "'attachment; filename=\"'", ".", "$", "pdfName", ".", "'\"'", ")", ")", ";", "}" ]
Finds a order object by a given id from the url and returns a rendered pdf in a download window @param Request $request @param $id @throws OrderNotFoundException @return Response
[ "Finds", "a", "order", "object", "by", "a", "given", "id", "from", "the", "url", "and", "returns", "a", "rendered", "pdf", "in", "a", "download", "window" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Controller/PdfController.php#L49-L74
15,364
kderyabin/logger
src/Handlers/StreamHandler.php
StreamHandler.open
public function open(): bool { $path = $this->getOptionOrDefault('path'); if (is_resource($path)) { $this->resource = $path; return true; } $context = $this->getOptionOrDefault('context'); if (is_resource($context)) { $this->resource = @fopen($path, 'ab', false, $context); } else { $this->resource = @fopen($path, 'ab'); } return is_resource($this->resource); }
php
public function open(): bool { $path = $this->getOptionOrDefault('path'); if (is_resource($path)) { $this->resource = $path; return true; } $context = $this->getOptionOrDefault('context'); if (is_resource($context)) { $this->resource = @fopen($path, 'ab', false, $context); } else { $this->resource = @fopen($path, 'ab'); } return is_resource($this->resource); }
[ "public", "function", "open", "(", ")", ":", "bool", "{", "$", "path", "=", "$", "this", "->", "getOptionOrDefault", "(", "'path'", ")", ";", "if", "(", "is_resource", "(", "$", "path", ")", ")", "{", "$", "this", "->", "resource", "=", "$", "path", ";", "return", "true", ";", "}", "$", "context", "=", "$", "this", "->", "getOptionOrDefault", "(", "'context'", ")", ";", "if", "(", "is_resource", "(", "$", "context", ")", ")", "{", "$", "this", "->", "resource", "=", "@", "fopen", "(", "$", "path", ",", "'ab'", ",", "false", ",", "$", "context", ")", ";", "}", "else", "{", "$", "this", "->", "resource", "=", "@", "fopen", "(", "$", "path", ",", "'ab'", ")", ";", "}", "return", "is_resource", "(", "$", "this", "->", "resource", ")", ";", "}" ]
Open a log destination. @return bool
[ "Open", "a", "log", "destination", "." ]
683890192b37fe9d36611972e12c2994669f5b85
https://github.com/kderyabin/logger/blob/683890192b37fe9d36611972e12c2994669f5b85/src/Handlers/StreamHandler.php#L41-L57
15,365
siriusphp/middleware
src/FrameRunner.php
FrameRunner.factory
public static function factory(array $middlewares = array()) { $runner = null; foreach ($middlewares as $middleware) { $runner = $runner ? $runner->add($middleware) : new static($middleware); } return $runner; }
php
public static function factory(array $middlewares = array()) { $runner = null; foreach ($middlewares as $middleware) { $runner = $runner ? $runner->add($middleware) : new static($middleware); } return $runner; }
[ "public", "static", "function", "factory", "(", "array", "$", "middlewares", "=", "array", "(", ")", ")", "{", "$", "runner", "=", "null", ";", "foreach", "(", "$", "middlewares", "as", "$", "middleware", ")", "{", "$", "runner", "=", "$", "runner", "?", "$", "runner", "->", "add", "(", "$", "middleware", ")", ":", "new", "static", "(", "$", "middleware", ")", ";", "}", "return", "$", "runner", ";", "}" ]
Creates a runner based on an array of middleware @param array $middlewares @return FrameRunner
[ "Creates", "a", "runner", "based", "on", "an", "array", "of", "middleware" ]
e6805639982d2c0ae01dc9e9a1583915b7873782
https://github.com/siriusphp/middleware/blob/e6805639982d2c0ae01dc9e9a1583915b7873782/src/FrameRunner.php#L26-L33
15,366
fuzz-productions/laravel-api-data
src/Support/CollectionUtility.php
CollectionUtility.collapseSerialized
public static function collapseSerialized(EloquentCollection $collection) { return $collection->map( function (SerializedModel $menu_item) { return $menu_item->serialized(); } )->collapse(); }
php
public static function collapseSerialized(EloquentCollection $collection) { return $collection->map( function (SerializedModel $menu_item) { return $menu_item->serialized(); } )->collapse(); }
[ "public", "static", "function", "collapseSerialized", "(", "EloquentCollection", "$", "collection", ")", "{", "return", "$", "collection", "->", "map", "(", "function", "(", "SerializedModel", "$", "menu_item", ")", "{", "return", "$", "menu_item", "->", "serialized", "(", ")", ";", "}", ")", "->", "collapse", "(", ")", ";", "}" ]
Collapse a keyed Eloquent Collection. @param \Illuminate\Database\Eloquent\Collection $collection @return \Illuminate\Support\Collection
[ "Collapse", "a", "keyed", "Eloquent", "Collection", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Support/CollectionUtility.php#L21-L28
15,367
Laralum/Roles
src/Models/Role.php
Role.addUser
public function addUser($user) { if (!$this->hasUser($user)) { return RoleUser::create(['role_id' => $this->id, 'user_id' => $user->id]); } return false; }
php
public function addUser($user) { if (!$this->hasUser($user)) { return RoleUser::create(['role_id' => $this->id, 'user_id' => $user->id]); } return false; }
[ "public", "function", "addUser", "(", "$", "user", ")", "{", "if", "(", "!", "$", "this", "->", "hasUser", "(", "$", "user", ")", ")", "{", "return", "RoleUser", "::", "create", "(", "[", "'role_id'", "=>", "$", "this", "->", "id", ",", "'user_id'", "=>", "$", "user", "->", "id", "]", ")", ";", "}", "return", "false", ";", "}" ]
Adds a user into the role. @param mixed $user
[ "Adds", "a", "user", "into", "the", "role", "." ]
f934967a5dcebebf81915dd50fccdbcb7e23c113
https://github.com/Laralum/Roles/blob/f934967a5dcebebf81915dd50fccdbcb7e23c113/src/Models/Role.php#L62-L69
15,368
Laralum/Roles
src/Models/Role.php
Role.addPermission
public function addPermission($permission) { if (!$this->hasPermission($permission)) { return PermissionRole::create(['role_id' => $this->id, 'permission_id' => $permission->id]); } return false; }
php
public function addPermission($permission) { if (!$this->hasPermission($permission)) { return PermissionRole::create(['role_id' => $this->id, 'permission_id' => $permission->id]); } return false; }
[ "public", "function", "addPermission", "(", "$", "permission", ")", "{", "if", "(", "!", "$", "this", "->", "hasPermission", "(", "$", "permission", ")", ")", "{", "return", "PermissionRole", "::", "create", "(", "[", "'role_id'", "=>", "$", "this", "->", "id", ",", "'permission_id'", "=>", "$", "permission", "->", "id", "]", ")", ";", "}", "return", "false", ";", "}" ]
Adds a permission into the role. @param mixed $permission
[ "Adds", "a", "permission", "into", "the", "role", "." ]
f934967a5dcebebf81915dd50fccdbcb7e23c113
https://github.com/Laralum/Roles/blob/f934967a5dcebebf81915dd50fccdbcb7e23c113/src/Models/Role.php#L76-L83
15,369
Laralum/Roles
src/Models/Role.php
Role.deleteUser
public function deleteUser($user) { if ($this->hasUser($user)) { return RoleUser::where( ['role_id' => $this->id, 'user_id' => $user->id] )->first()->delete(); } return false; }
php
public function deleteUser($user) { if ($this->hasUser($user)) { return RoleUser::where( ['role_id' => $this->id, 'user_id' => $user->id] )->first()->delete(); } return false; }
[ "public", "function", "deleteUser", "(", "$", "user", ")", "{", "if", "(", "$", "this", "->", "hasUser", "(", "$", "user", ")", ")", "{", "return", "RoleUser", "::", "where", "(", "[", "'role_id'", "=>", "$", "this", "->", "id", ",", "'user_id'", "=>", "$", "user", "->", "id", "]", ")", "->", "first", "(", ")", "->", "delete", "(", ")", ";", "}", "return", "false", ";", "}" ]
Deletes the specified role user. @param mixed $user
[ "Deletes", "the", "specified", "role", "user", "." ]
f934967a5dcebebf81915dd50fccdbcb7e23c113
https://github.com/Laralum/Roles/blob/f934967a5dcebebf81915dd50fccdbcb7e23c113/src/Models/Role.php#L118-L127
15,370
Laralum/Roles
src/Models/Role.php
Role.deletePermission
public function deletePermission($permission) { if ($this->hasPermission($permission)) { return PermissionRole::where( ['role_id' => $this->id, 'permission_id' => $permission->id] )->first()->delete(); } return false; }
php
public function deletePermission($permission) { if ($this->hasPermission($permission)) { return PermissionRole::where( ['role_id' => $this->id, 'permission_id' => $permission->id] )->first()->delete(); } return false; }
[ "public", "function", "deletePermission", "(", "$", "permission", ")", "{", "if", "(", "$", "this", "->", "hasPermission", "(", "$", "permission", ")", ")", "{", "return", "PermissionRole", "::", "where", "(", "[", "'role_id'", "=>", "$", "this", "->", "id", ",", "'permission_id'", "=>", "$", "permission", "->", "id", "]", ")", "->", "first", "(", ")", "->", "delete", "(", ")", ";", "}", "return", "false", ";", "}" ]
Deletes the specified role permission. @param mixed $permission
[ "Deletes", "the", "specified", "role", "permission", "." ]
f934967a5dcebebf81915dd50fccdbcb7e23c113
https://github.com/Laralum/Roles/blob/f934967a5dcebebf81915dd50fccdbcb7e23c113/src/Models/Role.php#L134-L143
15,371
heyday/heystack
src/Storage/Storage.php
Storage.process
public function process(StorableInterface $object) { if (is_array($this->backends) && count($this->backends) > 0) { $results = []; $identifiers = $object->getStorableBackendIdentifiers(); foreach ($this->backends as $identifier => $backend) { if (in_array($identifier, $identifiers)) { $results[$identifier] = $backend->write($object); } } return $results; } else { throw new StorageProcessingException( sprintf( "Tried to process an storable object '%s' with no backends", $object->getStorableIdentifier() ) ); } }
php
public function process(StorableInterface $object) { if (is_array($this->backends) && count($this->backends) > 0) { $results = []; $identifiers = $object->getStorableBackendIdentifiers(); foreach ($this->backends as $identifier => $backend) { if (in_array($identifier, $identifiers)) { $results[$identifier] = $backend->write($object); } } return $results; } else { throw new StorageProcessingException( sprintf( "Tried to process an storable object '%s' with no backends", $object->getStorableIdentifier() ) ); } }
[ "public", "function", "process", "(", "StorableInterface", "$", "object", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "backends", ")", "&&", "count", "(", "$", "this", "->", "backends", ")", ">", "0", ")", "{", "$", "results", "=", "[", "]", ";", "$", "identifiers", "=", "$", "object", "->", "getStorableBackendIdentifiers", "(", ")", ";", "foreach", "(", "$", "this", "->", "backends", "as", "$", "identifier", "=>", "$", "backend", ")", "{", "if", "(", "in_array", "(", "$", "identifier", ",", "$", "identifiers", ")", ")", "{", "$", "results", "[", "$", "identifier", "]", "=", "$", "backend", "->", "write", "(", "$", "object", ")", ";", "}", "}", "return", "$", "results", ";", "}", "else", "{", "throw", "new", "StorageProcessingException", "(", "sprintf", "(", "\"Tried to process an storable object '%s' with no backends\"", ",", "$", "object", "->", "getStorableIdentifier", "(", ")", ")", ")", ";", "}", "}" ]
Runs through each storage backend and processes the Storable object @param StorableInterface $object @return array @throws \Exception
[ "Runs", "through", "each", "storage", "backend", "and", "processes", "the", "Storable", "object" ]
2c051933f8c532d0a9a23be6ee1ff5c619e47dfe
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/Storage/Storage.php#L69-L91
15,372
phower/escaper
src/Phower/Escaper/Escaper.php
Escaper.toUtf8
protected function toUtf8($string) { if ($this->getEncoding() === 'utf-8') { $result = $string; } else { $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding()); } return $result; }
php
protected function toUtf8($string) { if ($this->getEncoding() === 'utf-8') { $result = $string; } else { $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding()); } return $result; }
[ "protected", "function", "toUtf8", "(", "$", "string", ")", "{", "if", "(", "$", "this", "->", "getEncoding", "(", ")", "===", "'utf-8'", ")", "{", "$", "result", "=", "$", "string", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "convertEncoding", "(", "$", "string", ",", "'UTF-8'", ",", "$", "this", "->", "getEncoding", "(", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Convert string to UTF-8 @param string $string @return string @throws RuntimeException
[ "Convert", "string", "to", "UTF", "-", "8" ]
2c74ab507ac8cb272da27d6225c596abd972a0c3
https://github.com/phower/escaper/blob/2c74ab507ac8cb272da27d6225c596abd972a0c3/src/Phower/Escaper/Escaper.php#L187-L196
15,373
pageon/SlackWebhookMonolog
src/Monolog/Error.php
Error.addParameterFallback
private function addParameterFallback($name, $fallbackData = null) { if (!isset($this->parameters[$name]) && !empty($fallbackData)) { $this->parameters[$name] = $fallbackData; } }
php
private function addParameterFallback($name, $fallbackData = null) { if (!isset($this->parameters[$name]) && !empty($fallbackData)) { $this->parameters[$name] = $fallbackData; } }
[ "private", "function", "addParameterFallback", "(", "$", "name", ",", "$", "fallbackData", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "parameters", "[", "$", "name", "]", ")", "&&", "!", "empty", "(", "$", "fallbackData", ")", ")", "{", "$", "this", "->", "parameters", "[", "$", "name", "]", "=", "$", "fallbackData", ";", "}", "}" ]
This will add fallback data to the parameters if the key is not set. @param string $name @param mixed $fallbackData
[ "This", "will", "add", "fallback", "data", "to", "the", "parameters", "if", "the", "key", "is", "not", "set", "." ]
6755060ddd6429620fd4c7decbb95f05463fc36b
https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Monolog/Error.php#L127-L132
15,374
wpottier/WizadSettingsBundle
DependencyInjection/ContainerInjectionManager.php
ContainerInjectionManager.inject
public function inject(ContainerBuilder $container) { foreach ($this->schema as $parameter) { $value = $parameter['default']; if ($this->parametersStorage->has($parameter['key'])) { $value = $this->parametersStorage->get($parameter['key']); } $container->setParameter($this->getParametersName($parameter['key']), $this->protectParameterValue($value)); } }
php
public function inject(ContainerBuilder $container) { foreach ($this->schema as $parameter) { $value = $parameter['default']; if ($this->parametersStorage->has($parameter['key'])) { $value = $this->parametersStorage->get($parameter['key']); } $container->setParameter($this->getParametersName($parameter['key']), $this->protectParameterValue($value)); } }
[ "public", "function", "inject", "(", "ContainerBuilder", "$", "container", ")", "{", "foreach", "(", "$", "this", "->", "schema", "as", "$", "parameter", ")", "{", "$", "value", "=", "$", "parameter", "[", "'default'", "]", ";", "if", "(", "$", "this", "->", "parametersStorage", "->", "has", "(", "$", "parameter", "[", "'key'", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "parametersStorage", "->", "get", "(", "$", "parameter", "[", "'key'", "]", ")", ";", "}", "$", "container", "->", "setParameter", "(", "$", "this", "->", "getParametersName", "(", "$", "parameter", "[", "'key'", "]", ")", ",", "$", "this", "->", "protectParameterValue", "(", "$", "value", ")", ")", ";", "}", "}" ]
Inject dynamic parameters in the container builder @param ContainerBuilder $container
[ "Inject", "dynamic", "parameters", "in", "the", "container", "builder" ]
92738c59d4da28d3a7376de854ce8505898159cb
https://github.com/wpottier/WizadSettingsBundle/blob/92738c59d4da28d3a7376de854ce8505898159cb/DependencyInjection/ContainerInjectionManager.php#L39-L51
15,375
wpottier/WizadSettingsBundle
DependencyInjection/ContainerInjectionManager.php
ContainerInjectionManager.rebuild
public function rebuild(Kernel $kernel) { $kernelReflectionClass = new \ReflectionClass($kernel); $buildContainerReflectionMethod = $kernelReflectionClass->getMethod('buildContainer'); $buildContainerReflectionMethod->setAccessible(true); $dumpContainerReflectionMethod = $kernelReflectionClass->getMethod('dumpContainer'); $dumpContainerReflectionMethod->setAccessible(true); $getContainerClassReflectionMethod = $kernelReflectionClass->getMethod('getContainerClass'); $getContainerClassReflectionMethod->setAccessible(true); $getContainerBaseClassReflectionMethod = $kernelReflectionClass->getMethod('getContainerBaseClass'); $getContainerBaseClassReflectionMethod->setAccessible(true); /** @var ContainerBuilder $newContainer */ $newContainer = $buildContainerReflectionMethod->invoke($kernel); $this->inject($newContainer); $newContainer->compile(); $class = $getContainerClassReflectionMethod->invoke($kernel); $cache = new ConfigCache($kernel->getCacheDir() . '/' . $class . '.php', $kernel->isDebug()); $dumpContainerReflectionMethod->invoke($kernel, $cache, $newContainer, $class, $getContainerBaseClassReflectionMethod->invoke($kernel)); }
php
public function rebuild(Kernel $kernel) { $kernelReflectionClass = new \ReflectionClass($kernel); $buildContainerReflectionMethod = $kernelReflectionClass->getMethod('buildContainer'); $buildContainerReflectionMethod->setAccessible(true); $dumpContainerReflectionMethod = $kernelReflectionClass->getMethod('dumpContainer'); $dumpContainerReflectionMethod->setAccessible(true); $getContainerClassReflectionMethod = $kernelReflectionClass->getMethod('getContainerClass'); $getContainerClassReflectionMethod->setAccessible(true); $getContainerBaseClassReflectionMethod = $kernelReflectionClass->getMethod('getContainerBaseClass'); $getContainerBaseClassReflectionMethod->setAccessible(true); /** @var ContainerBuilder $newContainer */ $newContainer = $buildContainerReflectionMethod->invoke($kernel); $this->inject($newContainer); $newContainer->compile(); $class = $getContainerClassReflectionMethod->invoke($kernel); $cache = new ConfigCache($kernel->getCacheDir() . '/' . $class . '.php', $kernel->isDebug()); $dumpContainerReflectionMethod->invoke($kernel, $cache, $newContainer, $class, $getContainerBaseClassReflectionMethod->invoke($kernel)); }
[ "public", "function", "rebuild", "(", "Kernel", "$", "kernel", ")", "{", "$", "kernelReflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "kernel", ")", ";", "$", "buildContainerReflectionMethod", "=", "$", "kernelReflectionClass", "->", "getMethod", "(", "'buildContainer'", ")", ";", "$", "buildContainerReflectionMethod", "->", "setAccessible", "(", "true", ")", ";", "$", "dumpContainerReflectionMethod", "=", "$", "kernelReflectionClass", "->", "getMethod", "(", "'dumpContainer'", ")", ";", "$", "dumpContainerReflectionMethod", "->", "setAccessible", "(", "true", ")", ";", "$", "getContainerClassReflectionMethod", "=", "$", "kernelReflectionClass", "->", "getMethod", "(", "'getContainerClass'", ")", ";", "$", "getContainerClassReflectionMethod", "->", "setAccessible", "(", "true", ")", ";", "$", "getContainerBaseClassReflectionMethod", "=", "$", "kernelReflectionClass", "->", "getMethod", "(", "'getContainerBaseClass'", ")", ";", "$", "getContainerBaseClassReflectionMethod", "->", "setAccessible", "(", "true", ")", ";", "/** @var ContainerBuilder $newContainer */", "$", "newContainer", "=", "$", "buildContainerReflectionMethod", "->", "invoke", "(", "$", "kernel", ")", ";", "$", "this", "->", "inject", "(", "$", "newContainer", ")", ";", "$", "newContainer", "->", "compile", "(", ")", ";", "$", "class", "=", "$", "getContainerClassReflectionMethod", "->", "invoke", "(", "$", "kernel", ")", ";", "$", "cache", "=", "new", "ConfigCache", "(", "$", "kernel", "->", "getCacheDir", "(", ")", ".", "'/'", ".", "$", "class", ".", "'.php'", ",", "$", "kernel", "->", "isDebug", "(", ")", ")", ";", "$", "dumpContainerReflectionMethod", "->", "invoke", "(", "$", "kernel", ",", "$", "cache", ",", "$", "newContainer", ",", "$", "class", ",", "$", "getContainerBaseClassReflectionMethod", "->", "invoke", "(", "$", "kernel", ")", ")", ";", "}" ]
Rebuild the container and dump it to the cache to apply change on redis stored parameters
[ "Rebuild", "the", "container", "and", "dump", "it", "to", "the", "cache", "to", "apply", "change", "on", "redis", "stored", "parameters" ]
92738c59d4da28d3a7376de854ce8505898159cb
https://github.com/wpottier/WizadSettingsBundle/blob/92738c59d4da28d3a7376de854ce8505898159cb/DependencyInjection/ContainerInjectionManager.php#L56-L82
15,376
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php
RoleQuery.filterByCreateDate
public function filterByCreateDate($createDate = null, $comparison = null) { if (is_array($createDate)) { $useMinMax = false; if (isset($createDate['min'])) { $this->addUsingAlias(RoleTableMap::COL_CREATE_DATE, $createDate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createDate['max'])) { $this->addUsingAlias(RoleTableMap::COL_CREATE_DATE, $createDate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RoleTableMap::COL_CREATE_DATE, $createDate, $comparison); }
php
public function filterByCreateDate($createDate = null, $comparison = null) { if (is_array($createDate)) { $useMinMax = false; if (isset($createDate['min'])) { $this->addUsingAlias(RoleTableMap::COL_CREATE_DATE, $createDate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createDate['max'])) { $this->addUsingAlias(RoleTableMap::COL_CREATE_DATE, $createDate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RoleTableMap::COL_CREATE_DATE, $createDate, $comparison); }
[ "public", "function", "filterByCreateDate", "(", "$", "createDate", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "createDate", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "createDate", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RoleTableMap", "::", "COL_CREATE_DATE", ",", "$", "createDate", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "createDate", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RoleTableMap", "::", "COL_CREATE_DATE", ",", "$", "createDate", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RoleTableMap", "::", "COL_CREATE_DATE", ",", "$", "createDate", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the create_date column Example usage: <code> $query->filterByCreateDate('2011-03-14'); // WHERE create_date = '2011-03-14' $query->filterByCreateDate('now'); // WHERE create_date = '2011-03-14' $query->filterByCreateDate(array('max' => 'yesterday')); // WHERE create_date > '2011-03-13' </code> @param mixed $createDate 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|ChildRoleQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "create_date", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php#L366-L387
15,377
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php
RoleQuery.filterByUpdateDate
public function filterByUpdateDate($updateDate = null, $comparison = null) { if (is_array($updateDate)) { $useMinMax = false; if (isset($updateDate['min'])) { $this->addUsingAlias(RoleTableMap::COL_UPDATE_DATE, $updateDate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updateDate['max'])) { $this->addUsingAlias(RoleTableMap::COL_UPDATE_DATE, $updateDate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RoleTableMap::COL_UPDATE_DATE, $updateDate, $comparison); }
php
public function filterByUpdateDate($updateDate = null, $comparison = null) { if (is_array($updateDate)) { $useMinMax = false; if (isset($updateDate['min'])) { $this->addUsingAlias(RoleTableMap::COL_UPDATE_DATE, $updateDate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updateDate['max'])) { $this->addUsingAlias(RoleTableMap::COL_UPDATE_DATE, $updateDate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RoleTableMap::COL_UPDATE_DATE, $updateDate, $comparison); }
[ "public", "function", "filterByUpdateDate", "(", "$", "updateDate", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "updateDate", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "updateDate", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RoleTableMap", "::", "COL_UPDATE_DATE", ",", "$", "updateDate", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "updateDate", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RoleTableMap", "::", "COL_UPDATE_DATE", ",", "$", "updateDate", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RoleTableMap", "::", "COL_UPDATE_DATE", ",", "$", "updateDate", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the update_date column Example usage: <code> $query->filterByUpdateDate('2011-03-14'); // WHERE update_date = '2011-03-14' $query->filterByUpdateDate('now'); // WHERE update_date = '2011-03-14' $query->filterByUpdateDate(array('max' => 'yesterday')); // WHERE update_date > '2011-03-13' </code> @param mixed $updateDate 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|ChildRoleQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "update_date", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php#L409-L430
15,378
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php
RoleQuery.filterByUserRole
public function filterByUserRole($userRole, $comparison = null) { if ($userRole instanceof \Alchemy\Component\Cerberus\Model\UserRole) { return $this ->addUsingAlias(RoleTableMap::COL_ID, $userRole->getRoleId(), $comparison); } elseif ($userRole instanceof ObjectCollection) { return $this ->useUserRoleQuery() ->filterByPrimaryKeys($userRole->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByUserRole() only accepts arguments of type \Alchemy\Component\Cerberus\Model\UserRole or Collection'); } }
php
public function filterByUserRole($userRole, $comparison = null) { if ($userRole instanceof \Alchemy\Component\Cerberus\Model\UserRole) { return $this ->addUsingAlias(RoleTableMap::COL_ID, $userRole->getRoleId(), $comparison); } elseif ($userRole instanceof ObjectCollection) { return $this ->useUserRoleQuery() ->filterByPrimaryKeys($userRole->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByUserRole() only accepts arguments of type \Alchemy\Component\Cerberus\Model\UserRole or Collection'); } }
[ "public", "function", "filterByUserRole", "(", "$", "userRole", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "userRole", "instanceof", "\\", "Alchemy", "\\", "Component", "\\", "Cerberus", "\\", "Model", "\\", "UserRole", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "RoleTableMap", "::", "COL_ID", ",", "$", "userRole", "->", "getRoleId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "userRole", "instanceof", "ObjectCollection", ")", "{", "return", "$", "this", "->", "useUserRoleQuery", "(", ")", "->", "filterByPrimaryKeys", "(", "$", "userRole", "->", "getPrimaryKeys", "(", ")", ")", "->", "endUse", "(", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByUserRole() only accepts arguments of type \\Alchemy\\Component\\Cerberus\\Model\\UserRole or Collection'", ")", ";", "}", "}" ]
Filter the query by a related \Alchemy\Component\Cerberus\Model\UserRole object @param \Alchemy\Component\Cerberus\Model\UserRole|ObjectCollection $userRole the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildRoleQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "Alchemy", "\\", "Component", "\\", "Cerberus", "\\", "Model", "\\", "UserRole", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php#L469-L482
15,379
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php
RoleQuery.useUserRoleQuery
public function useUserRoleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinUserRole($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'UserRole', '\Alchemy\Component\Cerberus\Model\UserRoleQuery'); }
php
public function useUserRoleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinUserRole($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'UserRole', '\Alchemy\Component\Cerberus\Model\UserRoleQuery'); }
[ "public", "function", "useUserRoleQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinUserRole", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'UserRole'", ",", "'\\Alchemy\\Component\\Cerberus\\Model\\UserRoleQuery'", ")", ";", "}" ]
Use the UserRole relation UserRole object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Alchemy\Component\Cerberus\Model\UserRoleQuery A secondary query class using the current class as primary query
[ "Use", "the", "UserRole", "relation", "UserRole", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php#L527-L532
15,380
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php
RoleQuery.useRolePermissionQuery
public function useRolePermissionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinRolePermission($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'RolePermission', '\Alchemy\Component\Cerberus\Model\RolePermissionQuery'); }
php
public function useRolePermissionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinRolePermission($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'RolePermission', '\Alchemy\Component\Cerberus\Model\RolePermissionQuery'); }
[ "public", "function", "useRolePermissionQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinRolePermission", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'RolePermission'", ",", "'\\Alchemy\\Component\\Cerberus\\Model\\RolePermissionQuery'", ")", ";", "}" ]
Use the RolePermission relation RolePermission object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Alchemy\Component\Cerberus\Model\RolePermissionQuery A secondary query class using the current class as primary query
[ "Use", "the", "RolePermission", "relation", "RolePermission", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php#L600-L605
15,381
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php
RoleQuery.filterByUser
public function filterByUser($user, $comparison = Criteria::EQUAL) { return $this ->useUserRoleQuery() ->filterByUser($user, $comparison) ->endUse(); }
php
public function filterByUser($user, $comparison = Criteria::EQUAL) { return $this ->useUserRoleQuery() ->filterByUser($user, $comparison) ->endUse(); }
[ "public", "function", "filterByUser", "(", "$", "user", ",", "$", "comparison", "=", "Criteria", "::", "EQUAL", ")", "{", "return", "$", "this", "->", "useUserRoleQuery", "(", ")", "->", "filterByUser", "(", "$", "user", ",", "$", "comparison", ")", "->", "endUse", "(", ")", ";", "}" ]
Filter the query by a related User object using the user_role table as cross reference @param User $user the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildRoleQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "User", "object", "using", "the", "user_role", "table", "as", "cross", "reference" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php#L616-L622
15,382
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php
RoleQuery.filterByPermission
public function filterByPermission($permission, $comparison = Criteria::EQUAL) { return $this ->useRolePermissionQuery() ->filterByPermission($permission, $comparison) ->endUse(); }
php
public function filterByPermission($permission, $comparison = Criteria::EQUAL) { return $this ->useRolePermissionQuery() ->filterByPermission($permission, $comparison) ->endUse(); }
[ "public", "function", "filterByPermission", "(", "$", "permission", ",", "$", "comparison", "=", "Criteria", "::", "EQUAL", ")", "{", "return", "$", "this", "->", "useRolePermissionQuery", "(", ")", "->", "filterByPermission", "(", "$", "permission", ",", "$", "comparison", ")", "->", "endUse", "(", ")", ";", "}" ]
Filter the query by a related Permission object using the role_permission table as cross reference @param Permission $permission the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildRoleQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "Permission", "object", "using", "the", "role_permission", "table", "as", "cross", "reference" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php#L633-L639
15,383
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php
RoleQuery.doDeleteAll
public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(RoleTableMap::DATABASE_NAME); } // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. return $con->transaction(function () use ($con) { $affectedRows = 0; // initialize var to track total num of affected rows $affectedRows += parent::doDeleteAll($con); // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). RoleTableMap::clearInstancePool(); RoleTableMap::clearRelatedInstancePool(); return $affectedRows; }); }
php
public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(RoleTableMap::DATABASE_NAME); } // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. return $con->transaction(function () use ($con) { $affectedRows = 0; // initialize var to track total num of affected rows $affectedRows += parent::doDeleteAll($con); // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). RoleTableMap::clearInstancePool(); RoleTableMap::clearRelatedInstancePool(); return $affectedRows; }); }
[ "public", "function", "doDeleteAll", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getWriteConnection", "(", "RoleTableMap", "::", "DATABASE_NAME", ")", ";", "}", "// use transaction because $criteria could contain info", "// for more than one table or we could emulating ON DELETE CASCADE, etc.", "return", "$", "con", "->", "transaction", "(", "function", "(", ")", "use", "(", "$", "con", ")", "{", "$", "affectedRows", "=", "0", ";", "// initialize var to track total num of affected rows", "$", "affectedRows", "+=", "parent", "::", "doDeleteAll", "(", "$", "con", ")", ";", "// Because this db requires some delete cascade/set null emulation, we have to", "// clear the cached instance *after* the emulation has happened (since", "// instances get re-added by the select statement contained therein).", "RoleTableMap", "::", "clearInstancePool", "(", ")", ";", "RoleTableMap", "::", "clearRelatedInstancePool", "(", ")", ";", "return", "$", "affectedRows", ";", "}", ")", ";", "}" ]
Deletes all rows from the role table. @param ConnectionInterface $con the connection to use @return int The number of affected rows (if supported by underlying database driver).
[ "Deletes", "all", "rows", "from", "the", "role", "table", "." ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php#L663-L682
15,384
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php
RoleQuery.delete
public function delete(ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(RoleTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName $criteria->setDbName(RoleTableMap::DATABASE_NAME); // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. return $con->transaction(function () use ($con, $criteria) { $affectedRows = 0; // initialize var to track total num of affected rows RoleTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); RoleTableMap::clearRelatedInstancePool(); return $affectedRows; }); }
php
public function delete(ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(RoleTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName $criteria->setDbName(RoleTableMap::DATABASE_NAME); // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. return $con->transaction(function () use ($con, $criteria) { $affectedRows = 0; // initialize var to track total num of affected rows RoleTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); RoleTableMap::clearRelatedInstancePool(); return $affectedRows; }); }
[ "public", "function", "delete", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getWriteConnection", "(", "RoleTableMap", "::", "DATABASE_NAME", ")", ";", "}", "$", "criteria", "=", "$", "this", ";", "// Set the correct dbName", "$", "criteria", "->", "setDbName", "(", "RoleTableMap", "::", "DATABASE_NAME", ")", ";", "// use transaction because $criteria could contain info", "// for more than one table or we could emulating ON DELETE CASCADE, etc.", "return", "$", "con", "->", "transaction", "(", "function", "(", ")", "use", "(", "$", "con", ",", "$", "criteria", ")", "{", "$", "affectedRows", "=", "0", ";", "// initialize var to track total num of affected rows", "RoleTableMap", "::", "removeInstanceFromPool", "(", "$", "criteria", ")", ";", "$", "affectedRows", "+=", "ModelCriteria", "::", "delete", "(", "$", "con", ")", ";", "RoleTableMap", "::", "clearRelatedInstancePool", "(", ")", ";", "return", "$", "affectedRows", ";", "}", ")", ";", "}" ]
Performs a DELETE on the database based on the current ModelCriteria @param ConnectionInterface $con the connection to use @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows if supported by native driver or if emulated using Propel. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "a", "DELETE", "on", "the", "database", "based", "on", "the", "current", "ModelCriteria" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RoleQuery.php#L693-L716
15,385
awethemes/wp-session
src/Store.php
Store.start
public function start() { $data = $this->handler->read( $this->get_id() ); if ( false !== $data && ! is_null( $data ) && is_array( $data ) ) { $this->attributes = $data; } $this->started = true; }
php
public function start() { $data = $this->handler->read( $this->get_id() ); if ( false !== $data && ! is_null( $data ) && is_array( $data ) ) { $this->attributes = $data; } $this->started = true; }
[ "public", "function", "start", "(", ")", "{", "$", "data", "=", "$", "this", "->", "handler", "->", "read", "(", "$", "this", "->", "get_id", "(", ")", ")", ";", "if", "(", "false", "!==", "$", "data", "&&", "!", "is_null", "(", "$", "data", ")", "&&", "is_array", "(", "$", "data", ")", ")", "{", "$", "this", "->", "attributes", "=", "$", "data", ";", "}", "$", "this", "->", "started", "=", "true", ";", "}" ]
Start the session, reading the data from a handler. @return void
[ "Start", "the", "session", "reading", "the", "data", "from", "a", "handler", "." ]
4819c6392a0dbcbbf547027b70d5af88e7a89d61
https://github.com/awethemes/wp-session/blob/4819c6392a0dbcbbf547027b70d5af88e7a89d61/src/Store.php#L63-L71
15,386
awethemes/wp-session
src/Store.php
Store.keep
public function keep( $keys = null ) { $keys = is_array( $keys ) ? $keys : func_get_args(); $this->merge_new_flashes( $keys ); $this->remove_old_flash_data( $keys ); }
php
public function keep( $keys = null ) { $keys = is_array( $keys ) ? $keys : func_get_args(); $this->merge_new_flashes( $keys ); $this->remove_old_flash_data( $keys ); }
[ "public", "function", "keep", "(", "$", "keys", "=", "null", ")", "{", "$", "keys", "=", "is_array", "(", "$", "keys", ")", "?", "$", "keys", ":", "func_get_args", "(", ")", ";", "$", "this", "->", "merge_new_flashes", "(", "$", "keys", ")", ";", "$", "this", "->", "remove_old_flash_data", "(", "$", "keys", ")", ";", "}" ]
Reflash a subset of the current flash data. @param array|mixed $keys Keep flash keys. @return void
[ "Reflash", "a", "subset", "of", "the", "current", "flash", "data", "." ]
4819c6392a0dbcbbf547027b70d5af88e7a89d61
https://github.com/awethemes/wp-session/blob/4819c6392a0dbcbbf547027b70d5af88e7a89d61/src/Store.php#L292-L298
15,387
awethemes/wp-session
src/Store.php
Store.regenerate
public function regenerate( $destroy = false ) { if ( $destroy ) { $this->handler->destroy( $this->get_id() ); } $this->set_id( $this->generate_session_id() ); return true; }
php
public function regenerate( $destroy = false ) { if ( $destroy ) { $this->handler->destroy( $this->get_id() ); } $this->set_id( $this->generate_session_id() ); return true; }
[ "public", "function", "regenerate", "(", "$", "destroy", "=", "false", ")", "{", "if", "(", "$", "destroy", ")", "{", "$", "this", "->", "handler", "->", "destroy", "(", "$", "this", "->", "get_id", "(", ")", ")", ";", "}", "$", "this", "->", "set_id", "(", "$", "this", "->", "generate_session_id", "(", ")", ")", ";", "return", "true", ";", "}" ]
Generate a new session identifier. @param bool $destroy Destroy current session. @return bool
[ "Generate", "a", "new", "session", "identifier", "." ]
4819c6392a0dbcbbf547027b70d5af88e7a89d61
https://github.com/awethemes/wp-session/blob/4819c6392a0dbcbbf547027b70d5af88e7a89d61/src/Store.php#L387-L395
15,388
awethemes/wp-session
src/Store.php
Store.set_id
public function set_id( $id ) { $this->id = $this->is_valid_id( $id ) ? $id : $this->generate_session_id(); }
php
public function set_id( $id ) { $this->id = $this->is_valid_id( $id ) ? $id : $this->generate_session_id(); }
[ "public", "function", "set_id", "(", "$", "id", ")", "{", "$", "this", "->", "id", "=", "$", "this", "->", "is_valid_id", "(", "$", "id", ")", "?", "$", "id", ":", "$", "this", "->", "generate_session_id", "(", ")", ";", "}" ]
Set the session ID. @param string $id A valid session ID. @return void
[ "Set", "the", "session", "ID", "." ]
4819c6392a0dbcbbf547027b70d5af88e7a89d61
https://github.com/awethemes/wp-session/blob/4819c6392a0dbcbbf547027b70d5af88e7a89d61/src/Store.php#L449-L451
15,389
awethemes/wp-session
src/Store.php
Store.generate_session_id
protected function generate_session_id() { $length = 40; require_once ABSPATH . 'wp-includes/class-phpass.php'; $bytes = ( new \PasswordHash( 8, false ) )->get_random_bytes( $length * 2 ); return substr( str_replace( [ '/', '+', '=' ], '', base64_encode( $bytes ) ), 0, $length ); }
php
protected function generate_session_id() { $length = 40; require_once ABSPATH . 'wp-includes/class-phpass.php'; $bytes = ( new \PasswordHash( 8, false ) )->get_random_bytes( $length * 2 ); return substr( str_replace( [ '/', '+', '=' ], '', base64_encode( $bytes ) ), 0, $length ); }
[ "protected", "function", "generate_session_id", "(", ")", "{", "$", "length", "=", "40", ";", "require_once", "ABSPATH", ".", "'wp-includes/class-phpass.php'", ";", "$", "bytes", "=", "(", "new", "\\", "PasswordHash", "(", "8", ",", "false", ")", ")", "->", "get_random_bytes", "(", "$", "length", "*", "2", ")", ";", "return", "substr", "(", "str_replace", "(", "[", "'/'", ",", "'+'", ",", "'='", "]", ",", "''", ",", "base64_encode", "(", "$", "bytes", ")", ")", ",", "0", ",", "$", "length", ")", ";", "}" ]
Get a new, random session ID. @return string
[ "Get", "a", "new", "random", "session", "ID", "." ]
4819c6392a0dbcbbf547027b70d5af88e7a89d61
https://github.com/awethemes/wp-session/blob/4819c6392a0dbcbbf547027b70d5af88e7a89d61/src/Store.php#L468-L475
15,390
drunomics/service-utils
src/Core/Routing/CurrentRouteMatchTrait.php
CurrentRouteMatchTrait.getCurrentRouteMatch
public function getCurrentRouteMatch() { if (empty($this->currentRouteMatch)) { $this->currentRouteMatch = \Drupal::service('current_route_match'); } return $this->currentRouteMatch; }
php
public function getCurrentRouteMatch() { if (empty($this->currentRouteMatch)) { $this->currentRouteMatch = \Drupal::service('current_route_match'); } return $this->currentRouteMatch; }
[ "public", "function", "getCurrentRouteMatch", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "currentRouteMatch", ")", ")", "{", "$", "this", "->", "currentRouteMatch", "=", "\\", "Drupal", "::", "service", "(", "'current_route_match'", ")", ";", "}", "return", "$", "this", "->", "currentRouteMatch", ";", "}" ]
Gets the current route match. @return \Drupal\Core\Routing\ResettableStackedRouteMatchInterface The alias manager.
[ "Gets", "the", "current", "route", "match", "." ]
56761750043132365ef4ae5d9e0cf4263459328f
https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/Core/Routing/CurrentRouteMatchTrait.php#L38-L43
15,391
crossjoin/Css
src/Crossjoin/Css/Reader/CssString.php
CssString.setCssContent
protected function setCssContent($cssContent) { if (is_string($cssContent)) { $this->content = $cssContent; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($cssContent). "' for argument 'cssContent' given." ); } return $this; }
php
protected function setCssContent($cssContent) { if (is_string($cssContent)) { $this->content = $cssContent; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($cssContent). "' for argument 'cssContent' given." ); } return $this; }
[ "protected", "function", "setCssContent", "(", "$", "cssContent", ")", "{", "if", "(", "is_string", "(", "$", "cssContent", ")", ")", "{", "$", "this", "->", "content", "=", "$", "cssContent", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "cssContent", ")", ".", "\"' for argument 'cssContent' given.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the CSS source content. @param string $cssContent @return $this
[ "Sets", "the", "CSS", "source", "content", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Reader/CssString.php#L26-L37
15,392
rinvex/obsolete-module
src/Module.php
Module.migrate
protected function migrate() { if (! $this->container['migrator']->repositoryExists()) { throw new Exception('Migration table not found.'); } $this->container['migrator']->run($this->getAttribute('path').'/database/migrations'); }
php
protected function migrate() { if (! $this->container['migrator']->repositoryExists()) { throw new Exception('Migration table not found.'); } $this->container['migrator']->run($this->getAttribute('path').'/database/migrations'); }
[ "protected", "function", "migrate", "(", ")", "{", "if", "(", "!", "$", "this", "->", "container", "[", "'migrator'", "]", "->", "repositoryExists", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'Migration table not found.'", ")", ";", "}", "$", "this", "->", "container", "[", "'migrator'", "]", "->", "run", "(", "$", "this", "->", "getAttribute", "(", "'path'", ")", ".", "'/database/migrations'", ")", ";", "}" ]
Execute module migrations. @throws \Exception @return void
[ "Execute", "module", "migrations", "." ]
95e372ae97ecbe7071c3da397b0afd57f327361f
https://github.com/rinvex/obsolete-module/blob/95e372ae97ecbe7071c3da397b0afd57f327361f/src/Module.php#L160-L167
15,393
rinvex/obsolete-module
src/Module.php
Module.rollback
protected function rollback() { if (! $this->container['migrator']->repositoryExists()) { throw new Exception('Migration table not found.'); } $this->container['migrator']->rollback($this->getAttribute('path').'/database/migrations'); }
php
protected function rollback() { if (! $this->container['migrator']->repositoryExists()) { throw new Exception('Migration table not found.'); } $this->container['migrator']->rollback($this->getAttribute('path').'/database/migrations'); }
[ "protected", "function", "rollback", "(", ")", "{", "if", "(", "!", "$", "this", "->", "container", "[", "'migrator'", "]", "->", "repositoryExists", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'Migration table not found.'", ")", ";", "}", "$", "this", "->", "container", "[", "'migrator'", "]", "->", "rollback", "(", "$", "this", "->", "getAttribute", "(", "'path'", ")", ".", "'/database/migrations'", ")", ";", "}" ]
Rollback module migrations. @throws \Exception @return void
[ "Rollback", "module", "migrations", "." ]
95e372ae97ecbe7071c3da397b0afd57f327361f
https://github.com/rinvex/obsolete-module/blob/95e372ae97ecbe7071c3da397b0afd57f327361f/src/Module.php#L176-L183
15,394
rinvex/obsolete-module
src/Module.php
Module.seed
protected function seed() { $seederFilePath = $this->getAttribute('path').'/database/seeds/DatabaseSeeder.php'; if ($this->container['files']->exists($seederFilePath)) { require_once $seederFilePath; $namespace = $this->getAttribute('namespace').'Database\\Seeds\\DatabaseSeeder'; $class = '\\'.ltrim($namespace, '\\'); $seeder = new $class(); $seeder->run(); } }
php
protected function seed() { $seederFilePath = $this->getAttribute('path').'/database/seeds/DatabaseSeeder.php'; if ($this->container['files']->exists($seederFilePath)) { require_once $seederFilePath; $namespace = $this->getAttribute('namespace').'Database\\Seeds\\DatabaseSeeder'; $class = '\\'.ltrim($namespace, '\\'); $seeder = new $class(); $seeder->run(); } }
[ "protected", "function", "seed", "(", ")", "{", "$", "seederFilePath", "=", "$", "this", "->", "getAttribute", "(", "'path'", ")", ".", "'/database/seeds/DatabaseSeeder.php'", ";", "if", "(", "$", "this", "->", "container", "[", "'files'", "]", "->", "exists", "(", "$", "seederFilePath", ")", ")", "{", "require_once", "$", "seederFilePath", ";", "$", "namespace", "=", "$", "this", "->", "getAttribute", "(", "'namespace'", ")", ".", "'Database\\\\Seeds\\\\DatabaseSeeder'", ";", "$", "class", "=", "'\\\\'", ".", "ltrim", "(", "$", "namespace", ",", "'\\\\'", ")", ";", "$", "seeder", "=", "new", "$", "class", "(", ")", ";", "$", "seeder", "->", "run", "(", ")", ";", "}", "}" ]
Seed the database with module seeders. @return void
[ "Seed", "the", "database", "with", "module", "seeders", "." ]
95e372ae97ecbe7071c3da397b0afd57f327361f
https://github.com/rinvex/obsolete-module/blob/95e372ae97ecbe7071c3da397b0afd57f327361f/src/Module.php#L190-L203
15,395
acasademont/wurfl
WURFL/Request/GenericRequest.php
WURFL_Request_GenericRequest.getOriginalHeader
public function getOriginalHeader($name) { return array_key_exists($name, $this->_request)? $this->_request[$name]: null; }
php
public function getOriginalHeader($name) { return array_key_exists($name, $this->_request)? $this->_request[$name]: null; }
[ "public", "function", "getOriginalHeader", "(", "$", "name", ")", "{", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "_request", ")", "?", "$", "this", "->", "_request", "[", "$", "name", "]", ":", "null", ";", "}" ]
Get the original HTTP header value from the request @param string $name @return string
[ "Get", "the", "original", "HTTP", "header", "value", "from", "the", "request" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Request/GenericRequest.php#L97-L100
15,396
chris-schmitz/L5SimpleFM
src/L5SimpleFMBase.php
L5SimpleFMBase.primeCommandArray
protected function primeCommandArray() { if (empty($this->layoutName)) { throw new LayoutNameIsMissingException('You must specify a layout name.'); } $this->commandArray['-db'] = $this->adapter->getHostConnection()->getDbName(); $this->commandArray['-lay'] = $this->layoutName; }
php
protected function primeCommandArray() { if (empty($this->layoutName)) { throw new LayoutNameIsMissingException('You must specify a layout name.'); } $this->commandArray['-db'] = $this->adapter->getHostConnection()->getDbName(); $this->commandArray['-lay'] = $this->layoutName; }
[ "protected", "function", "primeCommandArray", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "layoutName", ")", ")", "{", "throw", "new", "LayoutNameIsMissingException", "(", "'You must specify a layout name.'", ")", ";", "}", "$", "this", "->", "commandArray", "[", "'-db'", "]", "=", "$", "this", "->", "adapter", "->", "getHostConnection", "(", ")", "->", "getDbName", "(", ")", ";", "$", "this", "->", "commandArray", "[", "'-lay'", "]", "=", "$", "this", "->", "layoutName", ";", "}" ]
Adds the default url parameters needed for any request. @return none
[ "Adds", "the", "default", "url", "parameters", "needed", "for", "any", "request", "." ]
9c3250e0918184d537a46c15140f15527e833a4c
https://github.com/chris-schmitz/L5SimpleFM/blob/9c3250e0918184d537a46c15140f15527e833a4c/src/L5SimpleFMBase.php#L39-L46
15,397
chris-schmitz/L5SimpleFM
src/L5SimpleFMBase.php
L5SimpleFMBase.addToCommandArray
protected function addToCommandArray($values) { foreach ($values as $key => $value) { $this->commandArray[$key] = $value; } }
php
protected function addToCommandArray($values) { foreach ($values as $key => $value) { $this->commandArray[$key] = $value; } }
[ "protected", "function", "addToCommandArray", "(", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "commandArray", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Adds additional Url parameters to the request. @param array An associative array of url keys and values. These are normally fields => values or additional FM XML flags => null
[ "Adds", "additional", "Url", "parameters", "to", "the", "request", "." ]
9c3250e0918184d537a46c15140f15527e833a4c
https://github.com/chris-schmitz/L5SimpleFM/blob/9c3250e0918184d537a46c15140f15527e833a4c/src/L5SimpleFMBase.php#L54-L59
15,398
chris-schmitz/L5SimpleFM
src/L5SimpleFMBase.php
L5SimpleFMBase.executeCommand
public function executeCommand() { $this->adapter->setCommandArray($this->commandArray); $result = $this->adapter->execute(); $commandArrayUsed = $this->adapter->getCommandArray(); $this->clearCommandArray(); $this->checkResultForError($result, $commandArrayUsed); return $result; }
php
public function executeCommand() { $this->adapter->setCommandArray($this->commandArray); $result = $this->adapter->execute(); $commandArrayUsed = $this->adapter->getCommandArray(); $this->clearCommandArray(); $this->checkResultForError($result, $commandArrayUsed); return $result; }
[ "public", "function", "executeCommand", "(", ")", "{", "$", "this", "->", "adapter", "->", "setCommandArray", "(", "$", "this", "->", "commandArray", ")", ";", "$", "result", "=", "$", "this", "->", "adapter", "->", "execute", "(", ")", ";", "$", "commandArrayUsed", "=", "$", "this", "->", "adapter", "->", "getCommandArray", "(", ")", ";", "$", "this", "->", "clearCommandArray", "(", ")", ";", "$", "this", "->", "checkResultForError", "(", "$", "result", ",", "$", "commandArrayUsed", ")", ";", "return", "$", "result", ";", "}" ]
Performs the steps necessary to execute a SimpleFM query. @return object The SimpleFM result Object
[ "Performs", "the", "steps", "necessary", "to", "execute", "a", "SimpleFM", "query", "." ]
9c3250e0918184d537a46c15140f15527e833a4c
https://github.com/chris-schmitz/L5SimpleFM/blob/9c3250e0918184d537a46c15140f15527e833a4c/src/L5SimpleFMBase.php#L77-L85
15,399
chris-schmitz/L5SimpleFM
src/L5SimpleFMBase.php
L5SimpleFMBase.checkResultForError
protected function checkResultForError($result, $commandArrayUsed) { if (empty($result)) { throw new NoResultReturnedException('The SimpleFM request did not return a result.'); } if ($result->getErrorCode() == 401) { throw new RecordsNotFoundException($result->getErrorMessage(), $result->getErrorCode(), $result); } if ($result->getErrorCode() !== 0) { $message = $result->getErrorMessage() . ". Command used: " . json_encode($commandArrayUsed); throw new GeneralException($message, $result->getErrorCode(), $result); } }
php
protected function checkResultForError($result, $commandArrayUsed) { if (empty($result)) { throw new NoResultReturnedException('The SimpleFM request did not return a result.'); } if ($result->getErrorCode() == 401) { throw new RecordsNotFoundException($result->getErrorMessage(), $result->getErrorCode(), $result); } if ($result->getErrorCode() !== 0) { $message = $result->getErrorMessage() . ". Command used: " . json_encode($commandArrayUsed); throw new GeneralException($message, $result->getErrorCode(), $result); } }
[ "protected", "function", "checkResultForError", "(", "$", "result", ",", "$", "commandArrayUsed", ")", "{", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "throw", "new", "NoResultReturnedException", "(", "'The SimpleFM request did not return a result.'", ")", ";", "}", "if", "(", "$", "result", "->", "getErrorCode", "(", ")", "==", "401", ")", "{", "throw", "new", "RecordsNotFoundException", "(", "$", "result", "->", "getErrorMessage", "(", ")", ",", "$", "result", "->", "getErrorCode", "(", ")", ",", "$", "result", ")", ";", "}", "if", "(", "$", "result", "->", "getErrorCode", "(", ")", "!==", "0", ")", "{", "$", "message", "=", "$", "result", "->", "getErrorMessage", "(", ")", ".", "\". Command used: \"", ".", "json_encode", "(", "$", "commandArrayUsed", ")", ";", "throw", "new", "GeneralException", "(", "$", "message", ",", "$", "result", "->", "getErrorCode", "(", ")", ",", "$", "result", ")", ";", "}", "}" ]
Parses the SimpleFM result and determines if a FileMaker error was thrown. @param object A SimpleFM result object @return none
[ "Parses", "the", "SimpleFM", "result", "and", "determines", "if", "a", "FileMaker", "error", "was", "thrown", "." ]
9c3250e0918184d537a46c15140f15527e833a4c
https://github.com/chris-schmitz/L5SimpleFM/blob/9c3250e0918184d537a46c15140f15527e833a4c/src/L5SimpleFMBase.php#L93-L105