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
238,000
ongr-archive/ContentBundle
Service/ContentService.php
ContentService.getDocumentBySlug
public function getDocumentBySlug($slug) { $search = $this->repository->createSearch(); $search->addQuery(new TermQuery('slug', $slug), 'must'); $results = $this->repository->execute($search); if (count($results) === 0) { $this->logger && $this->logger->warning( sprintf("Can not render snippet for '%s' because content was not found.", $slug) ); return null; } return $results->current(); }
php
public function getDocumentBySlug($slug) { $search = $this->repository->createSearch(); $search->addQuery(new TermQuery('slug', $slug), 'must'); $results = $this->repository->execute($search); if (count($results) === 0) { $this->logger && $this->logger->warning( sprintf("Can not render snippet for '%s' because content was not found.", $slug) ); return null; } return $results->current(); }
[ "public", "function", "getDocumentBySlug", "(", "$", "slug", ")", "{", "$", "search", "=", "$", "this", "->", "repository", "->", "createSearch", "(", ")", ";", "$", "search", "->", "addQuery", "(", "new", "TermQuery", "(", "'slug'", ",", "$", "slug", ...
Retrieves document by slug. @param string $slug @return DocumentInterface|null
[ "Retrieves", "document", "by", "slug", "." ]
453a02c0c89c16f66dc9caed000243534dbeffa5
https://github.com/ongr-archive/ContentBundle/blob/453a02c0c89c16f66dc9caed000243534dbeffa5/Service/ContentService.php#L46-L62
238,001
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.setDescription
public function setDescription($description = null) { if ( empty($description) ) $this->description = null; else if ( !is_string($description) ) throw new InvalidArgumentException("Invalid RpcMethod description"); else $this->description = $description; return $this; }
php
public function setDescription($description = null) { if ( empty($description) ) $this->description = null; else if ( !is_string($description) ) throw new InvalidArgumentException("Invalid RpcMethod description"); else $this->description = $description; return $this; }
[ "public", "function", "setDescription", "(", "$", "description", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "description", ")", ")", "$", "this", "->", "description", "=", "null", ";", "else", "if", "(", "!", "is_string", "(", "$", "descripti...
Set the method's description @param string $description @return self @throws InvalidArgumentException
[ "Set", "the", "method", "s", "description" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L153-L163
238,002
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.addSignature
public function addSignature() { $signature = [ "PARAMETERS" => [], "RETURNTYPE" => 'undefined' ]; array_push($this->signatures, $signature); $this->current_signature = max(array_keys($this->signatures)); return $this; }
php
public function addSignature() { $signature = [ "PARAMETERS" => [], "RETURNTYPE" => 'undefined' ]; array_push($this->signatures, $signature); $this->current_signature = max(array_keys($this->signatures)); return $this; }
[ "public", "function", "addSignature", "(", ")", "{", "$", "signature", "=", "[", "\"PARAMETERS\"", "=>", "[", "]", ",", "\"RETURNTYPE\"", "=>", "'undefined'", "]", ";", "array_push", "(", "$", "this", "->", "signatures", ",", "$", "signature", ")", ";", ...
Add a signature and switch internal pointer @return self
[ "Add", "a", "signature", "and", "switch", "internal", "pointer" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L192-L205
238,003
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.getSignatures
public function getSignatures($compact = true) { if ( $compact ) { $signatures = []; foreach ( $this->signatures as $signature ) { $signatures[] = array_merge([$signature["RETURNTYPE"]], array_values($signature["PARAMETERS"])); } return $signatures; } else { return $this->signatures; } }
php
public function getSignatures($compact = true) { if ( $compact ) { $signatures = []; foreach ( $this->signatures as $signature ) { $signatures[] = array_merge([$signature["RETURNTYPE"]], array_values($signature["PARAMETERS"])); } return $signatures; } else { return $this->signatures; } }
[ "public", "function", "getSignatures", "(", "$", "compact", "=", "true", ")", "{", "if", "(", "$", "compact", ")", "{", "$", "signatures", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "signatures", "as", "$", "signature", ")", "{", "$", "...
Get the method's signatures @param bool $compact (default) Compact signatures in a format compatible with system.methodSignature @return array
[ "Get", "the", "method", "s", "signatures" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L214-L234
238,004
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.getSignature
public function getSignature($compact = true) { if ( $compact ) { return array_merge([$this->signatures[$this->current_signature]["RETURNTYPE"]], array_values($this->signatures[$this->current_signature]["PARAMETERS"])); } else { return $this->signatures[$this->current_signature]; } }
php
public function getSignature($compact = true) { if ( $compact ) { return array_merge([$this->signatures[$this->current_signature]["RETURNTYPE"]], array_values($this->signatures[$this->current_signature]["PARAMETERS"])); } else { return $this->signatures[$this->current_signature]; } }
[ "public", "function", "getSignature", "(", "$", "compact", "=", "true", ")", "{", "if", "(", "$", "compact", ")", "{", "return", "array_merge", "(", "[", "$", "this", "->", "signatures", "[", "$", "this", "->", "current_signature", "]", "[", "\"RETURNTYP...
Get the current method's signature @param bool $compact (default) Compact signatures in a format compatible with system.methodSignature @return array
[ "Get", "the", "current", "method", "s", "signature" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L243-L255
238,005
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.deleteSignature
public function deleteSignature($signature) { if ( !is_integer($signature) || !isset($this->signatures[$signature]) ) { throw new InvalidArgumentException("Invalid RpcMethod signature reference"); } unset($this->signatures[$signature]); return true; }
php
public function deleteSignature($signature) { if ( !is_integer($signature) || !isset($this->signatures[$signature]) ) { throw new InvalidArgumentException("Invalid RpcMethod signature reference"); } unset($this->signatures[$signature]); return true; }
[ "public", "function", "deleteSignature", "(", "$", "signature", ")", "{", "if", "(", "!", "is_integer", "(", "$", "signature", ")", "||", "!", "isset", "(", "$", "this", "->", "signatures", "[", "$", "signature", "]", ")", ")", "{", "throw", "new", "...
Delete a signature @param integer $signature The signature's ID @return bool @throws InvalidArgumentException
[ "Delete", "a", "signature" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L265-L277
238,006
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.selectSignature
public function selectSignature($signature) { if ( !is_integer($signature) || !isset($this->signatures[$signature]) ) { throw new InvalidArgumentException("Invalid RpcMethod signature reference"); } $this->current_signature = $signature; return $this; }
php
public function selectSignature($signature) { if ( !is_integer($signature) || !isset($this->signatures[$signature]) ) { throw new InvalidArgumentException("Invalid RpcMethod signature reference"); } $this->current_signature = $signature; return $this; }
[ "public", "function", "selectSignature", "(", "$", "signature", ")", "{", "if", "(", "!", "is_integer", "(", "$", "signature", ")", "||", "!", "isset", "(", "$", "this", "->", "signatures", "[", "$", "signature", "]", ")", ")", "{", "throw", "new", "...
Select a signature @param integer $signature The signature's ID @return self @throws Exception
[ "Select", "a", "signature" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L287-L299
238,007
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.setReturnType
public function setReturnType($type) { if ( !in_array($type, self::$rpcvalues) ) throw new InvalidArgumentException("Invalid RpcMethod return type"); $this->signatures[$this->current_signature]["RETURNTYPE"] = self::$rpcvalues[$type]; return $this; }
php
public function setReturnType($type) { if ( !in_array($type, self::$rpcvalues) ) throw new InvalidArgumentException("Invalid RpcMethod return type"); $this->signatures[$this->current_signature]["RETURNTYPE"] = self::$rpcvalues[$type]; return $this; }
[ "public", "function", "setReturnType", "(", "$", "type", ")", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "self", "::", "$", "rpcvalues", ")", ")", "throw", "new", "InvalidArgumentException", "(", "\"Invalid RpcMethod return type\"", ")", ";", "$...
Set the current signature's return type @param string $type @return self @throws InvalidArgumentException
[ "Set", "the", "current", "signature", "s", "return", "type" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L309-L317
238,008
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.addParameter
public function addParameter($type, $name) { if ( !in_array($type, self::$rpcvalues) ) throw new InvalidArgumentException("Invalid type for parameter $name"); if ( empty($name) ) throw new InvalidArgumentException("Missing parameter name"); $this->signatures[$this->current_signature]["PARAMETERS"][$name] = self::$rpcvalues[$type]; return $this; }
php
public function addParameter($type, $name) { if ( !in_array($type, self::$rpcvalues) ) throw new InvalidArgumentException("Invalid type for parameter $name"); if ( empty($name) ) throw new InvalidArgumentException("Missing parameter name"); $this->signatures[$this->current_signature]["PARAMETERS"][$name] = self::$rpcvalues[$type]; return $this; }
[ "public", "function", "addParameter", "(", "$", "type", ",", "$", "name", ")", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "self", "::", "$", "rpcvalues", ")", ")", "throw", "new", "InvalidArgumentException", "(", "\"Invalid type for parameter $n...
Add a parameter to current signature @param string $type @param string $name @return self @throws InvalidArgumentException
[ "Add", "a", "parameter", "to", "current", "signature" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L339-L349
238,009
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.deleteParameter
public function deleteParameter($name) { if ( !array_key_exists($name, $this->signatures[$this->current_signature]["PARAMETERS"]) ) throw new Exception("Cannot find parameter $name"); unset($this->signatures[$this->current_signature]["PARAMETERS"][$name]); return $this; }
php
public function deleteParameter($name) { if ( !array_key_exists($name, $this->signatures[$this->current_signature]["PARAMETERS"]) ) throw new Exception("Cannot find parameter $name"); unset($this->signatures[$this->current_signature]["PARAMETERS"][$name]); return $this; }
[ "public", "function", "deleteParameter", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "signatures", "[", "$", "this", "->", "current_signature", "]", "[", "\"PARAMETERS\"", "]", ")", ")", "thro...
Delete a parameter from current signature @param string $name @return self @throws Exception
[ "Delete", "a", "parameter", "from", "current", "signature" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L359-L367
238,010
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.getParameters
public function getParameters($format = self::FETCH_ASSOC) { if ( $format === self::FETCH_NUMERIC ) return array_values($this->signatures[$this->current_signature]["PARAMETERS"]); else return $this->signatures[$this->current_signature]["PARAMETERS"]; }
php
public function getParameters($format = self::FETCH_ASSOC) { if ( $format === self::FETCH_NUMERIC ) return array_values($this->signatures[$this->current_signature]["PARAMETERS"]); else return $this->signatures[$this->current_signature]["PARAMETERS"]; }
[ "public", "function", "getParameters", "(", "$", "format", "=", "self", "::", "FETCH_ASSOC", ")", "{", "if", "(", "$", "format", "===", "self", "::", "FETCH_NUMERIC", ")", "return", "array_values", "(", "$", "this", "->", "signatures", "[", "$", "this", ...
Get current signature's parameters @param string $format The output array format (ASSOC|NUMERIC) @return array
[ "Get", "current", "signature", "s", "parameters" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L376-L382
238,011
comodojo/rpcserver
src/Comodojo/RpcServer/RpcMethod.php
RpcMethod.create
public static function create($name, callable $callback, ...$arguments) { try { return new RpcMethod($name, $callback, ...$arguments); } catch (Exception $e) { throw $e; } }
php
public static function create($name, callable $callback, ...$arguments) { try { return new RpcMethod($name, $callback, ...$arguments); } catch (Exception $e) { throw $e; } }
[ "public", "static", "function", "create", "(", "$", "name", ",", "callable", "$", "callback", ",", "...", "$", "arguments", ")", "{", "try", "{", "return", "new", "RpcMethod", "(", "$", "name", ",", "$", "callback", ",", "...", "$", "arguments", ")", ...
Static class constructor - create an RpcMethod object @param string $name @param string $callback @return RpcMethod @throws Exception
[ "Static", "class", "constructor", "-", "create", "an", "RpcMethod", "object" ]
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcMethod.php#L393-L405
238,012
magnus-eriksson/file-db
src/Storage/FileSystem.php
FileSystem.loadTable
public function loadTable($table) { $file = $this->path . '/' . $table . '.json'; if (is_file($file)) { $data = file_get_contents($file); if (!$data) { return $this->blankTable(); } if (!$data = @json_decode($data, true, 512)) { throw new Exception("Unable to parse table file '{$table}.json'"); } return $data; } return $this->blankTable(); }
php
public function loadTable($table) { $file = $this->path . '/' . $table . '.json'; if (is_file($file)) { $data = file_get_contents($file); if (!$data) { return $this->blankTable(); } if (!$data = @json_decode($data, true, 512)) { throw new Exception("Unable to parse table file '{$table}.json'"); } return $data; } return $this->blankTable(); }
[ "public", "function", "loadTable", "(", "$", "table", ")", "{", "$", "file", "=", "$", "this", "->", "path", ".", "'/'", ".", "$", "table", ".", "'.json'", ";", "if", "(", "is_file", "(", "$", "file", ")", ")", "{", "$", "data", "=", "file_get_co...
Load table data @param string $table @return array $data
[ "Load", "table", "data" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/Storage/FileSystem.php#L37-L54
238,013
magnus-eriksson/file-db
src/Storage/FileSystem.php
FileSystem.saveTable
public function saveTable($table, array &$data) { $file = $this->path . '/' . $table . '.json'; $data = $this->touchModified($data); $opt = is_numeric($this->opt['json_options']) ? $this->opt['json_options'] : 0; $dept = is_numeric($this->opt['json_depth']) ? $this->opt['json_depth'] : 512; return file_put_contents($file, json_encode($data, $opt, $dept), LOCK_EX) > 0; }
php
public function saveTable($table, array &$data) { $file = $this->path . '/' . $table . '.json'; $data = $this->touchModified($data); $opt = is_numeric($this->opt['json_options']) ? $this->opt['json_options'] : 0; $dept = is_numeric($this->opt['json_depth']) ? $this->opt['json_depth'] : 512; return file_put_contents($file, json_encode($data, $opt, $dept), LOCK_EX) > 0; }
[ "public", "function", "saveTable", "(", "$", "table", ",", "array", "&", "$", "data", ")", "{", "$", "file", "=", "$", "this", "->", "path", ".", "'/'", ".", "$", "table", ".", "'.json'", ";", "$", "data", "=", "$", "this", "->", "touchModified", ...
Save table data @param string $table @param array $data @return boolean
[ "Save", "table", "data" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/Storage/FileSystem.php#L63-L77
238,014
erunion/laravel-examine-config
src/Erunion/Console/Commands/ExamineConfigCommand.php
ExamineConfigCommand.generateTree
private function generateTree($data, $total_depth, $current_depth = 1) { ksort($data); $table = []; foreach ($data as $key => $value) { $row = []; if ($current_depth > 1) { $row = array_merge($row, array_fill(0, ($current_depth - 1), '')); } $row[] = '<comment>' . $key . '</comment>'; if (!is_array($value)) { $row[] = (is_bool($value)) ? (($value) ? 'true' : 'false') : $value; } // Pad the row out with empty columns equal to the total subtracting the current recursive depth. $empty_columns = ($total_depth - $current_depth); $empty_columns = array_fill(count($row) - 1, $empty_columns, ''); $row = array_merge($row, $empty_columns); $table[] = $row; if (is_array($value)) { $table = array_merge($table, $this->generateTree($value, $total_depth, $current_depth + 1)); } } return $table; }
php
private function generateTree($data, $total_depth, $current_depth = 1) { ksort($data); $table = []; foreach ($data as $key => $value) { $row = []; if ($current_depth > 1) { $row = array_merge($row, array_fill(0, ($current_depth - 1), '')); } $row[] = '<comment>' . $key . '</comment>'; if (!is_array($value)) { $row[] = (is_bool($value)) ? (($value) ? 'true' : 'false') : $value; } // Pad the row out with empty columns equal to the total subtracting the current recursive depth. $empty_columns = ($total_depth - $current_depth); $empty_columns = array_fill(count($row) - 1, $empty_columns, ''); $row = array_merge($row, $empty_columns); $table[] = $row; if (is_array($value)) { $table = array_merge($table, $this->generateTree($value, $total_depth, $current_depth + 1)); } } return $table; }
[ "private", "function", "generateTree", "(", "$", "data", ",", "$", "total_depth", ",", "$", "current_depth", "=", "1", ")", "{", "ksort", "(", "$", "data", ")", ";", "$", "table", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "key", ...
Take a configuration array, recursively traverse and create a padded tree array to output as a table. @param array $data @param integer $total_depth @param integer $current_depth @return array
[ "Take", "a", "configuration", "array", "recursively", "traverse", "and", "create", "a", "padded", "tree", "array", "to", "output", "as", "a", "table", "." ]
bb31c21a80baefe5641bc8b1322d6ec0c750f505
https://github.com/erunion/laravel-examine-config/blob/bb31c21a80baefe5641bc8b1322d6ec0c750f505/src/Erunion/Console/Commands/ExamineConfigCommand.php#L70-L99
238,015
erunion/laravel-examine-config
src/Erunion/Console/Commands/ExamineConfigCommand.php
ExamineConfigCommand.getConfigDepth
private function getConfigDepth($config) { $total_depth = 1; foreach ($config as $data) { if (is_array($data)) { $depth = $this->getConfigDepth($data) + 1; if ($depth > $total_depth) { $total_depth = $depth; } } } return $total_depth; }
php
private function getConfigDepth($config) { $total_depth = 1; foreach ($config as $data) { if (is_array($data)) { $depth = $this->getConfigDepth($data) + 1; if ($depth > $total_depth) { $total_depth = $depth; } } } return $total_depth; }
[ "private", "function", "getConfigDepth", "(", "$", "config", ")", "{", "$", "total_depth", "=", "1", ";", "foreach", "(", "$", "config", "as", "$", "data", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "depth", "=", "$", ...
Determine the depth of this configuration so we know how to pad the outputted table of data. @param array $config @return integer
[ "Determine", "the", "depth", "of", "this", "configuration", "so", "we", "know", "how", "to", "pad", "the", "outputted", "table", "of", "data", "." ]
bb31c21a80baefe5641bc8b1322d6ec0c750f505
https://github.com/erunion/laravel-examine-config/blob/bb31c21a80baefe5641bc8b1322d6ec0c750f505/src/Erunion/Console/Commands/ExamineConfigCommand.php#L106-L120
238,016
gorriecoe/silverstripe-sreg
src/SReg.php
SReg.sregValue
private function sregValue($value = '') { $owner = $this->owner; $values = explode('|', $value); $count = count($values); foreach ($values as $key => $fieldPath) { if ($fieldPath == '' || $fieldPath == 'null') { return null; } elseif ($relValue = $this->sregTraverse($fieldPath)) { if (is_object($relValue) && method_exists($relValue, 'AbsoluteLink')) { if ($link = $relValue->AbsoluteLink()) { return $link; } else { continue; } } else { return $relValue; } } elseif ($key + 1 == $count && !$owner->hasMethod($fieldPath) ) { return $fieldPath; } } }
php
private function sregValue($value = '') { $owner = $this->owner; $values = explode('|', $value); $count = count($values); foreach ($values as $key => $fieldPath) { if ($fieldPath == '' || $fieldPath == 'null') { return null; } elseif ($relValue = $this->sregTraverse($fieldPath)) { if (is_object($relValue) && method_exists($relValue, 'AbsoluteLink')) { if ($link = $relValue->AbsoluteLink()) { return $link; } else { continue; } } else { return $relValue; } } elseif ($key + 1 == $count && !$owner->hasMethod($fieldPath) ) { return $fieldPath; } } }
[ "private", "function", "sregValue", "(", "$", "value", "=", "''", ")", "{", "$", "owner", "=", "$", "this", "->", "owner", ";", "$", "values", "=", "explode", "(", "'|'", ",", "$", "value", ")", ";", "$", "count", "=", "count", "(", "$", "values"...
Splits string by |, loops each segment and returns the first non-null value @param string $value @param boolean $allowNoMatch @return string|null
[ "Splits", "string", "by", "|", "loops", "each", "segment", "and", "returns", "the", "first", "non", "-", "null", "value" ]
ef32e6c2bc4adb0af570be50cdbddce92202dcfa
https://github.com/gorriecoe/silverstripe-sreg/blob/ef32e6c2bc4adb0af570be50cdbddce92202dcfa/src/SReg.php#L45-L67
238,017
gourmet/common
Controller/CommonAppController.php
CommonAppController.forceSsl
public function forceSsl($type) { $host = env('SERVER_NAME'); if (empty($host)) { $host = env('HTTP_HOST'); } if ('secure' == $type) { $this->redirect('https://' . $host . $this->here); } }
php
public function forceSsl($type) { $host = env('SERVER_NAME'); if (empty($host)) { $host = env('HTTP_HOST'); } if ('secure' == $type) { $this->redirect('https://' . $host . $this->here); } }
[ "public", "function", "forceSsl", "(", "$", "type", ")", "{", "$", "host", "=", "env", "(", "'SERVER_NAME'", ")", ";", "if", "(", "empty", "(", "$", "host", ")", ")", "{", "$", "host", "=", "env", "(", "'HTTP_HOST'", ")", ";", "}", "if", "(", "...
Blackhole callback for the `SecurityComponent`. - Automatically redirect secured requests to HTTPS. @param string $type The type of blackhole. @return void
[ "Blackhole", "callback", "for", "the", "SecurityComponent", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Controller/CommonAppController.php#L292-L300
238,018
gourmet/common
Controller/CommonAppController.php
CommonAppController._edit
protected function _edit($id) { try { $result = $this->{$this->modelClass}->edit($id, $this->request->data); } catch (OutOfBoundsException $e) { return $this->alert($e, array('redirect' => $this->referer(array('action' => 'list'), true))); } $this->request->data = $this->{$this->modelClass}->data; if (!empty($this->request->data[$this->{$this->modelClass}->alias][$this->{$this->modelClass}->displayField])) { $this->_appendToCrumb($this->request->data[$this->{$this->modelClass}->alias][$this->{$this->modelClass}->displayField]); } if (false === $result) { $this->alert('save.fail'); } else if ($this->request->is('put')) { $this->alert('save.success'); } }
php
protected function _edit($id) { try { $result = $this->{$this->modelClass}->edit($id, $this->request->data); } catch (OutOfBoundsException $e) { return $this->alert($e, array('redirect' => $this->referer(array('action' => 'list'), true))); } $this->request->data = $this->{$this->modelClass}->data; if (!empty($this->request->data[$this->{$this->modelClass}->alias][$this->{$this->modelClass}->displayField])) { $this->_appendToCrumb($this->request->data[$this->{$this->modelClass}->alias][$this->{$this->modelClass}->displayField]); } if (false === $result) { $this->alert('save.fail'); } else if ($this->request->is('put')) { $this->alert('save.success'); } }
[ "protected", "function", "_edit", "(", "$", "id", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "{", "$", "this", "->", "modelClass", "}", "->", "edit", "(", "$", "id", ",", "$", "this", "->", "request", "->", "data", ")", ";", "...
Common edit action. @param string $id Model's record primary key value. @return void
[ "Common", "edit", "action", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Controller/CommonAppController.php#L474-L492
238,019
gourmet/common
Controller/CommonAppController.php
CommonAppController._list
protected function _list($object = null, $scope = array(), $whitelist = array()) { $View = $this->_getViewObject(); if (!$View->Helpers->loaded('Common.Table')) { $this->_getViewObject()->loadHelper('Common.Table'); } $this->{$this->modelClass}->recursive = 0; $this->set('results', $this->paginate($object, $scope, $whitelist)); }
php
protected function _list($object = null, $scope = array(), $whitelist = array()) { $View = $this->_getViewObject(); if (!$View->Helpers->loaded('Common.Table')) { $this->_getViewObject()->loadHelper('Common.Table'); } $this->{$this->modelClass}->recursive = 0; $this->set('results', $this->paginate($object, $scope, $whitelist)); }
[ "protected", "function", "_list", "(", "$", "object", "=", "null", ",", "$", "scope", "=", "array", "(", ")", ",", "$", "whitelist", "=", "array", "(", ")", ")", "{", "$", "View", "=", "$", "this", "->", "_getViewObject", "(", ")", ";", "if", "("...
Common list action. @param Model|string $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel') @param string|array $scope Additional find conditions to use while paginating @param array $whitelist List of allowed fields for ordering. This allows you to prevent ordering on non-indexed, or undesirable columns. @return void
[ "Common", "list", "action", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Controller/CommonAppController.php#L503-L510
238,020
gourmet/common
Controller/CommonAppController.php
CommonAppController._status
protected function _status($id, $status) { if (!$this->{$this->modelClass}->changeStatus($id, $status)) { return $this->alert('status.fail'); } $this->alert('status.success'); }
php
protected function _status($id, $status) { if (!$this->{$this->modelClass}->changeStatus($id, $status)) { return $this->alert('status.fail'); } $this->alert('status.success'); }
[ "protected", "function", "_status", "(", "$", "id", ",", "$", "status", ")", "{", "if", "(", "!", "$", "this", "->", "{", "$", "this", "->", "modelClass", "}", "->", "changeStatus", "(", "$", "id", ",", "$", "status", ")", ")", "{", "return", "$"...
Common status action. @param string $id Model's record primary key value. @param string $status New status to change to. @return void
[ "Common", "status", "action", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Controller/CommonAppController.php#L519-L524
238,021
cubicmushroom/slim-service-manager
src/CubicMushroom/Slim/ServiceManager/ServiceManager.php
ServiceManager.setupServices
public function setupServices() { $settings = $this->getApp()->container->get('settings'); if (!empty($settings['services'])) { if (!is_array($settings['services'])) { throw InvalidServiceConfigException::build([], ['serviceConfig' => $settings['services']]); } foreach ($settings['services'] as $service => $config) { $this->setupService($service, $config); } } }
php
public function setupServices() { $settings = $this->getApp()->container->get('settings'); if (!empty($settings['services'])) { if (!is_array($settings['services'])) { throw InvalidServiceConfigException::build([], ['serviceConfig' => $settings['services']]); } foreach ($settings['services'] as $service => $config) { $this->setupService($service, $config); } } }
[ "public", "function", "setupServices", "(", ")", "{", "$", "settings", "=", "$", "this", "->", "getApp", "(", ")", "->", "container", "->", "get", "(", "'settings'", ")", ";", "if", "(", "!", "empty", "(", "$", "settings", "[", "'services'", "]", ")"...
Registers the services with the application
[ "Registers", "the", "services", "with", "the", "application" ]
078dbe0d7dc97f42563b91571550b412350673b8
https://github.com/cubicmushroom/slim-service-manager/blob/078dbe0d7dc97f42563b91571550b412350673b8/src/CubicMushroom/Slim/ServiceManager/ServiceManager.php#L134-L147
238,022
cubicmushroom/slim-service-manager
src/CubicMushroom/Slim/ServiceManager/ServiceManager.php
ServiceManager.getService
public function getService($serviceName) { $serviceName = $this->getServiceName($serviceName); return $this->getApp()->container->get($serviceName); }
php
public function getService($serviceName) { $serviceName = $this->getServiceName($serviceName); return $this->getApp()->container->get($serviceName); }
[ "public", "function", "getService", "(", "$", "serviceName", ")", "{", "$", "serviceName", "=", "$", "this", "->", "getServiceName", "(", "$", "serviceName", ")", ";", "return", "$", "this", "->", "getApp", "(", ")", "->", "container", "->", "get", "(", ...
Returns a service using the service name given The service name will be prefixed with an '@' if it's not already @param string $serviceName Service name, with or without the '@' prefix @return mixed
[ "Returns", "a", "service", "using", "the", "service", "name", "given" ]
078dbe0d7dc97f42563b91571550b412350673b8
https://github.com/cubicmushroom/slim-service-manager/blob/078dbe0d7dc97f42563b91571550b412350673b8/src/CubicMushroom/Slim/ServiceManager/ServiceManager.php#L197-L202
238,023
meliorframework/melior
Classes/Helper/StringHelper.php
StringHelper.endsWith
public function endsWith(string $haystack, string $needle): bool { $escaped = preg_quote($needle); return (bool) preg_match("/$escaped$/", $haystack); }
php
public function endsWith(string $haystack, string $needle): bool { $escaped = preg_quote($needle); return (bool) preg_match("/$escaped$/", $haystack); }
[ "public", "function", "endsWith", "(", "string", "$", "haystack", ",", "string", "$", "needle", ")", ":", "bool", "{", "$", "escaped", "=", "preg_quote", "(", "$", "needle", ")", ";", "return", "(", "bool", ")", "preg_match", "(", "\"/$escaped$/\"", ",",...
Checks if a string ends with another one. @param string $haystack The string to search in @param string $needle The string to search for @return bool
[ "Checks", "if", "a", "string", "ends", "with", "another", "one", "." ]
f6469fa6e85f66a0507ae13603d19d78f2774e0b
https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Helper/StringHelper.php#L50-L55
238,024
hashstudio/Mindy_Application
src/Mindy/Application/Application.php
Application.processRequest
public function processRequest() { $this->signal->send($this, 'onProcessRequest'); if (Console::isCli()) { $exitCode = $this->_runner->run($_SERVER['argv']); if (is_int($exitCode)) { $this->end($exitCode); } } else { $this->runController($this->parseRoute()); } }
php
public function processRequest() { $this->signal->send($this, 'onProcessRequest'); if (Console::isCli()) { $exitCode = $this->_runner->run($_SERVER['argv']); if (is_int($exitCode)) { $this->end($exitCode); } } else { $this->runController($this->parseRoute()); } }
[ "public", "function", "processRequest", "(", ")", "{", "$", "this", "->", "signal", "->", "send", "(", "$", "this", ",", "'onProcessRequest'", ")", ";", "if", "(", "Console", "::", "isCli", "(", ")", ")", "{", "$", "exitCode", "=", "$", "this", "->",...
Processes the current request. It first resolves the request into controller and action, and then creates the controller to perform the action.
[ "Processes", "the", "current", "request", ".", "It", "first", "resolves", "the", "request", "into", "controller", "and", "action", "and", "then", "creates", "the", "controller", "to", "perform", "the", "action", "." ]
07f7e0f4a83e0f9a5f11edca2b3df540760757eb
https://github.com/hashstudio/Mindy_Application/blob/07f7e0f4a83e0f9a5f11edca2b3df540760757eb/src/Mindy/Application/Application.php#L61-L73
238,025
hashstudio/Mindy_Application
src/Mindy/Application/Application.php
Application.runController
public function runController($route) { if (($ca = $this->createController($route)) !== null) { /** @var \Mindy\Controller\BaseController $controller */ list($controller, $actionID, $params) = $ca; $_GET = array_merge($_GET, $params); $csrfExempt = $controller->getCsrfExempt(); if (Console::isCli() === false && in_array($actionID, $csrfExempt) === false) { /** @var \Mindy\Http\Request $request */ $request = $this->getComponent('request'); if ($request->enableCsrfValidation) { $request->csrf->validate(); } } $oldController = $this->_controller; $this->_controller = $controller; $controller->init(); $controller->run($actionID, $params); $this->_controller = $oldController; } else { throw new HttpException(404, Mindy::t('base', 'Unable to resolve the request "{route}".', [ '{route}' => $this->request->getPath() ])); } }
php
public function runController($route) { if (($ca = $this->createController($route)) !== null) { /** @var \Mindy\Controller\BaseController $controller */ list($controller, $actionID, $params) = $ca; $_GET = array_merge($_GET, $params); $csrfExempt = $controller->getCsrfExempt(); if (Console::isCli() === false && in_array($actionID, $csrfExempt) === false) { /** @var \Mindy\Http\Request $request */ $request = $this->getComponent('request'); if ($request->enableCsrfValidation) { $request->csrf->validate(); } } $oldController = $this->_controller; $this->_controller = $controller; $controller->init(); $controller->run($actionID, $params); $this->_controller = $oldController; } else { throw new HttpException(404, Mindy::t('base', 'Unable to resolve the request "{route}".', [ '{route}' => $this->request->getPath() ])); } }
[ "public", "function", "runController", "(", "$", "route", ")", "{", "if", "(", "(", "$", "ca", "=", "$", "this", "->", "createController", "(", "$", "route", ")", ")", "!==", "null", ")", "{", "/** @var \\Mindy\\Controller\\BaseController $controller */", "lis...
Creates the controller and performs the specified action. @param string $route the route of the current request. See {@link createController} for more details. @throws HttpException if the controller could not be created.
[ "Creates", "the", "controller", "and", "performs", "the", "specified", "action", "." ]
07f7e0f4a83e0f9a5f11edca2b3df540760757eb
https://github.com/hashstudio/Mindy_Application/blob/07f7e0f4a83e0f9a5f11edca2b3df540760757eb/src/Mindy/Application/Application.php#L102-L126
238,026
hashstudio/Mindy_Application
src/Mindy/Application/Application.php
Application.createController
public function createController($route, $owner = null) { if ($owner === null) { $owner = $this; } if ($route) { list($handler, $vars) = $route; if ($handler instanceof Closure) { $handler->__invoke($this->getComponent('request')); $this->end(); } else { list($className, $actionName) = $handler; $controller = Creator::createObject($className, time(), $owner === $this ? null : $owner, $this->getComponent('request')); return [$controller, $actionName, array_merge($_GET, $vars)]; } } return null; }
php
public function createController($route, $owner = null) { if ($owner === null) { $owner = $this; } if ($route) { list($handler, $vars) = $route; if ($handler instanceof Closure) { $handler->__invoke($this->getComponent('request')); $this->end(); } else { list($className, $actionName) = $handler; $controller = Creator::createObject($className, time(), $owner === $this ? null : $owner, $this->getComponent('request')); return [$controller, $actionName, array_merge($_GET, $vars)]; } } return null; }
[ "public", "function", "createController", "(", "$", "route", ",", "$", "owner", "=", "null", ")", "{", "if", "(", "$", "owner", "===", "null", ")", "{", "$", "owner", "=", "$", "this", ";", "}", "if", "(", "$", "route", ")", "{", "list", "(", "...
Creates a controller instance based on a route. The route should contain the controller ID and the action ID. It may also contain additional GET variables. All these must be concatenated together with slashes. This method will attempt to create a controller in the following order: <ol> <li>If the first segment is found in {@link controllerMap}, the corresponding controller configuration will be used to create the controller;</li> <li>If the first segment is found to be a module ID, the corresponding module will be used to create the controller;</li> <li>Otherwise, it will search under the {@link controllerPath} to create the corresponding controller. For example, if the route is "admin/user/create", then the controller will be created using the class file "protected/controllers/admin/UserController.php".</li> </ol> @param \Mindy\Router\Route $route the route of the request. @param \Mindy\Base\Module $owner the module that the new controller will belong to. Defaults to null, meaning the application instance is the owner. @return array the controller instance and the action ID. Null if the controller class does not exist or the route is invalid.
[ "Creates", "a", "controller", "instance", "based", "on", "a", "route", ".", "The", "route", "should", "contain", "the", "controller", "ID", "and", "the", "action", "ID", ".", "It", "may", "also", "contain", "additional", "GET", "variables", ".", "All", "th...
07f7e0f4a83e0f9a5f11edca2b3df540760757eb
https://github.com/hashstudio/Mindy_Application/blob/07f7e0f4a83e0f9a5f11edca2b3df540760757eb/src/Mindy/Application/Application.php#L148-L167
238,027
hashstudio/Mindy_Application
src/Mindy/Application/Application.php
Application.parseActionParams
protected function parseActionParams($pathInfo) { if (($pos = strpos($pathInfo, '/')) !== false) { $manager = $this->getUrlManager(); $manager->parsePathInfo((string)substr($pathInfo, $pos + 1)); $actionID = substr($pathInfo, 0, $pos); return $manager->caseSensitive ? $actionID : strtolower($actionID); } else { return $pathInfo; } }
php
protected function parseActionParams($pathInfo) { if (($pos = strpos($pathInfo, '/')) !== false) { $manager = $this->getUrlManager(); $manager->parsePathInfo((string)substr($pathInfo, $pos + 1)); $actionID = substr($pathInfo, 0, $pos); return $manager->caseSensitive ? $actionID : strtolower($actionID); } else { return $pathInfo; } }
[ "protected", "function", "parseActionParams", "(", "$", "pathInfo", ")", "{", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "pathInfo", ",", "'/'", ")", ")", "!==", "false", ")", "{", "$", "manager", "=", "$", "this", "->", "getUrlManager", "(...
Parses a path info into an action ID and GET variables. @param string $pathInfo path info @return string action ID
[ "Parses", "a", "path", "info", "into", "an", "action", "ID", "and", "GET", "variables", "." ]
07f7e0f4a83e0f9a5f11edca2b3df540760757eb
https://github.com/hashstudio/Mindy_Application/blob/07f7e0f4a83e0f9a5f11edca2b3df540760757eb/src/Mindy/Application/Application.php#L174-L184
238,028
hashstudio/Mindy_Application
src/Mindy/Application/Application.php
Application.findModule
public function findModule($id) { if (($controller = $this->getController()) !== null && ($module = $controller->getModule()) !== null) { do { if (($m = $module->getModule($id)) !== null) { return $m; } } while (($module = $module->getParentModule()) !== null); } if (($m = $this->getModule($id)) !== null) { return $m; } }
php
public function findModule($id) { if (($controller = $this->getController()) !== null && ($module = $controller->getModule()) !== null) { do { if (($m = $module->getModule($id)) !== null) { return $m; } } while (($module = $module->getParentModule()) !== null); } if (($m = $this->getModule($id)) !== null) { return $m; } }
[ "public", "function", "findModule", "(", "$", "id", ")", "{", "if", "(", "(", "$", "controller", "=", "$", "this", "->", "getController", "(", ")", ")", "!==", "null", "&&", "(", "$", "module", "=", "$", "controller", "->", "getModule", "(", ")", "...
Do not call this method. This method is used internally to search for a module by its ID. @param string $id module ID @return \Mindy\Base\Module the module that has the specified ID. Null if no module is found.
[ "Do", "not", "call", "this", "method", ".", "This", "method", "is", "used", "internally", "to", "search", "for", "a", "module", "by", "its", "ID", "." ]
07f7e0f4a83e0f9a5f11edca2b3df540760757eb
https://github.com/hashstudio/Mindy_Application/blob/07f7e0f4a83e0f9a5f11edca2b3df540760757eb/src/Mindy/Application/Application.php#L246-L258
238,029
hashstudio/Mindy_Application
src/Mindy/Application/Application.php
Application.init
public function init() { if (Console::isCli()) { // fix for fcgi defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); if (!isset($_SERVER['argv'])) { die('This script must be run from the command line.'); } $this->_runner = $this->createCommandRunner(); $this->_runner->commands = $this->commandMap; $this->_runner->addCommands($this->getCommandPath()); $env = @getenv('CONSOLE_COMMANDS'); if (!empty($env)) { $this->_runner->addCommands($env); } foreach ($this->modules as $name => $settings) { $modulePath = Alias::get("Modules." . $name . ".Commands"); if ($modulePath) { $this->_runner->addCommands($modulePath); } } } else { // preload 'request' so that it has chance to respond to onBeginRequest event. $this->getComponent('request'); } }
php
public function init() { if (Console::isCli()) { // fix for fcgi defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); if (!isset($_SERVER['argv'])) { die('This script must be run from the command line.'); } $this->_runner = $this->createCommandRunner(); $this->_runner->commands = $this->commandMap; $this->_runner->addCommands($this->getCommandPath()); $env = @getenv('CONSOLE_COMMANDS'); if (!empty($env)) { $this->_runner->addCommands($env); } foreach ($this->modules as $name => $settings) { $modulePath = Alias::get("Modules." . $name . ".Commands"); if ($modulePath) { $this->_runner->addCommands($modulePath); } } } else { // preload 'request' so that it has chance to respond to onBeginRequest event. $this->getComponent('request'); } }
[ "public", "function", "init", "(", ")", "{", "if", "(", "Console", "::", "isCli", "(", ")", ")", "{", "// fix for fcgi", "defined", "(", "'STDIN'", ")", "or", "define", "(", "'STDIN'", ",", "fopen", "(", "'php://stdin'", ",", "'r'", ")", ")", ";", "i...
Initializes the application. This method overrides the parent implementation by preloading the 'request' component.
[ "Initializes", "the", "application", ".", "This", "method", "overrides", "the", "parent", "implementation", "by", "preloading", "the", "request", "component", "." ]
07f7e0f4a83e0f9a5f11edca2b3df540760757eb
https://github.com/hashstudio/Mindy_Application/blob/07f7e0f4a83e0f9a5f11edca2b3df540760757eb/src/Mindy/Application/Application.php#L365-L393
238,030
samurai-fw/samurai
src/Samurai/Component/Spec/Runner/Runner.php
Runner.findConfigurationFile
public function findConfigurationFile($filename = null, $pwd = null) { $filename = $filename ?: $this->getConfigurationFileName(); $pwd = $pwd ?: getcwd(); $dirs = explode(DS, $pwd); $find = false; do { $dir = join(DS, $dirs); $config_file_path = $dir . DS . $filename; if (file_exists($config_file_path) && is_file($config_file_path)) return $config_file_path; } while (array_pop($dirs)); return $pwd . DS . $filename; }
php
public function findConfigurationFile($filename = null, $pwd = null) { $filename = $filename ?: $this->getConfigurationFileName(); $pwd = $pwd ?: getcwd(); $dirs = explode(DS, $pwd); $find = false; do { $dir = join(DS, $dirs); $config_file_path = $dir . DS . $filename; if (file_exists($config_file_path) && is_file($config_file_path)) return $config_file_path; } while (array_pop($dirs)); return $pwd . DS . $filename; }
[ "public", "function", "findConfigurationFile", "(", "$", "filename", "=", "null", ",", "$", "pwd", "=", "null", ")", "{", "$", "filename", "=", "$", "filename", "?", ":", "$", "this", "->", "getConfigurationFileName", "(", ")", ";", "$", "pwd", "=", "$...
find configuration file @param string $filename @param string $pwd @return string
[ "find", "configuration", "file" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Spec/Runner/Runner.php#L149-L164
238,031
samurai-fw/samurai
src/Samurai/Component/Spec/Runner/Runner.php
Runner.loadConfigurationFile
public function loadConfigurationFile($file = null) { $file = $file ?: $this->findConfigurationFile(); if (! file_exists($file)) return; $this->config = $this->yaml->load($file); }
php
public function loadConfigurationFile($file = null) { $file = $file ?: $this->findConfigurationFile(); if (! file_exists($file)) return; $this->config = $this->yaml->load($file); }
[ "public", "function", "loadConfigurationFile", "(", "$", "file", "=", "null", ")", "{", "$", "file", "=", "$", "file", "?", ":", "$", "this", "->", "findConfigurationFile", "(", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "re...
load configuraton file @param string $file
[ "load", "configuraton", "file" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Spec/Runner/Runner.php#L171-L178
238,032
tomvlk/sweet-orm
src/SweetORM/Structure/Annotation/Constraint.php
Constraint.valid
public function valid ($value) { $valid = true; $error = array(); if ($this->minLength !== null && ! (strlen($value) >= $this->minLength)) { $valid = false; $error[] = 'minimum length'; } if ($this->maxLength !== null && ! (strlen($value) <= $this->maxLength)) { $valid = false; $error[] = 'maximum length'; } // var_dump(array('cur' => $value, 'min' => $this->minValue)); if ($this->minValue !== null && (! is_numeric($value) || ! ($value >= $this->minValue))) { $valid = false; $error[] = 'minimum value'; } if ($this->maxValue !== null && (! is_numeric($value) || ! ($value <= $this->maxValue))) { $valid = false; $error[] = 'maximum value'; } if ($this->startsWith !== null && ! (strpos($value, $this->startsWith) === 0)) { $valid = false; $error[] = 'starts with'; } if ($this->endsWith !== null && ! (strpos($value, $this->endsWith) === strlen($value)-strlen($this->endsWith))) { $valid = false; $error[] = 'ends with'; } if ($this->regex !== null && ! preg_match($this->regex, $value)) { $valid = false; $error[] = 'valid custom field'; } if ($this->enum !== null && is_array($this->enum)) { if (! in_array($value, $this->enum)) { $valid = false; $error[] = 'is value of list'; } } if ($this->valid !== null) { switch ($this->valid) { case 'email': if (! filter_var($value, FILTER_VALIDATE_EMAIL)) $valid = false; break; case 'url': if (! filter_var($value, FILTER_VALIDATE_URL)) $valid = false; break; default: $valid = false; } } if (! $valid) { $error[] = 'valid \'' . $this->valid . '\''; } return $valid === true ? true : $error; }
php
public function valid ($value) { $valid = true; $error = array(); if ($this->minLength !== null && ! (strlen($value) >= $this->minLength)) { $valid = false; $error[] = 'minimum length'; } if ($this->maxLength !== null && ! (strlen($value) <= $this->maxLength)) { $valid = false; $error[] = 'maximum length'; } // var_dump(array('cur' => $value, 'min' => $this->minValue)); if ($this->minValue !== null && (! is_numeric($value) || ! ($value >= $this->minValue))) { $valid = false; $error[] = 'minimum value'; } if ($this->maxValue !== null && (! is_numeric($value) || ! ($value <= $this->maxValue))) { $valid = false; $error[] = 'maximum value'; } if ($this->startsWith !== null && ! (strpos($value, $this->startsWith) === 0)) { $valid = false; $error[] = 'starts with'; } if ($this->endsWith !== null && ! (strpos($value, $this->endsWith) === strlen($value)-strlen($this->endsWith))) { $valid = false; $error[] = 'ends with'; } if ($this->regex !== null && ! preg_match($this->regex, $value)) { $valid = false; $error[] = 'valid custom field'; } if ($this->enum !== null && is_array($this->enum)) { if (! in_array($value, $this->enum)) { $valid = false; $error[] = 'is value of list'; } } if ($this->valid !== null) { switch ($this->valid) { case 'email': if (! filter_var($value, FILTER_VALIDATE_EMAIL)) $valid = false; break; case 'url': if (! filter_var($value, FILTER_VALIDATE_URL)) $valid = false; break; default: $valid = false; } } if (! $valid) { $error[] = 'valid \'' . $this->valid . '\''; } return $valid === true ? true : $error; }
[ "public", "function", "valid", "(", "$", "value", ")", "{", "$", "valid", "=", "true", ";", "$", "error", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "minLength", "!==", "null", "&&", "!", "(", "strlen", "(", "$", "value", ")", "...
Validate constraints. @param $value @return true|array True on success, error will give array that contains error messages.
[ "Validate", "constraints", "." ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Structure/Annotation/Constraint.php#L82-L149
238,033
zicht/z-plugin-qa
qa/Plugin.php
Plugin.appendConfiguration
public function appendConfiguration(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('qa') ->children() ->arrayNode('phpcs') ->children() ->arrayNode('dir') ->prototype('scalar')->end() ->performNoDeepMerging() ->end() ->scalarNode('standard')->end() ->scalarNode('options')->end() ->end() ->end() ->arrayNode('jshint') ->children() ->arrayNode('files') ->beforeNormalization() ->ifString()->then( function($v) { return array_filter(array($v)); } ) ->end() ->prototype('scalar')->end() ->performNoDeepMerging() ->end() ->scalarNode('run')->end() ->end() ->end() ->end() ->end(); }
php
public function appendConfiguration(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('qa') ->children() ->arrayNode('phpcs') ->children() ->arrayNode('dir') ->prototype('scalar')->end() ->performNoDeepMerging() ->end() ->scalarNode('standard')->end() ->scalarNode('options')->end() ->end() ->end() ->arrayNode('jshint') ->children() ->arrayNode('files') ->beforeNormalization() ->ifString()->then( function($v) { return array_filter(array($v)); } ) ->end() ->prototype('scalar')->end() ->performNoDeepMerging() ->end() ->scalarNode('run')->end() ->end() ->end() ->end() ->end(); }
[ "public", "function", "appendConfiguration", "(", "ArrayNodeDefinition", "$", "rootNode", ")", "{", "$", "rootNode", "->", "children", "(", ")", "->", "arrayNode", "(", "'qa'", ")", "->", "children", "(", ")", "->", "arrayNode", "(", "'phpcs'", ")", "->", ...
Appends the QA configuration @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode @return void
[ "Appends", "the", "QA", "configuration" ]
eea78e4eb604a41969108523f123d0f3a795503f
https://github.com/zicht/z-plugin-qa/blob/eea78e4eb604a41969108523f123d0f3a795503f/qa/Plugin.php#L25-L59
238,034
deasilworks/cef
src/Cassandra/Transformer.php
Transformer.transformRows
public function transformRows(\Cassandra\Rows $rows) { $entries = []; // page through all results and transform as we go while (true) { while ($rows->valid()) { // transform $entry = $this->transform($rows->current()); if ($entry) { array_push($entries, $entry); } $rows->next(); } if ($rows->isLastPage()) { break; } $rows = $rows->nextPage(); } return $entries; }
php
public function transformRows(\Cassandra\Rows $rows) { $entries = []; // page through all results and transform as we go while (true) { while ($rows->valid()) { // transform $entry = $this->transform($rows->current()); if ($entry) { array_push($entries, $entry); } $rows->next(); } if ($rows->isLastPage()) { break; } $rows = $rows->nextPage(); } return $entries; }
[ "public", "function", "transformRows", "(", "\\", "Cassandra", "\\", "Rows", "$", "rows", ")", "{", "$", "entries", "=", "[", "]", ";", "// page through all results and transform as we go", "while", "(", "true", ")", "{", "while", "(", "$", "rows", "->", "va...
Transform Cassandra Rows. @param \Cassandra\Rows $rows @return array
[ "Transform", "Cassandra", "Rows", "." ]
18c65f2b123512bba2208975dc655354f57670be
https://github.com/deasilworks/cef/blob/18c65f2b123512bba2208975dc655354f57670be/src/Cassandra/Transformer.php#L46-L72
238,035
novuso/common
src/Application/Logging/SqlLogger.php
SqlLogger.log
public function log(string $sql, array $parameters = []): void { $message = sprintf('[SQL]: %s', $this->removeWhitespace($sql)); $this->logger->log($this->logLevel, $message, $parameters); }
php
public function log(string $sql, array $parameters = []): void { $message = sprintf('[SQL]: %s', $this->removeWhitespace($sql)); $this->logger->log($this->logLevel, $message, $parameters); }
[ "public", "function", "log", "(", "string", "$", "sql", ",", "array", "$", "parameters", "=", "[", "]", ")", ":", "void", "{", "$", "message", "=", "sprintf", "(", "'[SQL]: %s'", ",", "$", "this", "->", "removeWhitespace", "(", "$", "sql", ")", ")", ...
Logs SQL and parameters @param string $sql The SQL statement @param array $parameters The parameters @return void
[ "Logs", "SQL", "and", "parameters" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Logging/SqlLogger.php#L51-L55
238,036
rozaverta/cmf
core/Cmd/IO/ConfigOption.php
ConfigOption.setValue
public function setValue($value) { // set default if( $value === "" ) { $value = $this->value; } if( $this->type === "boolean" ) { $value = is_bool($value) ? $value : in_array($value, ['y', 'yes', 'on', '1']); } else if( $this->type === "number" ) { if( ! is_numeric($value) ) { throw new \InvalidArgumentException($this->getTheTitle() . " must be a number"); } $value = (float) $value; if( $this->required && $value === 0 ) { throw new \InvalidArgumentException($this->getTheTitle() . " is required"); } } else if( $this->type === "enum" ) { if( ! in_array($value, $this->enum, true) ) { $variant = "'" . implode("' or '", $this->enum) . "'"; throw new \InvalidArgumentException($this->getTheTitle() . " must be equal " . $variant); } } else { $value = trim($value); if( $this->required && ! strlen($value) ) { throw new \InvalidArgumentException($this->getTheTitle() . " is required"); } } if( $this->type_of ) { $value = call_user_func($this->type_of, $value); if( $value === false && $this->type !== "boolean" ) { throw new \InvalidArgumentException($this->getTheTitle() . " value is invalid"); } } $this->value = $value; return $this; }
php
public function setValue($value) { // set default if( $value === "" ) { $value = $this->value; } if( $this->type === "boolean" ) { $value = is_bool($value) ? $value : in_array($value, ['y', 'yes', 'on', '1']); } else if( $this->type === "number" ) { if( ! is_numeric($value) ) { throw new \InvalidArgumentException($this->getTheTitle() . " must be a number"); } $value = (float) $value; if( $this->required && $value === 0 ) { throw new \InvalidArgumentException($this->getTheTitle() . " is required"); } } else if( $this->type === "enum" ) { if( ! in_array($value, $this->enum, true) ) { $variant = "'" . implode("' or '", $this->enum) . "'"; throw new \InvalidArgumentException($this->getTheTitle() . " must be equal " . $variant); } } else { $value = trim($value); if( $this->required && ! strlen($value) ) { throw new \InvalidArgumentException($this->getTheTitle() . " is required"); } } if( $this->type_of ) { $value = call_user_func($this->type_of, $value); if( $value === false && $this->type !== "boolean" ) { throw new \InvalidArgumentException($this->getTheTitle() . " value is invalid"); } } $this->value = $value; return $this; }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "// set default", "if", "(", "$", "value", "===", "\"\"", ")", "{", "$", "value", "=", "$", "this", "->", "value", ";", "}", "if", "(", "$", "this", "->", "type", "===", "\"boolean\"", ...
Set new value @param $value @return $this
[ "Set", "new", "value" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Cmd/IO/ConfigOption.php#L91-L143
238,037
cstabor/screw
src/Screw/ProcessUtil.php
ProcessUtil.exec
public static function exec($cmd, $timeout, &$code) { $code = -11; // File descriptors passed to the process. $descriptors = [ 0 => ['pipe', 'r'], // stdin 1 => ['pipe', 'w'], // stdout 2 => ['pipe', 'w'] // stderr ]; // Start the process. $process = proc_open('exec ' . $cmd, $descriptors, $pipes); if (!is_resource($process)) { throw new \Exception('Could not execute process'); } // Set the stdout stream to none-blocking. stream_set_blocking($pipes[1], 0); stream_set_blocking($pipes[2], 0); // Turn the timeout into microseconds. $timeout *= 1000000; // Output buffer. $buffer = ''; // While we have time to wait. while ($timeout > 0) { $start = microtime(true); // Wait until we have output or the timer expired. $read = [$pipes[1]]; $write = $other = []; stream_select($read, $write, $other, 0, $timeout); // Get the status of the process. // Do this before we read from the stream, // this way we can't lose the last bit of output if the process dies between these functions. $status = proc_get_status($process); if (false === $status['running']) { $code = $status['exitcode']; } // Read the contents from the buffer. // This function will always return immediately as the stream is none-blocking. $buffer .= stream_get_contents($pipes[1]); if (!$status['running']) { break; // Break from this loop if the process exited before the timeout. } // Subtract the number of microseconds that we waited. $timeout -= (microtime(true) - $start) * 1000000; } // Check if there were any errors. $errors = stream_get_contents($pipes[2]); if (!empty($errors)) { throw new \Exception($errors); } // Kill the process in case the timeout expired and it's still running. // If the process already exited this won't do anything. proc_terminate($process, 9); // Close all streams. fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); proc_close($process); return $buffer; }
php
public static function exec($cmd, $timeout, &$code) { $code = -11; // File descriptors passed to the process. $descriptors = [ 0 => ['pipe', 'r'], // stdin 1 => ['pipe', 'w'], // stdout 2 => ['pipe', 'w'] // stderr ]; // Start the process. $process = proc_open('exec ' . $cmd, $descriptors, $pipes); if (!is_resource($process)) { throw new \Exception('Could not execute process'); } // Set the stdout stream to none-blocking. stream_set_blocking($pipes[1], 0); stream_set_blocking($pipes[2], 0); // Turn the timeout into microseconds. $timeout *= 1000000; // Output buffer. $buffer = ''; // While we have time to wait. while ($timeout > 0) { $start = microtime(true); // Wait until we have output or the timer expired. $read = [$pipes[1]]; $write = $other = []; stream_select($read, $write, $other, 0, $timeout); // Get the status of the process. // Do this before we read from the stream, // this way we can't lose the last bit of output if the process dies between these functions. $status = proc_get_status($process); if (false === $status['running']) { $code = $status['exitcode']; } // Read the contents from the buffer. // This function will always return immediately as the stream is none-blocking. $buffer .= stream_get_contents($pipes[1]); if (!$status['running']) { break; // Break from this loop if the process exited before the timeout. } // Subtract the number of microseconds that we waited. $timeout -= (microtime(true) - $start) * 1000000; } // Check if there were any errors. $errors = stream_get_contents($pipes[2]); if (!empty($errors)) { throw new \Exception($errors); } // Kill the process in case the timeout expired and it's still running. // If the process already exited this won't do anything. proc_terminate($process, 9); // Close all streams. fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); proc_close($process); return $buffer; }
[ "public", "static", "function", "exec", "(", "$", "cmd", ",", "$", "timeout", ",", "&", "$", "code", ")", "{", "$", "code", "=", "-", "11", ";", "// File descriptors passed to the process.", "$", "descriptors", "=", "[", "0", "=>", "[", "'pipe'", ",", ...
Execute a command and return it's output. Exit when the timeout has expired. @param string $cmd Command to execute. @param integer $timeout Timeout in seconds. @param integer $code @return string Output of the command. @throws \Exception
[ "Execute", "a", "command", "and", "return", "it", "s", "output", ".", "Exit", "when", "the", "timeout", "has", "expired", "." ]
c160c2b740bd1e0e72535fddf1c15cab99558669
https://github.com/cstabor/screw/blob/c160c2b740bd1e0e72535fddf1c15cab99558669/src/Screw/ProcessUtil.php#L17-L87
238,038
eureka-framework/Eurekon
Out.php
Out.err
public static function err($message, $endLine = PHP_EOL) { if (! Argument::getInstance()->has('quiet')) { fwrite(STDERR, $message . $endLine); } }
php
public static function err($message, $endLine = PHP_EOL) { if (! Argument::getInstance()->has('quiet')) { fwrite(STDERR, $message . $endLine); } }
[ "public", "static", "function", "err", "(", "$", "message", ",", "$", "endLine", "=", "PHP_EOL", ")", "{", "if", "(", "!", "Argument", "::", "getInstance", "(", ")", "->", "has", "(", "'quiet'", ")", ")", "{", "fwrite", "(", "STDERR", ",", "$", "me...
Display message on error output @param string $message @param string $endLine @return void
[ "Display", "message", "on", "error", "output" ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Out.php#L28-L33
238,039
eureka-framework/Eurekon
Out.php
Out.std
public static function std($message, $endLine = PHP_EOL) { if (! Argument::getInstance()->has('quiet')) { fwrite(STDOUT, $message . $endLine); } }
php
public static function std($message, $endLine = PHP_EOL) { if (! Argument::getInstance()->has('quiet')) { fwrite(STDOUT, $message . $endLine); } }
[ "public", "static", "function", "std", "(", "$", "message", ",", "$", "endLine", "=", "PHP_EOL", ")", "{", "if", "(", "!", "Argument", "::", "getInstance", "(", ")", "->", "has", "(", "'quiet'", ")", ")", "{", "fwrite", "(", "STDOUT", ",", "$", "me...
Display message on standart output @param string $message @param string $endLine @return void
[ "Display", "message", "on", "standart", "output" ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Out.php#L42-L47
238,040
lucavicidomini/blade-materialize
src/FormBuilder.php
FormBuilder.checkbox
public function checkbox( $name_id, $checked = false ) { $el = $this->element( 'input', $name_id, 'checkbox' ) ->value( 1 ) ->attribute( 'checked', $checked ? 'checked' : null ); return $el; }
php
public function checkbox( $name_id, $checked = false ) { $el = $this->element( 'input', $name_id, 'checkbox' ) ->value( 1 ) ->attribute( 'checked', $checked ? 'checked' : null ); return $el; }
[ "public", "function", "checkbox", "(", "$", "name_id", ",", "$", "checked", "=", "false", ")", "{", "$", "el", "=", "$", "this", "->", "element", "(", "'input'", ",", "$", "name_id", ",", "'checkbox'", ")", "->", "value", "(", "1", ")", "->", "attr...
Creates a checkbox. @param $name @param $label @param null $cssClasses @param bool $checked @param null $value @return array|HtmlElementsCollection
[ "Creates", "a", "checkbox", "." ]
4683c01f51c056d322fc9133eb5484a9b163e5d0
https://github.com/lucavicidomini/blade-materialize/blob/4683c01f51c056d322fc9133eb5484a9b163e5d0/src/FormBuilder.php#L134-L140
238,041
webforge-labs/webforge-utils
src/php/Webforge/Common/Url.php
Url.addRelativeUrl
public function addRelativeUrl($relativeUrl) { $this->pathTrailingSlash = S::endsWith($relativeUrl, '/'); $parts = array_filter(explode('/', trim($relativeUrl, '/'))); $this->path = array_merge($this->path, $parts); return $this; }
php
public function addRelativeUrl($relativeUrl) { $this->pathTrailingSlash = S::endsWith($relativeUrl, '/'); $parts = array_filter(explode('/', trim($relativeUrl, '/'))); $this->path = array_merge($this->path, $parts); return $this; }
[ "public", "function", "addRelativeUrl", "(", "$", "relativeUrl", ")", "{", "$", "this", "->", "pathTrailingSlash", "=", "S", "::", "endsWith", "(", "$", "relativeUrl", ",", "'/'", ")", ";", "$", "parts", "=", "array_filter", "(", "explode", "(", "'/'", "...
Modifies the current URL with adding an relative Url to the pathParts @param string $url only / slashes, first / is optional no query string, no fragment
[ "Modifies", "the", "current", "URL", "with", "adding", "an", "relative", "Url", "to", "the", "pathParts" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/Url.php#L211-L218
238,042
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/PregReplace.php
PregReplace.filter
public function filter($value) { if (!is_scalar($value) && !is_array($value)) { return $value; } if ($this->options['pattern'] === null) { throw new Exception\RuntimeException(sprintf( 'Filter %s does not have a valid pattern set', get_class($this) )); } return preg_replace($this->options['pattern'], $this->options['replacement'], $value); }
php
public function filter($value) { if (!is_scalar($value) && !is_array($value)) { return $value; } if ($this->options['pattern'] === null) { throw new Exception\RuntimeException(sprintf( 'Filter %s does not have a valid pattern set', get_class($this) )); } return preg_replace($this->options['pattern'], $this->options['replacement'], $value); }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "value", ")", "&&", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "$", "this", "->", "options", ...
Perform regexp replacement as filter @param mixed $value @return mixed @throws Exception\RuntimeException
[ "Perform", "regexp", "replacement", "as", "filter" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/PregReplace.php#L128-L142
238,043
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/PregReplace.php
PregReplace.validatePattern
protected function validatePattern($pattern) { if (!preg_match('/(?<modifier>[imsxeADSUXJu]+)$/', $pattern, $matches)) { return true; } if (false !== strstr($matches['modifier'], 'e')) { throw new Exception\InvalidArgumentException(sprintf( 'Pattern for a PregReplace filter may not contain the "e" pattern modifier; received "%s"', $pattern )); } }
php
protected function validatePattern($pattern) { if (!preg_match('/(?<modifier>[imsxeADSUXJu]+)$/', $pattern, $matches)) { return true; } if (false !== strstr($matches['modifier'], 'e')) { throw new Exception\InvalidArgumentException(sprintf( 'Pattern for a PregReplace filter may not contain the "e" pattern modifier; received "%s"', $pattern )); } }
[ "protected", "function", "validatePattern", "(", "$", "pattern", ")", "{", "if", "(", "!", "preg_match", "(", "'/(?<modifier>[imsxeADSUXJu]+)$/'", ",", "$", "pattern", ",", "$", "matches", ")", ")", "{", "return", "true", ";", "}", "if", "(", "false", "!==...
Validate a pattern and ensure it does not contain the "e" modifier @param string $pattern @return bool @throws Exception\InvalidArgumentException
[ "Validate", "a", "pattern", "and", "ensure", "it", "does", "not", "contain", "the", "e", "modifier" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/PregReplace.php#L151-L163
238,044
m-jch/ZagrosCore
src/models/User.php
User.getRules
public static function getRules($update, $id) { if (is_null($update)) { return static::$registerRules; } static::$updateRules['name'] .= ','.$id.',user_id'; static::$updateRules['email'] .= ','.$id.',user_id'; return static::$updateRules; }
php
public static function getRules($update, $id) { if (is_null($update)) { return static::$registerRules; } static::$updateRules['name'] .= ','.$id.',user_id'; static::$updateRules['email'] .= ','.$id.',user_id'; return static::$updateRules; }
[ "public", "static", "function", "getRules", "(", "$", "update", ",", "$", "id", ")", "{", "if", "(", "is_null", "(", "$", "update", ")", ")", "{", "return", "static", "::", "$", "registerRules", ";", "}", "static", "::", "$", "updateRules", "[", "'na...
Get rules for new or update @param $update string|null @param $id string|null @return array
[ "Get", "rules", "for", "new", "or", "update" ]
06771fe13e77f7663ea5cc561c6078be08b0f557
https://github.com/m-jch/ZagrosCore/blob/06771fe13e77f7663ea5cc561c6078be08b0f557/src/models/User.php#L73-L82
238,045
m-jch/ZagrosCore
src/models/User.php
User.getIsAdminAttribute
public function getIsAdminAttribute() { $project = Project::getProjectByUrl(Route::Input('project')); if ($project) { $admins = explode(',', $project->admins); if (in_array(Auth::id(), $admins)) { return $this->attributes['is_admin'] = true; } return $this->attributes['is_admin'] = false; } }
php
public function getIsAdminAttribute() { $project = Project::getProjectByUrl(Route::Input('project')); if ($project) { $admins = explode(',', $project->admins); if (in_array(Auth::id(), $admins)) { return $this->attributes['is_admin'] = true; } return $this->attributes['is_admin'] = false; } }
[ "public", "function", "getIsAdminAttribute", "(", ")", "{", "$", "project", "=", "Project", "::", "getProjectByUrl", "(", "Route", "::", "Input", "(", "'project'", ")", ")", ";", "if", "(", "$", "project", ")", "{", "$", "admins", "=", "explode", "(", ...
This attribute specified user is admin or not for logined user @return bool
[ "This", "attribute", "specified", "user", "is", "admin", "or", "not", "for", "logined", "user" ]
06771fe13e77f7663ea5cc561c6078be08b0f557
https://github.com/m-jch/ZagrosCore/blob/06771fe13e77f7663ea5cc561c6078be08b0f557/src/models/User.php#L88-L100
238,046
m-jch/ZagrosCore
src/models/User.php
User.getIsWriterAttribute
public function getIsWriterAttribute() { $project = Project::getProjectByUrl(Route::Input('project')); if ($project) { $writers = explode(',', $project->writers); if (in_array(Auth::id(), $writers)) { return $this->attributes['is_writer'] = true; } return $this->attributes['is_writer'] = false; } }
php
public function getIsWriterAttribute() { $project = Project::getProjectByUrl(Route::Input('project')); if ($project) { $writers = explode(',', $project->writers); if (in_array(Auth::id(), $writers)) { return $this->attributes['is_writer'] = true; } return $this->attributes['is_writer'] = false; } }
[ "public", "function", "getIsWriterAttribute", "(", ")", "{", "$", "project", "=", "Project", "::", "getProjectByUrl", "(", "Route", "::", "Input", "(", "'project'", ")", ")", ";", "if", "(", "$", "project", ")", "{", "$", "writers", "=", "explode", "(", ...
This attribute specified user is write or not for logined user @return bool
[ "This", "attribute", "specified", "user", "is", "write", "or", "not", "for", "logined", "user" ]
06771fe13e77f7663ea5cc561c6078be08b0f557
https://github.com/m-jch/ZagrosCore/blob/06771fe13e77f7663ea5cc561c6078be08b0f557/src/models/User.php#L106-L118
238,047
m-jch/ZagrosCore
src/models/User.php
User.getIsReaderAttribute
public function getIsReaderAttribute() { $project = Project::getProjectByUrl(Route::Input('project')); if ($project) { $readers = explode(',', $project->readers); if (in_array(Auth::id(), $readers)) { return $this->attributes['is_reader'] = true; } return $this->attributes['is_reader'] = false; } }
php
public function getIsReaderAttribute() { $project = Project::getProjectByUrl(Route::Input('project')); if ($project) { $readers = explode(',', $project->readers); if (in_array(Auth::id(), $readers)) { return $this->attributes['is_reader'] = true; } return $this->attributes['is_reader'] = false; } }
[ "public", "function", "getIsReaderAttribute", "(", ")", "{", "$", "project", "=", "Project", "::", "getProjectByUrl", "(", "Route", "::", "Input", "(", "'project'", ")", ")", ";", "if", "(", "$", "project", ")", "{", "$", "readers", "=", "explode", "(", ...
This attribute specified user is reader or not for logined user @return bool
[ "This", "attribute", "specified", "user", "is", "reader", "or", "not", "for", "logined", "user" ]
06771fe13e77f7663ea5cc561c6078be08b0f557
https://github.com/m-jch/ZagrosCore/blob/06771fe13e77f7663ea5cc561c6078be08b0f557/src/models/User.php#L124-L136
238,048
m-jch/ZagrosCore
src/models/User.php
User.getGroupIdName
public static function getGroupIdName($users) { $users = explode(",", $users); $usersArray = array(); foreach ($users as $user) { $user = User::find($user); if ($user) $usersArray[] = array('name' => $user->name, 'user_id' => $user->user_id); } return $usersArray; }
php
public static function getGroupIdName($users) { $users = explode(",", $users); $usersArray = array(); foreach ($users as $user) { $user = User::find($user); if ($user) $usersArray[] = array('name' => $user->name, 'user_id' => $user->user_id); } return $usersArray; }
[ "public", "static", "function", "getGroupIdName", "(", "$", "users", ")", "{", "$", "users", "=", "explode", "(", "\",\"", ",", "$", "users", ")", ";", "$", "usersArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ...
Get id of groups permission @param $projectId int @return array
[ "Get", "id", "of", "groups", "permission" ]
06771fe13e77f7663ea5cc561c6078be08b0f557
https://github.com/m-jch/ZagrosCore/blob/06771fe13e77f7663ea5cc561c6078be08b0f557/src/models/User.php#L143-L154
238,049
joegreen88/zf1-component-locale
src/Zend/Locale/Data.php
Zend_Locale_Data._readFile
private static function _readFile($locale, $path, $attribute, $value, $temp) { // without attribute - read all values // with attribute - read only this value if (!empty(self::$_ldml[(string) $locale])) { $result = self::$_ldml[(string) $locale]->xpath($path); if (!empty($result)) { foreach ($result as &$found) { if (empty($value)) { if (empty($attribute)) { // Case 1 $temp[] = (string) $found; } else if (empty($temp[(string) $found[$attribute]])){ // Case 2 $temp[(string) $found[$attribute]] = (string) $found; } } else if (empty ($temp[$value])) { if (empty($attribute)) { // Case 3 $temp[$value] = (string) $found; } else { // Case 4 $temp[$value] = (string) $found[$attribute]; } } } } } return $temp; }
php
private static function _readFile($locale, $path, $attribute, $value, $temp) { // without attribute - read all values // with attribute - read only this value if (!empty(self::$_ldml[(string) $locale])) { $result = self::$_ldml[(string) $locale]->xpath($path); if (!empty($result)) { foreach ($result as &$found) { if (empty($value)) { if (empty($attribute)) { // Case 1 $temp[] = (string) $found; } else if (empty($temp[(string) $found[$attribute]])){ // Case 2 $temp[(string) $found[$attribute]] = (string) $found; } } else if (empty ($temp[$value])) { if (empty($attribute)) { // Case 3 $temp[$value] = (string) $found; } else { // Case 4 $temp[$value] = (string) $found[$attribute]; } } } } } return $temp; }
[ "private", "static", "function", "_readFile", "(", "$", "locale", ",", "$", "path", ",", "$", "attribute", ",", "$", "value", ",", "$", "temp", ")", "{", "// without attribute - read all values", "// with attribute - read only this value", "if", "(", "!", "empt...
Read the content from locale Can be called like: <ldml> <delimiter>test</delimiter> <second type='myone'>content</second> <second type='mysecond'>content2</second> <third type='mythird' /> </ldml> Case 1: _readFile('ar','/ldml/delimiter') -> returns [] = test Case 1: _readFile('ar','/ldml/second[@type=myone]') -> returns [] = content Case 2: _readFile('ar','/ldml/second','type') -> returns [myone] = content; [mysecond] = content2 Case 3: _readFile('ar','/ldml/delimiter',,'right') -> returns [right] = test Case 4: _readFile('ar','/ldml/third','type','myone') -> returns [myone] = mythird @param string $locale @param string $path @param string $attribute @param string $value @access private @return array
[ "Read", "the", "content", "from", "locale" ]
2e8dab3c9a1878f91ff2b934716638f4eb2e7f94
https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Data.php#L101-L136
238,050
joegreen88/zf1-component-locale
src/Zend/Locale/Data.php
Zend_Locale_Data._findRoute
private static function _findRoute($locale, $path, $attribute, $value, &$temp) { // load locale file if not already in cache // needed for alias tag when referring to other locale if (empty(self::$_ldml[(string) $locale])) { $filename = dirname(__FILE__) . '/Data/' . $locale . '.xml'; if (!file_exists($filename)) { throw new Zend_Locale_Exception("Missing locale file '$filename' for '$locale' locale."); } self::$_ldml[(string) $locale] = simplexml_load_file($filename); } // search for 'alias' tag in the search path for redirection $search = ''; $tok = strtok($path, '/'); // parse the complete path if (!empty(self::$_ldml[(string) $locale])) { while ($tok !== false) { $search .= '/' . $tok; if (strpos($search, '[@') !== false) { while (strrpos($search, '[@') > strrpos($search, ']')) { $tok = strtok('/'); if (empty($tok)) { $search .= '/'; } $search = $search . '/' . $tok; } } $result = self::$_ldml[(string) $locale]->xpath($search . '/alias'); // alias found if (!empty($result)) { $source = $result[0]['source']; $newpath = $result[0]['path']; // new path - path //ldml is to ignore if ($newpath != '//ldml') { // other path - parse to make real path while (substr($newpath,0,3) == '../') { $newpath = substr($newpath, 3); $search = substr($search, 0, strrpos($search, '/')); } // truncate ../ to realpath otherwise problems with alias $path = $search . '/' . $newpath; while (($tok = strtok('/'))!== false) { $path = $path . '/' . $tok; } } // reroute to other locale if ($source != 'locale') { $locale = $source; } $temp = self::_getFile($locale, $path, $attribute, $value, $temp); return false; } $tok = strtok('/'); } } return true; }
php
private static function _findRoute($locale, $path, $attribute, $value, &$temp) { // load locale file if not already in cache // needed for alias tag when referring to other locale if (empty(self::$_ldml[(string) $locale])) { $filename = dirname(__FILE__) . '/Data/' . $locale . '.xml'; if (!file_exists($filename)) { throw new Zend_Locale_Exception("Missing locale file '$filename' for '$locale' locale."); } self::$_ldml[(string) $locale] = simplexml_load_file($filename); } // search for 'alias' tag in the search path for redirection $search = ''; $tok = strtok($path, '/'); // parse the complete path if (!empty(self::$_ldml[(string) $locale])) { while ($tok !== false) { $search .= '/' . $tok; if (strpos($search, '[@') !== false) { while (strrpos($search, '[@') > strrpos($search, ']')) { $tok = strtok('/'); if (empty($tok)) { $search .= '/'; } $search = $search . '/' . $tok; } } $result = self::$_ldml[(string) $locale]->xpath($search . '/alias'); // alias found if (!empty($result)) { $source = $result[0]['source']; $newpath = $result[0]['path']; // new path - path //ldml is to ignore if ($newpath != '//ldml') { // other path - parse to make real path while (substr($newpath,0,3) == '../') { $newpath = substr($newpath, 3); $search = substr($search, 0, strrpos($search, '/')); } // truncate ../ to realpath otherwise problems with alias $path = $search . '/' . $newpath; while (($tok = strtok('/'))!== false) { $path = $path . '/' . $tok; } } // reroute to other locale if ($source != 'locale') { $locale = $source; } $temp = self::_getFile($locale, $path, $attribute, $value, $temp); return false; } $tok = strtok('/'); } } return true; }
[ "private", "static", "function", "_findRoute", "(", "$", "locale", ",", "$", "path", ",", "$", "attribute", ",", "$", "value", ",", "&", "$", "temp", ")", "{", "// load locale file if not already in cache", "// needed for alias tag when referring to other locale", "if...
Find possible routing to other path or locale @param string $locale @param string $path @param string $attribute @param string $value @param array $temp @throws Zend_Locale_Exception @access private
[ "Find", "possible", "routing", "to", "other", "path", "or", "locale" ]
2e8dab3c9a1878f91ff2b934716638f4eb2e7f94
https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Data.php#L149-L217
238,051
joegreen88/zf1-component-locale
src/Zend/Locale/Data.php
Zend_Locale_Data._getFile
private static function _getFile($locale, $path, $attribute = false, $value = false, $temp = array()) { $result = self::_findRoute($locale, $path, $attribute, $value, $temp); if ($result) { $temp = self::_readFile($locale, $path, $attribute, $value, $temp); } // parse required locales reversive // example: when given zh_Hans_CN // 1. -> zh_Hans_CN // 2. -> zh_Hans // 3. -> zh // 4. -> root if (($locale != 'root') && ($result)) { $locale = substr($locale, 0, -strlen(strrchr($locale, '_'))); if (!empty($locale)) { $temp = self::_getFile($locale, $path, $attribute, $value, $temp); } else { $temp = self::_getFile('root', $path, $attribute, $value, $temp); } } return $temp; }
php
private static function _getFile($locale, $path, $attribute = false, $value = false, $temp = array()) { $result = self::_findRoute($locale, $path, $attribute, $value, $temp); if ($result) { $temp = self::_readFile($locale, $path, $attribute, $value, $temp); } // parse required locales reversive // example: when given zh_Hans_CN // 1. -> zh_Hans_CN // 2. -> zh_Hans // 3. -> zh // 4. -> root if (($locale != 'root') && ($result)) { $locale = substr($locale, 0, -strlen(strrchr($locale, '_'))); if (!empty($locale)) { $temp = self::_getFile($locale, $path, $attribute, $value, $temp); } else { $temp = self::_getFile('root', $path, $attribute, $value, $temp); } } return $temp; }
[ "private", "static", "function", "_getFile", "(", "$", "locale", ",", "$", "path", ",", "$", "attribute", "=", "false", ",", "$", "value", "=", "false", ",", "$", "temp", "=", "array", "(", ")", ")", "{", "$", "result", "=", "self", "::", "_findRou...
Read the right LDML file @param string $locale @param string $path @param string $attribute @param string $value @access private
[ "Read", "the", "right", "LDML", "file" ]
2e8dab3c9a1878f91ff2b934716638f4eb2e7f94
https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Data.php#L228-L250
238,052
joegreen88/zf1-component-locale
src/Zend/Locale/Data.php
Zend_Locale_Data._calendarDetail
private static function _calendarDetail($locale, $list) { $ret = "001"; foreach ($list as $key => $value) { if (strpos($locale, '_') !== false) { $locale = substr($locale, strpos($locale, '_') + 1); } if (strpos($key, $locale) !== false) { $ret = $key; break; } } return $ret; }
php
private static function _calendarDetail($locale, $list) { $ret = "001"; foreach ($list as $key => $value) { if (strpos($locale, '_') !== false) { $locale = substr($locale, strpos($locale, '_') + 1); } if (strpos($key, $locale) !== false) { $ret = $key; break; } } return $ret; }
[ "private", "static", "function", "_calendarDetail", "(", "$", "locale", ",", "$", "list", ")", "{", "$", "ret", "=", "\"001\"", ";", "foreach", "(", "$", "list", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "locale...
Find the details for supplemental calendar datas @param string $locale Locale for Detaildata @param array $list List to search @return string Key for Detaildata
[ "Find", "the", "details", "for", "supplemental", "calendar", "datas" ]
2e8dab3c9a1878f91ff2b934716638f4eb2e7f94
https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Data.php#L259-L272
238,053
joegreen88/zf1-component-locale
src/Zend/Locale/Data.php
Zend_Locale_Data._checkLocale
private static function _checkLocale($locale) { if (empty($locale)) { $locale = new Zend_Locale(); } if (!(Zend_Locale::isLocale((string) $locale, null, false))) { throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale"); } return (string) $locale; }
php
private static function _checkLocale($locale) { if (empty($locale)) { $locale = new Zend_Locale(); } if (!(Zend_Locale::isLocale((string) $locale, null, false))) { throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale"); } return (string) $locale; }
[ "private", "static", "function", "_checkLocale", "(", "$", "locale", ")", "{", "if", "(", "empty", "(", "$", "locale", ")", ")", "{", "$", "locale", "=", "new", "Zend_Locale", "(", ")", ";", "}", "if", "(", "!", "(", "Zend_Locale", "::", "isLocale", ...
Internal function for checking the locale @param string|Zend_Locale $locale Locale to check @return string
[ "Internal", "function", "for", "checking", "the", "locale" ]
2e8dab3c9a1878f91ff2b934716638f4eb2e7f94
https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Data.php#L280-L292
238,054
joegreen88/zf1-component-locale
src/Zend/Locale/Data.php
Zend_Locale_Data.clearCache
public static function clearCache() { if (self::$_cacheTags) { self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Zend_Locale')); } else { self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL); } }
php
public static function clearCache() { if (self::$_cacheTags) { self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Zend_Locale')); } else { self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL); } }
[ "public", "static", "function", "clearCache", "(", ")", "{", "if", "(", "self", "::", "$", "_cacheTags", ")", "{", "self", "::", "$", "_cache", "->", "clean", "(", "Zend_Cache", "::", "CLEANING_MODE_MATCHING_TAG", ",", "array", "(", "'Zend_Locale'", ")", "...
Clears all set cache data @return void
[ "Clears", "all", "set", "cache", "data" ]
2e8dab3c9a1878f91ff2b934716638f4eb2e7f94
https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Data.php#L1481-L1488
238,055
joegreen88/zf1-component-locale
src/Zend/Locale/Data.php
Zend_Locale_Data._getTagSupportForCache
private static function _getTagSupportForCache() { $backend = self::$_cache->getBackend(); if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) { $cacheOptions = $backend->getCapabilities(); self::$_cacheTags = $cacheOptions['tags']; } else { self::$_cacheTags = false; } return self::$_cacheTags; }
php
private static function _getTagSupportForCache() { $backend = self::$_cache->getBackend(); if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) { $cacheOptions = $backend->getCapabilities(); self::$_cacheTags = $cacheOptions['tags']; } else { self::$_cacheTags = false; } return self::$_cacheTags; }
[ "private", "static", "function", "_getTagSupportForCache", "(", ")", "{", "$", "backend", "=", "self", "::", "$", "_cache", "->", "getBackend", "(", ")", ";", "if", "(", "$", "backend", "instanceof", "Zend_Cache_Backend_ExtendedInterface", ")", "{", "$", "cach...
Internal method to check if the given cache supports tags @param Zend_Cache $cache
[ "Internal", "method", "to", "check", "if", "the", "given", "cache", "supports", "tags" ]
2e8dab3c9a1878f91ff2b934716638f4eb2e7f94
https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Data.php#L1505-L1516
238,056
kengoldfarb/underscore_libs
src/_Libs/_Log.php
_Log._getFile
protected static function _getFile($fullPath) { $file = ''; if (preg_match('/\/(_[A-Z].[A-Za-z]+)\.php$/', $fullPath, $matches)) { $file = isset($matches) && isset($matches[1]) ? $matches[1] : $file; self::$numFileLogs = 0; } else { switch (self::$numFileLogs) { case 0: self::_doLog('Unable to get filename for: ' . $fullPath); break; case 1: self::_doLog('MULTIPLE ERRORS ENCOUNTERED GETTING FILE NAMES (no more will be logged): ' . $fullPath); break; default: break; } self::$numFileLogs++; } return $file; }
php
protected static function _getFile($fullPath) { $file = ''; if (preg_match('/\/(_[A-Z].[A-Za-z]+)\.php$/', $fullPath, $matches)) { $file = isset($matches) && isset($matches[1]) ? $matches[1] : $file; self::$numFileLogs = 0; } else { switch (self::$numFileLogs) { case 0: self::_doLog('Unable to get filename for: ' . $fullPath); break; case 1: self::_doLog('MULTIPLE ERRORS ENCOUNTERED GETTING FILE NAMES (no more will be logged): ' . $fullPath); break; default: break; } self::$numFileLogs++; } return $file; }
[ "protected", "static", "function", "_getFile", "(", "$", "fullPath", ")", "{", "$", "file", "=", "''", ";", "if", "(", "preg_match", "(", "'/\\/(_[A-Z].[A-Za-z]+)\\.php$/'", ",", "$", "fullPath", ",", "$", "matches", ")", ")", "{", "$", "file", "=", "iss...
Extracts the filename from a full path @param string $fullPath The full path name @return string The file name
[ "Extracts", "the", "filename", "from", "a", "full", "path" ]
e0d584f25093b594e67b8a3068ebd41c7f6483c5
https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_Log.php#L372-L393
238,057
ellipsephp/providers-session
src/SessionServiceProvider.php
SessionServiceProvider.getSessionHandler
public function getSessionHandler(ContainerInterface $container): SessionHandlerInterface { $prefix = $container->get('ellipse.session.id.prefix'); $ttl = $container->get('ellipse.session.ttl'); $cache = $container->get('ellipse.session.cache'); return new Psr6SessionHandler($cache, ['prefix' => $prefix, 'ttl' => $ttl]); }
php
public function getSessionHandler(ContainerInterface $container): SessionHandlerInterface { $prefix = $container->get('ellipse.session.id.prefix'); $ttl = $container->get('ellipse.session.ttl'); $cache = $container->get('ellipse.session.cache'); return new Psr6SessionHandler($cache, ['prefix' => $prefix, 'ttl' => $ttl]); }
[ "public", "function", "getSessionHandler", "(", "ContainerInterface", "$", "container", ")", ":", "SessionHandlerInterface", "{", "$", "prefix", "=", "$", "container", "->", "get", "(", "'ellipse.session.id.prefix'", ")", ";", "$", "ttl", "=", "$", "container", ...
Return a session handler based on the cache item pool. @param \Psr\Container\ContainerInterface $container @return \SessionHandlerInterface
[ "Return", "a", "session", "handler", "based", "on", "the", "cache", "item", "pool", "." ]
ca1c677d4d345bd40c1cda7fc334bc845eaad197
https://github.com/ellipsephp/providers-session/blob/ca1c677d4d345bd40c1cda7fc334bc845eaad197/src/SessionServiceProvider.php#L87-L94
238,058
ellipsephp/providers-session
src/SessionServiceProvider.php
SessionServiceProvider.getSetSessionHandlerMiddleware
public function getSetSessionHandlerMiddleware(ContainerInterface $container): SetSessionHandlerMiddleware { $handler = $container->get(SessionHandlerInterface::class); return new SetSessionHandlerMiddleware($handler); }
php
public function getSetSessionHandlerMiddleware(ContainerInterface $container): SetSessionHandlerMiddleware { $handler = $container->get(SessionHandlerInterface::class); return new SetSessionHandlerMiddleware($handler); }
[ "public", "function", "getSetSessionHandlerMiddleware", "(", "ContainerInterface", "$", "container", ")", ":", "SetSessionHandlerMiddleware", "{", "$", "handler", "=", "$", "container", "->", "get", "(", "SessionHandlerInterface", "::", "class", ")", ";", "return", ...
Return a set session handler middleware. @param \Psr\Container\ContainerInterface $container @return \Ellipse\Session\SetSessionHandlerMiddleware
[ "Return", "a", "set", "session", "handler", "middleware", "." ]
ca1c677d4d345bd40c1cda7fc334bc845eaad197
https://github.com/ellipsephp/providers-session/blob/ca1c677d4d345bd40c1cda7fc334bc845eaad197/src/SessionServiceProvider.php#L102-L107
238,059
milkyway-multimedia/ss-mwm-core
code/Core/CookieJar.php
CookieJar.updateConfig
protected function updateConfig($key, $value = null, $default = null) { $value = $value ?: singleton('env')->get('Cookie.'.$key); if (!$value && !singleton('env')->get('Cookie.dont_use_same_config_as_sessions')) { $value = singleton('env')->get('Session.'.$key); } if(!$value && $default) { $value = $default; } return $value; }
php
protected function updateConfig($key, $value = null, $default = null) { $value = $value ?: singleton('env')->get('Cookie.'.$key); if (!$value && !singleton('env')->get('Cookie.dont_use_same_config_as_sessions')) { $value = singleton('env')->get('Session.'.$key); } if(!$value && $default) { $value = $default; } return $value; }
[ "protected", "function", "updateConfig", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "$", "value", "?", ":", "singleton", "(", "'env'", ")", "->", "get", "(", "'Cookie.'", ".", "$"...
Allow setting cookie domain @param string $key @param mixed $value @param mixed $default @return mixed
[ "Allow", "setting", "cookie", "domain" ]
e7216653b7100ead5a7d56736a124bee1c76fcd5
https://github.com/milkyway-multimedia/ss-mwm-core/blob/e7216653b7100ead5a7d56736a124bee1c76fcd5/code/Core/CookieJar.php#L45-L58
238,060
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDBquery.append
public function append($query, $args = null) { if ($query instanceof PDBquery) { $args = $query->getArgs(); $query = $query->getQuery(); }; $this->_query .= ' ' . $query; if (is_array($args)) { foreach ($args as $arg) { $this->_args[] = $arg; // Faster than array_merge() which copies }; } elseif ($args !== null) { $this->_args[] = $args; }; return $this; }
php
public function append($query, $args = null) { if ($query instanceof PDBquery) { $args = $query->getArgs(); $query = $query->getQuery(); }; $this->_query .= ' ' . $query; if (is_array($args)) { foreach ($args as $arg) { $this->_args[] = $arg; // Faster than array_merge() which copies }; } elseif ($args !== null) { $this->_args[] = $args; }; return $this; }
[ "public", "function", "append", "(", "$", "query", ",", "$", "args", "=", "null", ")", "{", "if", "(", "$", "query", "instanceof", "PDBquery", ")", "{", "$", "args", "=", "$", "query", "->", "getArgs", "(", ")", ";", "$", "query", "=", "$", "quer...
Append to current query @param string|object $query String portion or other query @param array $args (Optional) List of arguments @return object PDBquery this same object, for chaining
[ "Append", "to", "current", "query" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L86-L101
238,061
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDBquery.implode
public function implode($glue, $queries) { $first = true; foreach ($queries as $query) { if ($first) { $first = false; } else { $this->_query .= ' ' . $glue; }; $this->append($query); }; return $this; }
php
public function implode($glue, $queries) { $first = true; foreach ($queries as $query) { if ($first) { $first = false; } else { $this->_query .= ' ' . $glue; }; $this->append($query); }; return $this; }
[ "public", "function", "implode", "(", "$", "glue", ",", "$", "queries", ")", "{", "$", "first", "=", "true", ";", "foreach", "(", "$", "queries", "as", "$", "query", ")", "{", "if", "(", "$", "first", ")", "{", "$", "first", "=", "false", ";", ...
Append multiple PDBquery objects @param string $glue What to insert between joined queries @param array $queries PDBquery objects or strings to join @return object PDBquery this same object, for chaining
[ "Append", "multiple", "PDBquery", "objects" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L155-L167
238,062
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDBquery.implodeClosed
public function implodeClosed($glue, $queries) { $this->_query .= ' ('; $this->implode($glue, $queries); $this->_query .= ' )'; return $this; }
php
public function implodeClosed($glue, $queries) { $this->_query .= ' ('; $this->implode($glue, $queries); $this->_query .= ' )'; return $this; }
[ "public", "function", "implodeClosed", "(", "$", "glue", ",", "$", "queries", ")", "{", "$", "this", "->", "_query", ".=", "' ('", ";", "$", "this", "->", "implode", "(", "$", "glue", ",", "$", "queries", ")", ";", "$", "this", "->", "_query", ".="...
Append multiple PDBquery objects, wrapped in parenthesis This is identical to our implode() except '(' and ')' are wrapped around the insertion. @param string $glue What to insert between joined queries @param array $queries PDBquery objects or strings to join @return object PDBquery this same object, for chaining
[ "Append", "multiple", "PDBquery", "objects", "wrapped", "in", "parenthesis" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L198-L204
238,063
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB._getColumns
private function _getColumns($table) { if (isset($this->_tables[$table])) { return $this->_tables[$table]; }; $this->_tables[$table] = false; if ($rows = $this->selectArray("PRAGMA table_info({$table})")) { $cols = array(); foreach ($rows as $row) { $cols[] = $row['name']; }; if (count($cols) > 0) { $this->_tables[$table] = $cols; }; }; return $this->_tables[$table]; }
php
private function _getColumns($table) { if (isset($this->_tables[$table])) { return $this->_tables[$table]; }; $this->_tables[$table] = false; if ($rows = $this->selectArray("PRAGMA table_info({$table})")) { $cols = array(); foreach ($rows as $row) { $cols[] = $row['name']; }; if (count($cols) > 0) { $this->_tables[$table] = $cols; }; }; return $this->_tables[$table]; }
[ "private", "function", "_getColumns", "(", "$", "table", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_tables", "[", "$", "table", "]", ")", ")", "{", "return", "$", "this", "->", "_tables", "[", "$", "table", "]", ";", "}", ";", "$", ...
Get list of column names for a table Cached in $this to minimize I/O @param string $table Name of table to inspect @return array List of column names, false on failure
[ "Get", "list", "of", "column", "names", "for", "a", "table" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L298-L314
238,064
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB._execute
private function _execute($args = array()) { if ($this->_err) { return false; }; if ($this->_sth) { if ($this->_sth->execute($args)) { return true; } else { $this->_err = implode(' ', $this->_sth->errorInfo()); return false; }; } else { $this->_err = "No statement to execute."; }; return false; }
php
private function _execute($args = array()) { if ($this->_err) { return false; }; if ($this->_sth) { if ($this->_sth->execute($args)) { return true; } else { $this->_err = implode(' ', $this->_sth->errorInfo()); return false; }; } else { $this->_err = "No statement to execute."; }; return false; }
[ "private", "function", "_execute", "(", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "_err", ")", "{", "return", "false", ";", "}", ";", "if", "(", "$", "this", "->", "_sth", ")", "{", "if", "(", "$", "this", "...
Execute stored prepared statement @param array $args (Optional) List of values corresponding to placeholders @return bool Whether it succeeded
[ "Execute", "stored", "prepared", "statement" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L339-L355
238,065
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB.exec
public function exec($q, $args = array()) { if ($q instanceof PDBquery) { $args = $q->getArgs(); $q = $q->getQuery(); }; return $this->_prepare($q)->_execute($args) ? $this->_sth->rowCount() : false; }
php
public function exec($q, $args = array()) { if ($q instanceof PDBquery) { $args = $q->getArgs(); $q = $q->getQuery(); }; return $this->_prepare($q)->_execute($args) ? $this->_sth->rowCount() : false; }
[ "public", "function", "exec", "(", "$", "q", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "$", "q", "instanceof", "PDBquery", ")", "{", "$", "args", "=", "$", "q", "->", "getArgs", "(", ")", ";", "$", "q", "=", "$", "q", "...
Execute a result-less statement Typically INSERT, UPDATE, DELETE. @param string|object $q SQL query with '?' placeholders or PDBquery object @param array $args (Optional) List of values corresponding to placeholders @return mixed Number of affected rows, false on error
[ "Execute", "a", "result", "-", "less", "statement" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L367-L374
238,066
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB.insert
public function insert($table, $values) { $colOK = $this->_getColumns($table); $query = $this->query('INSERT INTO ' . $table); $colQs = array(); $cols = array(); if (is_array($values)) { foreach ($values as $key => $val) { if (in_array($key, $colOK)) { $cols[] = $key; $colQs[] = $this->query('?', $val); }; }; }; $query->implodeClosed(',', $cols)->append('VALUES')->implodeClosed(',', $colQs); return $this->_prepare($query->getQuery())->_execute($query->getArgs()) ? $this->_dbh->lastInsertId() : false ; }
php
public function insert($table, $values) { $colOK = $this->_getColumns($table); $query = $this->query('INSERT INTO ' . $table); $colQs = array(); $cols = array(); if (is_array($values)) { foreach ($values as $key => $val) { if (in_array($key, $colOK)) { $cols[] = $key; $colQs[] = $this->query('?', $val); }; }; }; $query->implodeClosed(',', $cols)->append('VALUES')->implodeClosed(',', $colQs); return $this->_prepare($query->getQuery())->_execute($query->getArgs()) ? $this->_dbh->lastInsertId() : false ; }
[ "public", "function", "insert", "(", "$", "table", ",", "$", "values", ")", "{", "$", "colOK", "=", "$", "this", "->", "_getColumns", "(", "$", "table", ")", ";", "$", "query", "=", "$", "this", "->", "query", "(", "'INSERT INTO '", ".", "$", "tabl...
Execute INSERT statement with variable associative column data Note that the first time a table is referenced with insert() or update(), its list of columns will be fetched from the database to create a whitelist. It is thus safe to pass a form result directly to $values. @param string $table Name of table to update @param array $values Associative list of columns/values to set @return mixed New ID if supported/available, false on failure
[ "Execute", "INSERT", "statement", "with", "variable", "associative", "column", "data" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L412-L432
238,067
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB.update
public function update($table, $values, $tail, $tailArgs = array()) { $colOK = $this->_getColumns($table); $query = $this->query('UPDATE ' . $table . ' SET'); $cols = array(); if (!($tail instanceof PDBquery)) { $tail = $this->query($tail, $tailArgs); }; if (is_array($values)) { foreach ($values as $key => $val) { if (in_array($key, $colOK)) { $cols[] = $this->query("{$key}=?", array($val)); // Array to allow NULL }; }; }; $query->implode(',', $cols)->append($tail); return $this->_prepare($query->getQuery())->_execute($query->getArgs()) ? $this->_sth->rowCount() : false ; }
php
public function update($table, $values, $tail, $tailArgs = array()) { $colOK = $this->_getColumns($table); $query = $this->query('UPDATE ' . $table . ' SET'); $cols = array(); if (!($tail instanceof PDBquery)) { $tail = $this->query($tail, $tailArgs); }; if (is_array($values)) { foreach ($values as $key => $val) { if (in_array($key, $colOK)) { $cols[] = $this->query("{$key}=?", array($val)); // Array to allow NULL }; }; }; $query->implode(',', $cols)->append($tail); return $this->_prepare($query->getQuery())->_execute($query->getArgs()) ? $this->_sth->rowCount() : false ; }
[ "public", "function", "update", "(", "$", "table", ",", "$", "values", ",", "$", "tail", ",", "$", "tailArgs", "=", "array", "(", ")", ")", "{", "$", "colOK", "=", "$", "this", "->", "_getColumns", "(", "$", "table", ")", ";", "$", "query", "=", ...
Execute UPDATE statement with variable associative column data Note that the first time a table is referenced with insert() or update(), its list of columns will be fetched from the database to create a whitelist. It is thus safe to pass a form result directly to $values. Also, note that if you want to append custom column assignments, it is up to you to prepend ", " to $tail before your WHERE clause. $tail can be a string (in which case $tailArgs specifies any arguments) or a PDBquery object. @param string $table Name of table to update @param array $values Associative list of columns/values to set @param string|object $tail Final part of SQL query (i.e. custom columns, WHERE clause) @param array $tailArgs (Optional) List of values corresponding to placeholders in $tail @return mixed Last ID if supported/available, false on failure
[ "Execute", "UPDATE", "statement", "with", "variable", "associative", "column", "data" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L455-L478
238,068
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB.selectAtom
public function selectAtom($q, $args = array()) { $this->exec($q, $args); // FIXME: Test if it is indeed NULL return $this->_sth ? $this->_sth->fetchColumn() : false; }
php
public function selectAtom($q, $args = array()) { $this->exec($q, $args); // FIXME: Test if it is indeed NULL return $this->_sth ? $this->_sth->fetchColumn() : false; }
[ "public", "function", "selectAtom", "(", "$", "q", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "this", "->", "exec", "(", "$", "q", ",", "$", "args", ")", ";", "// FIXME: Test if it is indeed NULL", "return", "$", "this", "->", "_sth", "...
Fetch a single value The result is the value returned in row 0, column 0. Useful for COUNT(*) and such. Extra columns/rows are safely ignored. @param string $q SQL query with '?' value placeholders @param array $args (Optional) List of values corresponding to placeholders @return mixed Single result cell, false if no results
[ "Fetch", "a", "single", "value" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L491-L496
238,069
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB.selectList
public function selectList($q, $args = array()) { $this->exec($q, $args); return $this->_sth ? $this->_sth->fetchAll(\PDO::FETCH_COLUMN, 0) : false; }
php
public function selectList($q, $args = array()) { $this->exec($q, $args); return $this->_sth ? $this->_sth->fetchAll(\PDO::FETCH_COLUMN, 0) : false; }
[ "public", "function", "selectList", "(", "$", "q", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "this", "->", "exec", "(", "$", "q", ",", "$", "args", ")", ";", "return", "$", "this", "->", "_sth", "?", "$", "this", "->", "_sth", ...
Fetch a simple list of result values The result is a list of the values found in the first column of each row. @param string $q SQL query with '?' value placeholders @param array $args (Optional) List of values corresponding to placeholders @return array
[ "Fetch", "a", "simple", "list", "of", "result", "values" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L509-L513
238,070
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB.selectSingleArray
public function selectSingleArray($q, $args = array()) { $this->exec($q, $args); return $this->_sth ? $this->_sth->fetch(\PDO::FETCH_ASSOC) : false; }
php
public function selectSingleArray($q, $args = array()) { $this->exec($q, $args); return $this->_sth ? $this->_sth->fetch(\PDO::FETCH_ASSOC) : false; }
[ "public", "function", "selectSingleArray", "(", "$", "q", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "this", "->", "exec", "(", "$", "q", ",", "$", "args", ")", ";", "return", "$", "this", "->", "_sth", "?", "$", "this", "->", "_s...
Fetch a single row as associative array Fetches the first row of results, so from the caller's side it's equivalent to selectArray()[0] however only the first row is ever fetched from the server. Note that if you're not selecting by a unique ID, a LIMIT of 1 should still be specified in SQL for optimal performance. @param string $q SQL query with '?' value placeholders @param array $args (Optional) List of values corresponding to placeholders @return array Single associative row
[ "Fetch", "a", "single", "row", "as", "associative", "array" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L530-L534
238,071
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB.selectArray
public function selectArray($q, $args = array()) { $this->exec($q, $args); return $this->_sth ? $this->_sth->fetchAll(\PDO::FETCH_ASSOC) : false; }
php
public function selectArray($q, $args = array()) { $this->exec($q, $args); return $this->_sth ? $this->_sth->fetchAll(\PDO::FETCH_ASSOC) : false; }
[ "public", "function", "selectArray", "(", "$", "q", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "this", "->", "exec", "(", "$", "q", ",", "$", "args", ")", ";", "return", "$", "this", "->", "_sth", "?", "$", "this", "->", "_sth", ...
Fetch all results in an associative array @param string $q SQL query with '?' value placeholders @param array $args (Optional) List of values corresponding to placeholders @return array All associative rows
[ "Fetch", "all", "results", "in", "an", "associative", "array" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L544-L548
238,072
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB.selectArrayIndexed
public function selectArrayIndexed($q, $args = array()) { $this->exec($q, $args); if ($this->_sth) { $result = array(); while ($row = $this->_sth->fetch(\PDO::FETCH_ASSOC)) { $result[$row[key($row)]] = $row; }; return $result; } else { return false; }; }
php
public function selectArrayIndexed($q, $args = array()) { $this->exec($q, $args); if ($this->_sth) { $result = array(); while ($row = $this->_sth->fetch(\PDO::FETCH_ASSOC)) { $result[$row[key($row)]] = $row; }; return $result; } else { return false; }; }
[ "public", "function", "selectArrayIndexed", "(", "$", "q", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "this", "->", "exec", "(", "$", "q", ",", "$", "args", ")", ";", "if", "(", "$", "this", "->", "_sth", ")", "{", "$", "result", ...
Fetch all results in an associative array, index by first column Whereas selectArray() returns a list of associative rows, this returns an associative array keyed on the first column of each row. @param string $q SQL query with '?' value placeholders @param array $args (Optional) List of values corresponding to placeholders @return array All associative rows, keyed on first column
[ "Fetch", "all", "results", "in", "an", "associative", "array", "index", "by", "first", "column" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L561-L573
238,073
vphantom/pyritephp
src/Pyrite/Core/PDB.php
PDB.selectArrayPairs
public function selectArrayPairs($q, $args = array()) { $this->exec($q, $args); return $this->_sth ? $this->_sth->fetchAll(\PDO::FETCH_COLUMN | \PDO::FETCH_GROUP) : false; }
php
public function selectArrayPairs($q, $args = array()) { $this->exec($q, $args); return $this->_sth ? $this->_sth->fetchAll(\PDO::FETCH_COLUMN | \PDO::FETCH_GROUP) : false; }
[ "public", "function", "selectArrayPairs", "(", "$", "q", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "this", "->", "exec", "(", "$", "q", ",", "$", "args", ")", ";", "return", "$", "this", "->", "_sth", "?", "$", "this", "->", "_st...
Fetch 2-column result into associative array Create one key per row, indexed on the first column, containing the second column. Handy for retreiving key/value pairs. @param string $q SQL query with '?' value placeholders @param array $args (Optional) List of values corresponding to placeholders @return array Associative pairs
[ "Fetch", "2", "-", "column", "result", "into", "associative", "array" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/PDB.php#L586-L590
238,074
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.andAdd
public function andAdd() { $args = func_get_args(); $value = array_shift($args); $params = []; while ($args) { $param = array_shift($args); if (is_array($param)) { $params = array_merge($params, $param); } else { $params[] = $param; } } $value = new WhereConditionValue($this, $value, $params); $this->add($value); return $this; }
php
public function andAdd() { $args = func_get_args(); $value = array_shift($args); $params = []; while ($args) { $param = array_shift($args); if (is_array($param)) { $params = array_merge($params, $param); } else { $params[] = $param; } } $value = new WhereConditionValue($this, $value, $params); $this->add($value); return $this; }
[ "public", "function", "andAdd", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "value", "=", "array_shift", "(", "$", "args", ")", ";", "$", "params", "=", "[", "]", ";", "while", "(", "$", "args", ")", "{", "$", "param", ...
add condition. 1. $cond->where->add('foo = ?', $foo); 2. $cond->where->add('foo = ? AND bar = ?', [$foo, $bar]); 3. $cond->where->add('foo = ? AND bar = ?', $foo, $bar); 4. $cond->where->add('foo = :foo AND bar = :bar', [':foo' => $foo, ':bar' => $bar]); @return Samurai\Onikiri\Criteria\WhereCondition
[ "add", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L69-L88
238,075
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.andNot
public function andNot() { $args = func_get_args(); call_user_func_array(array($this, 'andAdd'), $args); $value = array_pop($this->conditions); $value->not(); $this->add($value); return $this; }
php
public function andNot() { $args = func_get_args(); call_user_func_array(array($this, 'andAdd'), $args); $value = array_pop($this->conditions); $value->not(); $this->add($value); return $this; }
[ "public", "function", "andNot", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "call_user_func_array", "(", "array", "(", "$", "this", ",", "'andAdd'", ")", ",", "$", "args", ")", ";", "$", "value", "=", "array_pop", "(", "$", "this...
add not condition. @return Samurai\Onikiri\Criteria\WhereCondition
[ "add", "not", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L95-L105
238,076
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.orAdd
public function orAdd() { $args = func_get_args(); $value = array_shift($args); $params = []; while ($args) { $param = array_shift($args); if (is_array($param)) { $params = array_merge($params, $param); } else { $params[] = $param; } } $value = new WhereConditionValue($this, $value, $params); $value->chain_by = WhereCondition::CHAIN_BY_OR; $this->add($value); return $this; }
php
public function orAdd() { $args = func_get_args(); $value = array_shift($args); $params = []; while ($args) { $param = array_shift($args); if (is_array($param)) { $params = array_merge($params, $param); } else { $params[] = $param; } } $value = new WhereConditionValue($this, $value, $params); $value->chain_by = WhereCondition::CHAIN_BY_OR; $this->add($value); return $this; }
[ "public", "function", "orAdd", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "value", "=", "array_shift", "(", "$", "args", ")", ";", "$", "params", "=", "[", "]", ";", "while", "(", "$", "args", ")", "{", "$", "param", ...
add or condition. @return Samurai\Onikiri\Criteria\WhereCondition
[ "add", "or", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L112-L132
238,077
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.andNotIn
public function andNotIn($key, array $values) { if ($values) { $value = sprintf('%s NOT IN (%s)', $key, join(', ', array_fill(0, count($values), '?'))); return $this->andAdd($value, $values); } else { $value = '1'; return $this->andAdd($value, $values); } }
php
public function andNotIn($key, array $values) { if ($values) { $value = sprintf('%s NOT IN (%s)', $key, join(', ', array_fill(0, count($values), '?'))); return $this->andAdd($value, $values); } else { $value = '1'; return $this->andAdd($value, $values); } }
[ "public", "function", "andNotIn", "(", "$", "key", ",", "array", "$", "values", ")", "{", "if", "(", "$", "values", ")", "{", "$", "value", "=", "sprintf", "(", "'%s NOT IN (%s)'", ",", "$", "key", ",", "join", "(", "', '", ",", "array_fill", "(", ...
add not in condition. @param string $key @param array $values @return Samurai\Onikiri\Criteria\WhereCondition
[ "add", "not", "in", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L177-L186
238,078
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.orIn
public function orIn($key, array $values) { if ($values) { $value = sprintf('%s IN (%s)', $key, join(', ', array_fill(0, count($values), '?'))); return $this->orAdd($value, $values); } else { $value = '0'; return $this->orAdd($value, $values); } }
php
public function orIn($key, array $values) { if ($values) { $value = sprintf('%s IN (%s)', $key, join(', ', array_fill(0, count($values), '?'))); return $this->orAdd($value, $values); } else { $value = '0'; return $this->orAdd($value, $values); } }
[ "public", "function", "orIn", "(", "$", "key", ",", "array", "$", "values", ")", "{", "if", "(", "$", "values", ")", "{", "$", "value", "=", "sprintf", "(", "'%s IN (%s)'", ",", "$", "key", ",", "join", "(", "', '", ",", "array_fill", "(", "0", "...
or in condition. @param string $key @param array $values @return Samurai\Onikiri\Criteria\WhereCondition
[ "or", "in", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L195-L204
238,079
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.andBetween
public function andBetween($key, $min, $max) { $value = sprintf('%s BETWEEN ? AND ?', $key); return $this->andAdd($value, [$min, $max]); }
php
public function andBetween($key, $min, $max) { $value = sprintf('%s BETWEEN ? AND ?', $key); return $this->andAdd($value, [$min, $max]); }
[ "public", "function", "andBetween", "(", "$", "key", ",", "$", "min", ",", "$", "max", ")", "{", "$", "value", "=", "sprintf", "(", "'%s BETWEEN ? AND ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "andAdd", "(", "$", "value", ",", "[...
add between condition. @param string $key @param mixed $min @param mixed $max @return Samurai\Onikiri\Criteria\WhereCondition
[ "add", "between", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L233-L237
238,080
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.andNotBetween
public function andNotBetween($key, $min, $max) { $value = sprintf('%s NOT BETWEEN ? AND ?', $key); return $this->andAdd($value, [$min, $max]); }
php
public function andNotBetween($key, $min, $max) { $value = sprintf('%s NOT BETWEEN ? AND ?', $key); return $this->andAdd($value, [$min, $max]); }
[ "public", "function", "andNotBetween", "(", "$", "key", ",", "$", "min", ",", "$", "max", ")", "{", "$", "value", "=", "sprintf", "(", "'%s NOT BETWEEN ? AND ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "andAdd", "(", "$", "value", ",...
add not between condition. @param string $key @param mixed $min @param mixed $max @return Samurai\Onikiri\Criteria\WhereCondition
[ "add", "not", "between", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L247-L251
238,081
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.orBetween
public function orBetween($key, $min, $max) { $value = sprintf('%s BETWEEN ? AND ?', $key); return $this->orAdd($value, [$min, $max]); }
php
public function orBetween($key, $min, $max) { $value = sprintf('%s BETWEEN ? AND ?', $key); return $this->orAdd($value, [$min, $max]); }
[ "public", "function", "orBetween", "(", "$", "key", ",", "$", "min", ",", "$", "max", ")", "{", "$", "value", "=", "sprintf", "(", "'%s BETWEEN ? AND ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "orAdd", "(", "$", "value", ",", "[",...
or between condition. @param string $key @param mixed $min @param mixed $max @return Samurai\Onikiri\Criteria\WhereCondition
[ "or", "between", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L261-L265
238,082
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.orNotBetween
public function orNotBetween($key, $min, $max) { $value = sprintf('%s NOT BETWEEN ? AND ?', $key); return $this->orAdd($value, [$min, $max]); }
php
public function orNotBetween($key, $min, $max) { $value = sprintf('%s NOT BETWEEN ? AND ?', $key); return $this->orAdd($value, [$min, $max]); }
[ "public", "function", "orNotBetween", "(", "$", "key", ",", "$", "min", ",", "$", "max", ")", "{", "$", "value", "=", "sprintf", "(", "'%s NOT BETWEEN ? AND ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "orAdd", "(", "$", "value", ",",...
or not between condition. @param string $key @param mixed $min @param mixed $max @return Samurai\Onikiri\Criteria\WhereCondition
[ "or", "not", "between", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L275-L279
238,083
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.andLike
public function andLike($key, $like) { $value = sprintf('%s LIKE ?', $key); return $this->andAdd($value, [$like]); }
php
public function andLike($key, $like) { $value = sprintf('%s LIKE ?', $key); return $this->andAdd($value, [$like]); }
[ "public", "function", "andLike", "(", "$", "key", ",", "$", "like", ")", "{", "$", "value", "=", "sprintf", "(", "'%s LIKE ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "andAdd", "(", "$", "value", ",", "[", "$", "like", "]", ")", ...
add like condition. @param string $key @param string $like @return Samurai\Onikiri\Criteria\WhereCondition
[ "add", "like", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L289-L293
238,084
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.andNotLike
public function andNotLike($key, $like) { $value = sprintf('%s NOT LIKE ?', $key); return $this->andAdd($value, [$like]); }
php
public function andNotLike($key, $like) { $value = sprintf('%s NOT LIKE ?', $key); return $this->andAdd($value, [$like]); }
[ "public", "function", "andNotLike", "(", "$", "key", ",", "$", "like", ")", "{", "$", "value", "=", "sprintf", "(", "'%s NOT LIKE ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "andAdd", "(", "$", "value", ",", "[", "$", "like", "]", ...
add not like condition. @param string $key @param string $like @return Samurai\Onikiri\Criteria\WhereCondition
[ "add", "not", "like", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L302-L306
238,085
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.orLike
public function orLike($key, $like) { $value = sprintf('%s LIKE ?', $key); return $this->orAdd($value, [$like]); }
php
public function orLike($key, $like) { $value = sprintf('%s LIKE ?', $key); return $this->orAdd($value, [$like]); }
[ "public", "function", "orLike", "(", "$", "key", ",", "$", "like", ")", "{", "$", "value", "=", "sprintf", "(", "'%s LIKE ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "orAdd", "(", "$", "value", ",", "[", "$", "like", "]", ")", ...
or like condition. @param string $key @param string $like @return Samurai\Onikiri\Criteria\WhereCondition
[ "or", "like", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L315-L319
238,086
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.orNotLike
public function orNotLike($key, $like) { $value = sprintf('%s NOT LIKE ?', $key); return $this->orAdd($value, [$like]); }
php
public function orNotLike($key, $like) { $value = sprintf('%s NOT LIKE ?', $key); return $this->orAdd($value, [$like]); }
[ "public", "function", "orNotLike", "(", "$", "key", ",", "$", "like", ")", "{", "$", "value", "=", "sprintf", "(", "'%s NOT LIKE ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "orAdd", "(", "$", "value", ",", "[", "$", "like", "]", ...
or not like condition. @param string $key @param string $like @return Samurai\Onikiri\Criteria\WhereCondition
[ "or", "not", "like", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L328-L332
238,087
antarctica/laravel-base-exceptions
src/Exception/InvalidArgumentValueException.php
InvalidArgumentValueException.constructException
private function constructException(array $details) { $this->details['argument_value_error'][$this->argument] = $this->details['argument_value_error']['ARG']; $this->details['argument_value_error'][$this->argument] = $details; unset($this->details['argument_value_error']['ARG']); }
php
private function constructException(array $details) { $this->details['argument_value_error'][$this->argument] = $this->details['argument_value_error']['ARG']; $this->details['argument_value_error'][$this->argument] = $details; unset($this->details['argument_value_error']['ARG']); }
[ "private", "function", "constructException", "(", "array", "$", "details", ")", "{", "$", "this", "->", "details", "[", "'argument_value_error'", "]", "[", "$", "this", "->", "argument", "]", "=", "$", "this", "->", "details", "[", "'argument_value_error'", ...
Fill in exception details @param array $details
[ "Fill", "in", "exception", "details" ]
c5747b51dcf31e91ccc038302a0bb9a74d3daefc
https://github.com/antarctica/laravel-base-exceptions/blob/c5747b51dcf31e91ccc038302a0bb9a74d3daefc/src/Exception/InvalidArgumentValueException.php#L43-L48
238,088
face-orm/face
lib/Face/Sql/Query/FQuery.php
FQuery.parseColumnNames
public function parseColumnNames($string, ContextAwareInterface $context = null) { $matchArray = []; preg_match_all("#~([a-zA-Z0-9_]\\.{0,1})+#", $string, $matchArray); $matchArray = array_unique($matchArray[0]); foreach ($matchArray as $match) { if($context){ $nsMatch = $context->getNameInContext($match); }else{ $nsMatch = $match; } $path=ltrim($nsMatch, "~"); $tablePath = rtrim(substr($nsMatch, 1, strrpos($nsMatch, ".")), "."); $replace= $this->_doFQLTableName($tablePath, null, true) . "." . $this->getBaseFace() ->getElement($path) ->getSqlColumnName(true); $string = str_replace($match, $replace, $string); } return $string; }
php
public function parseColumnNames($string, ContextAwareInterface $context = null) { $matchArray = []; preg_match_all("#~([a-zA-Z0-9_]\\.{0,1})+#", $string, $matchArray); $matchArray = array_unique($matchArray[0]); foreach ($matchArray as $match) { if($context){ $nsMatch = $context->getNameInContext($match); }else{ $nsMatch = $match; } $path=ltrim($nsMatch, "~"); $tablePath = rtrim(substr($nsMatch, 1, strrpos($nsMatch, ".")), "."); $replace= $this->_doFQLTableName($tablePath, null, true) . "." . $this->getBaseFace() ->getElement($path) ->getSqlColumnName(true); $string = str_replace($match, $replace, $string); } return $string; }
[ "public", "function", "parseColumnNames", "(", "$", "string", ",", "ContextAwareInterface", "$", "context", "=", "null", ")", "{", "$", "matchArray", "=", "[", "]", ";", "preg_match_all", "(", "\"#~([a-zA-Z0-9_]\\\\.{0,1})+#\"", ",", "$", "string", ",", "$", "...
replaces the waved string by the sql-valid column name @param $string
[ "replaces", "the", "waved", "string", "by", "the", "sql", "-", "valid", "column", "name" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/FQuery.php#L51-L78
238,089
face-orm/face
lib/Face/Sql/Query/FQuery.php
FQuery.execute
public function execute($config = null) { if(null == $config){ $pdo = Config::getDefault()->getPdo(); }else if($config instanceof \PDO){ $pdo = $config; }else if($config instanceof Config){ $pdo = $config->getPdo(); }else{ throw new BadParameterException('First parameter of FQuery::execute is not correct'); } $stmt = $this->getPdoStatement($pdo); if ($stmt->execute()) { return $stmt; } else { // TODO : handle errors ".__FILE__.":".__LINE__; throw new QueryFailedException($stmt); //return false; } }
php
public function execute($config = null) { if(null == $config){ $pdo = Config::getDefault()->getPdo(); }else if($config instanceof \PDO){ $pdo = $config; }else if($config instanceof Config){ $pdo = $config->getPdo(); }else{ throw new BadParameterException('First parameter of FQuery::execute is not correct'); } $stmt = $this->getPdoStatement($pdo); if ($stmt->execute()) { return $stmt; } else { // TODO : handle errors ".__FILE__.":".__LINE__; throw new QueryFailedException($stmt); //return false; } }
[ "public", "function", "execute", "(", "$", "config", "=", "null", ")", "{", "if", "(", "null", "==", "$", "config", ")", "{", "$", "pdo", "=", "Config", "::", "getDefault", "(", ")", "->", "getPdo", "(", ")", ";", "}", "else", "if", "(", "$", "...
Executes the query from the given pdo object @param \PDO|Config|null $pdo @return \PDOStatement the pdo statement ready to fetch
[ "Executes", "the", "query", "from", "the", "given", "pdo", "object" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/FQuery.php#L94-L118
238,090
face-orm/face
lib/Face/Sql/Query/FQuery.php
FQuery.getPdoStatement
public function getPdoStatement(\PDO $pdo) { $stmt = $pdo->prepare($this->getSqlString()); $bound = $this->getBoundValues(); foreach ($bound as $name => $bind) { $stmt->bindValue($name, $bind[0], $bind[1]); } return $stmt; }
php
public function getPdoStatement(\PDO $pdo) { $stmt = $pdo->prepare($this->getSqlString()); $bound = $this->getBoundValues(); foreach ($bound as $name => $bind) { $stmt->bindValue($name, $bind[0], $bind[1]); } return $stmt; }
[ "public", "function", "getPdoStatement", "(", "\\", "PDO", "$", "pdo", ")", "{", "$", "stmt", "=", "$", "pdo", "->", "prepare", "(", "$", "this", "->", "getSqlString", "(", ")", ")", ";", "$", "bound", "=", "$", "this", "->", "getBoundValues", "(", ...
get a statement for the given pdo object, values are already bound @param \PDO $pdo
[ "get", "a", "statement", "for", "the", "given", "pdo", "object", "values", "are", "already", "bound" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/FQuery.php#L124-L135
238,091
face-orm/face
lib/Face/Sql/Query/FQuery.php
FQuery.__doFQLTableNameStatic
public static function __doFQLTableNameStatic($path, $token = null, $escape = false) { if (null===$token) { $token=self::$DOT_TOKEN; } if ("this"===$path || empty($path)) { if($escape){ return "`this`"; }else{ return "this"; } } if ( ! StringUtils::beginsWith("this.", $path)) { // if doesn't begin with "this." then we prepend "this." $path = "this.".$path; } $name = str_replace(".", $token, $path); if($escape){ return "`$name`"; }else{ return $name; } }
php
public static function __doFQLTableNameStatic($path, $token = null, $escape = false) { if (null===$token) { $token=self::$DOT_TOKEN; } if ("this"===$path || empty($path)) { if($escape){ return "`this`"; }else{ return "this"; } } if ( ! StringUtils::beginsWith("this.", $path)) { // if doesn't begin with "this." then we prepend "this." $path = "this.".$path; } $name = str_replace(".", $token, $path); if($escape){ return "`$name`"; }else{ return $name; } }
[ "public", "static", "function", "__doFQLTableNameStatic", "(", "$", "path", ",", "$", "token", "=", "null", ",", "$", "escape", "=", "false", ")", "{", "if", "(", "null", "===", "$", "token", ")", "{", "$", "token", "=", "self", "::", "$", "DOT_TOKEN...
reserved for internal usage @param $path @param null $token @return mixed|string
[ "reserved", "for", "internal", "usage" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/FQuery.php#L194-L220
238,092
ellipsephp/http
src/Handlers/DetailledJsonExceptionRequestHandler.php
DetailledJsonExceptionRequestHandler.handle
public function handle(ServerRequestInterface $request): ResponseInterface { $details = new Inspector($this->e); $contents = json_encode([ 'type' => get_class($details->inner()), 'message' => $details->inner()->getMessage(), 'context' => [ 'type' => get_class($details->current()), 'message' => $details->current()->getMessage(), ], 'trace' => $details->inner()->getTrace(), ]); $response = $this->factory ->createResponse(500) ->withHeader('Content-type', 'application/json'); $response->getBody()->write($contents); return $response; }
php
public function handle(ServerRequestInterface $request): ResponseInterface { $details = new Inspector($this->e); $contents = json_encode([ 'type' => get_class($details->inner()), 'message' => $details->inner()->getMessage(), 'context' => [ 'type' => get_class($details->current()), 'message' => $details->current()->getMessage(), ], 'trace' => $details->inner()->getTrace(), ]); $response = $this->factory ->createResponse(500) ->withHeader('Content-type', 'application/json'); $response->getBody()->write($contents); return $response; }
[ "public", "function", "handle", "(", "ServerRequestInterface", "$", "request", ")", ":", "ResponseInterface", "{", "$", "details", "=", "new", "Inspector", "(", "$", "this", "->", "e", ")", ";", "$", "contents", "=", "json_encode", "(", "[", "'type'", "=>"...
Return a detailled json response for the exception. @param \Psr\Http\Message\ServerRequestInterface $request @return \Psr\Http\Message\ResponseInterface
[ "Return", "a", "detailled", "json", "response", "for", "the", "exception", "." ]
20a2b0ae1d3a149a905b93ae0993203eb7d414e1
https://github.com/ellipsephp/http/blob/20a2b0ae1d3a149a905b93ae0993203eb7d414e1/src/Handlers/DetailledJsonExceptionRequestHandler.php#L50-L71
238,093
GovTribe/laravel-kinvey
src/GovTribe/LaravelKinvey/Database/Eloquent/Builder.php
Builder.compileWhereBasic
protected function compileWhereBasic($where) { extract($where); // Replace like with MongoRegex if ($operator == 'like') { $operator = '='; $regex = str_replace('%', '', $value); // Prepare regex if (substr($value, 0, 1) != '%') $regex = '^' . $regex; if (substr($value, -1) != '%') $regex = $regex . '$'; $value = array('$regex' => "$regex"); } if (!isset($operator) || $operator == '=') { $query = array( $column => $value ); } elseif (array_key_exists($operator, $this->conversion)) { $query = array( $column => array( $this->conversion[$operator] => $value ) ); } else { $query = array( $column => array( '$' . $operator => $value ) ); } return $query; }
php
protected function compileWhereBasic($where) { extract($where); // Replace like with MongoRegex if ($operator == 'like') { $operator = '='; $regex = str_replace('%', '', $value); // Prepare regex if (substr($value, 0, 1) != '%') $regex = '^' . $regex; if (substr($value, -1) != '%') $regex = $regex . '$'; $value = array('$regex' => "$regex"); } if (!isset($operator) || $operator == '=') { $query = array( $column => $value ); } elseif (array_key_exists($operator, $this->conversion)) { $query = array( $column => array( $this->conversion[$operator] => $value ) ); } else { $query = array( $column => array( '$' . $operator => $value ) ); } return $query; }
[ "protected", "function", "compileWhereBasic", "(", "$", "where", ")", "{", "extract", "(", "$", "where", ")", ";", "// Replace like with MongoRegex", "if", "(", "$", "operator", "==", "'like'", ")", "{", "$", "operator", "=", "'='", ";", "$", "regex", "=",...
Compile the query's where clauses. @param array $where @return array
[ "Compile", "the", "query", "s", "where", "clauses", "." ]
8a25dafdf80a933384dfcfe8b70b0a7663fe9289
https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/Database/Eloquent/Builder.php#L310-L352
238,094
GovTribe/laravel-kinvey
src/GovTribe/LaravelKinvey/Database/Eloquent/Builder.php
Builder.formatQuery
public function formatQuery(array $data, array $formatted = array()) { // Convert dot notation to multidimensional array elements. foreach ($data as $key => $value) { array_set($formatted, $key, $value); } return $formatted; }
php
public function formatQuery(array $data, array $formatted = array()) { // Convert dot notation to multidimensional array elements. foreach ($data as $key => $value) { array_set($formatted, $key, $value); } return $formatted; }
[ "public", "function", "formatQuery", "(", "array", "$", "data", ",", "array", "$", "formatted", "=", "array", "(", ")", ")", "{", "// Convert dot notation to multidimensional array elements.", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ...
Format a query. @param array $data @param array $formatted @return array
[ "Format", "a", "query", "." ]
8a25dafdf80a933384dfcfe8b70b0a7663fe9289
https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/Database/Eloquent/Builder.php#L361-L369
238,095
AlexHowansky/ork-base
src/Utility/Collection.php
Collection.getFirstNonEmptyElement
public static function getFirstNonEmptyElement($list, $default = null) { foreach ($list as $item) { if (empty($item) === false) { return $item; } } return $default; }
php
public static function getFirstNonEmptyElement($list, $default = null) { foreach ($list as $item) { if (empty($item) === false) { return $item; } } return $default; }
[ "public", "static", "function", "getFirstNonEmptyElement", "(", "$", "list", ",", "$", "default", "=", "null", ")", "{", "foreach", "(", "$", "list", "as", "$", "item", ")", "{", "if", "(", "empty", "(", "$", "item", ")", "===", "false", ")", "{", ...
Get the first non-empty element of a list. @param array $list The list to scan. @param mixed $default If no non-empty element is found, return this value. @return mixed The first non-empty element in the list.
[ "Get", "the", "first", "non", "-", "empty", "element", "of", "a", "list", "." ]
5f4ab14e63bbc8b17898639fd1fff86ee6659bb0
https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/Utility/Collection.php#L28-L36
238,096
AlexHowansky/ork-base
src/Utility/Collection.php
Collection.inCsv
public static function inCsv($item, $list, $delimiter = ',', $enclosure = '"', $escape = '\\') { return in_array($item, str_getcsv($list, $delimiter, $enclosure, $escape)); }
php
public static function inCsv($item, $list, $delimiter = ',', $enclosure = '"', $escape = '\\') { return in_array($item, str_getcsv($list, $delimiter, $enclosure, $escape)); }
[ "public", "static", "function", "inCsv", "(", "$", "item", ",", "$", "list", ",", "$", "delimiter", "=", "','", ",", "$", "enclosure", "=", "'\"'", ",", "$", "escape", "=", "'\\\\'", ")", "{", "return", "in_array", "(", "$", "item", ",", "str_getcsv"...
Is an item in a CSV-formatted string list? @param string $item The item to scan for. @param string $list The list to scan. @param type $delimiter The delimiter character to use. @param type $enclosure The enclosure character to use. @param type $escape The escape character to use. @return boolean True if the item is in the list.
[ "Is", "an", "item", "in", "a", "CSV", "-", "formatted", "string", "list?" ]
5f4ab14e63bbc8b17898639fd1fff86ee6659bb0
https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/Utility/Collection.php#L49-L52
238,097
rseyferth/chickenwire
src/ChickenWire/Route.php
Route.i18n
public static function i18n($pattern, array $options = array()) { // Trim the pattern $pattern = rtrim($pattern, '/ '); // Do the default options $options = array_merge(array( "controller" => "\\ChickenWire\\I18n\\I18nController" ), $options); // Create basic route for all Route::match($pattern, array_merge(array( "action" => "all" ), $options)); // Get current language Route::match($pattern . '/current', array_merge(array( "action" => "current" ), $options)); // All sub requests Route::match($pattern . '/current/{*path}', array_merge(array( "action" => "current" ), $options)); // All sub requests with a language Route::match($pattern . '/{*path}', array_merge(array( "action" => "all" ), $options)); }
php
public static function i18n($pattern, array $options = array()) { // Trim the pattern $pattern = rtrim($pattern, '/ '); // Do the default options $options = array_merge(array( "controller" => "\\ChickenWire\\I18n\\I18nController" ), $options); // Create basic route for all Route::match($pattern, array_merge(array( "action" => "all" ), $options)); // Get current language Route::match($pattern . '/current', array_merge(array( "action" => "current" ), $options)); // All sub requests Route::match($pattern . '/current/{*path}', array_merge(array( "action" => "current" ), $options)); // All sub requests with a language Route::match($pattern . '/{*path}', array_merge(array( "action" => "all" ), $options)); }
[ "public", "static", "function", "i18n", "(", "$", "pattern", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "// Trim the pattern", "$", "pattern", "=", "rtrim", "(", "$", "pattern", ",", "'/ '", ")", ";", "// Do the default options", "$", ...
Create a pattern for client-side I18n requests @param string The base pattern to link to the I18n controller @param array Additional options @return void
[ "Create", "a", "pattern", "for", "client", "-", "side", "I18n", "requests" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Route.php#L60-L91
238,098
rseyferth/chickenwire
src/ChickenWire/Route.php
Route.request
public static function request($request, &$httpStatus, &$urlParams) { // We will look for a best match $status = 404; $foundRoute = null; $foundParams = null; // Loop through routes foreach (self::$_routes as $route) { // Already done? if ($route->checked) continue; // Do the regex! preg_match_all($route->_regexPattern, $request->uri, $matches); // Set flag that this route has been matched $route->checked = true; // Does the route match? if (count($matches[0]) == 1) { // Is the method correct as well? if (Arry::Contains($request->method, $route->methods, false)) { //@TODO Check SSL config // We have a method and path match! $foundRoute = $route; $status = 200; // Get parameters $foundParams = array(); if (count($matches) > 1) { for ($q = 1; $q < count($matches); $q++) { $foundParams[] = $matches[$q][0]; } } // That's all we need break; } else { // Wrong method; is this the best yet? if (is_null($foundRoute) || $status !== 200) { // This is the best yet... $foundRoute = $route; $status = 405; } } } } // Parse params if (sizeof($foundParams) > 0) { // Look up the param names in the route $urlParams = array(); foreach ($route->_patternVariables as $index =>$varName) { // #'ed param? $value = $foundParams[$index]; if (substr($varName, 0, 1) == '#') { $value = intval($value); $varName = substr($varName, 1); } // *'ed param? if (substr($varName, 0, 1) == '*') { $varName = substr($varName, 1); } $urlParams[$varName] = $value; } } else { $urlParams = array(); } // Store it! $httpStatus = $status; self::$_currentRoute = $foundRoute; return $foundRoute; }
php
public static function request($request, &$httpStatus, &$urlParams) { // We will look for a best match $status = 404; $foundRoute = null; $foundParams = null; // Loop through routes foreach (self::$_routes as $route) { // Already done? if ($route->checked) continue; // Do the regex! preg_match_all($route->_regexPattern, $request->uri, $matches); // Set flag that this route has been matched $route->checked = true; // Does the route match? if (count($matches[0]) == 1) { // Is the method correct as well? if (Arry::Contains($request->method, $route->methods, false)) { //@TODO Check SSL config // We have a method and path match! $foundRoute = $route; $status = 200; // Get parameters $foundParams = array(); if (count($matches) > 1) { for ($q = 1; $q < count($matches); $q++) { $foundParams[] = $matches[$q][0]; } } // That's all we need break; } else { // Wrong method; is this the best yet? if (is_null($foundRoute) || $status !== 200) { // This is the best yet... $foundRoute = $route; $status = 405; } } } } // Parse params if (sizeof($foundParams) > 0) { // Look up the param names in the route $urlParams = array(); foreach ($route->_patternVariables as $index =>$varName) { // #'ed param? $value = $foundParams[$index]; if (substr($varName, 0, 1) == '#') { $value = intval($value); $varName = substr($varName, 1); } // *'ed param? if (substr($varName, 0, 1) == '*') { $varName = substr($varName, 1); } $urlParams[$varName] = $value; } } else { $urlParams = array(); } // Store it! $httpStatus = $status; self::$_currentRoute = $foundRoute; return $foundRoute; }
[ "public", "static", "function", "request", "(", "$", "request", ",", "&", "$", "httpStatus", ",", "&", "$", "urlParams", ")", "{", "// We will look for a best match", "$", "status", "=", "404", ";", "$", "foundRoute", "=", "null", ";", "$", "foundParams", ...
Match the given request on all configured routes and return first match @param ChickenWire\Request $request The request to match @param Number &$httpStatus This param will be filled with the resulting HTTP status code @param Array &$urlParams This will be an array containing the matched URL parameters @return Route|number The matched, orfalse when no match was found
[ "Match", "the", "given", "request", "on", "all", "configured", "routes", "and", "return", "first", "match" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Route.php#L101-L192
238,099
rseyferth/chickenwire
src/ChickenWire/Route.php
Route.replaceFields
public function replaceFields($models) { // Loop through my fields $url = $this->_pattern; foreach ($this->_patternVariables as $var) { // Look up $varName = $var[0] == '#' ? substr($var, 1) : $var; // Was there a dot (.) in it, signifying a different model? if (strstr($varName, '.')) { // Split it! list($modelName, $varName) = explode(".", $varName); // Loop through model instances to see if we have a match for the model name $model = null; foreach ($models as $m) { if (Str::removeNamespace(get_class($m)) == $modelName) { // Use this model instead $model = $m; break; } } // !Found? if (is_null($model)) { // Too bad... throw new \Exception("You need to pass an Model instance of $modelName to generate a url for " . $this->_pattern, 1); } } else { // Use last model $model = $models[count($models) - 1]; } // Is there a slug var available? $sluggedVarName = $varName . "Slug"; if ($model->hasAttribute($sluggedVarName)) { $value = $model->$sluggedVarName; } else { $value = $model->$varName; } // Replace! $url = str_replace('{' . $var . '}', strval($value), $url); } return $url; }
php
public function replaceFields($models) { // Loop through my fields $url = $this->_pattern; foreach ($this->_patternVariables as $var) { // Look up $varName = $var[0] == '#' ? substr($var, 1) : $var; // Was there a dot (.) in it, signifying a different model? if (strstr($varName, '.')) { // Split it! list($modelName, $varName) = explode(".", $varName); // Loop through model instances to see if we have a match for the model name $model = null; foreach ($models as $m) { if (Str::removeNamespace(get_class($m)) == $modelName) { // Use this model instead $model = $m; break; } } // !Found? if (is_null($model)) { // Too bad... throw new \Exception("You need to pass an Model instance of $modelName to generate a url for " . $this->_pattern, 1); } } else { // Use last model $model = $models[count($models) - 1]; } // Is there a slug var available? $sluggedVarName = $varName . "Slug"; if ($model->hasAttribute($sluggedVarName)) { $value = $model->$sluggedVarName; } else { $value = $model->$varName; } // Replace! $url = str_replace('{' . $var . '}', strval($value), $url); } return $url; }
[ "public", "function", "replaceFields", "(", "$", "models", ")", "{", "// Loop through my fields", "$", "url", "=", "$", "this", "->", "_pattern", ";", "foreach", "(", "$", "this", "->", "_patternVariables", "as", "$", "var", ")", "{", "// Look up", "$", "v...
Replace fields in the Route with values from the Model instances @param \ChickenWire\Model $models Array of Model instances to use for values. The last in the array is assumed to be the primary Model to use for values. @return string The uri with the fields replaced
[ "Replace", "fields", "in", "the", "Route", "with", "values", "from", "the", "Model", "instances" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Route.php#L614-L673