repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
francescogabbrielli/AwsSesWrapper | src/AwsSesWrapper.php | AwsSesWrapper.sendEmail | public function sendEmail($dest, $subject, $html, $text)
{
$mail = [
'Destination' => $this->buildDestination($dest),
//'FromArn' => '<string>',
'Message' => [ // REQUIRED
'Body' => [ // REQUIRED
'Html' => ['Charset' => $this->charset,'Data' => $html],
'Text' => ['Charset' => $this->charset,'Data' => $text],
],
'Subject' => ['Charset' => $this->charset,'Data' => $subject],
],
//'ReplyToAddresses' => [],
//'ReturnPath' => '',
//'ReturnPathArn' => '<string>',
'Source' => $this->from, // REQUIRED
//'SourceArn' => '<string>',
];
if ($this->tags)
$mail['Tags'] = $this->buildTags();
return $this->invokeMethod("sendEmail", $mail, true);
} | php | public function sendEmail($dest, $subject, $html, $text)
{
$mail = [
'Destination' => $this->buildDestination($dest),
//'FromArn' => '<string>',
'Message' => [ // REQUIRED
'Body' => [ // REQUIRED
'Html' => ['Charset' => $this->charset,'Data' => $html],
'Text' => ['Charset' => $this->charset,'Data' => $text],
],
'Subject' => ['Charset' => $this->charset,'Data' => $subject],
],
//'ReplyToAddresses' => [],
//'ReturnPath' => '',
//'ReturnPathArn' => '<string>',
'Source' => $this->from, // REQUIRED
//'SourceArn' => '<string>',
];
if ($this->tags)
$mail['Tags'] = $this->buildTags();
return $this->invokeMethod("sendEmail", $mail, true);
} | [
"public",
"function",
"sendEmail",
"(",
"$",
"dest",
",",
"$",
"subject",
",",
"$",
"html",
",",
"$",
"text",
")",
"{",
"$",
"mail",
"=",
"[",
"'Destination'",
"=>",
"$",
"this",
"->",
"buildDestination",
"(",
"$",
"dest",
")",
",",
"//'FromArn' => '<s... | Send simple formatted email. No attachments.
@param array $dest destinations as a simple array or associative in the form:
['to' => [email1, email2, ...], 'cc' => [ etc..], bcc => [etc...]]
@param string $subject email subject
@param string $html email in HTML format
@param string $text email in text format
@return mixed Aws\Result (or Promise for async version)
@throws AwsException | [
"Send",
"simple",
"formatted",
"email",
".",
"No",
"attachments",
"."
] | 9edba623ee73f75d786f94178758474968877e0f | https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L425-L449 | train |
francescogabbrielli/AwsSesWrapper | src/AwsSesWrapper.php | AwsSesWrapper.sendRawEmail | public function sendRawEmail($raw_data, $dest=[])
{
//force base64 encoding on v2 Api
if ($this->isVersion2() && base64_decode($raw_data, true)===false)
$raw_data = base64_encode($raw_data);
$mail = [
//'FromArn' => '<string>',
'Source' => $this->from, // REQUIRED
//'SourceArn' => '<string>',
'RawMessage' => ['Data' => $raw_data],
//'ReturnPathArn' => '<string>',
];
// override destinations
if ($dest)
$mail['Destinations'] = $dest;
if ($this->tags)
$mail['Tags'] = $this->buildTags();
return $this->invokeMethod("sendRawEmail", $mail, true);
} | php | public function sendRawEmail($raw_data, $dest=[])
{
//force base64 encoding on v2 Api
if ($this->isVersion2() && base64_decode($raw_data, true)===false)
$raw_data = base64_encode($raw_data);
$mail = [
//'FromArn' => '<string>',
'Source' => $this->from, // REQUIRED
//'SourceArn' => '<string>',
'RawMessage' => ['Data' => $raw_data],
//'ReturnPathArn' => '<string>',
];
// override destinations
if ($dest)
$mail['Destinations'] = $dest;
if ($this->tags)
$mail['Tags'] = $this->buildTags();
return $this->invokeMethod("sendRawEmail", $mail, true);
} | [
"public",
"function",
"sendRawEmail",
"(",
"$",
"raw_data",
",",
"$",
"dest",
"=",
"[",
"]",
")",
"{",
"//force base64 encoding on v2 Api\r",
"if",
"(",
"$",
"this",
"->",
"isVersion2",
"(",
")",
"&&",
"base64_decode",
"(",
"$",
"raw_data",
",",
"true",
")... | Send raw email. Beware of differences between Api v2 and v3
@param string $raw_data mail in raw format (string|resource|Psr\Http\Message\StreamInterface)
@param array $dest destinations in this format:
["To => [...], "Cc => [...], "Bcc" => [...]]
- Mandatory in v2!
- DO NOT SPECIFIY in v3 unless you want to override raw headers!
@return mixed Aws\Result (or Promise for async version)
@throws Aws\Exception | [
"Send",
"raw",
"email",
".",
"Beware",
"of",
"differences",
"between",
"Api",
"v2",
"and",
"v3"
] | 9edba623ee73f75d786f94178758474968877e0f | https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L462-L484 | train |
francescogabbrielli/AwsSesWrapper | src/AwsSesWrapper.php | AwsSesWrapper.buildDestination | private function buildDestination($emails)
{
$ret = ['ToAddresses' => isset($emails['to']) ? $emails['to'] : array_values($emails)];
if (isset($emails['cc']) && $emails['cc'])
$ret['CcAddresses'] = $emails['cc'];
if (isset($emails['bcc']) && $emails['cc'])
$ret['BccAddresses'] = $emails['bcc'];
return $ret;
} | php | private function buildDestination($emails)
{
$ret = ['ToAddresses' => isset($emails['to']) ? $emails['to'] : array_values($emails)];
if (isset($emails['cc']) && $emails['cc'])
$ret['CcAddresses'] = $emails['cc'];
if (isset($emails['bcc']) && $emails['cc'])
$ret['BccAddresses'] = $emails['bcc'];
return $ret;
} | [
"private",
"function",
"buildDestination",
"(",
"$",
"emails",
")",
"{",
"$",
"ret",
"=",
"[",
"'ToAddresses'",
"=>",
"isset",
"(",
"$",
"emails",
"[",
"'to'",
"]",
")",
"?",
"$",
"emails",
"[",
"'to'",
"]",
":",
"array_values",
"(",
"$",
"emails",
"... | Create an array mapped with 'ToAddesses', 'CcAddresses', 'BccAddresses'
@param array $emails destinations as a simple array or associative in the form:
['to' => [email1, email2, ...], 'cc' => [ etc..], bcc => [etc...]]
@return array destinations in AWS format | [
"Create",
"an",
"array",
"mapped",
"with",
"ToAddesses",
"CcAddresses",
"BccAddresses"
] | 9edba623ee73f75d786f94178758474968877e0f | https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L567-L575 | train |
francescogabbrielli/AwsSesWrapper | src/AwsSesWrapper.php | AwsSesWrapper.buildDestinations | private function buildDestinations($destinations)
{
$ret = array();
foreach ($destinations as $dest)
{
$d = [
"Destination" => $this->buildDestination($dest["dest"]),
"ReplacementTemplateData" => $this->buildReplacements($dest["data"])
];
if (isset($dest["tags"]) && $dest["tags"])
$d['ReplacementTags'] = $this->buildTags($dest["tags"]);
$ret[] = $d;
}
return $ret;
} | php | private function buildDestinations($destinations)
{
$ret = array();
foreach ($destinations as $dest)
{
$d = [
"Destination" => $this->buildDestination($dest["dest"]),
"ReplacementTemplateData" => $this->buildReplacements($dest["data"])
];
if (isset($dest["tags"]) && $dest["tags"])
$d['ReplacementTags'] = $this->buildTags($dest["tags"]);
$ret[] = $d;
}
return $ret;
} | [
"private",
"function",
"buildDestinations",
"(",
"$",
"destinations",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"destinations",
"as",
"$",
"dest",
")",
"{",
"$",
"d",
"=",
"[",
"\"Destination\"",
"=>",
"$",
"this",
"->",
... | Create an array of destinations for bulk mail send
@param array $destinations in the required format
<pre>
[
"dest" => destination emails (array ['to' => [...], 'cc' => [...], 'bcc' => [...]])
"data" => replacement data (array)
"tags" => tags (array [name1 => value1, ...])
],
...
</pre>
@return array | [
"Create",
"an",
"array",
"of",
"destinations",
"for",
"bulk",
"mail",
"send"
] | 9edba623ee73f75d786f94178758474968877e0f | https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L614-L628 | train |
dazarobbo/Cola | src/MString.php | MString.codeUnit | public function codeUnit(){
$result = \unpack('N', \mb_convert_encoding(
$this->_Value,
'UCS-4BE',
'UTF-8'));
if(\is_array($result)){
return $result[1];
}
return \ord($this->_Value);
//$code = 0;
//$l = \strlen($this->_Value);
//$byte = $l - 1;
//
//for($i = 0; $i < $l; ++$i, --$byte){
// $code += \ord($this->_Value[$i]) << $byte * 8;
//}
//
//return $code;
} | php | public function codeUnit(){
$result = \unpack('N', \mb_convert_encoding(
$this->_Value,
'UCS-4BE',
'UTF-8'));
if(\is_array($result)){
return $result[1];
}
return \ord($this->_Value);
//$code = 0;
//$l = \strlen($this->_Value);
//$byte = $l - 1;
//
//for($i = 0; $i < $l; ++$i, --$byte){
// $code += \ord($this->_Value[$i]) << $byte * 8;
//}
//
//return $code;
} | [
"public",
"function",
"codeUnit",
"(",
")",
"{",
"$",
"result",
"=",
"\\",
"unpack",
"(",
"'N'",
",",
"\\",
"mb_convert_encoding",
"(",
"$",
"this",
"->",
"_Value",
",",
"'UCS-4BE'",
",",
"'UTF-8'",
")",
")",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$... | Returns the UTF-8 code unit for the string.
This is only useful on single-character strings
@return int decimal value of the code unit | [
"Returns",
"the",
"UTF",
"-",
"8",
"code",
"unit",
"for",
"the",
"string",
".",
"This",
"is",
"only",
"useful",
"on",
"single",
"-",
"character",
"strings"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L60-L83 | train |
dazarobbo/Cola | src/MString.php | MString.compareTo | public function compareTo($obj) {
if(!($obj instanceof static)){
throw new \InvalidArgumentException('$obj is not a comparable instance');
}
$coll = new \Collator('');
return $coll->compare($this->_Value, $obj->_Value);
} | php | public function compareTo($obj) {
if(!($obj instanceof static)){
throw new \InvalidArgumentException('$obj is not a comparable instance');
}
$coll = new \Collator('');
return $coll->compare($this->_Value, $obj->_Value);
} | [
"public",
"function",
"compareTo",
"(",
"$",
"obj",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"obj",
"instanceof",
"static",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$obj is not a comparable instance'",
")",
";",
"}",
"$",
"coll",
... | Compares this string against a given string lexicographically
@param static $obj
@return int -1, 0, or 1 depending on order
@throws \InvalidArgumentException if comparable type is incomparable | [
"Compares",
"this",
"string",
"against",
"a",
"given",
"string",
"lexicographically"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L117-L127 | train |
dazarobbo/Cola | src/MString.php | MString.convertEncoding | public function convertEncoding($newEncoding){
if(!\is_string($newEncoding)){
throw new \InvalidArgumentException('$newEncoding must be a string');
}
$newEncoding = \strtoupper($newEncoding);
return new static(\mb_convert_encoding($this->_Value, $newEncoding, $this->_Encoding),
$newEncoding);
} | php | public function convertEncoding($newEncoding){
if(!\is_string($newEncoding)){
throw new \InvalidArgumentException('$newEncoding must be a string');
}
$newEncoding = \strtoupper($newEncoding);
return new static(\mb_convert_encoding($this->_Value, $newEncoding, $this->_Encoding),
$newEncoding);
} | [
"public",
"function",
"convertEncoding",
"(",
"$",
"newEncoding",
")",
"{",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"newEncoding",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$newEncoding must be a string'",
")",
";",
"}",
"$",... | Converts the string to a new encoding
@link https://php.net/manual/en/mbstring.supported-encodings.php
@param string $newEncoding
@return \static | [
"Converts",
"the",
"string",
"to",
"a",
"new",
"encoding"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L163-L174 | train |
dazarobbo/Cola | src/MString.php | MString.fromCodeUnit | public static function fromCodeUnit($unit){
if(!\is_numeric($unit)){
throw new \InvalidArgumentException('$unit must be a number');
}
$str = \mb_convert_encoding(
\sprintf('&#%s;', $unit),
static::ENCODING,
'HTML-ENTITIES');
return new static($str, static::ENCODING);
} | php | public static function fromCodeUnit($unit){
if(!\is_numeric($unit)){
throw new \InvalidArgumentException('$unit must be a number');
}
$str = \mb_convert_encoding(
\sprintf('&#%s;', $unit),
static::ENCODING,
'HTML-ENTITIES');
return new static($str, static::ENCODING);
} | [
"public",
"static",
"function",
"fromCodeUnit",
"(",
"$",
"unit",
")",
"{",
"if",
"(",
"!",
"\\",
"is_numeric",
"(",
"$",
"unit",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$unit must be a number'",
")",
";",
"}",
"$",
"str",
... | Converts a code unit to a unicode character in UTF-8 encoding
@param int $unit
@return \static | [
"Converts",
"a",
"code",
"unit",
"to",
"a",
"unicode",
"character",
"in",
"UTF",
"-",
"8",
"encoding"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L226-L239 | train |
dazarobbo/Cola | src/MString.php | MString.fromString | public static function fromString($str, $encoding = self::ENCODING){
if(!\is_string($str)){
throw new \InvalidArgumentException('$str must be a PHP string');
}
if(!\is_string($encoding)){
throw new \InvalidArgumentException('$encoding must be a string');
}
return new static($str, $encoding);
} | php | public static function fromString($str, $encoding = self::ENCODING){
if(!\is_string($str)){
throw new \InvalidArgumentException('$str must be a PHP string');
}
if(!\is_string($encoding)){
throw new \InvalidArgumentException('$encoding must be a string');
}
return new static($str, $encoding);
} | [
"public",
"static",
"function",
"fromString",
"(",
"$",
"str",
",",
"$",
"encoding",
"=",
"self",
"::",
"ENCODING",
")",
"{",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"str",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$s... | Create a String from a PHP string
@param string $str
@param string $encoding default is UTF-8
@return \static | [
"Create",
"a",
"String",
"from",
"a",
"PHP",
"string"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L247-L259 | train |
dazarobbo/Cola | src/MString.php | MString.indexOf | public function indexOf(self $str, $offset = 0, MStringComparison $cmp = null){
if(!$this->offsetExists($offset)){
throw new \OutOfRangeException('$offset is invalid');
}
if($cmp === null || $cmp->Value === MStringComparison::CASE_SENSITIVE){
$index = \mb_strpos($this->_Value, $str->_Value, $offset, $this->_Encoding);
}
else{
$index = \mb_stripos($this->_Value, $str->_Value, $offset, $this->_Encoding);
}
return $index !== false ? $index : static::NO_INDEX;
} | php | public function indexOf(self $str, $offset = 0, MStringComparison $cmp = null){
if(!$this->offsetExists($offset)){
throw new \OutOfRangeException('$offset is invalid');
}
if($cmp === null || $cmp->Value === MStringComparison::CASE_SENSITIVE){
$index = \mb_strpos($this->_Value, $str->_Value, $offset, $this->_Encoding);
}
else{
$index = \mb_stripos($this->_Value, $str->_Value, $offset, $this->_Encoding);
}
return $index !== false ? $index : static::NO_INDEX;
} | [
"public",
"function",
"indexOf",
"(",
"self",
"$",
"str",
",",
"$",
"offset",
"=",
"0",
",",
"MStringComparison",
"$",
"cmp",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
"new... | Returns the index of a given string in this string
@param self $str string to search for
@param type $offset where to start searching, default is 0
@param MStringComparison $cmp default is null, case sensitive
@return int -1 for no index found | [
"Returns",
"the",
"index",
"of",
"a",
"given",
"string",
"in",
"this",
"string"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L280-L295 | train |
dazarobbo/Cola | src/MString.php | MString.insert | public function insert($index, self $str){
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
return new static(
$this->substring(0, $index) .
$str->_Value .
$this->substring($index),
$this->_Encoding);
} | php | public function insert($index, self $str){
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
return new static(
$this->substring(0, $index) .
$str->_Value .
$this->substring($index),
$this->_Encoding);
} | [
"public",
"function",
"insert",
"(",
"$",
"index",
",",
"self",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
"'$index is invalid'",
")",
";"... | Returns a new string with a given string inserted at a given index
@param int $index
@param self $str
@return \static | [
"Returns",
"a",
"new",
"string",
"with",
"a",
"given",
"string",
"inserted",
"at",
"a",
"given",
"index"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L303-L315 | train |
dazarobbo/Cola | src/MString.php | MString.lastIndexOf | public function lastIndexOf(self $str, $offset = 0, MStringComparison $cmp = null){
if(!$this->offsetExists($offset)){
throw new \OutOfRangeException('$offset is invalid');
}
if($cmp === null || $cmp->Value === MStringComparison::CASE_SENSITIVE){
$index = \mb_strrpos($this->_Value, $str->_Value, $offset, $this->_Encoding);
}
else{
$index = \mb_strripos($this->_Value, $str->_Value, $offset, $this->_Encoding);
}
return $index !== false ? $index : static::NO_INDEX;
} | php | public function lastIndexOf(self $str, $offset = 0, MStringComparison $cmp = null){
if(!$this->offsetExists($offset)){
throw new \OutOfRangeException('$offset is invalid');
}
if($cmp === null || $cmp->Value === MStringComparison::CASE_SENSITIVE){
$index = \mb_strrpos($this->_Value, $str->_Value, $offset, $this->_Encoding);
}
else{
$index = \mb_strripos($this->_Value, $str->_Value, $offset, $this->_Encoding);
}
return $index !== false ? $index : static::NO_INDEX;
} | [
"public",
"function",
"lastIndexOf",
"(",
"self",
"$",
"str",
",",
"$",
"offset",
"=",
"0",
",",
"MStringComparison",
"$",
"cmp",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
... | Returns the last index of a given string
@param self $str
@param type $offset optional offset to start searching from, default is 0
@param MStringComparison $cmp optional comparison parameter, default is null for case sensitivity
@return int -1 if no match found | [
"Returns",
"the",
"last",
"index",
"of",
"a",
"given",
"string"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L373-L388 | train |
dazarobbo/Cola | src/MString.php | MString.lcfirst | public function lcfirst(){
if($this->isNullOrWhitespace()){
return clone $this;
}
else if($this->count() === 1){
return new static(\mb_strtolower($this->_Value, $this->_Encoding), $this->_Encoding);
}
$str = $this[0]->lcfirst() . $this->substring(1);
return new static($str, $this->_Encoding);
} | php | public function lcfirst(){
if($this->isNullOrWhitespace()){
return clone $this;
}
else if($this->count() === 1){
return new static(\mb_strtolower($this->_Value, $this->_Encoding), $this->_Encoding);
}
$str = $this[0]->lcfirst() . $this->substring(1);
return new static($str, $this->_Encoding);
} | [
"public",
"function",
"lcfirst",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNullOrWhitespace",
"(",
")",
")",
"{",
"return",
"clone",
"$",
"this",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"count",
"(",
")",
"===",
"1",
")",
"{",
"retu... | Returns a new string with the first character in lower case
@return \static | [
"Returns",
"a",
"new",
"string",
"with",
"the",
"first",
"character",
"in",
"lower",
"case"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L394-L407 | train |
dazarobbo/Cola | src/MString.php | MString.slowEquals | public function slowEquals(self $str){
$l1 = \strlen($this->_Value);
$l2 = \strlen($str->_Value);
$diff = $l1 ^ $l2;
for($i = 0; $i < $l1 && $i < $l2; ++$i){
$diff |= \ord($this->_Value[$i]) ^ \ord($str->_Encoding[$i]);
}
return $diff === 0;
} | php | public function slowEquals(self $str){
$l1 = \strlen($this->_Value);
$l2 = \strlen($str->_Value);
$diff = $l1 ^ $l2;
for($i = 0; $i < $l1 && $i < $l2; ++$i){
$diff |= \ord($this->_Value[$i]) ^ \ord($str->_Encoding[$i]);
}
return $diff === 0;
} | [
"public",
"function",
"slowEquals",
"(",
"self",
"$",
"str",
")",
"{",
"$",
"l1",
"=",
"\\",
"strlen",
"(",
"$",
"this",
"->",
"_Value",
")",
";",
"$",
"l2",
"=",
"\\",
"strlen",
"(",
"$",
"str",
"->",
"_Value",
")",
";",
"$",
"diff",
"=",
"$",... | Checks for string equality in constant time
@param self $str
@return bool | [
"Checks",
"for",
"string",
"equality",
"in",
"constant",
"time"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L503-L515 | train |
dazarobbo/Cola | src/MString.php | MString.substring | public function substring($start, $length = null){
if(!$this->offsetExists($start)){
throw new \OutOfRangeException('$start is an invalid index');
}
if($length !== null && !\is_numeric($length) || $length < 0){
throw new \InvalidArgumentException('$length is invalid');
}
return new static(\mb_substr($this->_Value, $start, $length, $this->_Encoding),
$this->_Encoding);
} | php | public function substring($start, $length = null){
if(!$this->offsetExists($start)){
throw new \OutOfRangeException('$start is an invalid index');
}
if($length !== null && !\is_numeric($length) || $length < 0){
throw new \InvalidArgumentException('$length is invalid');
}
return new static(\mb_substr($this->_Value, $start, $length, $this->_Encoding),
$this->_Encoding);
} | [
"public",
"function",
"substring",
"(",
"$",
"start",
",",
"$",
"length",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"start",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
"'$start is an invalid... | Returns a new string as a substring from the current one
@param int $start where to start extracting
@param int $length how many characters to extract
@return \static | [
"Returns",
"a",
"new",
"string",
"as",
"a",
"substring",
"from",
"the",
"current",
"one"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L523-L536 | train |
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 st... | 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 | train |
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 emp... | 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 | train |
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",
")",... | 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 | train |
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",
"->",
"_Enco... | 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 | train |
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",
"->",
"_... | 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 | train |
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",
"->",
... | 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 | train |
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",
")",
"{",
"retu... | 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 | train |
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",
"=",
"$... | 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 | train |
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",
"(",
"'_d... | 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 | train |
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",
"->",
"header... | 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 | train |
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",
"->",
"heade... | 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 | train |
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",
"::",
"getSuppo... | 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 | train |
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",
"(",
")",
"]",
")",
")",
"{",
... | 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 | train |
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",
"(",
")",
"]",
")",
")",
"{",
... | 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 | train |
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",
"(",
")",
";",
"$",
"suppor... | 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 | train |
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",
"$",
"th... | 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 | train |
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... | 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 | train |
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",
"(",
... | 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 | train |
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",
")",
";",
"retu... | 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 | train |
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'",
")"... | 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 | train |
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'",
")",
";",
"}",
"$",
"mainHa... | Loads frontend scripts | [
"Loads",
"frontend",
"scripts"
] | e31a46b0afa4126788f5754f928552ce13f8531f | https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L79-L94 | train |
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",
"=",
"$",
"t... | Loads frontend styles | [
"Loads",
"frontend",
"styles"
] | e31a46b0afa4126788f5754f928552ce13f8531f | https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L99-L112 | train |
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... | Loads customize page script | [
"Loads",
"customize",
"page",
"script"
] | e31a46b0afa4126788f5754f928552ce13f8531f | https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L149-L155 | train |
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_conten... | 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 | train |
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",
"... | 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 | train |
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",
"... | 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 | train |
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'",
"]",
")",
"?",
"$",
"dependenci... | 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 | train |
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... | 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 | train |
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",
"->",
"getThemeConfigD... | Retrieves the dependencies config
@return array | [
"Retrieves",
"the",
"dependencies",
"config"
] | e31a46b0afa4126788f5754f928552ce13f8531f | https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/Assets.php#L245-L257 | train |
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'",
";",
"}",
"... | 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 | train |
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",
"(... | Register a group of routes | [
"Register",
"a",
"group",
"of",
"routes"
] | 1b87b0b91c227752cc6d3e09cc02d9d2bb4bc7de | https://github.com/onesimus-systems/osrouter/blob/1b87b0b91c227752cc6d3e09cc02d9d2bb4bc7de/src/Router.php#L74-L103 | train |
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",
... | 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 | train |
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",
"->",
"loadViewsFro... | 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 | train |
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... | 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 | train |
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",
"=",
... | 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 | train |
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",
"=",
"$"... | 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 | train |
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 | train |
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 | train |
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 | train |
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'",
"... | Creates a line
@param array $settings = []
@return GD | [
"Creates",
"a",
"line"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L881-L902 | train |
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",
"$",
... | 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 | train |
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_'",
")",
")",
";",
"re... | 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 | train |
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",
"imageloa... | Set load font
@param string $file
@return int | [
"Set",
"load",
"font"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1093-L1101 | train |
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",
"(",
"$",
... | Get copy palette
@param resource $source
@return resource | [
"Get",
"copy",
"palette"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1110-L1118 | train |
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",
"(",
"$",
... | Protected create image canvas | [
"Protected",
"create",
"image",
"canvas"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1202-L1216 | train |
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... | Protected create empty canvas | [
"Protected",
"create",
"empty",
"canvas"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1221-L1243 | train |
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",
"->",
"w... | Protected align image watermark | [
"Protected",
"align",
"image",
"watermark"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1248-L1264 | train |
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",
"=",
"$",
"rg... | Protected Image Color | [
"Protected",
"Image",
"Color"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GD.php#L1303-L1313 | train |
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 | train |
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",
"->",
... | 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 | train |
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",
"->",
"pd... | 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 | train |
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",
")",
... | 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 | train |
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",
")",
... | 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 | train |
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",
")",
";",
... | 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 | train |
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",
")",
";",
"retu... | 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 | train |
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",
",",
"$",
"col... | 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 | train |
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 | train |
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 | train |
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 | train |
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",
"(",... | 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 | train |
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",
"(",
... | 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 | train |
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",
"::",
"$",
... | 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 | train |
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",
")",
";",
... | Formats the version.
@return string | [
"Formats",
"the",
"version",
"."
] | 2653209f2620e1d4a8baf17a0b5b74fd339abba3 | https://github.com/zicht/version/blob/2653209f2620e1d4a8baf17a0b5b74fd339abba3/src/Zicht/Version/Version.php#L270-L291 | train |
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",... | 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 | train |
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 c... | 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 | train |
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",
... | 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 | train |
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",
"[",
"$",
"... | 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 | train |
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"... | 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 | train |
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",
"->",... | 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 | train |
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_arr... | 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 | train |
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",
"[",
"]",
"... | 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 | train |
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"... | 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 | train |
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",
"->",
"loadMa... | 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 | train |
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_InvalidA... | 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 | train |
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",
")",... | 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 | train |
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'",
")",
";",
"}"... | 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 | train |
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",
"]",
... | 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 | train |
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'"... | 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",
"performance... | d59344fc204a74995224e3da39b9debd78fdb974 | https://github.com/osflab/controller/blob/d59344fc204a74995224e3da39b9debd78fdb974/Response/Callback.php#L35-L43 | train |
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",
"(",
"$... | 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 | train |
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... | 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 | train |
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",
")",
";... | 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 | train |
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'",
"... | 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 | train |
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",
... | 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 | train |
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"... | 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 | train |
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",
... | 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 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.