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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
240,400
dazarobbo/Cola
src/MString.php
MString.split
public function split($regex = '//u', $limit = -1){ if(!\is_string($regex)){ throw new \InvalidArgumentException('$regex is not a string'); } if(!\is_numeric($limit)){ throw new \InvalidArgumentException('$limit is not a number'); } return \preg_split($regex, $this->_Value, $limit, \PREG_SPLIT_NO_EMPTY); }
php
public function split($regex = '//u', $limit = -1){ if(!\is_string($regex)){ throw new \InvalidArgumentException('$regex is not a string'); } if(!\is_numeric($limit)){ throw new \InvalidArgumentException('$limit is not a number'); } return \preg_split($regex, $this->_Value, $limit, \PREG_SPLIT_NO_EMPTY); }
[ "public", "function", "split", "(", "$", "regex", "=", "'//u'", ",", "$", "limit", "=", "-", "1", ")", "{", "if", "(", "!", "\\", "is_string", "(", "$", "regex", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$regex is not a string'", ")", ";", "}", "if", "(", "!", "\\", "is_numeric", "(", "$", "limit", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$limit is not a number'", ")", ";", "}", "return", "\\", "preg_split", "(", "$", "regex", ",", "$", "this", "->", "_Value", ",", "$", "limit", ",", "\\", "PREG_SPLIT_NO_EMPTY", ")", ";", "}" ]
Splits this string according to a regular expression @param string $regex optional default is to split all characters @param int $limit limit number of splits, default is -1 (no limit) @return string[]
[ "Splits", "this", "string", "according", "to", "a", "regular", "expression" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L563-L575
240,401
dazarobbo/Cola
src/MString.php
MString.startsWith
public function startsWith(self $str, MStringComparison $cmp = null){ if($str->isNullOrEmpty()){ throw new \InvalidArgumentException('$str is empty'); } if($str->count() > $this->count()){ throw new \InvalidArgumentException('$str is longer than $this'); } if($cmp === null || $cmp->getValue() === MStringComparison::CASE_SENSITIVE){ return $this->substring(0, $str->count())->_Value === $str->_Value; } else{ return $this->substring(0, $str->count())->toLower() ->_Value === $str->toLower()->_Value; } }
php
public function startsWith(self $str, MStringComparison $cmp = null){ if($str->isNullOrEmpty()){ throw new \InvalidArgumentException('$str is empty'); } if($str->count() > $this->count()){ throw new \InvalidArgumentException('$str is longer than $this'); } if($cmp === null || $cmp->getValue() === MStringComparison::CASE_SENSITIVE){ return $this->substring(0, $str->count())->_Value === $str->_Value; } else{ return $this->substring(0, $str->count())->toLower() ->_Value === $str->toLower()->_Value; } }
[ "public", "function", "startsWith", "(", "self", "$", "str", ",", "MStringComparison", "$", "cmp", "=", "null", ")", "{", "if", "(", "$", "str", "->", "isNullOrEmpty", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$str is empty'", ")", ";", "}", "if", "(", "$", "str", "->", "count", "(", ")", ">", "$", "this", "->", "count", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$str is longer than $this'", ")", ";", "}", "if", "(", "$", "cmp", "===", "null", "||", "$", "cmp", "->", "getValue", "(", ")", "===", "MStringComparison", "::", "CASE_SENSITIVE", ")", "{", "return", "$", "this", "->", "substring", "(", "0", ",", "$", "str", "->", "count", "(", ")", ")", "->", "_Value", "===", "$", "str", "->", "_Value", ";", "}", "else", "{", "return", "$", "this", "->", "substring", "(", "0", ",", "$", "str", "->", "count", "(", ")", ")", "->", "toLower", "(", ")", "->", "_Value", "===", "$", "str", "->", "toLower", "(", ")", "->", "_Value", ";", "}", "}" ]
Whether this string starts with a given string @link http://stackoverflow.com/a/3282864/570787 @param self $str @param MStringComparison $cmp optional comparision option, default is null (case sensitive) @return bool
[ "Whether", "this", "string", "starts", "with", "a", "given", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L584-L602
240,402
dazarobbo/Cola
src/MString.php
MString.toCharArray
public function toCharArray(){ $arr = array(); for($i = 0, $l = $this->count(); $i < $l; ++$i){ $arr[] = \mb_substr($this->_Value, $i, 1, $this->_Encoding); } return $arr; }
php
public function toCharArray(){ $arr = array(); for($i = 0, $l = $this->count(); $i < $l; ++$i){ $arr[] = \mb_substr($this->_Value, $i, 1, $this->_Encoding); } return $arr; }
[ "public", "function", "toCharArray", "(", ")", "{", "$", "arr", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ",", "$", "l", "=", "$", "this", "->", "count", "(", ")", ";", "$", "i", "<", "$", "l", ";", "++", "$", "i", ")", "{", "$", "arr", "[", "]", "=", "\\", "mb_substr", "(", "$", "this", "->", "_Value", ",", "$", "i", ",", "1", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "return", "$", "arr", ";", "}" ]
Returns an array of each character in this string @return string[]
[ "Returns", "an", "array", "of", "each", "character", "in", "this", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L608-L618
240,403
dazarobbo/Cola
src/MString.php
MString.trim
public function trim(array $chars = null){ if($chars === null){ return new static(\trim($this->_Value), $this->_Encoding); } $chars = \preg_quote(\implode(static::NONE, $chars)); $str = \preg_replace( \sprintf('/(^[%s]+)|([%s]+$)/us', $chars, $chars), static::NONE, $this->_Value); return new static($str, $this->_Encoding); }
php
public function trim(array $chars = null){ if($chars === null){ return new static(\trim($this->_Value), $this->_Encoding); } $chars = \preg_quote(\implode(static::NONE, $chars)); $str = \preg_replace( \sprintf('/(^[%s]+)|([%s]+$)/us', $chars, $chars), static::NONE, $this->_Value); return new static($str, $this->_Encoding); }
[ "public", "function", "trim", "(", "array", "$", "chars", "=", "null", ")", "{", "if", "(", "$", "chars", "===", "null", ")", "{", "return", "new", "static", "(", "\\", "trim", "(", "$", "this", "->", "_Value", ")", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "$", "chars", "=", "\\", "preg_quote", "(", "\\", "implode", "(", "static", "::", "NONE", ",", "$", "chars", ")", ")", ";", "$", "str", "=", "\\", "preg_replace", "(", "\\", "sprintf", "(", "'/(^[%s]+)|([%s]+$)/us'", ",", "$", "chars", ",", "$", "chars", ")", ",", "static", "::", "NONE", ",", "$", "this", "->", "_Value", ")", ";", "return", "new", "static", "(", "$", "str", ",", "$", "this", "->", "_Encoding", ")", ";", "}" ]
Trims whitespace or a set of characters from both ends of this string @param array $chars optional @return \static
[ "Trims", "whitespace", "or", "a", "set", "of", "characters", "from", "both", "ends", "of", "this", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L649-L664
240,404
dazarobbo/Cola
src/MString.php
MString.trimEnd
public function trimEnd(array $chars = null){ if($chars === null){ return new static(\rtrim($this->_Value), $this->_Encoding); } $chars = \preg_quote(\implode(static::NONE, $chars)); $str = \preg_replace( \sprintf('/[%s]+$/us', $chars), static::NONE, $this->_Value); return new static($str, $this->_Encoding); }
php
public function trimEnd(array $chars = null){ if($chars === null){ return new static(\rtrim($this->_Value), $this->_Encoding); } $chars = \preg_quote(\implode(static::NONE, $chars)); $str = \preg_replace( \sprintf('/[%s]+$/us', $chars), static::NONE, $this->_Value); return new static($str, $this->_Encoding); }
[ "public", "function", "trimEnd", "(", "array", "$", "chars", "=", "null", ")", "{", "if", "(", "$", "chars", "===", "null", ")", "{", "return", "new", "static", "(", "\\", "rtrim", "(", "$", "this", "->", "_Value", ")", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "$", "chars", "=", "\\", "preg_quote", "(", "\\", "implode", "(", "static", "::", "NONE", ",", "$", "chars", ")", ")", ";", "$", "str", "=", "\\", "preg_replace", "(", "\\", "sprintf", "(", "'/[%s]+$/us'", ",", "$", "chars", ")", ",", "static", "::", "NONE", ",", "$", "this", "->", "_Value", ")", ";", "return", "new", "static", "(", "$", "str", ",", "$", "this", "->", "_Encoding", ")", ";", "}" ]
Trims whitespace or a set of characters from the end of this string @param array $chars optional @return \static
[ "Trims", "whitespace", "or", "a", "set", "of", "characters", "from", "the", "end", "of", "this", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L671-L686
240,405
dazarobbo/Cola
src/MString.php
MString.trimStart
public function trimStart(array $chars = null){ if($chars === null){ return new static(\ltrim($this->_Value), $this->_Encoding); } $chars = \preg_quote(\implode(static::NONE, $chars)); $str = \preg_replace( \sprintf('/^[%s]+/us', $chars), static::NONE, $this->_Value); return new static($str, $this->_Encoding); }
php
public function trimStart(array $chars = null){ if($chars === null){ return new static(\ltrim($this->_Value), $this->_Encoding); } $chars = \preg_quote(\implode(static::NONE, $chars)); $str = \preg_replace( \sprintf('/^[%s]+/us', $chars), static::NONE, $this->_Value); return new static($str, $this->_Encoding); }
[ "public", "function", "trimStart", "(", "array", "$", "chars", "=", "null", ")", "{", "if", "(", "$", "chars", "===", "null", ")", "{", "return", "new", "static", "(", "\\", "ltrim", "(", "$", "this", "->", "_Value", ")", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "$", "chars", "=", "\\", "preg_quote", "(", "\\", "implode", "(", "static", "::", "NONE", ",", "$", "chars", ")", ")", ";", "$", "str", "=", "\\", "preg_replace", "(", "\\", "sprintf", "(", "'/^[%s]+/us'", ",", "$", "chars", ")", ",", "static", "::", "NONE", ",", "$", "this", "->", "_Value", ")", ";", "return", "new", "static", "(", "$", "str", ",", "$", "this", "->", "_Encoding", ")", ";", "}" ]
Trims whitespace or a set of characters from the beginning of this string @param array $chars optional @return \static
[ "Trims", "whitespace", "or", "a", "set", "of", "characters", "from", "the", "beginning", "of", "this", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L693-L708
240,406
dazarobbo/Cola
src/MString.php
MString.ucfirst
public function ucfirst(){ if($this->isNullOrWhitespace()){ return clone $this; } else if($this->count() === 1){ return new static(\mb_strtoupper($this->_Value, $this->_Encoding), $this->_Encoding); } $str = $this[0]->ucfirst() . $this->substring(1); return new static($str, $this->_Encoding); }
php
public function ucfirst(){ if($this->isNullOrWhitespace()){ return clone $this; } else if($this->count() === 1){ return new static(\mb_strtoupper($this->_Value, $this->_Encoding), $this->_Encoding); } $str = $this[0]->ucfirst() . $this->substring(1); return new static($str, $this->_Encoding); }
[ "public", "function", "ucfirst", "(", ")", "{", "if", "(", "$", "this", "->", "isNullOrWhitespace", "(", ")", ")", "{", "return", "clone", "$", "this", ";", "}", "else", "if", "(", "$", "this", "->", "count", "(", ")", "===", "1", ")", "{", "return", "new", "static", "(", "\\", "mb_strtoupper", "(", "$", "this", "->", "_Value", ",", "$", "this", "->", "_Encoding", ")", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "$", "str", "=", "$", "this", "[", "0", "]", "->", "ucfirst", "(", ")", ".", "$", "this", "->", "substring", "(", "1", ")", ";", "return", "new", "static", "(", "$", "str", ",", "$", "this", "->", "_Encoding", ")", ";", "}" ]
Returns a new string with the first character in upper case @return \static
[ "Returns", "a", "new", "string", "with", "the", "first", "character", "in", "upper", "case" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L714-L728
240,407
dazarobbo/Cola
src/MString.php
MString.unserialize
public function unserialize($serialized) { $arr = \unserialize($serialized); $this->_Value = $arr[0]; $this->_Encoding = $arr[1]; }
php
public function unserialize($serialized) { $arr = \unserialize($serialized); $this->_Value = $arr[0]; $this->_Encoding = $arr[1]; }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "$", "arr", "=", "\\", "unserialize", "(", "$", "serialized", ")", ";", "$", "this", "->", "_Value", "=", "$", "arr", "[", "0", "]", ";", "$", "this", "->", "_Encoding", "=", "$", "arr", "[", "1", "]", ";", "}" ]
Unserializes a serialized string @param string $serialized @return \static
[ "Unserializes", "a", "serialized", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L735-L739
240,408
GovTribe/laravel-kinvey
src/GovTribe/LaravelKinvey/Database/Eloquent/File.php
File.download
public function download($pathToFile, $name = null, array $headers = array()) { $response = StaticClient::get($this->offsetGet('_downloadURL'), array( 'headers' => $headers, 'timeout' => $this->timeout, 'save_to' => $pathToFile, )); file_put_contents($pathToFile, $response->getBody()->getStream()); }
php
public function download($pathToFile, $name = null, array $headers = array()) { $response = StaticClient::get($this->offsetGet('_downloadURL'), array( 'headers' => $headers, 'timeout' => $this->timeout, 'save_to' => $pathToFile, )); file_put_contents($pathToFile, $response->getBody()->getStream()); }
[ "public", "function", "download", "(", "$", "pathToFile", ",", "$", "name", "=", "null", ",", "array", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "response", "=", "StaticClient", "::", "get", "(", "$", "this", "->", "offsetGet", "(", "'_downloadURL'", ")", ",", "array", "(", "'headers'", "=>", "$", "headers", ",", "'timeout'", "=>", "$", "this", "->", "timeout", ",", "'save_to'", "=>", "$", "pathToFile", ",", ")", ")", ";", "file_put_contents", "(", "$", "pathToFile", ",", "$", "response", "->", "getBody", "(", ")", "->", "getStream", "(", ")", ")", ";", "}" ]
Download the file to a local path. @param string $pathToFile, @param string $name @param headers $array @return void
[ "Download", "the", "file", "to", "a", "local", "path", "." ]
8a25dafdf80a933384dfcfe8b70b0a7663fe9289
https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/Database/Eloquent/File.php#L40-L49
240,409
marcoazn89/http-wrapper
src/Response.php
Response.withType
public function withType($value) { $new = clone $this; $new->headers[Header\ContentType::name()] = []; $new->headers[Header\ContentType::name()][] = $value; return $new; }
php
public function withType($value) { $new = clone $this; $new->headers[Header\ContentType::name()] = []; $new->headers[Header\ContentType::name()][] = $value; return $new; }
[ "public", "function", "withType", "(", "$", "value", ")", "{", "$", "new", "=", "clone", "$", "this", ";", "$", "new", "->", "headers", "[", "Header", "\\", "ContentType", "::", "name", "(", ")", "]", "=", "[", "]", ";", "$", "new", "->", "headers", "[", "Header", "\\", "ContentType", "::", "name", "(", ")", "]", "[", "]", "=", "$", "value", ";", "return", "$", "new", ";", "}" ]
Return an instance with the provided value replacing the Content-Type header. While header names are case-insensitive, the casing of the header will be preserved by this function, and returned from getHeaders(). @param string $name Case-insensitive header field name. @param string|string[] $value Header value(s). @return self @throws \InvalidArgumentException for invalid header names or values.
[ "Return", "an", "instance", "with", "the", "provided", "value", "replacing", "the", "Content", "-", "Type", "header", "." ]
23e3809c439791ce699f67b4886c066896ea4556
https://github.com/marcoazn89/http-wrapper/blob/23e3809c439791ce699f67b4886c066896ea4556/src/Response.php#L272-L281
240,410
marcoazn89/http-wrapper
src/Response.php
Response.withLanguage
public function withLanguage($value) { $new = clone $this; $new->headers[Header\Language::name()] = []; $new->headers[Header\Language::name()][] = $value; return $new; }
php
public function withLanguage($value) { $new = clone $this; $new->headers[Header\Language::name()] = []; $new->headers[Header\Language::name()][] = $value; return $new; }
[ "public", "function", "withLanguage", "(", "$", "value", ")", "{", "$", "new", "=", "clone", "$", "this", ";", "$", "new", "->", "headers", "[", "Header", "\\", "Language", "::", "name", "(", ")", "]", "=", "[", "]", ";", "$", "new", "->", "headers", "[", "Header", "\\", "Language", "::", "name", "(", ")", "]", "[", "]", "=", "$", "value", ";", "return", "$", "new", ";", "}" ]
Return an instance with the provided value replacing the Language header. While header names are case-insensitive, the casing of the header will be preserved by this function, and returned from getHeaders(). @param string $name Case-insensitive header field name. @param string|string[] $value Header value(s). @return self @throws \InvalidArgumentException for invalid header names or values.
[ "Return", "an", "instance", "with", "the", "provided", "value", "replacing", "the", "Language", "header", "." ]
23e3809c439791ce699f67b4886c066896ea4556
https://github.com/marcoazn89/http-wrapper/blob/23e3809c439791ce699f67b4886c066896ea4556/src/Response.php#L294-L303
240,411
marcoazn89/http-wrapper
src/Response.php
Response.withTypeNegotiation
public function withTypeNegotiation($strongNegotiation = false) { $negotiation = array_intersect(Request\AcceptType::getContent(), Support\TypeSupport::getSupport()); $content = ''; if(count($negotiation) > 0) { $content = current($negotiation); } else { if($strongNegotiation) { $this->failTypeNegotiation(); } else { $content = Support\TypeSupport::getSupport(); $content = $content[0]; } } return $this->withType($content); }
php
public function withTypeNegotiation($strongNegotiation = false) { $negotiation = array_intersect(Request\AcceptType::getContent(), Support\TypeSupport::getSupport()); $content = ''; if(count($negotiation) > 0) { $content = current($negotiation); } else { if($strongNegotiation) { $this->failTypeNegotiation(); } else { $content = Support\TypeSupport::getSupport(); $content = $content[0]; } } return $this->withType($content); }
[ "public", "function", "withTypeNegotiation", "(", "$", "strongNegotiation", "=", "false", ")", "{", "$", "negotiation", "=", "array_intersect", "(", "Request", "\\", "AcceptType", "::", "getContent", "(", ")", ",", "Support", "\\", "TypeSupport", "::", "getSupport", "(", ")", ")", ";", "$", "content", "=", "''", ";", "if", "(", "count", "(", "$", "negotiation", ")", ">", "0", ")", "{", "$", "content", "=", "current", "(", "$", "negotiation", ")", ";", "}", "else", "{", "if", "(", "$", "strongNegotiation", ")", "{", "$", "this", "->", "failTypeNegotiation", "(", ")", ";", "}", "else", "{", "$", "content", "=", "Support", "\\", "TypeSupport", "::", "getSupport", "(", ")", ";", "$", "content", "=", "$", "content", "[", "0", "]", ";", "}", "}", "return", "$", "this", "->", "withType", "(", "$", "content", ")", ";", "}" ]
Negotiate Mime types @param boolean $strongNegotiation Enfore a strong negotiation @todo Implement weights @return [type] [description]
[ "Negotiate", "Mime", "types" ]
23e3809c439791ce699f67b4886c066896ea4556
https://github.com/marcoazn89/http-wrapper/blob/23e3809c439791ce699f67b4886c066896ea4556/src/Response.php#L311-L331
240,412
marcoazn89/http-wrapper
src/Response.php
Response.withAddedType
public function withAddedType($value) { $new = clone $this; if (empty($new->headers[Header\ContentType::name()])) { $new->headers[Header\ContentType::name()] = []; } $new->headers[Header\ContentType::name()][] = $value; return $new; }
php
public function withAddedType($value) { $new = clone $this; if (empty($new->headers[Header\ContentType::name()])) { $new->headers[Header\ContentType::name()] = []; } $new->headers[Header\ContentType::name()][] = $value; return $new; }
[ "public", "function", "withAddedType", "(", "$", "value", ")", "{", "$", "new", "=", "clone", "$", "this", ";", "if", "(", "empty", "(", "$", "new", "->", "headers", "[", "Header", "\\", "ContentType", "::", "name", "(", ")", "]", ")", ")", "{", "$", "new", "->", "headers", "[", "Header", "\\", "ContentType", "::", "name", "(", ")", "]", "=", "[", "]", ";", "}", "$", "new", "->", "headers", "[", "Header", "\\", "ContentType", "::", "name", "(", ")", "]", "[", "]", "=", "$", "value", ";", "return", "$", "new", ";", "}" ]
Return an instance with the Content-Type header appended with the given value. Existing values for the specified header will be maintained. The new value(s) will be appended to the existing list. If the header did not exist previously, it will be added. @param string $name Case-insensitive header field name to add. @param string|string[] $value Header value(s). @return self @throws \InvalidArgumentException for invalid header names or values.
[ "Return", "an", "instance", "with", "the", "Content", "-", "Type", "header", "appended", "with", "the", "given", "value", "." ]
23e3809c439791ce699f67b4886c066896ea4556
https://github.com/marcoazn89/http-wrapper/blob/23e3809c439791ce699f67b4886c066896ea4556/src/Response.php#L370-L380
240,413
marcoazn89/http-wrapper
src/Response.php
Response.withAddedLanguage
public function withAddedLanguage($value) { $new = clone $this; if (empty($new->headers[Header\Language::name()])) { $new->headers[Header\Language::name()] = []; } $new->headers[Header\Language::name()][] = $value; return $new; }
php
public function withAddedLanguage($value) { $new = clone $this; if (empty($new->headers[Header\Language::name()])) { $new->headers[Header\Language::name()] = []; } $new->headers[Header\Language::name()][] = $value; return $new; }
[ "public", "function", "withAddedLanguage", "(", "$", "value", ")", "{", "$", "new", "=", "clone", "$", "this", ";", "if", "(", "empty", "(", "$", "new", "->", "headers", "[", "Header", "\\", "Language", "::", "name", "(", ")", "]", ")", ")", "{", "$", "new", "->", "headers", "[", "Header", "\\", "Language", "::", "name", "(", ")", "]", "=", "[", "]", ";", "}", "$", "new", "->", "headers", "[", "Header", "\\", "Language", "::", "name", "(", ")", "]", "[", "]", "=", "$", "value", ";", "return", "$", "new", ";", "}" ]
Return an instance with the Language header appended with the given value. Existing values for the specified header will be maintained. The new value(s) will be appended to the existing list. If the header did not exist previously, it will be added. @param string $name Case-insensitive header field name to add. @param string|string[] $value Header value(s). @return self @throws \InvalidArgumentException for invalid header names or values.
[ "Return", "an", "instance", "with", "the", "Language", "header", "appended", "with", "the", "given", "value", "." ]
23e3809c439791ce699f67b4886c066896ea4556
https://github.com/marcoazn89/http-wrapper/blob/23e3809c439791ce699f67b4886c066896ea4556/src/Response.php#L394-L405
240,414
marcoazn89/http-wrapper
src/Response.php
Response.failTypeNegotiation
protected function failTypeNegotiation() { $supported = Request\TypeSupport::getSupport(); $clientSupport = Request\AcceptType::getContent(); $supported = implode(',', $supported); $clientSupport = implode(',',$clientSupport); $this->withStatus(406)->withType(Response\ContentType::TEXT) ->write("NOT SUPPORTED\nThis server does not support {$supported}.\nSupported formats: {$clientSupport}") ->send(); exit(1); }
php
protected function failTypeNegotiation() { $supported = Request\TypeSupport::getSupport(); $clientSupport = Request\AcceptType::getContent(); $supported = implode(',', $supported); $clientSupport = implode(',',$clientSupport); $this->withStatus(406)->withType(Response\ContentType::TEXT) ->write("NOT SUPPORTED\nThis server does not support {$supported}.\nSupported formats: {$clientSupport}") ->send(); exit(1); }
[ "protected", "function", "failTypeNegotiation", "(", ")", "{", "$", "supported", "=", "Request", "\\", "TypeSupport", "::", "getSupport", "(", ")", ";", "$", "clientSupport", "=", "Request", "\\", "AcceptType", "::", "getContent", "(", ")", ";", "$", "supported", "=", "implode", "(", "','", ",", "$", "supported", ")", ";", "$", "clientSupport", "=", "implode", "(", "','", ",", "$", "clientSupport", ")", ";", "$", "this", "->", "withStatus", "(", "406", ")", "->", "withType", "(", "Response", "\\", "ContentType", "::", "TEXT", ")", "->", "write", "(", "\"NOT SUPPORTED\\nThis server does not support {$supported}.\\nSupported formats: {$clientSupport}\"", ")", "->", "send", "(", ")", ";", "exit", "(", "1", ")", ";", "}" ]
Send a 406 response for failed content negotiation
[ "Send", "a", "406", "response", "for", "failed", "content", "negotiation" ]
23e3809c439791ce699f67b4886c066896ea4556
https://github.com/marcoazn89/http-wrapper/blob/23e3809c439791ce699f67b4886c066896ea4556/src/Response.php#L459-L471
240,415
marcoazn89/http-wrapper
src/Response.php
Response.overwrite
public function overwrite($data) { $body = $this->getBody(); $body->rewind(); $body->write($data); return $this; }
php
public function overwrite($data) { $body = $this->getBody(); $body->rewind(); $body->write($data); return $this; }
[ "public", "function", "overwrite", "(", "$", "data", ")", "{", "$", "body", "=", "$", "this", "->", "getBody", "(", ")", ";", "$", "body", "->", "rewind", "(", ")", ";", "$", "body", "->", "write", "(", "$", "data", ")", ";", "return", "$", "this", ";", "}" ]
Write content to the stream by overwriting existing content @param mixed $data Data to be written to the body @return Response The Response object
[ "Write", "content", "to", "the", "stream", "by", "overwriting", "existing", "content" ]
23e3809c439791ce699f67b4886c066896ea4556
https://github.com/marcoazn89/http-wrapper/blob/23e3809c439791ce699f67b4886c066896ea4556/src/Response.php#L517-L524
240,416
marcoazn89/http-wrapper
src/Response.php
Response.send
public function send() { header($this->getStatusStr()); foreach($this->headers as $header => $value) { header(sprintf("%s: %s", $header, implode(',', $value))); } $body = $this->getBody(); if ($body->isAttached()) { $body->rewind(); while (!$body->eof()) { echo $body->read($this->bodySize); } } }
php
public function send() { header($this->getStatusStr()); foreach($this->headers as $header => $value) { header(sprintf("%s: %s", $header, implode(',', $value))); } $body = $this->getBody(); if ($body->isAttached()) { $body->rewind(); while (!$body->eof()) { echo $body->read($this->bodySize); } } }
[ "public", "function", "send", "(", ")", "{", "header", "(", "$", "this", "->", "getStatusStr", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "header", "=>", "$", "value", ")", "{", "header", "(", "sprintf", "(", "\"%s: %s\"", ",", "$", "header", ",", "implode", "(", "','", ",", "$", "value", ")", ")", ")", ";", "}", "$", "body", "=", "$", "this", "->", "getBody", "(", ")", ";", "if", "(", "$", "body", "->", "isAttached", "(", ")", ")", "{", "$", "body", "->", "rewind", "(", ")", ";", "while", "(", "!", "$", "body", "->", "eof", "(", ")", ")", "{", "echo", "$", "body", "->", "read", "(", "$", "this", "->", "bodySize", ")", ";", "}", "}", "}" ]
Send the Response object over the wire
[ "Send", "the", "Response", "object", "over", "the", "wire" ]
23e3809c439791ce699f67b4886c066896ea4556
https://github.com/marcoazn89/http-wrapper/blob/23e3809c439791ce699f67b4886c066896ea4556/src/Response.php#L554-L570
240,417
nattreid/app-manager
src/Helpers/Database/NextrasDbal.php
NextrasDbal.dropDatabase
public function dropDatabase(): void { $tables = $this->getTables(); if (!empty($tables)) { $this->connection->query('SET foreign_key_checks = 0'); foreach ($tables as $table) { $this->connection->query('DROP TABLE %table', $table); } $this->connection->query('SET foreign_key_checks = 1'); } }
php
public function dropDatabase(): void { $tables = $this->getTables(); if (!empty($tables)) { $this->connection->query('SET foreign_key_checks = 0'); foreach ($tables as $table) { $this->connection->query('DROP TABLE %table', $table); } $this->connection->query('SET foreign_key_checks = 1'); } }
[ "public", "function", "dropDatabase", "(", ")", ":", "void", "{", "$", "tables", "=", "$", "this", "->", "getTables", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "tables", ")", ")", "{", "$", "this", "->", "connection", "->", "query", "(", "'SET foreign_key_checks = 0'", ")", ";", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "$", "this", "->", "connection", "->", "query", "(", "'DROP TABLE %table'", ",", "$", "table", ")", ";", "}", "$", "this", "->", "connection", "->", "query", "(", "'SET foreign_key_checks = 1'", ")", ";", "}", "}" ]
Smaze vsechny tabulky v databazi @throws QueryException
[ "Smaze", "vsechny", "tabulky", "v", "databazi" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Database/NextrasDbal.php#L71-L81
240,418
vincenttouzet/BaseBundle
Twig/VinceTBaseExtension.php
VinceTBaseExtension.camelizeBundle
public function camelizeBundle($string) { $string = $this->camelize($string); $string = str_replace('_bundle', '', $string); return $string; }
php
public function camelizeBundle($string) { $string = $this->camelize($string); $string = str_replace('_bundle', '', $string); return $string; }
[ "public", "function", "camelizeBundle", "(", "$", "string", ")", "{", "$", "string", "=", "$", "this", "->", "camelize", "(", "$", "string", ")", ";", "$", "string", "=", "str_replace", "(", "'_bundle'", ",", "''", ",", "$", "string", ")", ";", "return", "$", "string", ";", "}" ]
camelize a bundle name. @param string $string Bundle name to camelize @return string
[ "camelize", "a", "bundle", "name", "." ]
04faac91884ac5ae270a32ba3d63dca8892aa1dd
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Twig/VinceTBaseExtension.php#L64-L70
240,419
phlexible/phlexible
src/Phlexible/Bundle/SearchBundle/Controller/StatusController.php
StatusController.indexAction
public function indexAction(Request $request) { $query = $request->query->get('query'); $limit = $request->query->get('limit'); $start = $request->query->get('start'); $searchProviders = $this->get('search.providers'); $content = ''; $content .= '<h3>Registered Search Providers:</h3><table><tr><th>Class</th><th>Resource</th><th>Search key</th></tr>'; foreach ($searchProviders as $searchProvider) { $content .= '<tr>'; $content .= '<td>'.get_class($searchProvider).'</td>'; $content .= '<td>'.$searchProvider->getResource().'</td>'; $content .= '<td>'.$searchProvider->getSearchKey().'</td>'; $content .= '</tr>'; } $content .= '</table>'; $content .= '<h3>Search:</h3>'; $content .= '<form><input name="query" value="'.$query.'"/><input type="submit" value="send" /></form>'; if ($query) { $content .= '<h3>Results:</h3>'; $search = $this->getContainer()->get('search.search'); $results = $search->search($query); $content .= '<pre>'; $content .= print_r($results, true); $content .= '</pre>'; } return new Response($content); }
php
public function indexAction(Request $request) { $query = $request->query->get('query'); $limit = $request->query->get('limit'); $start = $request->query->get('start'); $searchProviders = $this->get('search.providers'); $content = ''; $content .= '<h3>Registered Search Providers:</h3><table><tr><th>Class</th><th>Resource</th><th>Search key</th></tr>'; foreach ($searchProviders as $searchProvider) { $content .= '<tr>'; $content .= '<td>'.get_class($searchProvider).'</td>'; $content .= '<td>'.$searchProvider->getResource().'</td>'; $content .= '<td>'.$searchProvider->getSearchKey().'</td>'; $content .= '</tr>'; } $content .= '</table>'; $content .= '<h3>Search:</h3>'; $content .= '<form><input name="query" value="'.$query.'"/><input type="submit" value="send" /></form>'; if ($query) { $content .= '<h3>Results:</h3>'; $search = $this->getContainer()->get('search.search'); $results = $search->search($query); $content .= '<pre>'; $content .= print_r($results, true); $content .= '</pre>'; } return new Response($content); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ")", "{", "$", "query", "=", "$", "request", "->", "query", "->", "get", "(", "'query'", ")", ";", "$", "limit", "=", "$", "request", "->", "query", "->", "get", "(", "'limit'", ")", ";", "$", "start", "=", "$", "request", "->", "query", "->", "get", "(", "'start'", ")", ";", "$", "searchProviders", "=", "$", "this", "->", "get", "(", "'search.providers'", ")", ";", "$", "content", "=", "''", ";", "$", "content", ".=", "'<h3>Registered Search Providers:</h3><table><tr><th>Class</th><th>Resource</th><th>Search key</th></tr>'", ";", "foreach", "(", "$", "searchProviders", "as", "$", "searchProvider", ")", "{", "$", "content", ".=", "'<tr>'", ";", "$", "content", ".=", "'<td>'", ".", "get_class", "(", "$", "searchProvider", ")", ".", "'</td>'", ";", "$", "content", ".=", "'<td>'", ".", "$", "searchProvider", "->", "getResource", "(", ")", ".", "'</td>'", ";", "$", "content", ".=", "'<td>'", ".", "$", "searchProvider", "->", "getSearchKey", "(", ")", ".", "'</td>'", ";", "$", "content", ".=", "'</tr>'", ";", "}", "$", "content", ".=", "'</table>'", ";", "$", "content", ".=", "'<h3>Search:</h3>'", ";", "$", "content", ".=", "'<form><input name=\"query\" value=\"'", ".", "$", "query", ".", "'\"/><input type=\"submit\" value=\"send\" /></form>'", ";", "if", "(", "$", "query", ")", "{", "$", "content", ".=", "'<h3>Results:</h3>'", ";", "$", "search", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'search.search'", ")", ";", "$", "results", "=", "$", "search", "->", "search", "(", "$", "query", ")", ";", "$", "content", ".=", "'<pre>'", ";", "$", "content", ".=", "print_r", "(", "$", "results", ",", "true", ")", ";", "$", "content", ".=", "'</pre>'", ";", "}", "return", "new", "Response", "(", "$", "content", ")", ";", "}" ]
Return Search results. @param Request $request @return Response @Route("", name="search_status")
[ "Return", "Search", "results", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/SearchBundle/Controller/StatusController.php#L37-L69
240,420
novuso/novusopress
core/Assets.php
Assets.loadSiteScripts
public function loadSiteScripts() { if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } $mainHandle = 'site'; $this->loadMainScriptByHandle($mainHandle); $viewHandle = $this->getViewHandle(); if (file_exists(sprintf('%s/js/views/%s.js', $this->paths->getThemeAssetsDir(), $viewHandle))) { $viewSrc = sprintf('%s/js/views/%s.js', $this->paths->getThemeAssetsUri(), $viewHandle); $this->loadScript($viewHandle, $viewSrc, [$mainHandle], true); } }
php
public function loadSiteScripts() { if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } $mainHandle = 'site'; $this->loadMainScriptByHandle($mainHandle); $viewHandle = $this->getViewHandle(); if (file_exists(sprintf('%s/js/views/%s.js', $this->paths->getThemeAssetsDir(), $viewHandle))) { $viewSrc = sprintf('%s/js/views/%s.js', $this->paths->getThemeAssetsUri(), $viewHandle); $this->loadScript($viewHandle, $viewSrc, [$mainHandle], true); } }
[ "public", "function", "loadSiteScripts", "(", ")", "{", "if", "(", "is_singular", "(", ")", "&&", "comments_open", "(", ")", "&&", "get_option", "(", "'thread_comments'", ")", ")", "{", "wp_enqueue_script", "(", "'comment-reply'", ")", ";", "}", "$", "mainHandle", "=", "'site'", ";", "$", "this", "->", "loadMainScriptByHandle", "(", "$", "mainHandle", ")", ";", "$", "viewHandle", "=", "$", "this", "->", "getViewHandle", "(", ")", ";", "if", "(", "file_exists", "(", "sprintf", "(", "'%s/js/views/%s.js'", ",", "$", "this", "->", "paths", "->", "getThemeAssetsDir", "(", ")", ",", "$", "viewHandle", ")", ")", ")", "{", "$", "viewSrc", "=", "sprintf", "(", "'%s/js/views/%s.js'", ",", "$", "this", "->", "paths", "->", "getThemeAssetsUri", "(", ")", ",", "$", "viewHandle", ")", ";", "$", "this", "->", "loadScript", "(", "$", "viewHandle", ",", "$", "viewSrc", ",", "[", "$", "mainHandle", "]", ",", "true", ")", ";", "}", "}" ]
Loads frontend scripts
[ "Loads", "frontend", "scripts" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L79-L94
240,421
novuso/novusopress
core/Assets.php
Assets.loadSiteStyles
public function loadSiteStyles() { $this->loadCdnStyles(); $mainHandle = 'site'; $this->loadMainStyleByHandle($mainHandle); $viewHandle = $this->getViewHandle(); if (file_exists(sprintf('%s/css/views/%s.css', $this->paths->getThemeAssetsDir(), $viewHandle))) { $viewSrc = sprintf('%s/css/views/%s.css', $this->paths->getThemeAssetsUri(), $viewHandle); $this->loadStyle($viewHandle, $viewSrc, [$mainHandle]); } }
php
public function loadSiteStyles() { $this->loadCdnStyles(); $mainHandle = 'site'; $this->loadMainStyleByHandle($mainHandle); $viewHandle = $this->getViewHandle(); if (file_exists(sprintf('%s/css/views/%s.css', $this->paths->getThemeAssetsDir(), $viewHandle))) { $viewSrc = sprintf('%s/css/views/%s.css', $this->paths->getThemeAssetsUri(), $viewHandle); $this->loadStyle($viewHandle, $viewSrc, [$mainHandle]); } }
[ "public", "function", "loadSiteStyles", "(", ")", "{", "$", "this", "->", "loadCdnStyles", "(", ")", ";", "$", "mainHandle", "=", "'site'", ";", "$", "this", "->", "loadMainStyleByHandle", "(", "$", "mainHandle", ")", ";", "$", "viewHandle", "=", "$", "this", "->", "getViewHandle", "(", ")", ";", "if", "(", "file_exists", "(", "sprintf", "(", "'%s/css/views/%s.css'", ",", "$", "this", "->", "paths", "->", "getThemeAssetsDir", "(", ")", ",", "$", "viewHandle", ")", ")", ")", "{", "$", "viewSrc", "=", "sprintf", "(", "'%s/css/views/%s.css'", ",", "$", "this", "->", "paths", "->", "getThemeAssetsUri", "(", ")", ",", "$", "viewHandle", ")", ";", "$", "this", "->", "loadStyle", "(", "$", "viewHandle", ",", "$", "viewSrc", ",", "[", "$", "mainHandle", "]", ")", ";", "}", "}" ]
Loads frontend styles
[ "Loads", "frontend", "styles" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L99-L112
240,422
novuso/novusopress
core/Assets.php
Assets.loadCustomizeScript
public function loadCustomizeScript() { $handle = 'novusopress_customize'; $url = sprintf('%s/js/customize.js', $this->paths->getBaseAssetsUri()); $deps = ['jquery', 'customize-preview']; $this->loadScript($handle, $url, $deps, true); }
php
public function loadCustomizeScript() { $handle = 'novusopress_customize'; $url = sprintf('%s/js/customize.js', $this->paths->getBaseAssetsUri()); $deps = ['jquery', 'customize-preview']; $this->loadScript($handle, $url, $deps, true); }
[ "public", "function", "loadCustomizeScript", "(", ")", "{", "$", "handle", "=", "'novusopress_customize'", ";", "$", "url", "=", "sprintf", "(", "'%s/js/customize.js'", ",", "$", "this", "->", "paths", "->", "getBaseAssetsUri", "(", ")", ")", ";", "$", "deps", "=", "[", "'jquery'", ",", "'customize-preview'", "]", ";", "$", "this", "->", "loadScript", "(", "$", "handle", ",", "$", "url", ",", "$", "deps", ",", "true", ")", ";", "}" ]
Loads customize page script
[ "Loads", "customize", "page", "script" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L149-L155
240,423
novuso/novusopress
core/Assets.php
Assets.loadCdnStyles
protected function loadCdnStyles() { if (file_exists(sprintf('%s/cdn-styles.json', $this->paths->getThemeConfigDir()))) { $cdnContent = file_get_contents(sprintf('%s/cdn-styles.json', $this->paths->getThemeConfigDir())); $cdnStyles = json_decode($cdnContent, true); for ($i = 0; $i < count($cdnStyles); $i++) { $handle = $i ? 'cdn'.$i : 'cdn'; wp_enqueue_style($handle, $cdnStyles[$i], [], null); } } }
php
protected function loadCdnStyles() { if (file_exists(sprintf('%s/cdn-styles.json', $this->paths->getThemeConfigDir()))) { $cdnContent = file_get_contents(sprintf('%s/cdn-styles.json', $this->paths->getThemeConfigDir())); $cdnStyles = json_decode($cdnContent, true); for ($i = 0; $i < count($cdnStyles); $i++) { $handle = $i ? 'cdn'.$i : 'cdn'; wp_enqueue_style($handle, $cdnStyles[$i], [], null); } } }
[ "protected", "function", "loadCdnStyles", "(", ")", "{", "if", "(", "file_exists", "(", "sprintf", "(", "'%s/cdn-styles.json'", ",", "$", "this", "->", "paths", "->", "getThemeConfigDir", "(", ")", ")", ")", ")", "{", "$", "cdnContent", "=", "file_get_contents", "(", "sprintf", "(", "'%s/cdn-styles.json'", ",", "$", "this", "->", "paths", "->", "getThemeConfigDir", "(", ")", ")", ")", ";", "$", "cdnStyles", "=", "json_decode", "(", "$", "cdnContent", ",", "true", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "cdnStyles", ")", ";", "$", "i", "++", ")", "{", "$", "handle", "=", "$", "i", "?", "'cdn'", ".", "$", "i", ":", "'cdn'", ";", "wp_enqueue_style", "(", "$", "handle", ",", "$", "cdnStyles", "[", "$", "i", "]", ",", "[", "]", ",", "null", ")", ";", "}", "}", "}" ]
Loads stylesheets from CDNs such as Google fonts
[ "Loads", "stylesheets", "from", "CDNs", "such", "as", "Google", "fonts" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L160-L170
240,424
novuso/novusopress
core/Assets.php
Assets.loadMainScriptByHandle
protected function loadMainScriptByHandle($mainHandle) { $deps = $this->getScriptDeps($mainHandle); if (file_exists(sprintf('%s/js/%s.js', $this->paths->getThemeAssetsDir(), $mainHandle))) { $mainSrc = sprintf('%s/js/%s.js', $this->paths->getThemeAssetsUri(), $mainHandle); } else { // load empty script in case we need to load dependencies $mainSrc = sprintf('%s/js/%s.js', $this->paths->getBaseAssetsUri(), $mainHandle); } $this->loadScript($mainHandle, $mainSrc, $deps, true); }
php
protected function loadMainScriptByHandle($mainHandle) { $deps = $this->getScriptDeps($mainHandle); if (file_exists(sprintf('%s/js/%s.js', $this->paths->getThemeAssetsDir(), $mainHandle))) { $mainSrc = sprintf('%s/js/%s.js', $this->paths->getThemeAssetsUri(), $mainHandle); } else { // load empty script in case we need to load dependencies $mainSrc = sprintf('%s/js/%s.js', $this->paths->getBaseAssetsUri(), $mainHandle); } $this->loadScript($mainHandle, $mainSrc, $deps, true); }
[ "protected", "function", "loadMainScriptByHandle", "(", "$", "mainHandle", ")", "{", "$", "deps", "=", "$", "this", "->", "getScriptDeps", "(", "$", "mainHandle", ")", ";", "if", "(", "file_exists", "(", "sprintf", "(", "'%s/js/%s.js'", ",", "$", "this", "->", "paths", "->", "getThemeAssetsDir", "(", ")", ",", "$", "mainHandle", ")", ")", ")", "{", "$", "mainSrc", "=", "sprintf", "(", "'%s/js/%s.js'", ",", "$", "this", "->", "paths", "->", "getThemeAssetsUri", "(", ")", ",", "$", "mainHandle", ")", ";", "}", "else", "{", "// load empty script in case we need to load dependencies", "$", "mainSrc", "=", "sprintf", "(", "'%s/js/%s.js'", ",", "$", "this", "->", "paths", "->", "getBaseAssetsUri", "(", ")", ",", "$", "mainHandle", ")", ";", "}", "$", "this", "->", "loadScript", "(", "$", "mainHandle", ",", "$", "mainSrc", ",", "$", "deps", ",", "true", ")", ";", "}" ]
Loads a main script file using handle conventions @param string $mainHandle The script handle
[ "Loads", "a", "main", "script", "file", "using", "handle", "conventions" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L177-L189
240,425
novuso/novusopress
core/Assets.php
Assets.loadMainStyleByHandle
protected function loadMainStyleByHandle($mainHandle) { $deps = $this->getStyleDeps($mainHandle); if (file_exists(sprintf('%s/css/%s.css', $this->paths->getThemeAssetsDir(), $mainHandle))) { $mainSrc = sprintf('%s/css/%s.css', $this->paths->getThemeAssetsUri(), $mainHandle); } else { // load styles in case we need to load dependencies $mainSrc = sprintf('%s/css/%s.css', $this->paths->getBaseAssetsUri(), $mainHandle); } $this->loadStyle($mainHandle, $mainSrc, $deps); }
php
protected function loadMainStyleByHandle($mainHandle) { $deps = $this->getStyleDeps($mainHandle); if (file_exists(sprintf('%s/css/%s.css', $this->paths->getThemeAssetsDir(), $mainHandle))) { $mainSrc = sprintf('%s/css/%s.css', $this->paths->getThemeAssetsUri(), $mainHandle); } else { // load styles in case we need to load dependencies $mainSrc = sprintf('%s/css/%s.css', $this->paths->getBaseAssetsUri(), $mainHandle); } $this->loadStyle($mainHandle, $mainSrc, $deps); }
[ "protected", "function", "loadMainStyleByHandle", "(", "$", "mainHandle", ")", "{", "$", "deps", "=", "$", "this", "->", "getStyleDeps", "(", "$", "mainHandle", ")", ";", "if", "(", "file_exists", "(", "sprintf", "(", "'%s/css/%s.css'", ",", "$", "this", "->", "paths", "->", "getThemeAssetsDir", "(", ")", ",", "$", "mainHandle", ")", ")", ")", "{", "$", "mainSrc", "=", "sprintf", "(", "'%s/css/%s.css'", ",", "$", "this", "->", "paths", "->", "getThemeAssetsUri", "(", ")", ",", "$", "mainHandle", ")", ";", "}", "else", "{", "// load styles in case we need to load dependencies", "$", "mainSrc", "=", "sprintf", "(", "'%s/css/%s.css'", ",", "$", "this", "->", "paths", "->", "getBaseAssetsUri", "(", ")", ",", "$", "mainHandle", ")", ";", "}", "$", "this", "->", "loadStyle", "(", "$", "mainHandle", ",", "$", "mainSrc", ",", "$", "deps", ")", ";", "}" ]
Loads a main stylesheet file using handle conventions @param string $mainHandle The style handle
[ "Loads", "a", "main", "stylesheet", "file", "using", "handle", "conventions" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L196-L208
240,426
novuso/novusopress
core/Assets.php
Assets.getScriptDeps
protected function getScriptDeps($section) { $dependencies = $this->getDependencies(); $deps = isset($dependencies['scripts']) ? $dependencies['scripts'] : []; return isset($deps[$section]) ? $deps[$section] : []; }
php
protected function getScriptDeps($section) { $dependencies = $this->getDependencies(); $deps = isset($dependencies['scripts']) ? $dependencies['scripts'] : []; return isset($deps[$section]) ? $deps[$section] : []; }
[ "protected", "function", "getScriptDeps", "(", "$", "section", ")", "{", "$", "dependencies", "=", "$", "this", "->", "getDependencies", "(", ")", ";", "$", "deps", "=", "isset", "(", "$", "dependencies", "[", "'scripts'", "]", ")", "?", "$", "dependencies", "[", "'scripts'", "]", ":", "[", "]", ";", "return", "isset", "(", "$", "deps", "[", "$", "section", "]", ")", "?", "$", "deps", "[", "$", "section", "]", ":", "[", "]", ";", "}" ]
Retrieves script dependencies @param string $section The section of the site @return array
[ "Retrieves", "script", "dependencies" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L217-L223
240,427
novuso/novusopress
core/Assets.php
Assets.getStyleDeps
protected function getStyleDeps($section) { $dependencies = $this->getDependencies(); $deps = isset($dependencies['styles']) ? $dependencies['styles'] : []; return isset($deps[$section]) ? $deps[$section] : []; }
php
protected function getStyleDeps($section) { $dependencies = $this->getDependencies(); $deps = isset($dependencies['styles']) ? $dependencies['styles'] : []; return isset($deps[$section]) ? $deps[$section] : []; }
[ "protected", "function", "getStyleDeps", "(", "$", "section", ")", "{", "$", "dependencies", "=", "$", "this", "->", "getDependencies", "(", ")", ";", "$", "deps", "=", "isset", "(", "$", "dependencies", "[", "'styles'", "]", ")", "?", "$", "dependencies", "[", "'styles'", "]", ":", "[", "]", ";", "return", "isset", "(", "$", "deps", "[", "$", "section", "]", ")", "?", "$", "deps", "[", "$", "section", "]", ":", "[", "]", ";", "}" ]
Retrieves style dependencies @param string $section The section of the site @return array
[ "Retrieves", "style", "dependencies" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L232-L238
240,428
novuso/novusopress
core/Assets.php
Assets.getDependencies
protected function getDependencies() { if (null === $this->dependencies) { if (file_exists(sprintf('%s/dependencies.json', $this->paths->getThemeConfigDir()))) { $depsContent = file_get_contents(sprintf('%s/dependencies.json', $this->paths->getThemeConfigDir())); } else { $depsContent = file_get_contents(sprintf('%s/dependencies.json', $this->paths->getBaseConfigDir())); } $this->dependencies = json_decode($depsContent, true); } return $this->dependencies; }
php
protected function getDependencies() { if (null === $this->dependencies) { if (file_exists(sprintf('%s/dependencies.json', $this->paths->getThemeConfigDir()))) { $depsContent = file_get_contents(sprintf('%s/dependencies.json', $this->paths->getThemeConfigDir())); } else { $depsContent = file_get_contents(sprintf('%s/dependencies.json', $this->paths->getBaseConfigDir())); } $this->dependencies = json_decode($depsContent, true); } return $this->dependencies; }
[ "protected", "function", "getDependencies", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "dependencies", ")", "{", "if", "(", "file_exists", "(", "sprintf", "(", "'%s/dependencies.json'", ",", "$", "this", "->", "paths", "->", "getThemeConfigDir", "(", ")", ")", ")", ")", "{", "$", "depsContent", "=", "file_get_contents", "(", "sprintf", "(", "'%s/dependencies.json'", ",", "$", "this", "->", "paths", "->", "getThemeConfigDir", "(", ")", ")", ")", ";", "}", "else", "{", "$", "depsContent", "=", "file_get_contents", "(", "sprintf", "(", "'%s/dependencies.json'", ",", "$", "this", "->", "paths", "->", "getBaseConfigDir", "(", ")", ")", ")", ";", "}", "$", "this", "->", "dependencies", "=", "json_decode", "(", "$", "depsContent", ",", "true", ")", ";", "}", "return", "$", "this", "->", "dependencies", ";", "}" ]
Retrieves the dependencies config @return array
[ "Retrieves", "the", "dependencies", "config" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L245-L257
240,429
novuso/novusopress
core/Assets.php
Assets.getViewHandle
protected function getViewHandle() { if (is_front_page() && is_home()) { return 'index'; } elseif (is_front_page()) { return 'front-page'; } elseif (is_home()) { return 'index'; } elseif (is_page_template()) { global $wp_query; $templateName = get_post_meta($wp_query->post->ID, '_wp_page_template', true); return substr($templateName, 0, -4); } elseif (is_page()) { return 'page'; } elseif (is_attachment()) { return 'attacment'; } elseif (is_single()) { return 'single'; } elseif (is_archive()) { return 'archive'; } elseif (is_search()) { return 'search'; } return 'not-found'; }
php
protected function getViewHandle() { if (is_front_page() && is_home()) { return 'index'; } elseif (is_front_page()) { return 'front-page'; } elseif (is_home()) { return 'index'; } elseif (is_page_template()) { global $wp_query; $templateName = get_post_meta($wp_query->post->ID, '_wp_page_template', true); return substr($templateName, 0, -4); } elseif (is_page()) { return 'page'; } elseif (is_attachment()) { return 'attacment'; } elseif (is_single()) { return 'single'; } elseif (is_archive()) { return 'archive'; } elseif (is_search()) { return 'search'; } return 'not-found'; }
[ "protected", "function", "getViewHandle", "(", ")", "{", "if", "(", "is_front_page", "(", ")", "&&", "is_home", "(", ")", ")", "{", "return", "'index'", ";", "}", "elseif", "(", "is_front_page", "(", ")", ")", "{", "return", "'front-page'", ";", "}", "elseif", "(", "is_home", "(", ")", ")", "{", "return", "'index'", ";", "}", "elseif", "(", "is_page_template", "(", ")", ")", "{", "global", "$", "wp_query", ";", "$", "templateName", "=", "get_post_meta", "(", "$", "wp_query", "->", "post", "->", "ID", ",", "'_wp_page_template'", ",", "true", ")", ";", "return", "substr", "(", "$", "templateName", ",", "0", ",", "-", "4", ")", ";", "}", "elseif", "(", "is_page", "(", ")", ")", "{", "return", "'page'", ";", "}", "elseif", "(", "is_attachment", "(", ")", ")", "{", "return", "'attacment'", ";", "}", "elseif", "(", "is_single", "(", ")", ")", "{", "return", "'single'", ";", "}", "elseif", "(", "is_archive", "(", ")", ")", "{", "return", "'archive'", ";", "}", "elseif", "(", "is_search", "(", ")", ")", "{", "return", "'search'", ";", "}", "return", "'not-found'", ";", "}" ]
Retrieves the current view handle @return string
[ "Retrieves", "the", "current", "view", "handle" ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L264-L290
240,430
onesimus-systems/osrouter
src/Router.php
Router.group
public static function group(array $properties, array $routes) { // Translate a single filter to an array of one filter if (isset($properties['filter'])) { if (!is_array($properties['filter'])) { $properties['filter'] = [$properties['filter']]; } } else { $properties['filter'] = []; } $baseProperties = ['prefix' => '', 'rprefix' => '']; $properties = array_merge($baseProperties, $properties); // $routes: [0] = HTTP method, [1] = pattern, [2] = controller/method route foreach ($routes as $route) { $httpmethod = $route[0]; if (!method_exists(__CLASS__, $httpmethod)) { continue; } $pattern = $properties['prefix'].$route[1]; $callback = $properties['rprefix'].$route[2]; $options = [ 'filter' => $properties['filter'] ]; self::$httpmethod($pattern, $callback, $options); } }
php
public static function group(array $properties, array $routes) { // Translate a single filter to an array of one filter if (isset($properties['filter'])) { if (!is_array($properties['filter'])) { $properties['filter'] = [$properties['filter']]; } } else { $properties['filter'] = []; } $baseProperties = ['prefix' => '', 'rprefix' => '']; $properties = array_merge($baseProperties, $properties); // $routes: [0] = HTTP method, [1] = pattern, [2] = controller/method route foreach ($routes as $route) { $httpmethod = $route[0]; if (!method_exists(__CLASS__, $httpmethod)) { continue; } $pattern = $properties['prefix'].$route[1]; $callback = $properties['rprefix'].$route[2]; $options = [ 'filter' => $properties['filter'] ]; self::$httpmethod($pattern, $callback, $options); } }
[ "public", "static", "function", "group", "(", "array", "$", "properties", ",", "array", "$", "routes", ")", "{", "// Translate a single filter to an array of one filter", "if", "(", "isset", "(", "$", "properties", "[", "'filter'", "]", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "properties", "[", "'filter'", "]", ")", ")", "{", "$", "properties", "[", "'filter'", "]", "=", "[", "$", "properties", "[", "'filter'", "]", "]", ";", "}", "}", "else", "{", "$", "properties", "[", "'filter'", "]", "=", "[", "]", ";", "}", "$", "baseProperties", "=", "[", "'prefix'", "=>", "''", ",", "'rprefix'", "=>", "''", "]", ";", "$", "properties", "=", "array_merge", "(", "$", "baseProperties", ",", "$", "properties", ")", ";", "// $routes: [0] = HTTP method, [1] = pattern, [2] = controller/method route", "foreach", "(", "$", "routes", "as", "$", "route", ")", "{", "$", "httpmethod", "=", "$", "route", "[", "0", "]", ";", "if", "(", "!", "method_exists", "(", "__CLASS__", ",", "$", "httpmethod", ")", ")", "{", "continue", ";", "}", "$", "pattern", "=", "$", "properties", "[", "'prefix'", "]", ".", "$", "route", "[", "1", "]", ";", "$", "callback", "=", "$", "properties", "[", "'rprefix'", "]", ".", "$", "route", "[", "2", "]", ";", "$", "options", "=", "[", "'filter'", "=>", "$", "properties", "[", "'filter'", "]", "]", ";", "self", "::", "$", "httpmethod", "(", "$", "pattern", ",", "$", "callback", ",", "$", "options", ")", ";", "}", "}" ]
Register a group of routes
[ "Register", "a", "group", "of", "routes" ]
1b87b0b91c227752cc6d3e09cc02d9d2bb4bc7de
https://github.com/onesimus-systems/osrouter/blob/1b87b0b91c227752cc6d3e09cc02d9d2bb4bc7de/src/Router.php#L74-L103
240,431
onesimus-systems/osrouter
src/Router.php
Router.route
public static function route(Http\Request $request) { $path = $request->REQUEST_URI; $key = $request->getMethod().'@'.$path; $keyAny = 'ANY@'.$path; $matchedRoute = null; $matchedScore = 0; if (isset(self::$routes[$key])) { $matchedRoute = self::$routes[$key]; } elseif (isset(self::$routes[$keyAny])) { $matchedRoute = self::$routes[$keyAny]; } else { foreach (self::$routes as $key2 => $route) { if ($route->getMethod() != 'ANY' && $route->getMethod() != $request->getMethod()) { continue; } $score = $route->getScore($path, $request->getMethod()); if ($score > $matchedScore) { $matchedRoute = $route; $matchedScore = $score; } } } if ($matchedRoute) { $matchedRoute->setUrl($path); } elseif (self::$_404route) { $matchedRoute = self::$_404route; } else { throw new Exceptions\RouteException('Route not found'); } return $matchedRoute; }
php
public static function route(Http\Request $request) { $path = $request->REQUEST_URI; $key = $request->getMethod().'@'.$path; $keyAny = 'ANY@'.$path; $matchedRoute = null; $matchedScore = 0; if (isset(self::$routes[$key])) { $matchedRoute = self::$routes[$key]; } elseif (isset(self::$routes[$keyAny])) { $matchedRoute = self::$routes[$keyAny]; } else { foreach (self::$routes as $key2 => $route) { if ($route->getMethod() != 'ANY' && $route->getMethod() != $request->getMethod()) { continue; } $score = $route->getScore($path, $request->getMethod()); if ($score > $matchedScore) { $matchedRoute = $route; $matchedScore = $score; } } } if ($matchedRoute) { $matchedRoute->setUrl($path); } elseif (self::$_404route) { $matchedRoute = self::$_404route; } else { throw new Exceptions\RouteException('Route not found'); } return $matchedRoute; }
[ "public", "static", "function", "route", "(", "Http", "\\", "Request", "$", "request", ")", "{", "$", "path", "=", "$", "request", "->", "REQUEST_URI", ";", "$", "key", "=", "$", "request", "->", "getMethod", "(", ")", ".", "'@'", ".", "$", "path", ";", "$", "keyAny", "=", "'ANY@'", ".", "$", "path", ";", "$", "matchedRoute", "=", "null", ";", "$", "matchedScore", "=", "0", ";", "if", "(", "isset", "(", "self", "::", "$", "routes", "[", "$", "key", "]", ")", ")", "{", "$", "matchedRoute", "=", "self", "::", "$", "routes", "[", "$", "key", "]", ";", "}", "elseif", "(", "isset", "(", "self", "::", "$", "routes", "[", "$", "keyAny", "]", ")", ")", "{", "$", "matchedRoute", "=", "self", "::", "$", "routes", "[", "$", "keyAny", "]", ";", "}", "else", "{", "foreach", "(", "self", "::", "$", "routes", "as", "$", "key2", "=>", "$", "route", ")", "{", "if", "(", "$", "route", "->", "getMethod", "(", ")", "!=", "'ANY'", "&&", "$", "route", "->", "getMethod", "(", ")", "!=", "$", "request", "->", "getMethod", "(", ")", ")", "{", "continue", ";", "}", "$", "score", "=", "$", "route", "->", "getScore", "(", "$", "path", ",", "$", "request", "->", "getMethod", "(", ")", ")", ";", "if", "(", "$", "score", ">", "$", "matchedScore", ")", "{", "$", "matchedRoute", "=", "$", "route", ";", "$", "matchedScore", "=", "$", "score", ";", "}", "}", "}", "if", "(", "$", "matchedRoute", ")", "{", "$", "matchedRoute", "->", "setUrl", "(", "$", "path", ")", ";", "}", "elseif", "(", "self", "::", "$", "_404route", ")", "{", "$", "matchedRoute", "=", "self", "::", "$", "_404route", ";", "}", "else", "{", "throw", "new", "Exceptions", "\\", "RouteException", "(", "'Route not found'", ")", ";", "}", "return", "$", "matchedRoute", ";", "}" ]
Initiate the routing for the given URL
[ "Initiate", "the", "routing", "for", "the", "given", "URL" ]
1b87b0b91c227752cc6d3e09cc02d9d2bb4bc7de
https://github.com/onesimus-systems/osrouter/blob/1b87b0b91c227752cc6d3e09cc02d9d2bb4bc7de/src/Router.php#L125-L160
240,432
lembarek/core
src/Providers/ServiceProvider.php
ServiceProvider.fullBoot
public function fullBoot($package, $dir) { $this->mapRoutes($dir); if (file_exists($dir.'/views')) { $this->loadViewsFrom($dir.'/views', $package); } if (file_exists($dir.'/migrations')) { $this->publishes([ $dir.'/migrations' => base_path('database/migrations/') ], 'migrations'); } if (file_exists($dir.'/seeds')) { $this->publishes([ $dir.'/seeds' => base_path('database/seeds/') ], 'seeds'); } if (file_exists($dir."config/$package.php")) { $this->mergeConfigFrom( $dir."config/$package.php", $package ); $this->publishes([ $dir.'/config' => base_path('config') ], 'config'); } if (file_exists($dir.'/lang')) { $this->publishes([ $dir.'/lang' => resource_path()."/lang/vendor/$package", ]); $this->loadTranslationsFrom( $dir."/lang", $package ); } if (file_exists($dir.'/assets')) { $this->publishes([ $dir.'/assets' => base_path('resources/assets'), ], 'assets'); } if(file_exists($dir.'/factories/ModelFactory.php')){ require($dir.'/factories/ModelFactory.php'); } }
php
public function fullBoot($package, $dir) { $this->mapRoutes($dir); if (file_exists($dir.'/views')) { $this->loadViewsFrom($dir.'/views', $package); } if (file_exists($dir.'/migrations')) { $this->publishes([ $dir.'/migrations' => base_path('database/migrations/') ], 'migrations'); } if (file_exists($dir.'/seeds')) { $this->publishes([ $dir.'/seeds' => base_path('database/seeds/') ], 'seeds'); } if (file_exists($dir."config/$package.php")) { $this->mergeConfigFrom( $dir."config/$package.php", $package ); $this->publishes([ $dir.'/config' => base_path('config') ], 'config'); } if (file_exists($dir.'/lang')) { $this->publishes([ $dir.'/lang' => resource_path()."/lang/vendor/$package", ]); $this->loadTranslationsFrom( $dir."/lang", $package ); } if (file_exists($dir.'/assets')) { $this->publishes([ $dir.'/assets' => base_path('resources/assets'), ], 'assets'); } if(file_exists($dir.'/factories/ModelFactory.php')){ require($dir.'/factories/ModelFactory.php'); } }
[ "public", "function", "fullBoot", "(", "$", "package", ",", "$", "dir", ")", "{", "$", "this", "->", "mapRoutes", "(", "$", "dir", ")", ";", "if", "(", "file_exists", "(", "$", "dir", ".", "'/views'", ")", ")", "{", "$", "this", "->", "loadViewsFrom", "(", "$", "dir", ".", "'/views'", ",", "$", "package", ")", ";", "}", "if", "(", "file_exists", "(", "$", "dir", ".", "'/migrations'", ")", ")", "{", "$", "this", "->", "publishes", "(", "[", "$", "dir", ".", "'/migrations'", "=>", "base_path", "(", "'database/migrations/'", ")", "]", ",", "'migrations'", ")", ";", "}", "if", "(", "file_exists", "(", "$", "dir", ".", "'/seeds'", ")", ")", "{", "$", "this", "->", "publishes", "(", "[", "$", "dir", ".", "'/seeds'", "=>", "base_path", "(", "'database/seeds/'", ")", "]", ",", "'seeds'", ")", ";", "}", "if", "(", "file_exists", "(", "$", "dir", ".", "\"config/$package.php\"", ")", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "$", "dir", ".", "\"config/$package.php\"", ",", "$", "package", ")", ";", "$", "this", "->", "publishes", "(", "[", "$", "dir", ".", "'/config'", "=>", "base_path", "(", "'config'", ")", "]", ",", "'config'", ")", ";", "}", "if", "(", "file_exists", "(", "$", "dir", ".", "'/lang'", ")", ")", "{", "$", "this", "->", "publishes", "(", "[", "$", "dir", ".", "'/lang'", "=>", "resource_path", "(", ")", ".", "\"/lang/vendor/$package\"", ",", "]", ")", ";", "$", "this", "->", "loadTranslationsFrom", "(", "$", "dir", ".", "\"/lang\"", ",", "$", "package", ")", ";", "}", "if", "(", "file_exists", "(", "$", "dir", ".", "'/assets'", ")", ")", "{", "$", "this", "->", "publishes", "(", "[", "$", "dir", ".", "'/assets'", "=>", "base_path", "(", "'resources/assets'", ")", ",", "]", ",", "'assets'", ")", ";", "}", "if", "(", "file_exists", "(", "$", "dir", ".", "'/factories/ModelFactory.php'", ")", ")", "{", "require", "(", "$", "dir", ".", "'/factories/ModelFactory.php'", ")", ";", "}", "}" ]
it replace most thing that you can in boot in provider for packages @param string $dir @return void
[ "it", "replace", "most", "thing", "that", "you", "can", "in", "boot", "in", "provider", "for", "packages" ]
7d325ad9b7a81610a07a2f109306fb91b89ab215
https://github.com/lembarek/core/blob/7d325ad9b7a81610a07a2f109306fb91b89ab215/src/Providers/ServiceProvider.php#L15-L71
240,433
novuso/system
src/Collection/ArrayQueue.php
ArrayQueue.reindex
private function reindex(int $capacity): void { $temp = []; for ($i = 0; $i < $this->count; $i++) { $temp[$i] = $this->items[($i + $this->front) % $this->cap]; } $this->items = $temp; $this->cap = $capacity; $this->front = 0; $this->end = $this->count; }
php
private function reindex(int $capacity): void { $temp = []; for ($i = 0; $i < $this->count; $i++) { $temp[$i] = $this->items[($i + $this->front) % $this->cap]; } $this->items = $temp; $this->cap = $capacity; $this->front = 0; $this->end = $this->count; }
[ "private", "function", "reindex", "(", "int", "$", "capacity", ")", ":", "void", "{", "$", "temp", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "count", ";", "$", "i", "++", ")", "{", "$", "temp", "[", "$", "i", "]", "=", "$", "this", "->", "items", "[", "(", "$", "i", "+", "$", "this", "->", "front", ")", "%", "$", "this", "->", "cap", "]", ";", "}", "$", "this", "->", "items", "=", "$", "temp", ";", "$", "this", "->", "cap", "=", "$", "capacity", ";", "$", "this", "->", "front", "=", "0", ";", "$", "this", "->", "end", "=", "$", "this", "->", "count", ";", "}" ]
Re-indexes the underlying array This is needed to keep wrapping under control. Using direct indices allows operations in constant amortized time instead of O(n). Using array_(un)shift is easier, but requires re-indexing the array every time during the enqueue or dequeue operation. @param int $capacity The new capacity @return void
[ "Re", "-", "indexes", "the", "underlying", "array" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayQueue.php#L327-L337
240,434
znframework/package-image
GD.php
GD.jpegToWbmp
public function jpegToWbmp(String $jpegFile, String $wbmpFile, Array $settings = []) : Bool { if( is_file($jpegFile) ) { $height = $settings['height'] ?? $this->height ?? 0; $width = $settings['width'] ?? $this->width ?? 0; $threshold = $settings['threshold'] ?? $this->threshold ?? 0; $this->defaultRevolvingVariables(); return jpeg2wbmp($jpegFile, $wbmpFile, $height, $width, $threshold); } else { return false; } }
php
public function jpegToWbmp(String $jpegFile, String $wbmpFile, Array $settings = []) : Bool { if( is_file($jpegFile) ) { $height = $settings['height'] ?? $this->height ?? 0; $width = $settings['width'] ?? $this->width ?? 0; $threshold = $settings['threshold'] ?? $this->threshold ?? 0; $this->defaultRevolvingVariables(); return jpeg2wbmp($jpegFile, $wbmpFile, $height, $width, $threshold); } else { return false; } }
[ "public", "function", "jpegToWbmp", "(", "String", "$", "jpegFile", ",", "String", "$", "wbmpFile", ",", "Array", "$", "settings", "=", "[", "]", ")", ":", "Bool", "{", "if", "(", "is_file", "(", "$", "jpegFile", ")", ")", "{", "$", "height", "=", "$", "settings", "[", "'height'", "]", "??", "$", "this", "->", "height", "??", "0", ";", "$", "width", "=", "$", "settings", "[", "'width'", "]", "??", "$", "this", "->", "width", "??", "0", ";", "$", "threshold", "=", "$", "settings", "[", "'threshold'", "]", "??", "$", "this", "->", "threshold", "??", "0", ";", "$", "this", "->", "defaultRevolvingVariables", "(", ")", ";", "return", "jpeg2wbmp", "(", "$", "jpegFile", ",", "$", "wbmpFile", ",", "$", "height", ",", "$", "width", ",", "$", "threshold", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
JPEG to WBMP @param string $pngFile @param string $wbmpFile @param array $settings = [] @return bool
[ "JPEG", "to", "WBMP" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L209-L225
240,435
znframework/package-image
GD.php
GD.pngToWbmp
public function pngToWbmp(String $pngFile, String $wbmpFile, Array $settings = []) : Bool { if( is_file($pngFile) ) { $height = $settings['height'] ?? 0; $width = $settings['width'] ?? 0; $threshold = $settings['threshold'] ?? 0; return png2wbmp($pngFile, $wbmpFile, $height, $width, $threshold); } else { return false; } }
php
public function pngToWbmp(String $pngFile, String $wbmpFile, Array $settings = []) : Bool { if( is_file($pngFile) ) { $height = $settings['height'] ?? 0; $width = $settings['width'] ?? 0; $threshold = $settings['threshold'] ?? 0; return png2wbmp($pngFile, $wbmpFile, $height, $width, $threshold); } else { return false; } }
[ "public", "function", "pngToWbmp", "(", "String", "$", "pngFile", ",", "String", "$", "wbmpFile", ",", "Array", "$", "settings", "=", "[", "]", ")", ":", "Bool", "{", "if", "(", "is_file", "(", "$", "pngFile", ")", ")", "{", "$", "height", "=", "$", "settings", "[", "'height'", "]", "??", "0", ";", "$", "width", "=", "$", "settings", "[", "'width'", "]", "??", "0", ";", "$", "threshold", "=", "$", "settings", "[", "'threshold'", "]", "??", "0", ";", "return", "png2wbmp", "(", "$", "pngFile", ",", "$", "wbmpFile", ",", "$", "height", ",", "$", "width", ",", "$", "threshold", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
PNG to WBMP @param string $pngFile @param string $wbmpFile @param array $settings = [] @return bool
[ "PNG", "to", "WBMP" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L236-L250
240,436
znframework/package-image
GD.php
GD.alphaBlending
public function alphaBlending(Bool $blendMode = NULL) : GD { imagealphablending($this->canvas, (bool) $blendMode); return $this; }
php
public function alphaBlending(Bool $blendMode = NULL) : GD { imagealphablending($this->canvas, (bool) $blendMode); return $this; }
[ "public", "function", "alphaBlending", "(", "Bool", "$", "blendMode", "=", "NULL", ")", ":", "GD", "{", "imagealphablending", "(", "$", "this", "->", "canvas", ",", "(", "bool", ")", "$", "blendMode", ")", ";", "return", "$", "this", ";", "}" ]
Sets alpha blending @param bool $blendMode = NULL @return GD
[ "Sets", "alpha", "blending" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L259-L264
240,437
znframework/package-image
GD.php
GD.saveAlpha
public function saveAlpha(Bool $save = true) : GD { imagesavealpha($this->canvas, $save); return $this; }
php
public function saveAlpha(Bool $save = true) : GD { imagesavealpha($this->canvas, $save); return $this; }
[ "public", "function", "saveAlpha", "(", "Bool", "$", "save", "=", "true", ")", ":", "GD", "{", "imagesavealpha", "(", "$", "this", "->", "canvas", ",", "$", "save", ")", ";", "return", "$", "this", ";", "}" ]
Sets save alpha @param bool $save = true @return GD
[ "Sets", "save", "alpha" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L273-L278
240,438
znframework/package-image
GD.php
GD.pixelIndex
public function pixelIndex(Int $x, Int $y) : Int { return imagecolorat($this->canvas, $x, $y); }
php
public function pixelIndex(Int $x, Int $y) : Int { return imagecolorat($this->canvas, $x, $y); }
[ "public", "function", "pixelIndex", "(", "Int", "$", "x", ",", "Int", "$", "y", ")", ":", "Int", "{", "return", "imagecolorat", "(", "$", "this", "->", "canvas", ",", "$", "x", ",", "$", "y", ")", ";", "}" ]
Set pixel index @param int $x @param int $y @return int
[ "Set", "pixel", "index" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L578-L581
240,439
znframework/package-image
GD.php
GD.line
public function line(Array $settings = []) : GD { $x1 = $settings['x1'] ?? $this->x1 ?? 0; $y1 = $settings['y1'] ?? $this->y1 ?? 0; $x2 = $settings['x2'] ?? $this->x2 ?? 0; $y2 = $settings['y2'] ?? $this->y2 ?? 0; $rgb = $settings['color'] ?? $this->color ?? '0|0|0'; $type = $settings['type'] ?? $this->type ?? 'solid'; if( $type === 'solid' ) { imageline($this->canvas, $x1, $y1, $x2, $y2, $this->allocate($rgb)); } elseif( $type === 'dashed' ) { imagedashedline($this->canvas, $x1, $y1, $x2, $y2, $this->allocate($rgb)); } $this->defaultRevolvingVariables(); return $this; }
php
public function line(Array $settings = []) : GD { $x1 = $settings['x1'] ?? $this->x1 ?? 0; $y1 = $settings['y1'] ?? $this->y1 ?? 0; $x2 = $settings['x2'] ?? $this->x2 ?? 0; $y2 = $settings['y2'] ?? $this->y2 ?? 0; $rgb = $settings['color'] ?? $this->color ?? '0|0|0'; $type = $settings['type'] ?? $this->type ?? 'solid'; if( $type === 'solid' ) { imageline($this->canvas, $x1, $y1, $x2, $y2, $this->allocate($rgb)); } elseif( $type === 'dashed' ) { imagedashedline($this->canvas, $x1, $y1, $x2, $y2, $this->allocate($rgb)); } $this->defaultRevolvingVariables(); return $this; }
[ "public", "function", "line", "(", "Array", "$", "settings", "=", "[", "]", ")", ":", "GD", "{", "$", "x1", "=", "$", "settings", "[", "'x1'", "]", "??", "$", "this", "->", "x1", "??", "0", ";", "$", "y1", "=", "$", "settings", "[", "'y1'", "]", "??", "$", "this", "->", "y1", "??", "0", ";", "$", "x2", "=", "$", "settings", "[", "'x2'", "]", "??", "$", "this", "->", "x2", "??", "0", ";", "$", "y2", "=", "$", "settings", "[", "'y2'", "]", "??", "$", "this", "->", "y2", "??", "0", ";", "$", "rgb", "=", "$", "settings", "[", "'color'", "]", "??", "$", "this", "->", "color", "??", "'0|0|0'", ";", "$", "type", "=", "$", "settings", "[", "'type'", "]", "??", "$", "this", "->", "type", "??", "'solid'", ";", "if", "(", "$", "type", "===", "'solid'", ")", "{", "imageline", "(", "$", "this", "->", "canvas", ",", "$", "x1", ",", "$", "y1", ",", "$", "x2", ",", "$", "y2", ",", "$", "this", "->", "allocate", "(", "$", "rgb", ")", ")", ";", "}", "elseif", "(", "$", "type", "===", "'dashed'", ")", "{", "imagedashedline", "(", "$", "this", "->", "canvas", ",", "$", "x1", ",", "$", "y1", ",", "$", "x2", ",", "$", "y2", ",", "$", "this", "->", "allocate", "(", "$", "rgb", ")", ")", ";", "}", "$", "this", "->", "defaultRevolvingVariables", "(", ")", ";", "return", "$", "this", ";", "}" ]
Creates a line @param array $settings = [] @return GD
[ "Creates", "a", "line" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L881-L902
240,440
znframework/package-image
GD.php
GD.windowDisplay
public function windowDisplay(Int $window, Int $clientArea = 0) : GD { $this->canvas = imagegrabwindow($window, $clientArea); return $this; }
php
public function windowDisplay(Int $window, Int $clientArea = 0) : GD { $this->canvas = imagegrabwindow($window, $clientArea); return $this; }
[ "public", "function", "windowDisplay", "(", "Int", "$", "window", ",", "Int", "$", "clientArea", "=", "0", ")", ":", "GD", "{", "$", "this", "->", "canvas", "=", "imagegrabwindow", "(", "$", "window", ",", "$", "clientArea", ")", ";", "return", "$", "this", ";", "}" ]
Set window display @param int $window @param int $clientArea = 0 @return GD
[ "Set", "window", "display" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1065-L1070
240,441
znframework/package-image
GD.php
GD.layerEffect
public function layerEffect(String $effect = 'normal') : GD { imagelayereffect($this->canvas, Helper::toConstant($effect, 'IMG_EFFECT_')); return $this; }
php
public function layerEffect(String $effect = 'normal') : GD { imagelayereffect($this->canvas, Helper::toConstant($effect, 'IMG_EFFECT_')); return $this; }
[ "public", "function", "layerEffect", "(", "String", "$", "effect", "=", "'normal'", ")", ":", "GD", "{", "imagelayereffect", "(", "$", "this", "->", "canvas", ",", "Helper", "::", "toConstant", "(", "$", "effect", ",", "'IMG_EFFECT_'", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set layer effect @param string $effect = 'normal' @return GD
[ "Set", "layer", "effect" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1079-L1084
240,442
znframework/package-image
GD.php
GD.loadFont
public function loadFont(String $file) : Int { if( ! is_file($file) ) { throw new InvalidArgumentException(NULL, '[file]'); } return imageloadfont($file); }
php
public function loadFont(String $file) : Int { if( ! is_file($file) ) { throw new InvalidArgumentException(NULL, '[file]'); } return imageloadfont($file); }
[ "public", "function", "loadFont", "(", "String", "$", "file", ")", ":", "Int", "{", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "NULL", ",", "'[file]'", ")", ";", "}", "return", "imageloadfont", "(", "$", "file", ")", ";", "}" ]
Set load font @param string $file @return int
[ "Set", "load", "font" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1093-L1101
240,443
znframework/package-image
GD.php
GD.copyPalette
public function copyPalette($source) { if( ! is_resource($source) ) { throw new InvalidArgumentException(NULL, '[resource]'); } imagepalettecopy($this->canvas, $source); }
php
public function copyPalette($source) { if( ! is_resource($source) ) { throw new InvalidArgumentException(NULL, '[resource]'); } imagepalettecopy($this->canvas, $source); }
[ "public", "function", "copyPalette", "(", "$", "source", ")", "{", "if", "(", "!", "is_resource", "(", "$", "source", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "NULL", ",", "'[resource]'", ")", ";", "}", "imagepalettecopy", "(", "$", "this", "->", "canvas", ",", "$", "source", ")", ";", "}" ]
Get copy palette @param resource $source @return resource
[ "Get", "copy", "palette" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1110-L1118
240,444
znframework/package-image
GD.php
GD.createImageCanvas
protected function createImageCanvas($image) { $this->type = $this->mime->type($image, 1); $this->imageSize = ! isset($this->width) ? getimagesize($image) : [$this->width ?? 0, $this->height ?? 0]; $this->canvas = $this->createFrom($image, [ # For type gd2p 'x' => $this->x ?? 0, 'y' => $this->y ?? 0, 'width' => $this->width ?? $this->imageSize[0], 'height' => $this->height ?? $this->imageSize[1] ]); }
php
protected function createImageCanvas($image) { $this->type = $this->mime->type($image, 1); $this->imageSize = ! isset($this->width) ? getimagesize($image) : [$this->width ?? 0, $this->height ?? 0]; $this->canvas = $this->createFrom($image, [ # For type gd2p 'x' => $this->x ?? 0, 'y' => $this->y ?? 0, 'width' => $this->width ?? $this->imageSize[0], 'height' => $this->height ?? $this->imageSize[1] ]); }
[ "protected", "function", "createImageCanvas", "(", "$", "image", ")", "{", "$", "this", "->", "type", "=", "$", "this", "->", "mime", "->", "type", "(", "$", "image", ",", "1", ")", ";", "$", "this", "->", "imageSize", "=", "!", "isset", "(", "$", "this", "->", "width", ")", "?", "getimagesize", "(", "$", "image", ")", ":", "[", "$", "this", "->", "width", "??", "0", ",", "$", "this", "->", "height", "??", "0", "]", ";", "$", "this", "->", "canvas", "=", "$", "this", "->", "createFrom", "(", "$", "image", ",", "[", "# For type gd2p", "'x'", "=>", "$", "this", "->", "x", "??", "0", ",", "'y'", "=>", "$", "this", "->", "y", "??", "0", ",", "'width'", "=>", "$", "this", "->", "width", "??", "$", "this", "->", "imageSize", "[", "0", "]", ",", "'height'", "=>", "$", "this", "->", "height", "??", "$", "this", "->", "imageSize", "[", "1", "]", "]", ")", ";", "}" ]
Protected create image canvas
[ "Protected", "create", "image", "canvas" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1202-L1216
240,445
znframework/package-image
GD.php
GD.createEmptyCanvas
protected function createEmptyCanvas($width, $height, $rgb, $real) { $width = $this->width ?? $width; $height = $this->height ?? $height; $rgb = $this->color ?? $rgb; $real = $this->real ?? $real; $this->imageSize = [$width, $height]; if( $real === false ) { $this->canvas = imagecreate($width, $height); } else { $this->canvas = imagecreatetruecolor($width, $height); } if( ! empty($rgb) ) { $this->allocate($rgb); } }
php
protected function createEmptyCanvas($width, $height, $rgb, $real) { $width = $this->width ?? $width; $height = $this->height ?? $height; $rgb = $this->color ?? $rgb; $real = $this->real ?? $real; $this->imageSize = [$width, $height]; if( $real === false ) { $this->canvas = imagecreate($width, $height); } else { $this->canvas = imagecreatetruecolor($width, $height); } if( ! empty($rgb) ) { $this->allocate($rgb); } }
[ "protected", "function", "createEmptyCanvas", "(", "$", "width", ",", "$", "height", ",", "$", "rgb", ",", "$", "real", ")", "{", "$", "width", "=", "$", "this", "->", "width", "??", "$", "width", ";", "$", "height", "=", "$", "this", "->", "height", "??", "$", "height", ";", "$", "rgb", "=", "$", "this", "->", "color", "??", "$", "rgb", ";", "$", "real", "=", "$", "this", "->", "real", "??", "$", "real", ";", "$", "this", "->", "imageSize", "=", "[", "$", "width", ",", "$", "height", "]", ";", "if", "(", "$", "real", "===", "false", ")", "{", "$", "this", "->", "canvas", "=", "imagecreate", "(", "$", "width", ",", "$", "height", ")", ";", "}", "else", "{", "$", "this", "->", "canvas", "=", "imagecreatetruecolor", "(", "$", "width", ",", "$", "height", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "rgb", ")", ")", "{", "$", "this", "->", "allocate", "(", "$", "rgb", ")", ";", "}", "}" ]
Protected create empty canvas
[ "Protected", "create", "empty", "canvas" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1221-L1243
240,446
znframework/package-image
GD.php
GD.alignImageWatermark
protected function alignImageWatermark($source) { if( is_string($this->target ?? NULL) ) { $size = getimagesize($source); $this->width = $this->width ?? $size[0]; $this->height = $this->height ?? $size[1]; $return = WatermarkImageAligner::align($this->target, $this->width, $this->height, $this->imageSize[0], $this->imageSize[1], $this->margin ?? 0); $this->target = $return; if( isset($this->x) ) $this->source[0] = $this->x; if( isset($this->y) ) $this->source[1] = $this->y; } }
php
protected function alignImageWatermark($source) { if( is_string($this->target ?? NULL) ) { $size = getimagesize($source); $this->width = $this->width ?? $size[0]; $this->height = $this->height ?? $size[1]; $return = WatermarkImageAligner::align($this->target, $this->width, $this->height, $this->imageSize[0], $this->imageSize[1], $this->margin ?? 0); $this->target = $return; if( isset($this->x) ) $this->source[0] = $this->x; if( isset($this->y) ) $this->source[1] = $this->y; } }
[ "protected", "function", "alignImageWatermark", "(", "$", "source", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "target", "??", "NULL", ")", ")", "{", "$", "size", "=", "getimagesize", "(", "$", "source", ")", ";", "$", "this", "->", "width", "=", "$", "this", "->", "width", "??", "$", "size", "[", "0", "]", ";", "$", "this", "->", "height", "=", "$", "this", "->", "height", "??", "$", "size", "[", "1", "]", ";", "$", "return", "=", "WatermarkImageAligner", "::", "align", "(", "$", "this", "->", "target", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "$", "this", "->", "imageSize", "[", "0", "]", ",", "$", "this", "->", "imageSize", "[", "1", "]", ",", "$", "this", "->", "margin", "??", "0", ")", ";", "$", "this", "->", "target", "=", "$", "return", ";", "if", "(", "isset", "(", "$", "this", "->", "x", ")", ")", "$", "this", "->", "source", "[", "0", "]", "=", "$", "this", "->", "x", ";", "if", "(", "isset", "(", "$", "this", "->", "y", ")", ")", "$", "this", "->", "source", "[", "1", "]", "=", "$", "this", "->", "y", ";", "}", "}" ]
Protected align image watermark
[ "Protected", "align", "image", "watermark" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1248-L1264
240,447
znframework/package-image
GD.php
GD.getImageColor
public function getImageColor($rgb, $function) { $rgb = explode('|', $rgb); $red = $rgb[0] ?? 0; $green = $rgb[1] ?? 0; $blue = $rgb[2] ?? 0; $alpha = $rgb[3] ?? 0; return $function($this->canvas, $red, $green, $blue, $alpha); }
php
public function getImageColor($rgb, $function) { $rgb = explode('|', $rgb); $red = $rgb[0] ?? 0; $green = $rgb[1] ?? 0; $blue = $rgb[2] ?? 0; $alpha = $rgb[3] ?? 0; return $function($this->canvas, $red, $green, $blue, $alpha); }
[ "public", "function", "getImageColor", "(", "$", "rgb", ",", "$", "function", ")", "{", "$", "rgb", "=", "explode", "(", "'|'", ",", "$", "rgb", ")", ";", "$", "red", "=", "$", "rgb", "[", "0", "]", "??", "0", ";", "$", "green", "=", "$", "rgb", "[", "1", "]", "??", "0", ";", "$", "blue", "=", "$", "rgb", "[", "2", "]", "??", "0", ";", "$", "alpha", "=", "$", "rgb", "[", "3", "]", "??", "0", ";", "return", "$", "function", "(", "$", "this", "->", "canvas", ",", "$", "red", ",", "$", "green", ",", "$", "blue", ",", "$", "alpha", ")", ";", "}" ]
Protected Image Color
[ "Protected", "Image", "Color" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1303-L1313
240,448
znframework/package-image
GD.php
GD.defaultVariables
protected function defaultVariables() { $this->canvas = NULL; $this->save = NULL; $this->output = true; $this->quality = NULL; }
php
protected function defaultVariables() { $this->canvas = NULL; $this->save = NULL; $this->output = true; $this->quality = NULL; }
[ "protected", "function", "defaultVariables", "(", ")", "{", "$", "this", "->", "canvas", "=", "NULL", ";", "$", "this", "->", "save", "=", "NULL", ";", "$", "this", "->", "output", "=", "true", ";", "$", "this", "->", "quality", "=", "NULL", ";", "}" ]
Protected Default Variables
[ "Protected", "Default", "Variables" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1336-L1342
240,449
jaredtking/jaqb
src/QueryBuilder.php
QueryBuilder.select
public function select($fields = '*') { $query = new Query\SelectQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->select($fields); }
php
public function select($fields = '*') { $query = new Query\SelectQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->select($fields); }
[ "public", "function", "select", "(", "$", "fields", "=", "'*'", ")", "{", "$", "query", "=", "new", "Query", "\\", "SelectQuery", "(", ")", ";", "if", "(", "$", "this", "->", "pdo", ")", "{", "$", "query", "->", "setPDO", "(", "$", "this", "->", "pdo", ")", ";", "}", "return", "$", "query", "->", "select", "(", "$", "fields", ")", ";", "}" ]
Creates a SELECT query. @param string|array $fields select fields @return \JAQB\Query\SelectQuery
[ "Creates", "a", "SELECT", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/QueryBuilder.php#L48-L57
240,450
jaredtking/jaqb
src/QueryBuilder.php
QueryBuilder.insert
public function insert(array $values) { $query = new Query\InsertQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->values($values); }
php
public function insert(array $values) { $query = new Query\InsertQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->values($values); }
[ "public", "function", "insert", "(", "array", "$", "values", ")", "{", "$", "query", "=", "new", "Query", "\\", "InsertQuery", "(", ")", ";", "if", "(", "$", "this", "->", "pdo", ")", "{", "$", "query", "->", "setPDO", "(", "$", "this", "->", "pdo", ")", ";", "}", "return", "$", "query", "->", "values", "(", "$", "values", ")", ";", "}" ]
Creates an INSERT query. @param array $values insert values @return \JAQB\Query\InsertQuery
[ "Creates", "an", "INSERT", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/QueryBuilder.php#L66-L75
240,451
jaredtking/jaqb
src/QueryBuilder.php
QueryBuilder.update
public function update($table) { $query = new Query\UpdateQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->table($table); }
php
public function update($table) { $query = new Query\UpdateQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->table($table); }
[ "public", "function", "update", "(", "$", "table", ")", "{", "$", "query", "=", "new", "Query", "\\", "UpdateQuery", "(", ")", ";", "if", "(", "$", "this", "->", "pdo", ")", "{", "$", "query", "->", "setPDO", "(", "$", "this", "->", "pdo", ")", ";", "}", "return", "$", "query", "->", "table", "(", "$", "table", ")", ";", "}" ]
Creates an UPDATE query. @param string $table update table @return \JAQB\Query\UpdateQuery
[ "Creates", "an", "UPDATE", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/QueryBuilder.php#L84-L93
240,452
jaredtking/jaqb
src/QueryBuilder.php
QueryBuilder.delete
public function delete($from) { $query = new Query\DeleteQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->from($from); }
php
public function delete($from) { $query = new Query\DeleteQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->from($from); }
[ "public", "function", "delete", "(", "$", "from", ")", "{", "$", "query", "=", "new", "Query", "\\", "DeleteQuery", "(", ")", ";", "if", "(", "$", "this", "->", "pdo", ")", "{", "$", "query", "->", "setPDO", "(", "$", "this", "->", "pdo", ")", ";", "}", "return", "$", "query", "->", "from", "(", "$", "from", ")", ";", "}" ]
Creates a DELETE query. @param string $from delete table @return \JAQB\Query\DeleteQuery
[ "Creates", "a", "DELETE", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/QueryBuilder.php#L102-L111
240,453
jaredtking/jaqb
src/QueryBuilder.php
QueryBuilder.raw
public function raw($sql) { $query = new Query\SqlQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->raw($sql); }
php
public function raw($sql) { $query = new Query\SqlQuery(); if ($this->pdo) { $query->setPDO($this->pdo); } return $query->raw($sql); }
[ "public", "function", "raw", "(", "$", "sql", ")", "{", "$", "query", "=", "new", "Query", "\\", "SqlQuery", "(", ")", ";", "if", "(", "$", "this", "->", "pdo", ")", "{", "$", "query", "->", "setPDO", "(", "$", "this", "->", "pdo", ")", ";", "}", "return", "$", "query", "->", "raw", "(", "$", "sql", ")", ";", "}" ]
Creates a raw SQL query. @param string $sql SQL statement @return \JAQB\Query\SqlQuery
[ "Creates", "a", "raw", "SQL", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/QueryBuilder.php#L120-L129
240,454
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/query/builder/select.php
Database_Query_Builder_Select.select
public function select($columns = null) { $columns = func_get_args(); $this->_select = array_merge($this->_select, $columns); return $this; }
php
public function select($columns = null) { $columns = func_get_args(); $this->_select = array_merge($this->_select, $columns); return $this; }
[ "public", "function", "select", "(", "$", "columns", "=", "null", ")", "{", "$", "columns", "=", "func_get_args", "(", ")", ";", "$", "this", "->", "_select", "=", "array_merge", "(", "$", "this", "->", "_select", ",", "$", "columns", ")", ";", "return", "$", "this", ";", "}" ]
Choose the columns to select from. @param mixed $columns column name or array($column, $alias) or object @param ... @return $this
[ "Choose", "the", "columns", "to", "select", "from", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/select.php#L94-L101
240,455
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/query/builder/select.php
Database_Query_Builder_Select.select_array
public function select_array(array $columns, $reset = false) { $this->_select = $reset ? $columns : array_merge($this->_select, $columns); return $this; }
php
public function select_array(array $columns, $reset = false) { $this->_select = $reset ? $columns : array_merge($this->_select, $columns); return $this; }
[ "public", "function", "select_array", "(", "array", "$", "columns", ",", "$", "reset", "=", "false", ")", "{", "$", "this", "->", "_select", "=", "$", "reset", "?", "$", "columns", ":", "array_merge", "(", "$", "this", "->", "_select", ",", "$", "columns", ")", ";", "return", "$", "this", ";", "}" ]
Choose the columns to select from, using an array. @param array $columns list of column names or aliases @param bool $reset if true, don't merge but overwrite @return $this
[ "Choose", "the", "columns", "to", "select", "from", "using", "an", "array", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/select.php#L111-L116
240,456
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/query/builder/select.php
Database_Query_Builder_Select.from
public function from($tables) { $tables = func_get_args(); $this->_from = array_merge($this->_from, $tables); return $this; }
php
public function from($tables) { $tables = func_get_args(); $this->_from = array_merge($this->_from, $tables); return $this; }
[ "public", "function", "from", "(", "$", "tables", ")", "{", "$", "tables", "=", "func_get_args", "(", ")", ";", "$", "this", "->", "_from", "=", "array_merge", "(", "$", "this", "->", "_from", ",", "$", "tables", ")", ";", "return", "$", "this", ";", "}" ]
Choose the tables to select "FROM ..." @param mixed $tables table name or array($table, $alias) @param ... @return $this
[ "Choose", "the", "tables", "to", "select", "FROM", "..." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/select.php#L126-L133
240,457
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/query/builder/select.php
Database_Query_Builder_Select.and_on
public function and_on($c1, $op, $c2) { $this->_last_join->and_on($c1, $op, $c2); return $this; }
php
public function and_on($c1, $op, $c2) { $this->_last_join->and_on($c1, $op, $c2); return $this; }
[ "public", "function", "and_on", "(", "$", "c1", ",", "$", "op", ",", "$", "c2", ")", "{", "$", "this", "->", "_last_join", "->", "and_on", "(", "$", "c1", ",", "$", "op", ",", "$", "c2", ")", ";", "return", "$", "this", ";", "}" ]
Adds "AND ON ..." conditions for the last created JOIN statement. @param mixed $c1 column name or array($column, $alias) or object @param string $op logic operator @param mixed $c2 column name or array($column, $alias) or object @return $this
[ "Adds", "AND", "ON", "...", "conditions", "for", "the", "last", "created", "JOIN", "statement", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/select.php#L175-L180
240,458
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/query/builder/select.php
Database_Query_Builder_Select.or_on
public function or_on($c1, $op, $c2) { $this->_last_join->or_on($c1, $op, $c2); return $this; }
php
public function or_on($c1, $op, $c2) { $this->_last_join->or_on($c1, $op, $c2); return $this; }
[ "public", "function", "or_on", "(", "$", "c1", ",", "$", "op", ",", "$", "c2", ")", "{", "$", "this", "->", "_last_join", "->", "or_on", "(", "$", "c1", ",", "$", "op", ",", "$", "c2", ")", ";", "return", "$", "this", ";", "}" ]
Adds "OR ON ..." conditions for the last created JOIN statement. @param mixed $c1 column name or array($column, $alias) or object @param string $op logic operator @param mixed $c2 column name or array($column, $alias) or object @return $this
[ "Adds", "OR", "ON", "...", "conditions", "for", "the", "last", "created", "JOIN", "statement", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/select.php#L191-L196
240,459
zicht/version
src/Zicht/Version/Version.php
Version.compare
public static function compare(Version $a, Version $b) { $aValues = $a->numeric(); $bValues = $b->numeric(); foreach (array_keys(self::$ordinality) as $key) { $aVal = $aValues[$key]; $bVal = $bValues[$key]; if ($aVal < $bVal) { return -1; } elseif ($aVal > $bVal) { return 1; } } return 0; }
php
public static function compare(Version $a, Version $b) { $aValues = $a->numeric(); $bValues = $b->numeric(); foreach (array_keys(self::$ordinality) as $key) { $aVal = $aValues[$key]; $bVal = $bValues[$key]; if ($aVal < $bVal) { return -1; } elseif ($aVal > $bVal) { return 1; } } return 0; }
[ "public", "static", "function", "compare", "(", "Version", "$", "a", ",", "Version", "$", "b", ")", "{", "$", "aValues", "=", "$", "a", "->", "numeric", "(", ")", ";", "$", "bValues", "=", "$", "b", "->", "numeric", "(", ")", ";", "foreach", "(", "array_keys", "(", "self", "::", "$", "ordinality", ")", "as", "$", "key", ")", "{", "$", "aVal", "=", "$", "aValues", "[", "$", "key", "]", ";", "$", "bVal", "=", "$", "bValues", "[", "$", "key", "]", ";", "if", "(", "$", "aVal", "<", "$", "bVal", ")", "{", "return", "-", "1", ";", "}", "elseif", "(", "$", "aVal", ">", "$", "bVal", ")", "{", "return", "1", ";", "}", "}", "return", "0", ";", "}" ]
Comparator for version objects @param Version $a @param Version $b @return int
[ "Comparator", "for", "version", "objects" ]
2653209f2620e1d4a8baf17a0b5b74fd339abba3
https://github.com/zicht/version/blob/2653209f2620e1d4a8baf17a0b5b74fd339abba3/src/Zicht/Version/Version.php#L122-L138
240,460
zicht/version
src/Zicht/Version/Version.php
Version.increment
public function increment($part) { foreach (array_reverse(self::$ordinality) as $currentPart) { if ($currentPart === $part) { switch ($part) { case self::STABILITY: $this->set( $currentPart, self::$stabilities[ array_search( $this->get($currentPart), self::$stabilities ) +1 ] ); break; default: $this->set($currentPart, $this->get($currentPart) +1); break; } break; } else { switch ($currentPart) { case self::STABILITY_NO: $this->set($currentPart, null); break; case self::STABILITY: $this->set($currentPart, 'dev'); break; default: $this->set($currentPart, '0'); } } } return $this; }
php
public function increment($part) { foreach (array_reverse(self::$ordinality) as $currentPart) { if ($currentPart === $part) { switch ($part) { case self::STABILITY: $this->set( $currentPart, self::$stabilities[ array_search( $this->get($currentPart), self::$stabilities ) +1 ] ); break; default: $this->set($currentPart, $this->get($currentPart) +1); break; } break; } else { switch ($currentPart) { case self::STABILITY_NO: $this->set($currentPart, null); break; case self::STABILITY: $this->set($currentPart, 'dev'); break; default: $this->set($currentPart, '0'); } } } return $this; }
[ "public", "function", "increment", "(", "$", "part", ")", "{", "foreach", "(", "array_reverse", "(", "self", "::", "$", "ordinality", ")", "as", "$", "currentPart", ")", "{", "if", "(", "$", "currentPart", "===", "$", "part", ")", "{", "switch", "(", "$", "part", ")", "{", "case", "self", "::", "STABILITY", ":", "$", "this", "->", "set", "(", "$", "currentPart", ",", "self", "::", "$", "stabilities", "[", "array_search", "(", "$", "this", "->", "get", "(", "$", "currentPart", ")", ",", "self", "::", "$", "stabilities", ")", "+", "1", "]", ")", ";", "break", ";", "default", ":", "$", "this", "->", "set", "(", "$", "currentPart", ",", "$", "this", "->", "get", "(", "$", "currentPart", ")", "+", "1", ")", ";", "break", ";", "}", "break", ";", "}", "else", "{", "switch", "(", "$", "currentPart", ")", "{", "case", "self", "::", "STABILITY_NO", ":", "$", "this", "->", "set", "(", "$", "currentPart", ",", "null", ")", ";", "break", ";", "case", "self", "::", "STABILITY", ":", "$", "this", "->", "set", "(", "$", "currentPart", ",", "'dev'", ")", ";", "break", ";", "default", ":", "$", "this", "->", "set", "(", "$", "currentPart", ",", "'0'", ")", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Increment a specific part of the version. E.g.: incrementing "stability" of "2.0.0-alpha.4" would b @param string $part @return $this
[ "Increment", "a", "specific", "part", "of", "the", "version", "." ]
2653209f2620e1d4a8baf17a0b5b74fd339abba3
https://github.com/zicht/version/blob/2653209f2620e1d4a8baf17a0b5b74fd339abba3/src/Zicht/Version/Version.php#L190-L226
240,461
zicht/version
src/Zicht/Version/Version.php
Version.set
private function set($part, $value) { if (null === $value && isset(self::$defaults[$part])) { $value = self::$defaults[$part]; } $this->parts[$part] = $value; return $this; }
php
private function set($part, $value) { if (null === $value && isset(self::$defaults[$part])) { $value = self::$defaults[$part]; } $this->parts[$part] = $value; return $this; }
[ "private", "function", "set", "(", "$", "part", ",", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", "&&", "isset", "(", "self", "::", "$", "defaults", "[", "$", "part", "]", ")", ")", "{", "$", "value", "=", "self", "::", "$", "defaults", "[", "$", "part", "]", ";", "}", "$", "this", "->", "parts", "[", "$", "part", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set a specific part of the Version @param string $part @param mixed $value @return self
[ "Set", "a", "specific", "part", "of", "the", "Version" ]
2653209f2620e1d4a8baf17a0b5b74fd339abba3
https://github.com/zicht/version/blob/2653209f2620e1d4a8baf17a0b5b74fd339abba3/src/Zicht/Version/Version.php#L248-L255
240,462
zicht/version
src/Zicht/Version/Version.php
Version.format
public function format() { $ret = ''; foreach (self::$formats as $key => $format) { $value = $this->get($key); // -stable is not added to the version, it is implied if ($key == self::STABILITY && $value == end(self::$stabilities)) { break; } $ret .= sprintf($format, $value); // -dev has no stability increments if ($key == self::STABILITY && $value == self::$stabilities[0]) { break; } } return $ret; }
php
public function format() { $ret = ''; foreach (self::$formats as $key => $format) { $value = $this->get($key); // -stable is not added to the version, it is implied if ($key == self::STABILITY && $value == end(self::$stabilities)) { break; } $ret .= sprintf($format, $value); // -dev has no stability increments if ($key == self::STABILITY && $value == self::$stabilities[0]) { break; } } return $ret; }
[ "public", "function", "format", "(", ")", "{", "$", "ret", "=", "''", ";", "foreach", "(", "self", "::", "$", "formats", "as", "$", "key", "=>", "$", "format", ")", "{", "$", "value", "=", "$", "this", "->", "get", "(", "$", "key", ")", ";", "// -stable is not added to the version, it is implied", "if", "(", "$", "key", "==", "self", "::", "STABILITY", "&&", "$", "value", "==", "end", "(", "self", "::", "$", "stabilities", ")", ")", "{", "break", ";", "}", "$", "ret", ".=", "sprintf", "(", "$", "format", ",", "$", "value", ")", ";", "// -dev has no stability increments", "if", "(", "$", "key", "==", "self", "::", "STABILITY", "&&", "$", "value", "==", "self", "::", "$", "stabilities", "[", "0", "]", ")", "{", "break", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Formats the version. @return string
[ "Formats", "the", "version", "." ]
2653209f2620e1d4a8baf17a0b5b74fd339abba3
https://github.com/zicht/version/blob/2653209f2620e1d4a8baf17a0b5b74fd339abba3/src/Zicht/Version/Version.php#L270-L291
240,463
zicht/version
src/Zicht/Version/Version.php
Version.numeric
public function numeric() { $ret = array(); foreach (self::$ordinality as $part) { if ($part === self::STABILITY) { $ret[]= array_search($this->get($part), self::$stabilities); } else { $ret[]= $this->get($part); } } return $ret; }
php
public function numeric() { $ret = array(); foreach (self::$ordinality as $part) { if ($part === self::STABILITY) { $ret[]= array_search($this->get($part), self::$stabilities); } else { $ret[]= $this->get($part); } } return $ret; }
[ "public", "function", "numeric", "(", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "ordinality", "as", "$", "part", ")", "{", "if", "(", "$", "part", "===", "self", "::", "STABILITY", ")", "{", "$", "ret", "[", "]", "=", "array_search", "(", "$", "this", "->", "get", "(", "$", "part", ")", ",", "self", "::", "$", "stabilities", ")", ";", "}", "else", "{", "$", "ret", "[", "]", "=", "$", "this", "->", "get", "(", "$", "part", ")", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Returns a numeric representation of all version parts, used for comparison @return array
[ "Returns", "a", "numeric", "representation", "of", "all", "version", "parts", "used", "for", "comparison" ]
2653209f2620e1d4a8baf17a0b5b74fd339abba3
https://github.com/zicht/version/blob/2653209f2620e1d4a8baf17a0b5b74fd339abba3/src/Zicht/Version/Version.php#L310-L321
240,464
sgoendoer/sonic
src/Api/ResponseBuilder.php
ResponseBuilder.setBody
public function setBody($responseBody) { if($this->initialized !== true) throw new \Exception('ResponseBuilder not initialized. Call init() first'); // TODO make sure, this can only be a string or a BaseObject // TODO throws an error when not valid JSON - how to deal with this? if(gettype($responseBody) != 'string') $responseBody = $responseBody->getJSONString(); $this->sonicResponse->setBody($responseBody); return $this; }
php
public function setBody($responseBody) { if($this->initialized !== true) throw new \Exception('ResponseBuilder not initialized. Call init() first'); // TODO make sure, this can only be a string or a BaseObject // TODO throws an error when not valid JSON - how to deal with this? if(gettype($responseBody) != 'string') $responseBody = $responseBody->getJSONString(); $this->sonicResponse->setBody($responseBody); return $this; }
[ "public", "function", "setBody", "(", "$", "responseBody", ")", "{", "if", "(", "$", "this", "->", "initialized", "!==", "true", ")", "throw", "new", "\\", "Exception", "(", "'ResponseBuilder not initialized. Call init() first'", ")", ";", "// TODO make sure, this can only be a string or a BaseObject\r", "// TODO throws an error when not valid JSON - how to deal with this?\r", "if", "(", "gettype", "(", "$", "responseBody", ")", "!=", "'string'", ")", "$", "responseBody", "=", "$", "responseBody", "->", "getJSONString", "(", ")", ";", "$", "this", "->", "sonicResponse", "->", "setBody", "(", "$", "responseBody", ")", ";", "return", "$", "this", ";", "}" ]
Sets the payload for the response. This needs to be an object that inherits from BasicObject
[ "Sets", "the", "payload", "for", "the", "response", ".", "This", "needs", "to", "be", "an", "object", "that", "inherits", "from", "BasicObject" ]
2c32ebd78607dc3e8558f10a0b7bf881d37fc168
https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Api/ResponseBuilder.php#L67-L80
240,465
gliverphp/utilities
src/Inspector.php
Inspector.checkFilter
public static function checkFilter($comment_string) { //define the regular expression pattern to use for string matching $pattern = "#(@[a-zA-Z]+\s*[a-zA-Z0-9, ()_].*)#"; //perform the regular expression on the string provided preg_match_all($pattern, $comment_string, $matches, PREG_PATTERN_ORDER); //get the meta elements in array $meta_data_array = $matches[0]; //check meta data was found if(count($meta_data_array) > 0){ //set array for before and after filters $beforeFilters = array(); $afterFilters = array(); //loop through array getting before and after filters foreach($meta_data_array as $key => $value){ //get before filter if(strpos($value, "@before") !== false){ $strb = explode(' ', trim($value)); $strb = self::clean($strb); (isset($strb[1])) ? $beforeFilters[] = $strb[1] : ''; (isset($strb[2])) ? $beforeFilters[] = $strb[2] : ''; } //get after filters if(strpos($value,"@after") !== false){ $stra = explode(' ', trim($value)); $stra = self::clean($stra); (isset($stra[1])) ? $afterFilters[] = $stra[1] : ''; (isset($stra[2])) ? $afterFilters[] = $stra[2] : ''; } } //define the array to return $return = array(); //check if before and after filters were empty if( ! empty($beforeFilters)) $return['before'] = $beforeFilters; if( ! empty($afterFilters)) $return['after'] = $afterFilters; return $return; } //no meta data found, return false else return false; }
php
public static function checkFilter($comment_string) { //define the regular expression pattern to use for string matching $pattern = "#(@[a-zA-Z]+\s*[a-zA-Z0-9, ()_].*)#"; //perform the regular expression on the string provided preg_match_all($pattern, $comment_string, $matches, PREG_PATTERN_ORDER); //get the meta elements in array $meta_data_array = $matches[0]; //check meta data was found if(count($meta_data_array) > 0){ //set array for before and after filters $beforeFilters = array(); $afterFilters = array(); //loop through array getting before and after filters foreach($meta_data_array as $key => $value){ //get before filter if(strpos($value, "@before") !== false){ $strb = explode(' ', trim($value)); $strb = self::clean($strb); (isset($strb[1])) ? $beforeFilters[] = $strb[1] : ''; (isset($strb[2])) ? $beforeFilters[] = $strb[2] : ''; } //get after filters if(strpos($value,"@after") !== false){ $stra = explode(' ', trim($value)); $stra = self::clean($stra); (isset($stra[1])) ? $afterFilters[] = $stra[1] : ''; (isset($stra[2])) ? $afterFilters[] = $stra[2] : ''; } } //define the array to return $return = array(); //check if before and after filters were empty if( ! empty($beforeFilters)) $return['before'] = $beforeFilters; if( ! empty($afterFilters)) $return['after'] = $afterFilters; return $return; } //no meta data found, return false else return false; }
[ "public", "static", "function", "checkFilter", "(", "$", "comment_string", ")", "{", "//define the regular expression pattern to use for string matching", "$", "pattern", "=", "\"#(@[a-zA-Z]+\\s*[a-zA-Z0-9, ()_].*)#\"", ";", "//perform the regular expression on the string provided", "preg_match_all", "(", "$", "pattern", ",", "$", "comment_string", ",", "$", "matches", ",", "PREG_PATTERN_ORDER", ")", ";", "//get the meta elements in array", "$", "meta_data_array", "=", "$", "matches", "[", "0", "]", ";", "//check meta data was found", "if", "(", "count", "(", "$", "meta_data_array", ")", ">", "0", ")", "{", "//set array for before and after filters", "$", "beforeFilters", "=", "array", "(", ")", ";", "$", "afterFilters", "=", "array", "(", ")", ";", "//loop through array getting before and after filters", "foreach", "(", "$", "meta_data_array", "as", "$", "key", "=>", "$", "value", ")", "{", "//get before filter", "if", "(", "strpos", "(", "$", "value", ",", "\"@before\"", ")", "!==", "false", ")", "{", "$", "strb", "=", "explode", "(", "' '", ",", "trim", "(", "$", "value", ")", ")", ";", "$", "strb", "=", "self", "::", "clean", "(", "$", "strb", ")", ";", "(", "isset", "(", "$", "strb", "[", "1", "]", ")", ")", "?", "$", "beforeFilters", "[", "]", "=", "$", "strb", "[", "1", "]", ":", "''", ";", "(", "isset", "(", "$", "strb", "[", "2", "]", ")", ")", "?", "$", "beforeFilters", "[", "]", "=", "$", "strb", "[", "2", "]", ":", "''", ";", "}", "//get after filters", "if", "(", "strpos", "(", "$", "value", ",", "\"@after\"", ")", "!==", "false", ")", "{", "$", "stra", "=", "explode", "(", "' '", ",", "trim", "(", "$", "value", ")", ")", ";", "$", "stra", "=", "self", "::", "clean", "(", "$", "stra", ")", ";", "(", "isset", "(", "$", "stra", "[", "1", "]", ")", ")", "?", "$", "afterFilters", "[", "]", "=", "$", "stra", "[", "1", "]", ":", "''", ";", "(", "isset", "(", "$", "stra", "[", "2", "]", ")", ")", "?", "$", "afterFilters", "[", "]", "=", "$", "stra", "[", "2", "]", ":", "''", ";", "}", "}", "//define the array to return", "$", "return", "=", "array", "(", ")", ";", "//check if before and after filters were empty", "if", "(", "!", "empty", "(", "$", "beforeFilters", ")", ")", "$", "return", "[", "'before'", "]", "=", "$", "beforeFilters", ";", "if", "(", "!", "empty", "(", "$", "afterFilters", ")", ")", "$", "return", "[", "'after'", "]", "=", "$", "afterFilters", ";", "return", "$", "return", ";", "}", "//no meta data found, return false", "else", "return", "false", ";", "}" ]
This method checks if a filter has been defined in the doc block. @param string $comment_string The doc block comment string @return mixed method name as string if found or bool false if not found
[ "This", "method", "checks", "if", "a", "filter", "has", "been", "defined", "in", "the", "doc", "block", "." ]
9c0c3db3d0c72cfc4fabf701d37db398c007ade5
https://github.com/gliverphp/utilities/blob/9c0c3db3d0c72cfc4fabf701d37db398c007ade5/src/Inspector.php#L21-L77
240,466
0x20h/phloppy
src/Cache/MemoryCache.php
MemoryCache.get
public function get($key) { if (!isset($this->records[$key])) { return null; } $record = $this->records[$key]; if ($record['expire'] < time()) { unset($this->records[$key]); return null; } return $record['nodes']; }
php
public function get($key) { if (!isset($this->records[$key])) { return null; } $record = $this->records[$key]; if ($record['expire'] < time()) { unset($this->records[$key]); return null; } return $record['nodes']; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "records", "[", "$", "key", "]", ")", ")", "{", "return", "null", ";", "}", "$", "record", "=", "$", "this", "->", "records", "[", "$", "key", "]", ";", "if", "(", "$", "record", "[", "'expire'", "]", "<", "time", "(", ")", ")", "{", "unset", "(", "$", "this", "->", "records", "[", "$", "key", "]", ")", ";", "return", "null", ";", "}", "return", "$", "record", "[", "'nodes'", "]", ";", "}" ]
Retrieve the nodes under the given key. @param string $key @return string[]
[ "Retrieve", "the", "nodes", "under", "the", "given", "key", "." ]
d917f0578360395899bd583724046d36ac459535
https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Cache/MemoryCache.php#L21-L36
240,467
0x20h/phloppy
src/Cache/MemoryCache.php
MemoryCache.expires
public function expires($key) { if (!isset($this->records[$key])) { return 0; } return (int) max(0, $this->records[$key]['expire'] - time()); }
php
public function expires($key) { if (!isset($this->records[$key])) { return 0; } return (int) max(0, $this->records[$key]['expire'] - time()); }
[ "public", "function", "expires", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "records", "[", "$", "key", "]", ")", ")", "{", "return", "0", ";", "}", "return", "(", "int", ")", "max", "(", "0", ",", "$", "this", "->", "records", "[", "$", "key", "]", "[", "'expire'", "]", "-", "time", "(", ")", ")", ";", "}" ]
Return seconds left until the key expires. @param string $key @return int The number of seconds the key is valid. 0 if expired or unknown.
[ "Return", "seconds", "left", "until", "the", "key", "expires", "." ]
d917f0578360395899bd583724046d36ac459535
https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Cache/MemoryCache.php#L63-L70
240,468
dotkernel/dot-flashmessenger
src/FlashMessenger.php
FlashMessenger.init
public function init() { $container = $this->getSessionContainer(); //get the messages and data that was set in the previous request //clear them afterwards if (isset($container->messages)) { $this->messages = $container->messages; unset($container->messages); } if (isset($container->data)) { $this->data = $container->data; unset($container->data); } }
php
public function init() { $container = $this->getSessionContainer(); //get the messages and data that was set in the previous request //clear them afterwards if (isset($container->messages)) { $this->messages = $container->messages; unset($container->messages); } if (isset($container->data)) { $this->data = $container->data; unset($container->data); } }
[ "public", "function", "init", "(", ")", "{", "$", "container", "=", "$", "this", "->", "getSessionContainer", "(", ")", ";", "//get the messages and data that was set in the previous request", "//clear them afterwards", "if", "(", "isset", "(", "$", "container", "->", "messages", ")", ")", "{", "$", "this", "->", "messages", "=", "$", "container", "->", "messages", ";", "unset", "(", "$", "container", "->", "messages", ")", ";", "}", "if", "(", "isset", "(", "$", "container", "->", "data", ")", ")", "{", "$", "this", "->", "data", "=", "$", "container", "->", "data", ";", "unset", "(", "$", "container", "->", "data", ")", ";", "}", "}" ]
Initialize the messenger with the previous session messages
[ "Initialize", "the", "messenger", "with", "the", "previous", "session", "messages" ]
c789e017d14d18ce73bf0a310542f2ea1da58a5f
https://github.com/dotkernel/dot-flashmessenger/blob/c789e017d14d18ce73bf0a310542f2ea1da58a5f/src/FlashMessenger.php#L63-L77
240,469
dotkernel/dot-flashmessenger
src/FlashMessenger.php
FlashMessenger.addMessage
public function addMessage(string $type, $message, string $channel = FlashMessengerInterface::DEFAULT_CHANNEL) { if (!is_string($message) && !is_array($message)) { throw new InvalidArgumentException('Flash message must be a string or an array of strings'); } $container = $this->getSessionContainer(); if (!isset($container->messages)) { $container->messages = []; } if (!isset($container->messages[$channel])) { $container->messages[$channel] = []; } if (!isset($container->messages[$channel][$type])) { $container->messages[$channel][$type] = []; } $message = (array)$message; foreach ($message as $msg) { if (!is_string($msg)) { throw new InvalidArgumentException('Flash message must be a string or an array of strings'); } $container->messages[$channel][$type][] = $msg; } }
php
public function addMessage(string $type, $message, string $channel = FlashMessengerInterface::DEFAULT_CHANNEL) { if (!is_string($message) && !is_array($message)) { throw new InvalidArgumentException('Flash message must be a string or an array of strings'); } $container = $this->getSessionContainer(); if (!isset($container->messages)) { $container->messages = []; } if (!isset($container->messages[$channel])) { $container->messages[$channel] = []; } if (!isset($container->messages[$channel][$type])) { $container->messages[$channel][$type] = []; } $message = (array)$message; foreach ($message as $msg) { if (!is_string($msg)) { throw new InvalidArgumentException('Flash message must be a string or an array of strings'); } $container->messages[$channel][$type][] = $msg; } }
[ "public", "function", "addMessage", "(", "string", "$", "type", ",", "$", "message", ",", "string", "$", "channel", "=", "FlashMessengerInterface", "::", "DEFAULT_CHANNEL", ")", "{", "if", "(", "!", "is_string", "(", "$", "message", ")", "&&", "!", "is_array", "(", "$", "message", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Flash message must be a string or an array of strings'", ")", ";", "}", "$", "container", "=", "$", "this", "->", "getSessionContainer", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "container", "->", "messages", ")", ")", "{", "$", "container", "->", "messages", "=", "[", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "container", "->", "messages", "[", "$", "channel", "]", ")", ")", "{", "$", "container", "->", "messages", "[", "$", "channel", "]", "=", "[", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "container", "->", "messages", "[", "$", "channel", "]", "[", "$", "type", "]", ")", ")", "{", "$", "container", "->", "messages", "[", "$", "channel", "]", "[", "$", "type", "]", "=", "[", "]", ";", "}", "$", "message", "=", "(", "array", ")", "$", "message", ";", "foreach", "(", "$", "message", "as", "$", "msg", ")", "{", "if", "(", "!", "is_string", "(", "$", "msg", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Flash message must be a string or an array of strings'", ")", ";", "}", "$", "container", "->", "messages", "[", "$", "channel", "]", "[", "$", "type", "]", "[", "]", "=", "$", "msg", ";", "}", "}" ]
Add flash message @param string $type The namespace to store the message under @param mixed $message Message to show on next request @param string $channel
[ "Add", "flash", "message" ]
c789e017d14d18ce73bf0a310542f2ea1da58a5f
https://github.com/dotkernel/dot-flashmessenger/blob/c789e017d14d18ce73bf0a310542f2ea1da58a5f/src/FlashMessenger.php#L181-L208
240,470
AgencyPMG/metrics
src/Reporting.php
Reporting.report
public function report() : ReportingResult { $sets = []; $errors = []; foreach ($this->collectors as $collector) { $sets[] = $set = $collector->flush(); $errors[] = $this->reportOn($set); } return new ReportingResult($sets, array_merge(...$errors)); }
php
public function report() : ReportingResult { $sets = []; $errors = []; foreach ($this->collectors as $collector) { $sets[] = $set = $collector->flush(); $errors[] = $this->reportOn($set); } return new ReportingResult($sets, array_merge(...$errors)); }
[ "public", "function", "report", "(", ")", ":", "ReportingResult", "{", "$", "sets", "=", "[", "]", ";", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "collectors", "as", "$", "collector", ")", "{", "$", "sets", "[", "]", "=", "$", "set", "=", "$", "collector", "->", "flush", "(", ")", ";", "$", "errors", "[", "]", "=", "$", "this", "->", "reportOn", "(", "$", "set", ")", ";", "}", "return", "new", "ReportingResult", "(", "$", "sets", ",", "array_merge", "(", "...", "$", "errors", ")", ")", ";", "}" ]
Flush each collector and send its MetricSet to all the given reporters. Returns any exceptions thrown by reporters. Metrics Usually aren't crucial to how an app runs, so this is making the call to try and keep running. If that's not what's required for an application, then this class should not be used.
[ "Flush", "each", "collector", "and", "send", "its", "MetricSet", "to", "all", "the", "given", "reporters", "." ]
79a3275d0b27f5ebaa681136a3b9b714ee074279
https://github.com/AgencyPMG/metrics/blob/79a3275d0b27f5ebaa681136a3b9b714ee074279/src/Reporting.php#L49-L59
240,471
AgencyPMG/metrics
src/Reporting.php
Reporting.reportOn
private function reportOn(MetricSet $set) : array { $errors = []; foreach ($this->reporters as $reporter) { try { $reporter->reportOn($set); } catch (\Exception $e) { $errors[] = $e; } } return $errors; }
php
private function reportOn(MetricSet $set) : array { $errors = []; foreach ($this->reporters as $reporter) { try { $reporter->reportOn($set); } catch (\Exception $e) { $errors[] = $e; } } return $errors; }
[ "private", "function", "reportOn", "(", "MetricSet", "$", "set", ")", ":", "array", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "reporters", "as", "$", "reporter", ")", "{", "try", "{", "$", "reporter", "->", "reportOn", "(", "$", "set", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "errors", "[", "]", "=", "$", "e", ";", "}", "}", "return", "$", "errors", ";", "}" ]
Deliberately only catches `Exception` objects rather than all throwables. Exceptions are more likely to mean that something went wrong in the reporter vs an error (which probably means the programmer messed up).
[ "Deliberately", "only", "catches", "Exception", "objects", "rather", "than", "all", "throwables", "." ]
79a3275d0b27f5ebaa681136a3b9b714ee074279
https://github.com/AgencyPMG/metrics/blob/79a3275d0b27f5ebaa681136a3b9b714ee074279/src/Reporting.php#L67-L79
240,472
joegreen88/zf1-components-base
src/Zend/Loader/ClassMapAutoloader.php
Zend_Loader_ClassMapAutoloader.registerAutoloadMap
public function registerAutoloadMap($map) { if (is_string($map)) { $location = $map; if ($this === ($map = $this->loadMapFromFile($location))) { return $this; } } if (!is_array($map)) { throw new Zend_Loader_Exception_InvalidArgumentException('Map file provided does not return a map'); } $this->map = array_merge($this->map, $map); if (isset($location)) { $this->mapsLoaded[] = $location; } return $this; }
php
public function registerAutoloadMap($map) { if (is_string($map)) { $location = $map; if ($this === ($map = $this->loadMapFromFile($location))) { return $this; } } if (!is_array($map)) { throw new Zend_Loader_Exception_InvalidArgumentException('Map file provided does not return a map'); } $this->map = array_merge($this->map, $map); if (isset($location)) { $this->mapsLoaded[] = $location; } return $this; }
[ "public", "function", "registerAutoloadMap", "(", "$", "map", ")", "{", "if", "(", "is_string", "(", "$", "map", ")", ")", "{", "$", "location", "=", "$", "map", ";", "if", "(", "$", "this", "===", "(", "$", "map", "=", "$", "this", "->", "loadMapFromFile", "(", "$", "location", ")", ")", ")", "{", "return", "$", "this", ";", "}", "}", "if", "(", "!", "is_array", "(", "$", "map", ")", ")", "{", "throw", "new", "Zend_Loader_Exception_InvalidArgumentException", "(", "'Map file provided does not return a map'", ")", ";", "}", "$", "this", "->", "map", "=", "array_merge", "(", "$", "this", "->", "map", ",", "$", "map", ")", ";", "if", "(", "isset", "(", "$", "location", ")", ")", "{", "$", "this", "->", "mapsLoaded", "[", "]", "=", "$", "location", ";", "}", "return", "$", "this", ";", "}" ]
Register an autoload map An autoload map may be either an associative array, or a file returning an associative array. An autoload map should be an associative array containing classname/file pairs. @param string|array $location @return Zend_Loader_ClassMapAutoloader
[ "Register", "an", "autoload", "map" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/ClassMapAutoloader.php#L88-L109
240,473
joegreen88/zf1-components-base
src/Zend/Loader/ClassMapAutoloader.php
Zend_Loader_ClassMapAutoloader.registerAutoloadMaps
public function registerAutoloadMaps($locations) { if (!is_array($locations) && !($locations instanceof Traversable)) { throw new Zend_Loader_Exception_InvalidArgumentException('Map list must be an array or implement Traversable'); } foreach ($locations as $location) { $this->registerAutoloadMap($location); } return $this; }
php
public function registerAutoloadMaps($locations) { if (!is_array($locations) && !($locations instanceof Traversable)) { throw new Zend_Loader_Exception_InvalidArgumentException('Map list must be an array or implement Traversable'); } foreach ($locations as $location) { $this->registerAutoloadMap($location); } return $this; }
[ "public", "function", "registerAutoloadMaps", "(", "$", "locations", ")", "{", "if", "(", "!", "is_array", "(", "$", "locations", ")", "&&", "!", "(", "$", "locations", "instanceof", "Traversable", ")", ")", "{", "throw", "new", "Zend_Loader_Exception_InvalidArgumentException", "(", "'Map list must be an array or implement Traversable'", ")", ";", "}", "foreach", "(", "$", "locations", "as", "$", "location", ")", "{", "$", "this", "->", "registerAutoloadMap", "(", "$", "location", ")", ";", "}", "return", "$", "this", ";", "}" ]
Register many autoload maps at once @param array $locations @return Zend_Loader_ClassMapAutoloader
[ "Register", "many", "autoload", "maps", "at", "once" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/ClassMapAutoloader.php#L117-L127
240,474
joegreen88/zf1-components-base
src/Zend/Loader/ClassMapAutoloader.php
Zend_Loader_ClassMapAutoloader.register
public function register() { if (version_compare(PHP_VERSION, '5.3.0', '>=')) { spl_autoload_register(array($this, 'autoload'), true, true); } else { spl_autoload_register(array($this, 'autoload'), true); } }
php
public function register() { if (version_compare(PHP_VERSION, '5.3.0', '>=')) { spl_autoload_register(array($this, 'autoload'), true, true); } else { spl_autoload_register(array($this, 'autoload'), true); } }
[ "public", "function", "register", "(", ")", "{", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.3.0'", ",", "'>='", ")", ")", "{", "spl_autoload_register", "(", "array", "(", "$", "this", ",", "'autoload'", ")", ",", "true", ",", "true", ")", ";", "}", "else", "{", "spl_autoload_register", "(", "array", "(", "$", "this", ",", "'autoload'", ")", ",", "true", ")", ";", "}", "}" ]
Register the autoloader with spl_autoload registry @return void
[ "Register", "the", "autoloader", "with", "spl_autoload", "registry" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/ClassMapAutoloader.php#L157-L164
240,475
joegreen88/zf1-components-base
src/Zend/Loader/ClassMapAutoloader.php
Zend_Loader_ClassMapAutoloader.loadMapFromFile
protected function loadMapFromFile($location) { if (!file_exists($location)) { throw new Zend_Loader_Exception_InvalidArgumentException('Map file provided does not exist'); } if (!$path = self::realPharPath($location)) { $path = realpath($location); } if (in_array($path, $this->mapsLoaded)) { // Already loaded this map return $this; } $map = include $path; return $map; }
php
protected function loadMapFromFile($location) { if (!file_exists($location)) { throw new Zend_Loader_Exception_InvalidArgumentException('Map file provided does not exist'); } if (!$path = self::realPharPath($location)) { $path = realpath($location); } if (in_array($path, $this->mapsLoaded)) { // Already loaded this map return $this; } $map = include $path; return $map; }
[ "protected", "function", "loadMapFromFile", "(", "$", "location", ")", "{", "if", "(", "!", "file_exists", "(", "$", "location", ")", ")", "{", "throw", "new", "Zend_Loader_Exception_InvalidArgumentException", "(", "'Map file provided does not exist'", ")", ";", "}", "if", "(", "!", "$", "path", "=", "self", "::", "realPharPath", "(", "$", "location", ")", ")", "{", "$", "path", "=", "realpath", "(", "$", "location", ")", ";", "}", "if", "(", "in_array", "(", "$", "path", ",", "$", "this", "->", "mapsLoaded", ")", ")", "{", "// Already loaded this map", "return", "$", "this", ";", "}", "$", "map", "=", "include", "$", "path", ";", "return", "$", "map", ";", "}" ]
Load a map from a file If the map has been previously loaded, returns the current instance; otherwise, returns whatever was returned by calling include() on the location. @param string $location @return Zend_Loader_ClassMapAutoloader|mixed @throws Zend_Loader_Exception_InvalidArgumentException for nonexistent locations
[ "Load", "a", "map", "from", "a", "file" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/ClassMapAutoloader.php#L177-L196
240,476
joegreen88/zf1-components-base
src/Zend/Loader/ClassMapAutoloader.php
Zend_Loader_ClassMapAutoloader.resolvePharParentPath
public static function resolvePharParentPath($value, $key, &$parts) { if ($value !== '...') { return; } unset($parts[$key], $parts[$key-1]); $parts = array_values($parts); }
php
public static function resolvePharParentPath($value, $key, &$parts) { if ($value !== '...') { return; } unset($parts[$key], $parts[$key-1]); $parts = array_values($parts); }
[ "public", "static", "function", "resolvePharParentPath", "(", "$", "value", ",", "$", "key", ",", "&", "$", "parts", ")", "{", "if", "(", "$", "value", "!==", "'...'", ")", "{", "return", ";", "}", "unset", "(", "$", "parts", "[", "$", "key", "]", ",", "$", "parts", "[", "$", "key", "-", "1", "]", ")", ";", "$", "parts", "=", "array_values", "(", "$", "parts", ")", ";", "}" ]
Helper callback to resolve a parent path in a Phar archive @param string $value @param int $key @param array $parts @return void
[ "Helper", "callback", "to", "resolve", "a", "parent", "path", "in", "a", "Phar", "archive" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/ClassMapAutoloader.php#L240-L247
240,477
osflab/controller
Response/Callback.php
Callback.setCallback
public function setCallback(callable $callback, array $params = []) { if ($this->hasCallback()) { throw new ArchException('Callback already defined'); } $this->callback = $callback; $this->callbackParams = $params; return $this; }
php
public function setCallback(callable $callback, array $params = []) { if ($this->hasCallback()) { throw new ArchException('Callback already defined'); } $this->callback = $callback; $this->callbackParams = $params; return $this; }
[ "public", "function", "setCallback", "(", "callable", "$", "callback", ",", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "hasCallback", "(", ")", ")", "{", "throw", "new", "ArchException", "(", "'Callback already defined'", ")", ";", "}", "$", "this", "->", "callback", "=", "$", "callback", ";", "$", "this", "->", "callbackParams", "=", "$", "params", ";", "return", "$", "this", ";", "}" ]
Define the callback function. This function need to send a content feed on standard output. This callback is usefull to bypass the body in order to optimize performances. @param string $callback @return $this
[ "Define", "the", "callback", "function", ".", "This", "function", "need", "to", "send", "a", "content", "feed", "on", "standard", "output", ".", "This", "callback", "is", "usefull", "to", "bypass", "the", "body", "in", "order", "to", "optimize", "performances", "." ]
d59344fc204a74995224e3da39b9debd78fdb974
https://github.com/osflab/controller/blob/d59344fc204a74995224e3da39b9debd78fdb974/Response/Callback.php#L35-L43
240,478
Dhii/expression-renderer-abstract
src/GetTermTypeRendererContainerTrait.php
GetTermTypeRendererContainerTrait._getTermTypeRenderer
protected function _getTermTypeRenderer($termType, $context = null) { $container = $this->_getTermTypeRendererContainer(); return $this->_containerGet($container, $termType); }
php
protected function _getTermTypeRenderer($termType, $context = null) { $container = $this->_getTermTypeRendererContainer(); return $this->_containerGet($container, $termType); }
[ "protected", "function", "_getTermTypeRenderer", "(", "$", "termType", ",", "$", "context", "=", "null", ")", "{", "$", "container", "=", "$", "this", "->", "_getTermTypeRendererContainer", "(", ")", ";", "return", "$", "this", "->", "_containerGet", "(", "$", "container", ",", "$", "termType", ")", ";", "}" ]
Retrieves the renderer for a given term. @since [*next-version*] @param string|Stringable $termType The term type for which to retrieve a renderer. @param array|ArrayAccess|stdClass|ContainerInterface|null $context The context. @return TemplateInterface The renderer instance. @throws ContainerExceptionInterface If an error occurred while reading from the container. @throws NotFoundExceptionInterface If no renderer was found for the given term type.
[ "Retrieves", "the", "renderer", "for", "a", "given", "term", "." ]
8c315e1d034b4198a89e0157f045e4a0d6cc8de8
https://github.com/Dhii/expression-renderer-abstract/blob/8c315e1d034b4198a89e0157f045e4a0d6cc8de8/src/GetTermTypeRendererContainerTrait.php#L34-L39
240,479
flavorzyb/simple
src/Environment/Loader.php
Loader.ensureFileIsReadable
protected function ensureFileIsReadable() { $filePath = $this->filePath; if (!is_readable($filePath) || !is_file($filePath)) { throw new InvalidArgumentException(sprintf( 'Dotenv: Environment file .env not found or not readable. '. 'Create file with your environment settings at %s', $filePath )); } }
php
protected function ensureFileIsReadable() { $filePath = $this->filePath; if (!is_readable($filePath) || !is_file($filePath)) { throw new InvalidArgumentException(sprintf( 'Dotenv: Environment file .env not found or not readable. '. 'Create file with your environment settings at %s', $filePath )); } }
[ "protected", "function", "ensureFileIsReadable", "(", ")", "{", "$", "filePath", "=", "$", "this", "->", "filePath", ";", "if", "(", "!", "is_readable", "(", "$", "filePath", ")", "||", "!", "is_file", "(", "$", "filePath", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Dotenv: Environment file .env not found or not readable. '", ".", "'Create file with your environment settings at %s'", ",", "$", "filePath", ")", ")", ";", "}", "}" ]
Ensures the given filePath is readable. @throws \InvalidArgumentException
[ "Ensures", "the", "given", "filePath", "is", "readable", "." ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Environment/Loader.php#L64-L74
240,480
flavorzyb/simple
src/Environment/Loader.php
Loader.normaliseEnvironmentVariable
protected function normaliseEnvironmentVariable($name, $value) { list($name, $value) = $this->splitCompoundStringIntoParts($name, $value); return array($name, $value); }
php
protected function normaliseEnvironmentVariable($name, $value) { list($name, $value) = $this->splitCompoundStringIntoParts($name, $value); return array($name, $value); }
[ "protected", "function", "normaliseEnvironmentVariable", "(", "$", "name", ",", "$", "value", ")", "{", "list", "(", "$", "name", ",", "$", "value", ")", "=", "$", "this", "->", "splitCompoundStringIntoParts", "(", "$", "name", ",", "$", "value", ")", ";", "return", "array", "(", "$", "name", ",", "$", "value", ")", ";", "}" ]
Normalise the given environment variable. Takes value as passed in by developer and: - ensures we're dealing with a separate name and value, breaking apart the name string if needed - cleaning the value of quotes - cleaning the name of quotes - resolving nested variables @param $name @param $value @return array
[ "Normalise", "the", "given", "environment", "variable", "." ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Environment/Loader.php#L89-L93
240,481
flavorzyb/simple
src/Environment/Loader.php
Loader.readLinesFromFile
protected function readLinesFromFile($filePath) { // Read file into an array of lines with auto-detected line endings $autodetect = ini_get('auto_detect_line_endings'); ini_set('auto_detect_line_endings', '1'); $lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); ini_set('auto_detect_line_endings', $autodetect); return $lines; }
php
protected function readLinesFromFile($filePath) { // Read file into an array of lines with auto-detected line endings $autodetect = ini_get('auto_detect_line_endings'); ini_set('auto_detect_line_endings', '1'); $lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); ini_set('auto_detect_line_endings', $autodetect); return $lines; }
[ "protected", "function", "readLinesFromFile", "(", "$", "filePath", ")", "{", "// Read file into an array of lines with auto-detected line endings", "$", "autodetect", "=", "ini_get", "(", "'auto_detect_line_endings'", ")", ";", "ini_set", "(", "'auto_detect_line_endings'", ",", "'1'", ")", ";", "$", "lines", "=", "file", "(", "$", "filePath", ",", "FILE_IGNORE_NEW_LINES", "|", "FILE_SKIP_EMPTY_LINES", ")", ";", "ini_set", "(", "'auto_detect_line_endings'", ",", "$", "autodetect", ")", ";", "return", "$", "lines", ";", "}" ]
Read lines from the file, auto detecting line endings. @param string $filePath @return array
[ "Read", "lines", "from", "the", "file", "auto", "detecting", "line", "endings", "." ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Environment/Loader.php#L102-L110
240,482
calgamo/filesystem
src/File.php
File.getName
public function getName( $suffix = NULL ) : string { $name = $suffix ? basename( $this->path, $suffix ) : basename( $this->path ); return $name; }
php
public function getName( $suffix = NULL ) : string { $name = $suffix ? basename( $this->path, $suffix ) : basename( $this->path ); return $name; }
[ "public", "function", "getName", "(", "$", "suffix", "=", "NULL", ")", ":", "string", "{", "$", "name", "=", "$", "suffix", "?", "basename", "(", "$", "this", "->", "path", ",", "$", "suffix", ")", ":", "basename", "(", "$", "this", "->", "path", ")", ";", "return", "$", "name", ";", "}" ]
Name of the file or directory @param string|NULL $suffix file suffix which is ignored. @return string
[ "Name", "of", "the", "file", "or", "directory" ]
35b0f1286197f1566cdad3bca07fc41fb88edbf1
https://github.com/calgamo/filesystem/blob/35b0f1286197f1566cdad3bca07fc41fb88edbf1/src/File.php#L270-L275
240,483
calgamo/filesystem
src/File.php
File.putContents
public function putContents( $contents, $ex_lock = false ) : int { $flags = $ex_lock ? LOCK_EX : 0; $res = file_put_contents( $this->path, $contents, $flags ); if ($res === FALSE){ throw new FileOutputException($this); } return $res; }
php
public function putContents( $contents, $ex_lock = false ) : int { $flags = $ex_lock ? LOCK_EX : 0; $res = file_put_contents( $this->path, $contents, $flags ); if ($res === FALSE){ throw new FileOutputException($this); } return $res; }
[ "public", "function", "putContents", "(", "$", "contents", ",", "$", "ex_lock", "=", "false", ")", ":", "int", "{", "$", "flags", "=", "$", "ex_lock", "?", "LOCK_EX", ":", "0", ";", "$", "res", "=", "file_put_contents", "(", "$", "this", "->", "path", ",", "$", "contents", ",", "$", "flags", ")", ";", "if", "(", "$", "res", "===", "FALSE", ")", "{", "throw", "new", "FileOutputException", "(", "$", "this", ")", ";", "}", "return", "$", "res", ";", "}" ]
Save string data as a file @param string $contents @param bool $ex_lock @return int @throws FileOutputException
[ "Save", "string", "data", "as", "a", "file" ]
35b0f1286197f1566cdad3bca07fc41fb88edbf1
https://github.com/calgamo/filesystem/blob/35b0f1286197f1566cdad3bca07fc41fb88edbf1/src/File.php#L341-L349
240,484
calgamo/filesystem
src/File.php
File.rename
public function rename( $new_file ) { $res = @rename( $this->path, $new_file->getPath() ); if ( $res === FALSE ){ throw new FileRenameException($this, $new_file); } }
php
public function rename( $new_file ) { $res = @rename( $this->path, $new_file->getPath() ); if ( $res === FALSE ){ throw new FileRenameException($this, $new_file); } }
[ "public", "function", "rename", "(", "$", "new_file", ")", "{", "$", "res", "=", "@", "rename", "(", "$", "this", "->", "path", ",", "$", "new_file", "->", "getPath", "(", ")", ")", ";", "if", "(", "$", "res", "===", "FALSE", ")", "{", "throw", "new", "FileRenameException", "(", "$", "this", ",", "$", "new_file", ")", ";", "}", "}" ]
Rename the file or directory @param File $new_file @throws FileRenameException
[ "Rename", "the", "file", "or", "directory" ]
35b0f1286197f1566cdad3bca07fc41fb88edbf1
https://github.com/calgamo/filesystem/blob/35b0f1286197f1566cdad3bca07fc41fb88edbf1/src/File.php#L358-L364
240,485
calgamo/filesystem
src/File.php
File.makeDirectory
public function makeDirectory( $mode = NULL ) { $mode = $mode ? $mode : 0777; if ( file_exists($this->path) ){ if ( is_file($this->path) ){ throw new MakeDirectoryException($this); } return; } $parent_dir = $this->getParent(); if ( !$parent_dir->exists() ){ $parent_dir->makeDirectory( $mode ); } $res = @mkdir( $this->path, $mode ); if ( $res === FALSE ){ throw new MakeDirectoryException($this); } }
php
public function makeDirectory( $mode = NULL ) { $mode = $mode ? $mode : 0777; if ( file_exists($this->path) ){ if ( is_file($this->path) ){ throw new MakeDirectoryException($this); } return; } $parent_dir = $this->getParent(); if ( !$parent_dir->exists() ){ $parent_dir->makeDirectory( $mode ); } $res = @mkdir( $this->path, $mode ); if ( $res === FALSE ){ throw new MakeDirectoryException($this); } }
[ "public", "function", "makeDirectory", "(", "$", "mode", "=", "NULL", ")", "{", "$", "mode", "=", "$", "mode", "?", "$", "mode", ":", "0777", ";", "if", "(", "file_exists", "(", "$", "this", "->", "path", ")", ")", "{", "if", "(", "is_file", "(", "$", "this", "->", "path", ")", ")", "{", "throw", "new", "MakeDirectoryException", "(", "$", "this", ")", ";", "}", "return", ";", "}", "$", "parent_dir", "=", "$", "this", "->", "getParent", "(", ")", ";", "if", "(", "!", "$", "parent_dir", "->", "exists", "(", ")", ")", "{", "$", "parent_dir", "->", "makeDirectory", "(", "$", "mode", ")", ";", "}", "$", "res", "=", "@", "mkdir", "(", "$", "this", "->", "path", ",", "$", "mode", ")", ";", "if", "(", "$", "res", "===", "FALSE", ")", "{", "throw", "new", "MakeDirectoryException", "(", "$", "this", ")", ";", "}", "}" ]
Create empty directory @param string $mode File mode.If this parameter is set NULL, 0777 will be applied. @return void @throws MakeDirectoryException
[ "Create", "empty", "directory" ]
35b0f1286197f1566cdad3bca07fc41fb88edbf1
https://github.com/calgamo/filesystem/blob/35b0f1286197f1566cdad3bca07fc41fb88edbf1/src/File.php#L397-L418
240,486
calgamo/filesystem
src/File.php
File.listFiles
public function listFiles( $filter = NULL ) : array { $path = $this->path; if ( !file_exists($path) ) return NULL; if ( !is_readable($path) ) return NULL; if ( is_file($path) ) return NULL; $files = array(); $dh = opendir($path); while( ($file_name = readdir($dh)) !== FALSE ){ if ( $file_name === '.' || $file_name === '..' ){ continue; } $file = new File( $file_name, $this ); if ( $filter ){ if ( $filter instanceof FileFilterInterface ){ if ( $filter->accept($file) ){ $files[] = $file; } } else if ( is_callable($filter) ){ if ( $filter($file) ){ $files[] = $file; } } } else{ $files[] = $file; } } return $files; }
php
public function listFiles( $filter = NULL ) : array { $path = $this->path; if ( !file_exists($path) ) return NULL; if ( !is_readable($path) ) return NULL; if ( is_file($path) ) return NULL; $files = array(); $dh = opendir($path); while( ($file_name = readdir($dh)) !== FALSE ){ if ( $file_name === '.' || $file_name === '..' ){ continue; } $file = new File( $file_name, $this ); if ( $filter ){ if ( $filter instanceof FileFilterInterface ){ if ( $filter->accept($file) ){ $files[] = $file; } } else if ( is_callable($filter) ){ if ( $filter($file) ){ $files[] = $file; } } } else{ $files[] = $file; } } return $files; }
[ "public", "function", "listFiles", "(", "$", "filter", "=", "NULL", ")", ":", "array", "{", "$", "path", "=", "$", "this", "->", "path", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "return", "NULL", ";", "if", "(", "!", "is_readable", "(", "$", "path", ")", ")", "return", "NULL", ";", "if", "(", "is_file", "(", "$", "path", ")", ")", "return", "NULL", ";", "$", "files", "=", "array", "(", ")", ";", "$", "dh", "=", "opendir", "(", "$", "path", ")", ";", "while", "(", "(", "$", "file_name", "=", "readdir", "(", "$", "dh", ")", ")", "!==", "FALSE", ")", "{", "if", "(", "$", "file_name", "===", "'.'", "||", "$", "file_name", "===", "'..'", ")", "{", "continue", ";", "}", "$", "file", "=", "new", "File", "(", "$", "file_name", ",", "$", "this", ")", ";", "if", "(", "$", "filter", ")", "{", "if", "(", "$", "filter", "instanceof", "FileFilterInterface", ")", "{", "if", "(", "$", "filter", "->", "accept", "(", "$", "file", ")", ")", "{", "$", "files", "[", "]", "=", "$", "file", ";", "}", "}", "else", "if", "(", "is_callable", "(", "$", "filter", ")", ")", "{", "if", "(", "$", "filter", "(", "$", "file", ")", ")", "{", "$", "files", "[", "]", "=", "$", "file", ";", "}", "}", "}", "else", "{", "$", "files", "[", "]", "=", "$", "file", ";", "}", "}", "return", "$", "files", ";", "}" ]
Listing up files in directory which this object means @param FileFilterInterface|callable $filter Fileter object which implements selection logic. If this parameter is omitted, all files will be selected. @return File[]
[ "Listing", "up", "files", "in", "directory", "which", "this", "object", "means" ]
35b0f1286197f1566cdad3bca07fc41fb88edbf1
https://github.com/calgamo/filesystem/blob/35b0f1286197f1566cdad3bca07fc41fb88edbf1/src/File.php#L427-L462
240,487
calgamo/filesystem
src/File.php
File.touch
public function touch( $time = NULL ) : bool { if ( $time === NULL ){ return touch( $this->path ); } return touch( $this->path, $time ); }
php
public function touch( $time = NULL ) : bool { if ( $time === NULL ){ return touch( $this->path ); } return touch( $this->path, $time ); }
[ "public", "function", "touch", "(", "$", "time", "=", "NULL", ")", ":", "bool", "{", "if", "(", "$", "time", "===", "NULL", ")", "{", "return", "touch", "(", "$", "this", "->", "path", ")", ";", "}", "return", "touch", "(", "$", "this", "->", "path", ",", "$", "time", ")", ";", "}" ]
Update last modified date of the file @param int|Integer $time time value to set @return bool
[ "Update", "last", "modified", "date", "of", "the", "file" ]
35b0f1286197f1566cdad3bca07fc41fb88edbf1
https://github.com/calgamo/filesystem/blob/35b0f1286197f1566cdad3bca07fc41fb88edbf1/src/File.php#L472-L478
240,488
tenside/core-bundle
src/Security/PermissionVoter.php
PermissionVoter.supportsAnyAttribute
private function supportsAnyAttribute($attributes) { foreach ($attributes as $attribute) { if ($this->supportsAttribute($attribute)) { return true; } } return false; }
php
private function supportsAnyAttribute($attributes) { foreach ($attributes as $attribute) { if ($this->supportsAttribute($attribute)) { return true; } } return false; }
[ "private", "function", "supportsAnyAttribute", "(", "$", "attributes", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "if", "(", "$", "this", "->", "supportsAttribute", "(", "$", "attribute", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Test if we support any of the attributes. @param string[] $attributes The attributes to test. @return bool
[ "Test", "if", "we", "support", "any", "of", "the", "attributes", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Security/PermissionVoter.php#L151-L160
240,489
tenside/core-bundle
src/Security/PermissionVoter.php
PermissionVoter.getRouteRoles
private function getRouteRoles() { $router = $this->router; $cache = $this->getConfigCacheFactory()->cache( $this->options['cache_dir'].'/tenside_roles.php', function (ConfigCacheInterface $cache) use ($router) { $routes = $router->getRouteCollection(); $roles = []; foreach ($routes as $name => $route) { if ($requiredRole = $route->getOption('required_role')) { $roles[$name] = $requiredRole; } } $cache->write('<?php return ' . var_export($roles, true) . ';', $routes->getResources()); } ); return require_once $cache->getPath(); }
php
private function getRouteRoles() { $router = $this->router; $cache = $this->getConfigCacheFactory()->cache( $this->options['cache_dir'].'/tenside_roles.php', function (ConfigCacheInterface $cache) use ($router) { $routes = $router->getRouteCollection(); $roles = []; foreach ($routes as $name => $route) { if ($requiredRole = $route->getOption('required_role')) { $roles[$name] = $requiredRole; } } $cache->write('<?php return ' . var_export($roles, true) . ';', $routes->getResources()); } ); return require_once $cache->getPath(); }
[ "private", "function", "getRouteRoles", "(", ")", "{", "$", "router", "=", "$", "this", "->", "router", ";", "$", "cache", "=", "$", "this", "->", "getConfigCacheFactory", "(", ")", "->", "cache", "(", "$", "this", "->", "options", "[", "'cache_dir'", "]", ".", "'/tenside_roles.php'", ",", "function", "(", "ConfigCacheInterface", "$", "cache", ")", "use", "(", "$", "router", ")", "{", "$", "routes", "=", "$", "router", "->", "getRouteCollection", "(", ")", ";", "$", "roles", "=", "[", "]", ";", "foreach", "(", "$", "routes", "as", "$", "name", "=>", "$", "route", ")", "{", "if", "(", "$", "requiredRole", "=", "$", "route", "->", "getOption", "(", "'required_role'", ")", ")", "{", "$", "roles", "[", "$", "name", "]", "=", "$", "requiredRole", ";", "}", "}", "$", "cache", "->", "write", "(", "'<?php return '", ".", "var_export", "(", "$", "roles", ",", "true", ")", ".", "';'", ",", "$", "routes", "->", "getResources", "(", ")", ")", ";", "}", ")", ";", "return", "require_once", "$", "cache", "->", "getPath", "(", ")", ";", "}" ]
Get the required roles from cache if possible. @return array
[ "Get", "the", "required", "roles", "from", "cache", "if", "possible", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Security/PermissionVoter.php#L181-L201
240,490
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Raw.php
Raw.createNew
public function createNew( int $sourceId, string $collectionName, array $data ) : array { return $this->sendPost( sprintf('/profiles/%s/raw', $this->userName), [], [ 'source_id' => $sourceId, 'collection' => $collectionName, 'data' => $data ] ); }
php
public function createNew( int $sourceId, string $collectionName, array $data ) : array { return $this->sendPost( sprintf('/profiles/%s/raw', $this->userName), [], [ 'source_id' => $sourceId, 'collection' => $collectionName, 'data' => $data ] ); }
[ "public", "function", "createNew", "(", "int", "$", "sourceId", ",", "string", "$", "collectionName", ",", "array", "$", "data", ")", ":", "array", "{", "return", "$", "this", "->", "sendPost", "(", "sprintf", "(", "'/profiles/%s/raw'", ",", "$", "this", "->", "userName", ")", ",", "[", "]", ",", "[", "'source_id'", "=>", "$", "sourceId", ",", "'collection'", "=>", "$", "collectionName", ",", "'data'", "=>", "$", "data", "]", ")", ";", "}" ]
Creates a new raw data for the given source. @param int $sourceId @param string $collectionName @param array $data @return array Response
[ "Creates", "a", "new", "raw", "data", "for", "the", "given", "source", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Raw.php#L20-L34
240,491
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Raw.php
Raw.upsertOne
public function upsertOne( int $sourceId, string $collectionName, array $data ) : array { return $this->sendPut( sprintf('/profiles/%s/raw', $this->userName), [], [ 'source_id' => $sourceId, 'collection' => $collectionName, 'data' => $data ] ); }
php
public function upsertOne( int $sourceId, string $collectionName, array $data ) : array { return $this->sendPut( sprintf('/profiles/%s/raw', $this->userName), [], [ 'source_id' => $sourceId, 'collection' => $collectionName, 'data' => $data ] ); }
[ "public", "function", "upsertOne", "(", "int", "$", "sourceId", ",", "string", "$", "collectionName", ",", "array", "$", "data", ")", ":", "array", "{", "return", "$", "this", "->", "sendPut", "(", "sprintf", "(", "'/profiles/%s/raw'", ",", "$", "this", "->", "userName", ")", ",", "[", "]", ",", "[", "'source_id'", "=>", "$", "sourceId", ",", "'collection'", "=>", "$", "collectionName", ",", "'data'", "=>", "$", "data", "]", ")", ";", "}" ]
Tries to update a raw data and if it doesnt exists, creates a new raw data. @param int $sourceId @param string $collectionName @param array $data @return array Response
[ "Tries", "to", "update", "a", "raw", "data", "and", "if", "it", "doesnt", "exists", "creates", "a", "new", "raw", "data", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Raw.php#L45-L59
240,492
score-ya/cinderella-sdk
src/Common/ClientBuilder.php
ClientBuilder.get
public function get($name, $throwAway = false) { $client = parent::get($name, $throwAway); if ($client instanceof ApiKeyClientInterface) { $client->setApiKey(self::$apiKey); } return $client; }
php
public function get($name, $throwAway = false) { $client = parent::get($name, $throwAway); if ($client instanceof ApiKeyClientInterface) { $client->setApiKey(self::$apiKey); } return $client; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "throwAway", "=", "false", ")", "{", "$", "client", "=", "parent", "::", "get", "(", "$", "name", ",", "$", "throwAway", ")", ";", "if", "(", "$", "client", "instanceof", "ApiKeyClientInterface", ")", "{", "$", "client", "->", "setApiKey", "(", "self", "::", "$", "apiKey", ")", ";", "}", "return", "$", "client", ";", "}" ]
set the api key for api key clients @param string $name @param bool $throwAway @return ClientInterface
[ "set", "the", "api", "key", "for", "api", "key", "clients" ]
bed7371cb1caeefd1efcb09306c10d8805270e17
https://github.com/score-ya/cinderella-sdk/blob/bed7371cb1caeefd1efcb09306c10d8805270e17/src/Common/ClientBuilder.php#L40-L49
240,493
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php
AdminProductItemFieldDataController.showAction
public function showAction(ProductItemFieldData $productitemfielddata) { $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata, array( 'action' => $this->generateUrl('admin_productitemfielddata_update', array('id' => $productitemfielddata->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($productitemfielddata->getId(), 'admin_productitemfielddata_delete'); return array( 'productitemfielddata' => $productitemfielddata, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function showAction(ProductItemFieldData $productitemfielddata) { $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata, array( 'action' => $this->generateUrl('admin_productitemfielddata_update', array('id' => $productitemfielddata->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($productitemfielddata->getId(), 'admin_productitemfielddata_delete'); return array( 'productitemfielddata' => $productitemfielddata, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "showAction", "(", "ProductItemFieldData", "$", "productitemfielddata", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "\"amulen.shop.form.product.item.field.data\"", ")", ",", "$", "productitemfielddata", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_productitemfielddata_update'", ",", "array", "(", "'id'", "=>", "$", "productitemfielddata", "->", "getid", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "productitemfielddata", "->", "getId", "(", ")", ",", "'admin_productitemfielddata_delete'", ")", ";", "return", "array", "(", "'productitemfielddata'", "=>", "$", "productitemfielddata", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Finds and displays a ProductItemFieldData entity. @Route("/{id}/show", name="admin_productitemfielddata_show", requirements={"id"="\d+"}) @Method("GET") @Template()
[ "Finds", "and", "displays", "a", "ProductItemFieldData", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php#L47-L61
240,494
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php
AdminProductItemFieldDataController.newAction
public function newAction() { $productitemfielddata = new ProductItemFieldData(); $form = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata); return array( 'productitemfielddata' => $productitemfielddata, 'form' => $form->createView(), ); }
php
public function newAction() { $productitemfielddata = new ProductItemFieldData(); $form = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata); return array( 'productitemfielddata' => $productitemfielddata, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", ")", "{", "$", "productitemfielddata", "=", "new", "ProductItemFieldData", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "\"amulen.shop.form.product.item.field.data\"", ")", ",", "$", "productitemfielddata", ")", ";", "return", "array", "(", "'productitemfielddata'", "=>", "$", "productitemfielddata", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to create a new ProductItemFieldData entity. @Route("/new", name="admin_productitemfielddata_new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "ProductItemFieldData", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php#L70-L79
240,495
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php
AdminProductItemFieldDataController.createAction
public function createAction(Request $request) { $productitemfielddata = new ProductItemFieldData(); $form = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($productitemfielddata); $em->flush(); return $this->redirect($this->generateUrl('admin_productitemfielddata_show', array('id' => $productitemfielddata->getId()))); } return array( 'productitemfielddata' => $productitemfielddata, 'form' => $form->createView(), ); }
php
public function createAction(Request $request) { $productitemfielddata = new ProductItemFieldData(); $form = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($productitemfielddata); $em->flush(); return $this->redirect($this->generateUrl('admin_productitemfielddata_show', array('id' => $productitemfielddata->getId()))); } return array( 'productitemfielddata' => $productitemfielddata, 'form' => $form->createView(), ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "productitemfielddata", "=", "new", "ProductItemFieldData", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "\"amulen.shop.form.product.item.field.data\"", ")", ",", "$", "productitemfielddata", ")", ";", "if", "(", "$", "form", "->", "handleRequest", "(", "$", "request", ")", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "productitemfielddata", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_productitemfielddata_show'", ",", "array", "(", "'id'", "=>", "$", "productitemfielddata", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "return", "array", "(", "'productitemfielddata'", "=>", "$", "productitemfielddata", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Creates a new ProductItemFieldData entity. @Route("/create", name="admin_productitemfielddata_create") @Method("POST") @Template("AmulenShopBundle:ProductItemFieldData:new.html.twig")
[ "Creates", "a", "new", "ProductItemFieldData", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php#L88-L104
240,496
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php
AdminProductItemFieldDataController.updateAction
public function updateAction(ProductItemFieldData $productitemfielddata, Request $request) { $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata, array( 'action' => $this->generateUrl('admin_productitemfielddata_update', array('id' => $productitemfielddata->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('admin_productitemfielddata_show', array('id' => $productitemfielddata->getId()))); } $deleteForm = $this->createDeleteForm($productitemfielddata->getId(), 'admin_productitemfielddata_delete'); return array( 'productitemfielddata' => $productitemfielddata, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function updateAction(ProductItemFieldData $productitemfielddata, Request $request) { $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata, array( 'action' => $this->generateUrl('admin_productitemfielddata_update', array('id' => $productitemfielddata->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('admin_productitemfielddata_show', array('id' => $productitemfielddata->getId()))); } $deleteForm = $this->createDeleteForm($productitemfielddata->getId(), 'admin_productitemfielddata_delete'); return array( 'productitemfielddata' => $productitemfielddata, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "updateAction", "(", "ProductItemFieldData", "$", "productitemfielddata", ",", "Request", "$", "request", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "\"amulen.shop.form.product.item.field.data\"", ")", ",", "$", "productitemfielddata", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_productitemfielddata_update'", ",", "array", "(", "'id'", "=>", "$", "productitemfielddata", "->", "getid", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "if", "(", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", "->", "isValid", "(", ")", ")", "{", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_productitemfielddata_show'", ",", "array", "(", "'id'", "=>", "$", "productitemfielddata", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "productitemfielddata", "->", "getId", "(", ")", ",", "'admin_productitemfielddata_delete'", ")", ";", "return", "array", "(", "'productitemfielddata'", "=>", "$", "productitemfielddata", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Edits an existing ProductItemFieldData entity. @Route("/{id}/update", name="admin_productitemfielddata_update", requirements={"id"="\d+"}) @Method("PUT") @Template("AmulenShopBundle:ProductItemFieldData:edit.html.twig")
[ "Edits", "an", "existing", "ProductItemFieldData", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php#L113-L131
240,497
oaugustus/direct-silex-provider
src/Direct/Router.php
Router.route
public function route() { $batch = array(); foreach ($this->request->getCalls() as $call) { $batch[] = $this->dispatch($call); } return $this->response->encode($batch); }
php
public function route() { $batch = array(); foreach ($this->request->getCalls() as $call) { $batch[] = $this->dispatch($call); } return $this->response->encode($batch); }
[ "public", "function", "route", "(", ")", "{", "$", "batch", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "request", "->", "getCalls", "(", ")", "as", "$", "call", ")", "{", "$", "batch", "[", "]", "=", "$", "this", "->", "dispatch", "(", "$", "call", ")", ";", "}", "return", "$", "this", "->", "response", "->", "encode", "(", "$", "batch", ")", ";", "}" ]
Do the ExtDirect routing processing. @return JSON
[ "Do", "the", "ExtDirect", "routing", "processing", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router.php#L56-L65
240,498
oaugustus/direct-silex-provider
src/Direct/Router.php
Router.dispatch
private function dispatch($call) { $path = $call->getAction(); $method = $call->getMethod(); $matches = preg_split('/(?=[A-Z])/',$path); $route = strtolower(implode('/', $matches)); $route .= "/".$method; $request = $this->app['request']; $files = $this->fixFiles($request->files->all()); // create the route request $routeRequest = Request::create($route, 'POST', $call->getData(), $request->cookies->all(), $files, $request->server->all()); if ('form' == $this->request->getCallType()) { $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST); $response = $call->getResponse($result); } else { try{ $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST); $response = $call->getResponse($result); }catch(\Exception $e){ $response = $call->getException($e); } } return $response; }
php
private function dispatch($call) { $path = $call->getAction(); $method = $call->getMethod(); $matches = preg_split('/(?=[A-Z])/',$path); $route = strtolower(implode('/', $matches)); $route .= "/".$method; $request = $this->app['request']; $files = $this->fixFiles($request->files->all()); // create the route request $routeRequest = Request::create($route, 'POST', $call->getData(), $request->cookies->all(), $files, $request->server->all()); if ('form' == $this->request->getCallType()) { $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST); $response = $call->getResponse($result); } else { try{ $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST); $response = $call->getResponse($result); }catch(\Exception $e){ $response = $call->getException($e); } } return $response; }
[ "private", "function", "dispatch", "(", "$", "call", ")", "{", "$", "path", "=", "$", "call", "->", "getAction", "(", ")", ";", "$", "method", "=", "$", "call", "->", "getMethod", "(", ")", ";", "$", "matches", "=", "preg_split", "(", "'/(?=[A-Z])/'", ",", "$", "path", ")", ";", "$", "route", "=", "strtolower", "(", "implode", "(", "'/'", ",", "$", "matches", ")", ")", ";", "$", "route", ".=", "\"/\"", ".", "$", "method", ";", "$", "request", "=", "$", "this", "->", "app", "[", "'request'", "]", ";", "$", "files", "=", "$", "this", "->", "fixFiles", "(", "$", "request", "->", "files", "->", "all", "(", ")", ")", ";", "// create the route request", "$", "routeRequest", "=", "Request", "::", "create", "(", "$", "route", ",", "'POST'", ",", "$", "call", "->", "getData", "(", ")", ",", "$", "request", "->", "cookies", "->", "all", "(", ")", ",", "$", "files", ",", "$", "request", "->", "server", "->", "all", "(", ")", ")", ";", "if", "(", "'form'", "==", "$", "this", "->", "request", "->", "getCallType", "(", ")", ")", "{", "$", "result", "=", "$", "this", "->", "app", "->", "handle", "(", "$", "routeRequest", ",", "HttpKernelInterface", "::", "SUB_REQUEST", ")", ";", "$", "response", "=", "$", "call", "->", "getResponse", "(", "$", "result", ")", ";", "}", "else", "{", "try", "{", "$", "result", "=", "$", "this", "->", "app", "->", "handle", "(", "$", "routeRequest", ",", "HttpKernelInterface", "::", "SUB_REQUEST", ")", ";", "$", "response", "=", "$", "call", "->", "getResponse", "(", "$", "result", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "response", "=", "$", "call", "->", "getException", "(", "$", "e", ")", ";", "}", "}", "return", "$", "response", ";", "}" ]
Dispatch a remote method call. @param \Direct\Router\Call $call @return Mixed
[ "Dispatch", "a", "remote", "method", "call", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router.php#L73-L105
240,499
bishopb/vanilla
library/core/class.session.php
Gdn_Session.CheckPermission
public function CheckPermission($Permission, $FullMatch = TRUE, $JunctionTable = '', $JunctionID = '') { if (is_object($this->User)) { if ($this->User->Banned || GetValue('Deleted', $this->User)) return FALSE; elseif ($this->User->Admin) return TRUE; } // Allow wildcard permission checks (e.g. 'any' Category) if ($JunctionID == 'any') $JunctionID = ''; $Permissions = $this->GetPermissions(); if ($JunctionTable && !C('Garden.Permissions.Disabled.'.$JunctionTable)) { // Junction permission ($Permissions[PermissionName] = array(JunctionIDs)) if (is_array($Permission)) { foreach ($Permission as $PermissionName) { if($this->CheckPermission($PermissionName, FALSE, $JunctionTable, $JunctionID)) { if(!$FullMatch) return TRUE; } else { if($FullMatch) return FALSE; } } return TRUE; } else { if ($JunctionID !== '') { $Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && in_array($JunctionID, $Permissions[$Permission]); } else { $Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && count($Permissions[$Permission]); } return $Result; } } else { // Non-junction permission ($Permissions = array(PermissionNames)) if (is_array($Permission)) { return ArrayInArray($Permission, $Permissions, $FullMatch); } else { return in_array($Permission, $Permissions) || array_key_exists($Permission, $Permissions); } } }
php
public function CheckPermission($Permission, $FullMatch = TRUE, $JunctionTable = '', $JunctionID = '') { if (is_object($this->User)) { if ($this->User->Banned || GetValue('Deleted', $this->User)) return FALSE; elseif ($this->User->Admin) return TRUE; } // Allow wildcard permission checks (e.g. 'any' Category) if ($JunctionID == 'any') $JunctionID = ''; $Permissions = $this->GetPermissions(); if ($JunctionTable && !C('Garden.Permissions.Disabled.'.$JunctionTable)) { // Junction permission ($Permissions[PermissionName] = array(JunctionIDs)) if (is_array($Permission)) { foreach ($Permission as $PermissionName) { if($this->CheckPermission($PermissionName, FALSE, $JunctionTable, $JunctionID)) { if(!$FullMatch) return TRUE; } else { if($FullMatch) return FALSE; } } return TRUE; } else { if ($JunctionID !== '') { $Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && in_array($JunctionID, $Permissions[$Permission]); } else { $Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && count($Permissions[$Permission]); } return $Result; } } else { // Non-junction permission ($Permissions = array(PermissionNames)) if (is_array($Permission)) { return ArrayInArray($Permission, $Permissions, $FullMatch); } else { return in_array($Permission, $Permissions) || array_key_exists($Permission, $Permissions); } } }
[ "public", "function", "CheckPermission", "(", "$", "Permission", ",", "$", "FullMatch", "=", "TRUE", ",", "$", "JunctionTable", "=", "''", ",", "$", "JunctionID", "=", "''", ")", "{", "if", "(", "is_object", "(", "$", "this", "->", "User", ")", ")", "{", "if", "(", "$", "this", "->", "User", "->", "Banned", "||", "GetValue", "(", "'Deleted'", ",", "$", "this", "->", "User", ")", ")", "return", "FALSE", ";", "elseif", "(", "$", "this", "->", "User", "->", "Admin", ")", "return", "TRUE", ";", "}", "// Allow wildcard permission checks (e.g. 'any' Category)", "if", "(", "$", "JunctionID", "==", "'any'", ")", "$", "JunctionID", "=", "''", ";", "$", "Permissions", "=", "$", "this", "->", "GetPermissions", "(", ")", ";", "if", "(", "$", "JunctionTable", "&&", "!", "C", "(", "'Garden.Permissions.Disabled.'", ".", "$", "JunctionTable", ")", ")", "{", "// Junction permission ($Permissions[PermissionName] = array(JunctionIDs))", "if", "(", "is_array", "(", "$", "Permission", ")", ")", "{", "foreach", "(", "$", "Permission", "as", "$", "PermissionName", ")", "{", "if", "(", "$", "this", "->", "CheckPermission", "(", "$", "PermissionName", ",", "FALSE", ",", "$", "JunctionTable", ",", "$", "JunctionID", ")", ")", "{", "if", "(", "!", "$", "FullMatch", ")", "return", "TRUE", ";", "}", "else", "{", "if", "(", "$", "FullMatch", ")", "return", "FALSE", ";", "}", "}", "return", "TRUE", ";", "}", "else", "{", "if", "(", "$", "JunctionID", "!==", "''", ")", "{", "$", "Result", "=", "array_key_exists", "(", "$", "Permission", ",", "$", "Permissions", ")", "&&", "is_array", "(", "$", "Permissions", "[", "$", "Permission", "]", ")", "&&", "in_array", "(", "$", "JunctionID", ",", "$", "Permissions", "[", "$", "Permission", "]", ")", ";", "}", "else", "{", "$", "Result", "=", "array_key_exists", "(", "$", "Permission", ",", "$", "Permissions", ")", "&&", "is_array", "(", "$", "Permissions", "[", "$", "Permission", "]", ")", "&&", "count", "(", "$", "Permissions", "[", "$", "Permission", "]", ")", ";", "}", "return", "$", "Result", ";", "}", "}", "else", "{", "// Non-junction permission ($Permissions = array(PermissionNames))", "if", "(", "is_array", "(", "$", "Permission", ")", ")", "{", "return", "ArrayInArray", "(", "$", "Permission", ",", "$", "Permissions", ",", "$", "FullMatch", ")", ";", "}", "else", "{", "return", "in_array", "(", "$", "Permission", ",", "$", "Permissions", ")", "||", "array_key_exists", "(", "$", "Permission", ",", "$", "Permissions", ")", ";", "}", "}", "}" ]
Checks the currently authenticated user's permissions for the specified permission. Returns a boolean value indicating if the action is permitted. @param mixed $Permission The permission (or array of permissions) to check. @param int $JunctionID The JunctionID associated with $Permission (ie. A discussion category identifier). @param bool $FullMatch If $Permission is an array, $FullMatch indicates if all permissions specified are required. If false, the user only needs one of the specified permissions. @param string $JunctionTable The name of the junction table for a junction permission. @param in $JunctionID The ID of the junction permission. * @return boolean
[ "Checks", "the", "currently", "authenticated", "user", "s", "permissions", "for", "the", "specified", "permission", ".", "Returns", "a", "boolean", "value", "indicating", "if", "the", "action", "is", "permitted", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.session.php#L91-L137