id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
900 | silverorange/Net_Notifier | Net/Notifier/WebSocket/Frame.php | Net_Notifier_WebSocket_Frame.getHeader | protected function getHeader()
{
$header = '';
$fin = $this->fin ? 0x80 : 0x00;
$rsv1 = $this->rsv1 ? 0x40 : 0x00;
$rsv2 = $this->rsv2 ? 0x20 : 0x00;
$rsv3 = $this->rsv3 ? 0x10 : 0x00;
$byte1 = $fin | $rsv1 | $rsv2 | $rsv3 | $this->opcode;
$mask = $this->isMasked ? 0x80 : 0x00;
$byte2 = $mask | $this->length;
$header .= pack('CC', $byte1, $byte2);
if ($this->length === 0x7e) {
$header .= pack('s', $this->length16);
}
if ($this->length === 0x7f) {
// TODO
}
if ($this->isMasked) {
$header .= $this->mask;
}
return $header;
} | php | protected function getHeader()
{
$header = '';
$fin = $this->fin ? 0x80 : 0x00;
$rsv1 = $this->rsv1 ? 0x40 : 0x00;
$rsv2 = $this->rsv2 ? 0x20 : 0x00;
$rsv3 = $this->rsv3 ? 0x10 : 0x00;
$byte1 = $fin | $rsv1 | $rsv2 | $rsv3 | $this->opcode;
$mask = $this->isMasked ? 0x80 : 0x00;
$byte2 = $mask | $this->length;
$header .= pack('CC', $byte1, $byte2);
if ($this->length === 0x7e) {
$header .= pack('s', $this->length16);
}
if ($this->length === 0x7f) {
// TODO
}
if ($this->isMasked) {
$header .= $this->mask;
}
return $header;
} | [
"protected",
"function",
"getHeader",
"(",
")",
"{",
"$",
"header",
"=",
"''",
";",
"$",
"fin",
"=",
"$",
"this",
"->",
"fin",
"?",
"0x80",
":",
"0x00",
";",
"$",
"rsv1",
"=",
"$",
"this",
"->",
"rsv1",
"?",
"0x40",
":",
"0x00",
";",
"$",
"rsv2",
"=",
"$",
"this",
"->",
"rsv2",
"?",
"0x20",
":",
"0x00",
";",
"$",
"rsv3",
"=",
"$",
"this",
"->",
"rsv3",
"?",
"0x10",
":",
"0x00",
";",
"$",
"byte1",
"=",
"$",
"fin",
"|",
"$",
"rsv1",
"|",
"$",
"rsv2",
"|",
"$",
"rsv3",
"|",
"$",
"this",
"->",
"opcode",
";",
"$",
"mask",
"=",
"$",
"this",
"->",
"isMasked",
"?",
"0x80",
":",
"0x00",
";",
"$",
"byte2",
"=",
"$",
"mask",
"|",
"$",
"this",
"->",
"length",
";",
"$",
"header",
".=",
"pack",
"(",
"'CC'",
",",
"$",
"byte1",
",",
"$",
"byte2",
")",
";",
"if",
"(",
"$",
"this",
"->",
"length",
"===",
"0x7e",
")",
"{",
"$",
"header",
".=",
"pack",
"(",
"'s'",
",",
"$",
"this",
"->",
"length16",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"length",
"===",
"0x7f",
")",
"{",
"// TODO",
"}",
"if",
"(",
"$",
"this",
"->",
"isMasked",
")",
"{",
"$",
"header",
".=",
"$",
"this",
"->",
"mask",
";",
"}",
"return",
"$",
"header",
";",
"}"
] | Gets this frame's header as a binary string
@return string this frame's header as a binary string.
@todo Support long lengths (length values larger than a 32-bit signed
integer.) | [
"Gets",
"this",
"frame",
"s",
"header",
"as",
"a",
"binary",
"string"
] | b446e27cd1bebd58ba89243cde1272c5d281d3fb | https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/WebSocket/Frame.php#L525-L556 |
901 | silverorange/Net_Notifier | Net/Notifier/WebSocket/Frame.php | Net_Notifier_WebSocket_Frame.getData | protected function getData()
{
$data = $this->unmaskedData;
if ($this->isMasked) {
$data = $this->mask($data);
}
return $data;
} | php | protected function getData()
{
$data = $this->unmaskedData;
if ($this->isMasked) {
$data = $this->mask($data);
}
return $data;
} | [
"protected",
"function",
"getData",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"unmaskedData",
";",
"if",
"(",
"$",
"this",
"->",
"isMasked",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"mask",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Gets the data portion of this frame as a binary string
If this frame is masked, the displayed data is masked.
@return string the data portion of this frame as a binary string. | [
"Gets",
"the",
"data",
"portion",
"of",
"this",
"frame",
"as",
"a",
"binary",
"string"
] | b446e27cd1bebd58ba89243cde1272c5d281d3fb | https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/WebSocket/Frame.php#L568-L577 |
902 | silverorange/Net_Notifier | Net/Notifier/WebSocket/Frame.php | Net_Notifier_WebSocket_Frame.parseData | protected function parseData($data)
{
$length = mb_strlen($data, '8bit');
if ($this->cursor + $length > $this->getLength() + $this->headerLength) {
$dataLength = $this->getLength()
- $this->cursor
+ $this->headerLength;
} else {
$dataLength = $length;
}
$data = mb_substr($data, 0, $dataLength, '8bit');
$leftover = mb_substr($data, $length, $length - $dataLength, '8bit');
$this->data .= $data;
if ($this->isMasked()) {
$this->unmaskedData .= $this->mask($data);
} else {
$this->unmaskedData .= $data;
}
$this->cursor += mb_strlen($data, '8bit');
return $leftover;
} | php | protected function parseData($data)
{
$length = mb_strlen($data, '8bit');
if ($this->cursor + $length > $this->getLength() + $this->headerLength) {
$dataLength = $this->getLength()
- $this->cursor
+ $this->headerLength;
} else {
$dataLength = $length;
}
$data = mb_substr($data, 0, $dataLength, '8bit');
$leftover = mb_substr($data, $length, $length - $dataLength, '8bit');
$this->data .= $data;
if ($this->isMasked()) {
$this->unmaskedData .= $this->mask($data);
} else {
$this->unmaskedData .= $data;
}
$this->cursor += mb_strlen($data, '8bit');
return $leftover;
} | [
"protected",
"function",
"parseData",
"(",
"$",
"data",
")",
"{",
"$",
"length",
"=",
"mb_strlen",
"(",
"$",
"data",
",",
"'8bit'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cursor",
"+",
"$",
"length",
">",
"$",
"this",
"->",
"getLength",
"(",
")",
"+",
"$",
"this",
"->",
"headerLength",
")",
"{",
"$",
"dataLength",
"=",
"$",
"this",
"->",
"getLength",
"(",
")",
"-",
"$",
"this",
"->",
"cursor",
"+",
"$",
"this",
"->",
"headerLength",
";",
"}",
"else",
"{",
"$",
"dataLength",
"=",
"$",
"length",
";",
"}",
"$",
"data",
"=",
"mb_substr",
"(",
"$",
"data",
",",
"0",
",",
"$",
"dataLength",
",",
"'8bit'",
")",
";",
"$",
"leftover",
"=",
"mb_substr",
"(",
"$",
"data",
",",
"$",
"length",
",",
"$",
"length",
"-",
"$",
"dataLength",
",",
"'8bit'",
")",
";",
"$",
"this",
"->",
"data",
".=",
"$",
"data",
";",
"if",
"(",
"$",
"this",
"->",
"isMasked",
"(",
")",
")",
"{",
"$",
"this",
"->",
"unmaskedData",
".=",
"$",
"this",
"->",
"mask",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"unmaskedData",
".=",
"$",
"data",
";",
"}",
"$",
"this",
"->",
"cursor",
"+=",
"mb_strlen",
"(",
"$",
"data",
",",
"'8bit'",
")",
";",
"return",
"$",
"leftover",
";",
"}"
] | Parses the data payload of this frame from a raw data stream
If this frame is masked, the data is unmasked as it is parsed according
to RFC 6455 section 5.3.
@param string $data the raw data.
@return string any remaining unparsed data not belonging to this frame. | [
"Parses",
"the",
"data",
"payload",
"of",
"this",
"frame",
"from",
"a",
"raw",
"data",
"stream"
] | b446e27cd1bebd58ba89243cde1272c5d281d3fb | https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/WebSocket/Frame.php#L592-L616 |
903 | silverorange/Net_Notifier | Net/Notifier/WebSocket/Frame.php | Net_Notifier_WebSocket_Frame.mask | protected function mask($data)
{
$out = '';
$length = mb_strlen($data, '8bit');
$j = ($this->cursor - $this->headerLength) % 4;
for ($i = 0; $i < $length; $i++) {
$data_octet = $this->getChar($data, $i);
$mask_octet = $this->getChar($this->mask, $j);
$out .= pack('C', ($data_octet ^ $mask_octet));
$j++;
if ($j >= 4) {
$j = 0;
}
}
return $out;
} | php | protected function mask($data)
{
$out = '';
$length = mb_strlen($data, '8bit');
$j = ($this->cursor - $this->headerLength) % 4;
for ($i = 0; $i < $length; $i++) {
$data_octet = $this->getChar($data, $i);
$mask_octet = $this->getChar($this->mask, $j);
$out .= pack('C', ($data_octet ^ $mask_octet));
$j++;
if ($j >= 4) {
$j = 0;
}
}
return $out;
} | [
"protected",
"function",
"mask",
"(",
"$",
"data",
")",
"{",
"$",
"out",
"=",
"''",
";",
"$",
"length",
"=",
"mb_strlen",
"(",
"$",
"data",
",",
"'8bit'",
")",
";",
"$",
"j",
"=",
"(",
"$",
"this",
"->",
"cursor",
"-",
"$",
"this",
"->",
"headerLength",
")",
"%",
"4",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"data_octet",
"=",
"$",
"this",
"->",
"getChar",
"(",
"$",
"data",
",",
"$",
"i",
")",
";",
"$",
"mask_octet",
"=",
"$",
"this",
"->",
"getChar",
"(",
"$",
"this",
"->",
"mask",
",",
"$",
"j",
")",
";",
"$",
"out",
".=",
"pack",
"(",
"'C'",
",",
"(",
"$",
"data_octet",
"^",
"$",
"mask_octet",
")",
")",
";",
"$",
"j",
"++",
";",
"if",
"(",
"$",
"j",
">=",
"4",
")",
"{",
"$",
"j",
"=",
"0",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] | Masks data according the the algorithm described in RFC 6455 Section 5.3
@param string $data a binary string containing the data to mask.
@return string a binary string containing the the masked data. | [
"Masks",
"data",
"according",
"the",
"the",
"algorithm",
"described",
"in",
"RFC",
"6455",
"Section",
"5",
".",
"3"
] | b446e27cd1bebd58ba89243cde1272c5d281d3fb | https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/WebSocket/Frame.php#L740-L757 |
904 | romeOz/rock-date | src/DateTime.php | DateTime.setLocale | public function setLocale($locale)
{
if ($locale instanceof Locale) {
$this->locale = $locale;
return $this;
}
$this->locale = strtolower($locale);
return $this;
} | php | public function setLocale($locale)
{
if ($locale instanceof Locale) {
$this->locale = $locale;
return $this;
}
$this->locale = strtolower($locale);
return $this;
} | [
"public",
"function",
"setLocale",
"(",
"$",
"locale",
")",
"{",
"if",
"(",
"$",
"locale",
"instanceof",
"Locale",
")",
"{",
"$",
"this",
"->",
"locale",
"=",
"$",
"locale",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"locale",
"=",
"strtolower",
"(",
"$",
"locale",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a locale.
@param Locale|string $locale
@return $this | [
"Sets",
"a",
"locale",
"."
] | 31d67a8a56e3308f688dab036541e977c318f088 | https://github.com/romeOz/rock-date/blob/31d67a8a56e3308f688dab036541e977c318f088/src/DateTime.php#L105-L113 |
905 | romeOz/rock-date | src/DateTime.php | DateTime.getLocale | public function getLocale()
{
if ($this->locale instanceof Locale) {
return $this->locale;
}
if (!isset($this->locales[$this->locale])) {
$this->locale = 'en';
}
// lazy loading
if (isset(static::$localeInstances[$this->locale])) {
return static::$localeInstances[$this->locale];
}
return static::$localeInstances[$this->locale] = new $this->locales[$this->locale];
} | php | public function getLocale()
{
if ($this->locale instanceof Locale) {
return $this->locale;
}
if (!isset($this->locales[$this->locale])) {
$this->locale = 'en';
}
// lazy loading
if (isset(static::$localeInstances[$this->locale])) {
return static::$localeInstances[$this->locale];
}
return static::$localeInstances[$this->locale] = new $this->locales[$this->locale];
} | [
"public",
"function",
"getLocale",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locale",
"instanceof",
"Locale",
")",
"{",
"return",
"$",
"this",
"->",
"locale",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"locales",
"[",
"$",
"this",
"->",
"locale",
"]",
")",
")",
"{",
"$",
"this",
"->",
"locale",
"=",
"'en'",
";",
"}",
"// lazy loading",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"localeInstances",
"[",
"$",
"this",
"->",
"locale",
"]",
")",
")",
"{",
"return",
"static",
"::",
"$",
"localeInstances",
"[",
"$",
"this",
"->",
"locale",
"]",
";",
"}",
"return",
"static",
"::",
"$",
"localeInstances",
"[",
"$",
"this",
"->",
"locale",
"]",
"=",
"new",
"$",
"this",
"->",
"locales",
"[",
"$",
"this",
"->",
"locale",
"]",
";",
"}"
] | Returns a locale instance.
@return Locale | [
"Returns",
"a",
"locale",
"instance",
"."
] | 31d67a8a56e3308f688dab036541e977c318f088 | https://github.com/romeOz/rock-date/blob/31d67a8a56e3308f688dab036541e977c318f088/src/DateTime.php#L122-L135 |
906 | romeOz/rock-date | src/DateTime.php | DateTime.getFormat | public function getFormat($name)
{
if (isset($this->formats[$name])) {
return $this->formats[$name];
}
return null;
} | php | public function getFormat($name)
{
if (isset($this->formats[$name])) {
return $this->formats[$name];
}
return null;
} | [
"public",
"function",
"getFormat",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"formats",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"formats",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns a format by name.
@param $name string
@return string|null | [
"Returns",
"a",
"format",
"by",
"name",
"."
] | 31d67a8a56e3308f688dab036541e977c318f088 | https://github.com/romeOz/rock-date/blob/31d67a8a56e3308f688dab036541e977c318f088/src/DateTime.php#L185-L192 |
907 | romeOz/rock-date | src/DateTime.php | DateTime.setFormatOptions | public function setFormatOptions(array $options)
{
foreach ($options as $name => $handler) {
$this->setFormatOption($name, $handler);
}
return $this;
} | php | public function setFormatOptions(array $options)
{
foreach ($options as $name => $handler) {
$this->setFormatOption($name, $handler);
}
return $this;
} | [
"public",
"function",
"setFormatOptions",
"(",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"name",
"=>",
"$",
"handler",
")",
"{",
"$",
"this",
"->",
"setFormatOption",
"(",
"$",
"name",
",",
"$",
"handler",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a format options.
@param array $options
@return $this | [
"Adds",
"a",
"format",
"options",
"."
] | 31d67a8a56e3308f688dab036541e977c318f088 | https://github.com/romeOz/rock-date/blob/31d67a8a56e3308f688dab036541e977c318f088/src/DateTime.php#L208-L214 |
908 | romeOz/rock-date | src/DateTime.php | DateTime.setFormatOption | public function setFormatOption($name, callable $handler)
{
if (in_array($name, static::$formatOptionsNames)) {
return $this;
}
static::$formatOptionsNames[] = $name;
static::$formatOptionsPlaceholders[] = '~' . count(static::$formatOptionsPlaceholders) . '~';
static::$formatOptionsHandlers[] = $handler;
return $this;
} | php | public function setFormatOption($name, callable $handler)
{
if (in_array($name, static::$formatOptionsNames)) {
return $this;
}
static::$formatOptionsNames[] = $name;
static::$formatOptionsPlaceholders[] = '~' . count(static::$formatOptionsPlaceholders) . '~';
static::$formatOptionsHandlers[] = $handler;
return $this;
} | [
"public",
"function",
"setFormatOption",
"(",
"$",
"name",
",",
"callable",
"$",
"handler",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"static",
"::",
"$",
"formatOptionsNames",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"static",
"::",
"$",
"formatOptionsNames",
"[",
"]",
"=",
"$",
"name",
";",
"static",
"::",
"$",
"formatOptionsPlaceholders",
"[",
"]",
"=",
"'~'",
".",
"count",
"(",
"static",
"::",
"$",
"formatOptionsPlaceholders",
")",
".",
"'~'",
";",
"static",
"::",
"$",
"formatOptionsHandlers",
"[",
"]",
"=",
"$",
"handler",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a format option.
@param string $name name of option.
@param callable $handler
@return $this
@throws DateException | [
"Adds",
"a",
"format",
"option",
"."
] | 31d67a8a56e3308f688dab036541e977c318f088 | https://github.com/romeOz/rock-date/blob/31d67a8a56e3308f688dab036541e977c318f088/src/DateTime.php#L227-L236 |
909 | romeOz/rock-date | src/DateTime.php | DateTime.format | public function format($format = null)
{
if (empty($format)) {
$format = $this->defaultFormat;
}
return $this->formatDatetimeObject($format);
} | php | public function format($format = null)
{
if (empty($format)) {
$format = $this->defaultFormat;
}
return $this->formatDatetimeObject($format);
} | [
"public",
"function",
"format",
"(",
"$",
"format",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"format",
")",
")",
"{",
"$",
"format",
"=",
"$",
"this",
"->",
"defaultFormat",
";",
"}",
"return",
"$",
"this",
"->",
"formatDatetimeObject",
"(",
"$",
"format",
")",
";",
"}"
] | Returns formatting date.
@param string|null $format http://php.net/date format or format name. Default value is current
@return string | [
"Returns",
"formatting",
"date",
"."
] | 31d67a8a56e3308f688dab036541e977c318f088 | https://github.com/romeOz/rock-date/blob/31d67a8a56e3308f688dab036541e977c318f088/src/DateTime.php#L244-L250 |
910 | romeOz/rock-date | src/DateTime.php | DateTime.is | public static function is($date)
{
if (is_bool($date) || empty($date) xor ($date === 0 || $date === '0')) {
return false;
}
$date = static::isTimestamp($date) ? '@' . (string)$date : $date;
return (bool)date_create($date);
} | php | public static function is($date)
{
if (is_bool($date) || empty($date) xor ($date === 0 || $date === '0')) {
return false;
}
$date = static::isTimestamp($date) ? '@' . (string)$date : $date;
return (bool)date_create($date);
} | [
"public",
"static",
"function",
"is",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"date",
")",
"||",
"empty",
"(",
"$",
"date",
")",
"xor",
"(",
"$",
"date",
"===",
"0",
"||",
"$",
"date",
"===",
"'0'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"date",
"=",
"static",
"::",
"isTimestamp",
"(",
"$",
"date",
")",
"?",
"'@'",
".",
"(",
"string",
")",
"$",
"date",
":",
"$",
"date",
";",
"return",
"(",
"bool",
")",
"date_create",
"(",
"$",
"date",
")",
";",
"}"
] | Validate is date.
@param string|int $date
@return bool | [
"Validate",
"is",
"date",
"."
] | 31d67a8a56e3308f688dab036541e977c318f088 | https://github.com/romeOz/rock-date/blob/31d67a8a56e3308f688dab036541e977c318f088/src/DateTime.php#L355-L362 |
911 | romeOz/rock-date | src/DateTime.php | DateTime.isTimestamp | public static function isTimestamp($timestamp)
{
if (is_bool($timestamp) || !is_scalar($timestamp)) {
return false;
}
return ((string)(int)$timestamp === (string)$timestamp)
&& ($timestamp <= PHP_INT_MAX)
&& ($timestamp >= ~PHP_INT_MAX);
} | php | public static function isTimestamp($timestamp)
{
if (is_bool($timestamp) || !is_scalar($timestamp)) {
return false;
}
return ((string)(int)$timestamp === (string)$timestamp)
&& ($timestamp <= PHP_INT_MAX)
&& ($timestamp >= ~PHP_INT_MAX);
} | [
"public",
"static",
"function",
"isTimestamp",
"(",
"$",
"timestamp",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"timestamp",
")",
"||",
"!",
"is_scalar",
"(",
"$",
"timestamp",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"(",
"string",
")",
"(",
"int",
")",
"$",
"timestamp",
"===",
"(",
"string",
")",
"$",
"timestamp",
")",
"&&",
"(",
"$",
"timestamp",
"<=",
"PHP_INT_MAX",
")",
"&&",
"(",
"$",
"timestamp",
">=",
"~",
"PHP_INT_MAX",
")",
";",
"}"
] | Validate is timestamp.
@param string|int $timestamp
@return bool | [
"Validate",
"is",
"timestamp",
"."
] | 31d67a8a56e3308f688dab036541e977c318f088 | https://github.com/romeOz/rock-date/blob/31d67a8a56e3308f688dab036541e977c318f088/src/DateTime.php#L370-L378 |
912 | Jelle-S/bitmaskgenerator | src/BitMaskGenerator.php | BitMaskGenerator.generateNextMask | protected function generateNextMask() {
if (is_null($this->mask)) {
$this->generateFirstMask();
return TRUE;
}
if (!$this->generateNextPermutation()) {
return $this->addPositive();
}
return TRUE;
} | php | protected function generateNextMask() {
if (is_null($this->mask)) {
$this->generateFirstMask();
return TRUE;
}
if (!$this->generateNextPermutation()) {
return $this->addPositive();
}
return TRUE;
} | [
"protected",
"function",
"generateNextMask",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"mask",
")",
")",
"{",
"$",
"this",
"->",
"generateFirstMask",
"(",
")",
";",
"return",
"TRUE",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"generateNextPermutation",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"addPositive",
"(",
")",
";",
"}",
"return",
"TRUE",
";",
"}"
] | Generates the next mask.
@return boolean
TRUE on success, FALSE on failure (= there is no next mask left to be
generated). | [
"Generates",
"the",
"next",
"mask",
"."
] | 5389e12ac5159ff90d5fb76d12995585c392e7c0 | https://github.com/Jelle-S/bitmaskgenerator/blob/5389e12ac5159ff90d5fb76d12995585c392e7c0/src/BitMaskGenerator.php#L74-L83 |
913 | Jelle-S/bitmaskgenerator | src/BitMaskGenerator.php | BitMaskGenerator.generateNextPermutation | protected function generateNextPermutation() {
$number = implode('', $this->mask);
$result = LexographicalPermutation::getNextPermutation($number);
if ($result !== FALSE) {
$this->mask = str_split($result);
}
return $result !== FALSE;
} | php | protected function generateNextPermutation() {
$number = implode('', $this->mask);
$result = LexographicalPermutation::getNextPermutation($number);
if ($result !== FALSE) {
$this->mask = str_split($result);
}
return $result !== FALSE;
} | [
"protected",
"function",
"generateNextPermutation",
"(",
")",
"{",
"$",
"number",
"=",
"implode",
"(",
"''",
",",
"$",
"this",
"->",
"mask",
")",
";",
"$",
"result",
"=",
"LexographicalPermutation",
"::",
"getNextPermutation",
"(",
"$",
"number",
")",
";",
"if",
"(",
"$",
"result",
"!==",
"FALSE",
")",
"{",
"$",
"this",
"->",
"mask",
"=",
"str_split",
"(",
"$",
"result",
")",
";",
"}",
"return",
"$",
"result",
"!==",
"FALSE",
";",
"}"
] | Generates the next permutation of the current mask.
@return boolean
TRUE on success, FALSE on failure (= there is no next permutation of the
current mask). | [
"Generates",
"the",
"next",
"permutation",
"of",
"the",
"current",
"mask",
"."
] | 5389e12ac5159ff90d5fb76d12995585c392e7c0 | https://github.com/Jelle-S/bitmaskgenerator/blob/5389e12ac5159ff90d5fb76d12995585c392e7c0/src/BitMaskGenerator.php#L92-L99 |
914 | Jelle-S/bitmaskgenerator | src/BitMaskGenerator.php | BitMaskGenerator.generateFirstMask | protected function generateFirstMask() {
$this->mask = array_fill(0, $this->length, 0);
for ($i = 0; $i < $this->positivesAmount; $i++) {
$this->mask[$this->length - $i - 1] = 1;
}
} | php | protected function generateFirstMask() {
$this->mask = array_fill(0, $this->length, 0);
for ($i = 0; $i < $this->positivesAmount; $i++) {
$this->mask[$this->length - $i - 1] = 1;
}
} | [
"protected",
"function",
"generateFirstMask",
"(",
")",
"{",
"$",
"this",
"->",
"mask",
"=",
"array_fill",
"(",
"0",
",",
"$",
"this",
"->",
"length",
",",
"0",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"positivesAmount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"mask",
"[",
"$",
"this",
"->",
"length",
"-",
"$",
"i",
"-",
"1",
"]",
"=",
"1",
";",
"}",
"}"
] | Generates the very first mask. | [
"Generates",
"the",
"very",
"first",
"mask",
"."
] | 5389e12ac5159ff90d5fb76d12995585c392e7c0 | https://github.com/Jelle-S/bitmaskgenerator/blob/5389e12ac5159ff90d5fb76d12995585c392e7c0/src/BitMaskGenerator.php#L104-L109 |
915 | Jelle-S/bitmaskgenerator | src/BitMaskGenerator.php | BitMaskGenerator.addPositive | protected function addPositive() {
if ($this->positivesAmount >= $this->length) {
return FALSE;
}
$this->positivesAmount++;
$this->generateFirstMask();
return TRUE;
} | php | protected function addPositive() {
if ($this->positivesAmount >= $this->length) {
return FALSE;
}
$this->positivesAmount++;
$this->generateFirstMask();
return TRUE;
} | [
"protected",
"function",
"addPositive",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"positivesAmount",
">=",
"$",
"this",
"->",
"length",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"this",
"->",
"positivesAmount",
"++",
";",
"$",
"this",
"->",
"generateFirstMask",
"(",
")",
";",
"return",
"TRUE",
";",
"}"
] | Adds a positive marker to the mask.
@return boolean
TRUE on success, FALSE on failure (= all markers are already positive). | [
"Adds",
"a",
"positive",
"marker",
"to",
"the",
"mask",
"."
] | 5389e12ac5159ff90d5fb76d12995585c392e7c0 | https://github.com/Jelle-S/bitmaskgenerator/blob/5389e12ac5159ff90d5fb76d12995585c392e7c0/src/BitMaskGenerator.php#L117-L124 |
916 | vspvt/kohana-helpers | classes/Kohana/Helpers/Arr.php | Kohana_Helpers_Arr.inArray | public static function inArray($needle, $haystack, $strict = NULL)
{
return static::is_array($haystack) && in_array($needle, $haystack, $strict);
} | php | public static function inArray($needle, $haystack, $strict = NULL)
{
return static::is_array($haystack) && in_array($needle, $haystack, $strict);
} | [
"public",
"static",
"function",
"inArray",
"(",
"$",
"needle",
",",
"$",
"haystack",
",",
"$",
"strict",
"=",
"NULL",
")",
"{",
"return",
"static",
"::",
"is_array",
"(",
"$",
"haystack",
")",
"&&",
"in_array",
"(",
"$",
"needle",
",",
"$",
"haystack",
",",
"$",
"strict",
")",
";",
"}"
] | Checks if a value exists in an array
@param mixed $needle The searched value
@param mixed $haystack The array
@param bool $strict [optional]
@return bool true if needle is found in the array, false otherwise. | [
"Checks",
"if",
"a",
"value",
"exists",
"in",
"an",
"array"
] | 891c8f4e4efa09c97230162a2842d8ebf3105932 | https://github.com/vspvt/kohana-helpers/blob/891c8f4e4efa09c97230162a2842d8ebf3105932/classes/Kohana/Helpers/Arr.php#L20-L23 |
917 | pokap/pool-dbm | src/Pok/PoolDBM/Persisters/ModelBuilder.php | ModelBuilder.loaderModels | public function loaderModels(ClassMetadata $class, $manager, array $ids, \Closure $stacker)
{
$classOfManagerName = $class->getFieldMapping($manager);
$pool = $this->manager->getPool();
$methodFind = $classOfManagerName->getRepositoryMethod();
$repository = $pool->getManager($manager)->getRepository($classOfManagerName->getName());
if ($methodFind && method_exists($repository, $methodFind)) {
foreach ($repository->$methodFind($ids) as $object) {
$id = $class->getIdentifierValue($object);
$stacker($id, $object);
}
} else {
trigger_error(sprintf('findOneBy in ModelPersister::loadAll context is depreciate. Define repository-method for "%s" manager model, see mapping for "%s".', $manager, $class->getName()), E_USER_DEPRECATED);
$repository = $pool->getManager($manager)->getRepository($classOfManagerName->getName());
$field = $class->getIdentifierReference($manager)->field;
foreach ($ids as $id) {
$object = $repository->findOneBy(array($field => $id));
if (!$object) {
continue;
}
$id = $class->getIdentifierValue($object, $manager);
$stacker($id, $object);
}
}
} | php | public function loaderModels(ClassMetadata $class, $manager, array $ids, \Closure $stacker)
{
$classOfManagerName = $class->getFieldMapping($manager);
$pool = $this->manager->getPool();
$methodFind = $classOfManagerName->getRepositoryMethod();
$repository = $pool->getManager($manager)->getRepository($classOfManagerName->getName());
if ($methodFind && method_exists($repository, $methodFind)) {
foreach ($repository->$methodFind($ids) as $object) {
$id = $class->getIdentifierValue($object);
$stacker($id, $object);
}
} else {
trigger_error(sprintf('findOneBy in ModelPersister::loadAll context is depreciate. Define repository-method for "%s" manager model, see mapping for "%s".', $manager, $class->getName()), E_USER_DEPRECATED);
$repository = $pool->getManager($manager)->getRepository($classOfManagerName->getName());
$field = $class->getIdentifierReference($manager)->field;
foreach ($ids as $id) {
$object = $repository->findOneBy(array($field => $id));
if (!$object) {
continue;
}
$id = $class->getIdentifierValue($object, $manager);
$stacker($id, $object);
}
}
} | [
"public",
"function",
"loaderModels",
"(",
"ClassMetadata",
"$",
"class",
",",
"$",
"manager",
",",
"array",
"$",
"ids",
",",
"\\",
"Closure",
"$",
"stacker",
")",
"{",
"$",
"classOfManagerName",
"=",
"$",
"class",
"->",
"getFieldMapping",
"(",
"$",
"manager",
")",
";",
"$",
"pool",
"=",
"$",
"this",
"->",
"manager",
"->",
"getPool",
"(",
")",
";",
"$",
"methodFind",
"=",
"$",
"classOfManagerName",
"->",
"getRepositoryMethod",
"(",
")",
";",
"$",
"repository",
"=",
"$",
"pool",
"->",
"getManager",
"(",
"$",
"manager",
")",
"->",
"getRepository",
"(",
"$",
"classOfManagerName",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"methodFind",
"&&",
"method_exists",
"(",
"$",
"repository",
",",
"$",
"methodFind",
")",
")",
"{",
"foreach",
"(",
"$",
"repository",
"->",
"$",
"methodFind",
"(",
"$",
"ids",
")",
"as",
"$",
"object",
")",
"{",
"$",
"id",
"=",
"$",
"class",
"->",
"getIdentifierValue",
"(",
"$",
"object",
")",
";",
"$",
"stacker",
"(",
"$",
"id",
",",
"$",
"object",
")",
";",
"}",
"}",
"else",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'findOneBy in ModelPersister::loadAll context is depreciate. Define repository-method for \"%s\" manager model, see mapping for \"%s\".'",
",",
"$",
"manager",
",",
"$",
"class",
"->",
"getName",
"(",
")",
")",
",",
"E_USER_DEPRECATED",
")",
";",
"$",
"repository",
"=",
"$",
"pool",
"->",
"getManager",
"(",
"$",
"manager",
")",
"->",
"getRepository",
"(",
"$",
"classOfManagerName",
"->",
"getName",
"(",
")",
")",
";",
"$",
"field",
"=",
"$",
"class",
"->",
"getIdentifierReference",
"(",
"$",
"manager",
")",
"->",
"field",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"$",
"object",
"=",
"$",
"repository",
"->",
"findOneBy",
"(",
"array",
"(",
"$",
"field",
"=>",
"$",
"id",
")",
")",
";",
"if",
"(",
"!",
"$",
"object",
")",
"{",
"continue",
";",
"}",
"$",
"id",
"=",
"$",
"class",
"->",
"getIdentifierValue",
"(",
"$",
"object",
",",
"$",
"manager",
")",
";",
"$",
"stacker",
"(",
"$",
"id",
",",
"$",
"object",
")",
";",
"}",
"}",
"}"
] | Performed research on the model via their repository.
@param ClassMetadata $class
@param string $manager
@param array $ids
@param callable $stacker | [
"Performed",
"research",
"on",
"the",
"model",
"via",
"their",
"repository",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/Persisters/ModelBuilder.php#L118-L151 |
918 | pokap/pool-dbm | src/Pok/PoolDBM/Persisters/ModelBuilder.php | ModelBuilder.getManagersPerCollection | protected function getManagersPerCollection(array $referenceModels, array $fields = array())
{
$this->collections->clean();
if (empty($fields)) {
return;
}
foreach ($this->class->getAssociationDefinitions() as $assoc) {
$compatible = $assoc->getCompatible();
if (!empty($compatible) && !in_array($this->class->getManagerIdentifier(), $compatible)) {
continue;
}
foreach ($referenceModels as $referenceModel) {
$property = $assoc->getReferenceField($this->class->getManagerIdentifier());
if (!in_array($property, $fields)) {
continue;
}
/** @var null|object|ArrayCollection $coll */
$coll = call_user_func(array($referenceModel, 'get' . ucfirst($property)));
if (null === $coll || $assoc->isMany() && $coll->isEmpty()) {
continue;
}
$this->collections->append(new CollectionCenter($assoc, $this->manager->getClassMetadata($assoc->getTargetMultiModel()), $coll, $this->class->getIdentifierValue($referenceModel)));
}
}
} | php | protected function getManagersPerCollection(array $referenceModels, array $fields = array())
{
$this->collections->clean();
if (empty($fields)) {
return;
}
foreach ($this->class->getAssociationDefinitions() as $assoc) {
$compatible = $assoc->getCompatible();
if (!empty($compatible) && !in_array($this->class->getManagerIdentifier(), $compatible)) {
continue;
}
foreach ($referenceModels as $referenceModel) {
$property = $assoc->getReferenceField($this->class->getManagerIdentifier());
if (!in_array($property, $fields)) {
continue;
}
/** @var null|object|ArrayCollection $coll */
$coll = call_user_func(array($referenceModel, 'get' . ucfirst($property)));
if (null === $coll || $assoc->isMany() && $coll->isEmpty()) {
continue;
}
$this->collections->append(new CollectionCenter($assoc, $this->manager->getClassMetadata($assoc->getTargetMultiModel()), $coll, $this->class->getIdentifierValue($referenceModel)));
}
}
} | [
"protected",
"function",
"getManagersPerCollection",
"(",
"array",
"$",
"referenceModels",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"collections",
"->",
"clean",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"class",
"->",
"getAssociationDefinitions",
"(",
")",
"as",
"$",
"assoc",
")",
"{",
"$",
"compatible",
"=",
"$",
"assoc",
"->",
"getCompatible",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"compatible",
")",
"&&",
"!",
"in_array",
"(",
"$",
"this",
"->",
"class",
"->",
"getManagerIdentifier",
"(",
")",
",",
"$",
"compatible",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"referenceModels",
"as",
"$",
"referenceModel",
")",
"{",
"$",
"property",
"=",
"$",
"assoc",
"->",
"getReferenceField",
"(",
"$",
"this",
"->",
"class",
"->",
"getManagerIdentifier",
"(",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"property",
",",
"$",
"fields",
")",
")",
"{",
"continue",
";",
"}",
"/** @var null|object|ArrayCollection $coll */",
"$",
"coll",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"referenceModel",
",",
"'get'",
".",
"ucfirst",
"(",
"$",
"property",
")",
")",
")",
";",
"if",
"(",
"null",
"===",
"$",
"coll",
"||",
"$",
"assoc",
"->",
"isMany",
"(",
")",
"&&",
"$",
"coll",
"->",
"isEmpty",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"collections",
"->",
"append",
"(",
"new",
"CollectionCenter",
"(",
"$",
"assoc",
",",
"$",
"this",
"->",
"manager",
"->",
"getClassMetadata",
"(",
"$",
"assoc",
"->",
"getTargetMultiModel",
"(",
")",
")",
",",
"$",
"coll",
",",
"$",
"this",
"->",
"class",
"->",
"getIdentifierValue",
"(",
"$",
"referenceModel",
")",
")",
")",
";",
"}",
"}",
"}"
] | Returns list of collection.
@param array $referenceModels
@param array $fields List of fields prime (optional)
@return void | [
"Returns",
"list",
"of",
"collection",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/Persisters/ModelBuilder.php#L191-L223 |
919 | salernolabs/collapser | src/Media.php | Media.handleCharacter34 | protected function handleCharacter34()
{
//Unescaped double quote
if (!$this->inSingleQuotes && $this->lastCharacter != 92) {
$this->inQuotes = !$this->inQuotes;
}
return true;
} | php | protected function handleCharacter34()
{
//Unescaped double quote
if (!$this->inSingleQuotes && $this->lastCharacter != 92) {
$this->inQuotes = !$this->inQuotes;
}
return true;
} | [
"protected",
"function",
"handleCharacter34",
"(",
")",
"{",
"//Unescaped double quote",
"if",
"(",
"!",
"$",
"this",
"->",
"inSingleQuotes",
"&&",
"$",
"this",
"->",
"lastCharacter",
"!=",
"92",
")",
"{",
"$",
"this",
"->",
"inQuotes",
"=",
"!",
"$",
"this",
"->",
"inQuotes",
";",
"}",
"return",
"true",
";",
"}"
] | Handle unescaped double quotes
@return boolean | [
"Handle",
"unescaped",
"double",
"quotes"
] | fbf1ced832bafb4ffba7dd30b2d48e52e64a4e7c | https://github.com/salernolabs/collapser/blob/fbf1ced832bafb4ffba7dd30b2d48e52e64a4e7c/src/Media.php#L303-L311 |
920 | salernolabs/collapser | src/Media.php | Media.handleCharacter39 | protected function handleCharacter39()
{
if (!$this->inQuotes && $this->lastCharacter != 92) {
$this->inSingleQuotes = !$this->inSingleQuotes;
}
return true;
} | php | protected function handleCharacter39()
{
if (!$this->inQuotes && $this->lastCharacter != 92) {
$this->inSingleQuotes = !$this->inSingleQuotes;
}
return true;
} | [
"protected",
"function",
"handleCharacter39",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"inQuotes",
"&&",
"$",
"this",
"->",
"lastCharacter",
"!=",
"92",
")",
"{",
"$",
"this",
"->",
"inSingleQuotes",
"=",
"!",
"$",
"this",
"->",
"inSingleQuotes",
";",
"}",
"return",
"true",
";",
"}"
] | Handle unescaped single quotes
@return boolean | [
"Handle",
"unescaped",
"single",
"quotes"
] | fbf1ced832bafb4ffba7dd30b2d48e52e64a4e7c | https://github.com/salernolabs/collapser/blob/fbf1ced832bafb4ffba7dd30b2d48e52e64a4e7c/src/Media.php#L318-L325 |
921 | SugiPHP/Config | src/Config.php | Config.get | public function get($key, $default = null)
{
if (empty($key)) {
return $default;
}
$parts = explode(".", $key);
$file = array_shift($parts);
if (!isset($this->registry[$file])) {
$this->registry[$file] = $this->discover($file);
}
$res = $this->parse($key);
return is_null($res) ? $default : $res;
} | php | public function get($key, $default = null)
{
if (empty($key)) {
return $default;
}
$parts = explode(".", $key);
$file = array_shift($parts);
if (!isset($this->registry[$file])) {
$this->registry[$file] = $this->discover($file);
}
$res = $this->parse($key);
return is_null($res) ? $default : $res;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"key",
")",
";",
"$",
"file",
"=",
"array_shift",
"(",
"$",
"parts",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"file",
"]",
")",
")",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"file",
"]",
"=",
"$",
"this",
"->",
"discover",
"(",
"$",
"file",
")",
";",
"}",
"$",
"res",
"=",
"$",
"this",
"->",
"parse",
"(",
"$",
"key",
")",
";",
"return",
"is_null",
"(",
"$",
"res",
")",
"?",
"$",
"default",
":",
"$",
"res",
";",
"}"
] | Returns loaded config option. If the key is not found it checks if registered loaders can
find the key.
@param string $key
@param mixed $default - the value to be returned if the $key is not found
@return mixed | [
"Returns",
"loaded",
"config",
"option",
".",
"If",
"the",
"key",
"is",
"not",
"found",
"it",
"checks",
"if",
"registered",
"loaders",
"can",
"find",
"the",
"key",
"."
] | e5ff6f64d2a649ed9445ad773091f0c21935d7ea | https://github.com/SugiPHP/Config/blob/e5ff6f64d2a649ed9445ad773091f0c21935d7ea/src/Config.php#L49-L64 |
922 | SugiPHP/Config | src/Config.php | Config.set | public function set($key, $value)
{
if (empty($key)) {
throw new Exception("Key must be set");
}
$parts = array_reverse(explode(".", $key));
$file = array_pop($parts);
// we'll try to load a configuration file (if exists)
if (!isset($this->registry[$file])) {
$this->registry[$file] = $this->discover($file);
}
foreach ($parts as $part) {
$value = array($part => $value);
}
if (is_array($this->registry[$file]) && (is_array($value))) {
$this->registry[$file] = array_replace_recursive($this->registry[$file], $value);
} else {
$this->registry[$file] = $value;
}
} | php | public function set($key, $value)
{
if (empty($key)) {
throw new Exception("Key must be set");
}
$parts = array_reverse(explode(".", $key));
$file = array_pop($parts);
// we'll try to load a configuration file (if exists)
if (!isset($this->registry[$file])) {
$this->registry[$file] = $this->discover($file);
}
foreach ($parts as $part) {
$value = array($part => $value);
}
if (is_array($this->registry[$file]) && (is_array($value))) {
$this->registry[$file] = array_replace_recursive($this->registry[$file], $value);
} else {
$this->registry[$file] = $value;
}
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Key must be set\"",
")",
";",
"}",
"$",
"parts",
"=",
"array_reverse",
"(",
"explode",
"(",
"\".\"",
",",
"$",
"key",
")",
")",
";",
"$",
"file",
"=",
"array_pop",
"(",
"$",
"parts",
")",
";",
"// we'll try to load a configuration file (if exists)",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"file",
"]",
")",
")",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"file",
"]",
"=",
"$",
"this",
"->",
"discover",
"(",
"$",
"file",
")",
";",
"}",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"$",
"value",
"=",
"array",
"(",
"$",
"part",
"=>",
"$",
"value",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"file",
"]",
")",
"&&",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
")",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"file",
"]",
"=",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"file",
"]",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"file",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Registers a config variable
@param string $key
@param mixed $value
@return void | [
"Registers",
"a",
"config",
"variable"
] | e5ff6f64d2a649ed9445ad773091f0c21935d7ea | https://github.com/SugiPHP/Config/blob/e5ff6f64d2a649ed9445ad773091f0c21935d7ea/src/Config.php#L74-L97 |
923 | SugiPHP/Config | src/Config.php | Config.discover | protected function discover($resource)
{
foreach ($this->loaders as $loader) {
$res = $loader->load($resource);
if (!is_null($res)) {
return $res;
}
}
} | php | protected function discover($resource)
{
foreach ($this->loaders as $loader) {
$res = $loader->load($resource);
if (!is_null($res)) {
return $res;
}
}
} | [
"protected",
"function",
"discover",
"(",
"$",
"resource",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loaders",
"as",
"$",
"loader",
")",
"{",
"$",
"res",
"=",
"$",
"loader",
"->",
"load",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"res",
")",
")",
"{",
"return",
"$",
"res",
";",
"}",
"}",
"}"
] | Tries to find needed resource by looping each of registered loaders.
@param string $resource
@return array|null Returns null if resource is not found | [
"Tries",
"to",
"find",
"needed",
"resource",
"by",
"looping",
"each",
"of",
"registered",
"loaders",
"."
] | e5ff6f64d2a649ed9445ad773091f0c21935d7ea | https://github.com/SugiPHP/Config/blob/e5ff6f64d2a649ed9445ad773091f0c21935d7ea/src/Config.php#L106-L114 |
924 | SugiPHP/Config | src/Config.php | Config.parse | protected function parse($key)
{
$values = $this->registry;
$parts = explode(".", $key);
foreach ($parts as $part) {
if ($part === "") {
return $values;
}
if (!is_array($values) || !array_key_exists($part, $values)) {
return ;
}
$values = $values[$part];
}
return $values;
} | php | protected function parse($key)
{
$values = $this->registry;
$parts = explode(".", $key);
foreach ($parts as $part) {
if ($part === "") {
return $values;
}
if (!is_array($values) || !array_key_exists($part, $values)) {
return ;
}
$values = $values[$part];
}
return $values;
} | [
"protected",
"function",
"parse",
"(",
"$",
"key",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"registry",
";",
"$",
"parts",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"$",
"part",
"===",
"\"\"",
")",
"{",
"return",
"$",
"values",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"values",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"part",
",",
"$",
"values",
")",
")",
"{",
"return",
";",
"}",
"$",
"values",
"=",
"$",
"values",
"[",
"$",
"part",
"]",
";",
"}",
"return",
"$",
"values",
";",
"}"
] | Search for a key with dot notation in the array. If the key is not found NULL is returned
@param string $key
@return mixed|null Returns NULL if the key is not found. | [
"Search",
"for",
"a",
"key",
"with",
"dot",
"notation",
"in",
"the",
"array",
".",
"If",
"the",
"key",
"is",
"not",
"found",
"NULL",
"is",
"returned"
] | e5ff6f64d2a649ed9445ad773091f0c21935d7ea | https://github.com/SugiPHP/Config/blob/e5ff6f64d2a649ed9445ad773091f0c21935d7ea/src/Config.php#L123-L138 |
925 | kevindierkx/elicit | src/Elicit/Builder.php | Builder.first | public function first()
{
$path = $this->model->getPath('show');
$this->query->from($path);
return $this->get()->first();
} | php | public function first()
{
$path = $this->model->getPath('show');
$this->query->from($path);
return $this->get()->first();
} | [
"public",
"function",
"first",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"model",
"->",
"getPath",
"(",
"'show'",
")",
";",
"$",
"this",
"->",
"query",
"->",
"from",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
"->",
"get",
"(",
")",
"->",
"first",
"(",
")",
";",
"}"
] | Execute a "show" on the API and get the first result.
@return Model|static|null | [
"Execute",
"a",
"show",
"on",
"the",
"API",
"and",
"get",
"the",
"first",
"result",
"."
] | c277942f5f5f63b175bc37e9d392faa946888f65 | https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Elicit/Builder.php#L76-L83 |
926 | kevindierkx/elicit | src/Elicit/Builder.php | Builder.get | public function get()
{
$hasFrom = ! is_null($this->query->from);
// When no from has been specified at this point the developer
// tries to do a basic where query. In this case we want to use the index
// path, since the index path is supposed to return collections.
if (! $hasFrom) {
$path = $this->model->getPath('index');
$this->query->from($path);
}
$models = $this->getModels();
return $this->model->newCollection($models);
} | php | public function get()
{
$hasFrom = ! is_null($this->query->from);
// When no from has been specified at this point the developer
// tries to do a basic where query. In this case we want to use the index
// path, since the index path is supposed to return collections.
if (! $hasFrom) {
$path = $this->model->getPath('index');
$this->query->from($path);
}
$models = $this->getModels();
return $this->model->newCollection($models);
} | [
"public",
"function",
"get",
"(",
")",
"{",
"$",
"hasFrom",
"=",
"!",
"is_null",
"(",
"$",
"this",
"->",
"query",
"->",
"from",
")",
";",
"// When no from has been specified at this point the developer",
"// tries to do a basic where query. In this case we want to use the index",
"// path, since the index path is supposed to return collections.",
"if",
"(",
"!",
"$",
"hasFrom",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"model",
"->",
"getPath",
"(",
"'index'",
")",
";",
"$",
"this",
"->",
"query",
"->",
"from",
"(",
"$",
"path",
")",
";",
"}",
"$",
"models",
"=",
"$",
"this",
"->",
"getModels",
"(",
")",
";",
"return",
"$",
"this",
"->",
"model",
"->",
"newCollection",
"(",
"$",
"models",
")",
";",
"}"
] | Execute an "index" on the API.
@return Collection|static | [
"Execute",
"an",
"index",
"on",
"the",
"API",
"."
] | c277942f5f5f63b175bc37e9d392faa946888f65 | https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Elicit/Builder.php#L105-L120 |
927 | kevindierkx/elicit | src/Elicit/Builder.php | Builder.getModels | public function getModels()
{
// First, we will simply get the raw results from the query builders which we
// can use to populate an array with Eloquent models. We will pass columns
// that should be selected as well, which are typically just everything.
$results = $this->query->get();
$connection = $this->model->getConnectionName();
$models = [];
// Once we have the results, we can spin through them and instantiate a fresh
// model instance for each records we retrieved from the database. We will
// also set the proper connection name for the model after we create it.
foreach ($results as $result) {
$models[] = $model = $this->model->newFromBuilder($result);
$model->setConnection($connection);
}
return $models;
} | php | public function getModels()
{
// First, we will simply get the raw results from the query builders which we
// can use to populate an array with Eloquent models. We will pass columns
// that should be selected as well, which are typically just everything.
$results = $this->query->get();
$connection = $this->model->getConnectionName();
$models = [];
// Once we have the results, we can spin through them and instantiate a fresh
// model instance for each records we retrieved from the database. We will
// also set the proper connection name for the model after we create it.
foreach ($results as $result) {
$models[] = $model = $this->model->newFromBuilder($result);
$model->setConnection($connection);
}
return $models;
} | [
"public",
"function",
"getModels",
"(",
")",
"{",
"// First, we will simply get the raw results from the query builders which we",
"// can use to populate an array with Eloquent models. We will pass columns",
"// that should be selected as well, which are typically just everything.",
"$",
"results",
"=",
"$",
"this",
"->",
"query",
"->",
"get",
"(",
")",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"model",
"->",
"getConnectionName",
"(",
")",
";",
"$",
"models",
"=",
"[",
"]",
";",
"// Once we have the results, we can spin through them and instantiate a fresh",
"// model instance for each records we retrieved from the database. We will",
"// also set the proper connection name for the model after we create it.",
"foreach",
"(",
"$",
"results",
"as",
"$",
"result",
")",
"{",
"$",
"models",
"[",
"]",
"=",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
"->",
"newFromBuilder",
"(",
"$",
"result",
")",
";",
"$",
"model",
"->",
"setConnection",
"(",
"$",
"connection",
")",
";",
"}",
"return",
"$",
"models",
";",
"}"
] | Get the hydrated models.
@return Model | [
"Get",
"the",
"hydrated",
"models",
"."
] | c277942f5f5f63b175bc37e9d392faa946888f65 | https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Elicit/Builder.php#L140-L161 |
928 | detailnet/dfw-varcrypt | src/Detail/VarCrypt/MultiEncryptor.php | MultiEncryptor.applyVariables | public function applyVariables($groups, $separator = '_')
{
if (!is_array($groups)) {
$groups = array($groups);
}
foreach ($groups as $group) {
$values = $this->getVariables($group);
$this->setEnvironmentVariables($values, $group, $separator);
}
} | php | public function applyVariables($groups, $separator = '_')
{
if (!is_array($groups)) {
$groups = array($groups);
}
foreach ($groups as $group) {
$values = $this->getVariables($group);
$this->setEnvironmentVariables($values, $group, $separator);
}
} | [
"public",
"function",
"applyVariables",
"(",
"$",
"groups",
",",
"$",
"separator",
"=",
"'_'",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"groups",
")",
")",
"{",
"$",
"groups",
"=",
"array",
"(",
"$",
"groups",
")",
";",
"}",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getVariables",
"(",
"$",
"group",
")",
";",
"$",
"this",
"->",
"setEnvironmentVariables",
"(",
"$",
"values",
",",
"$",
"group",
",",
"$",
"separator",
")",
";",
"}",
"}"
] | Apply group's values as individual, plain environment variables.
The group name prefixes the variable name (joined by the separator).
@param array|string $groups
@param string $separator | [
"Apply",
"group",
"s",
"values",
"as",
"individual",
"plain",
"environment",
"variables",
"."
] | 0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb | https://github.com/detailnet/dfw-varcrypt/blob/0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb/src/Detail/VarCrypt/MultiEncryptor.php#L24-L35 |
929 | detailnet/dfw-varcrypt | src/Detail/VarCrypt/MultiEncryptor.php | MultiEncryptor.getVariables | public function getVariables($group)
{
$encodedValues = $this->getEnvironmentVariable($group);
if ($encodedValues === null) {
return null;
}
return $this->decode($encodedValues);
} | php | public function getVariables($group)
{
$encodedValues = $this->getEnvironmentVariable($group);
if ($encodedValues === null) {
return null;
}
return $this->decode($encodedValues);
} | [
"public",
"function",
"getVariables",
"(",
"$",
"group",
")",
"{",
"$",
"encodedValues",
"=",
"$",
"this",
"->",
"getEnvironmentVariable",
"(",
"$",
"group",
")",
";",
"if",
"(",
"$",
"encodedValues",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"decode",
"(",
"$",
"encodedValues",
")",
";",
"}"
] | Decode and decrypt values from a previously set environment variable.
@param string $group
@return array | [
"Decode",
"and",
"decrypt",
"values",
"from",
"a",
"previously",
"set",
"environment",
"variable",
"."
] | 0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb | https://github.com/detailnet/dfw-varcrypt/blob/0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb/src/Detail/VarCrypt/MultiEncryptor.php#L54-L63 |
930 | detailnet/dfw-varcrypt | src/Detail/VarCrypt/MultiEncryptor.php | MultiEncryptor.getVariable | public function getVariable($group, $name)
{
$variables = $this->getVariables($group);
return array_key_exists($name, $variables) ? $variables[$name] : null;
} | php | public function getVariable($group, $name)
{
$variables = $this->getVariables($group);
return array_key_exists($name, $variables) ? $variables[$name] : null;
} | [
"public",
"function",
"getVariable",
"(",
"$",
"group",
",",
"$",
"name",
")",
"{",
"$",
"variables",
"=",
"$",
"this",
"->",
"getVariables",
"(",
"$",
"group",
")",
";",
"return",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"variables",
")",
"?",
"$",
"variables",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] | Decode and decrypt a single value from a previously set environment variable.
@param string $group
@param string $name
@return mixed|null | [
"Decode",
"and",
"decrypt",
"a",
"single",
"value",
"from",
"a",
"previously",
"set",
"environment",
"variable",
"."
] | 0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb | https://github.com/detailnet/dfw-varcrypt/blob/0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb/src/Detail/VarCrypt/MultiEncryptor.php#L72-L77 |
931 | detailnet/dfw-varcrypt | src/Detail/VarCrypt/MultiEncryptor.php | MultiEncryptor.encode | public function encode($values)
{
$json = json_encode($values);
$this->handleJsonError('Failed to encode group values to JSON');
return parent::encode($json);
} | php | public function encode($values)
{
$json = json_encode($values);
$this->handleJsonError('Failed to encode group values to JSON');
return parent::encode($json);
} | [
"public",
"function",
"encode",
"(",
"$",
"values",
")",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"values",
")",
";",
"$",
"this",
"->",
"handleJsonError",
"(",
"'Failed to encode group values to JSON'",
")",
";",
"return",
"parent",
"::",
"encode",
"(",
"$",
"json",
")",
";",
"}"
] | Encrypt and encode group values.
@param array $values
@return string | [
"Encrypt",
"and",
"encode",
"group",
"values",
"."
] | 0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb | https://github.com/detailnet/dfw-varcrypt/blob/0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb/src/Detail/VarCrypt/MultiEncryptor.php#L85-L92 |
932 | detailnet/dfw-varcrypt | src/Detail/VarCrypt/MultiEncryptor.php | MultiEncryptor.decode | public function decode($value)
{
$json = parent::decode($value);
$values = json_decode($json, true);
$this->handleJsonError('Failed to decode group values from JSON');
return $values;
} | php | public function decode($value)
{
$json = parent::decode($value);
$values = json_decode($json, true);
$this->handleJsonError('Failed to decode group values from JSON');
return $values;
} | [
"public",
"function",
"decode",
"(",
"$",
"value",
")",
"{",
"$",
"json",
"=",
"parent",
"::",
"decode",
"(",
"$",
"value",
")",
";",
"$",
"values",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"$",
"this",
"->",
"handleJsonError",
"(",
"'Failed to decode group values from JSON'",
")",
";",
"return",
"$",
"values",
";",
"}"
] | Decode and decrypt group values.
@param string $value
@return array | [
"Decode",
"and",
"decrypt",
"group",
"values",
"."
] | 0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb | https://github.com/detailnet/dfw-varcrypt/blob/0e9edc1933f10f000b5d29e9c8ef0c6d8cc2f2bb/src/Detail/VarCrypt/MultiEncryptor.php#L100-L109 |
933 | mizmoz/router | src/Parser/Result.php | Result.addStack | public function addStack(StackInterface $stack): ResultInterface
{
$this->stack->addStack($stack, false);
return $this;
} | php | public function addStack(StackInterface $stack): ResultInterface
{
$this->stack->addStack($stack, false);
return $this;
} | [
"public",
"function",
"addStack",
"(",
"StackInterface",
"$",
"stack",
")",
":",
"ResultInterface",
"{",
"$",
"this",
"->",
"stack",
"->",
"addStack",
"(",
"$",
"stack",
",",
"false",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add items to the stack
@param StackInterface $stack
@return ResultInterface | [
"Add",
"items",
"to",
"the",
"stack"
] | 5269bc7e24c539a7f72a9ad308f15d6d10b575e4 | https://github.com/mizmoz/router/blob/5269bc7e24c539a7f72a9ad308f15d6d10b575e4/src/Parser/Result.php#L55-L59 |
934 | xinc-develop/xinc-core | src/Plugin/ModificationSet/BaseTask.php | BaseTask.process | final public function process(BuildInterface $build)
{
$result = $this->checkModified($build);
$this->frame->addResult($result);
} | php | final public function process(BuildInterface $build)
{
$result = $this->checkModified($build);
$this->frame->addResult($result);
} | [
"final",
"public",
"function",
"process",
"(",
"BuildInterface",
"$",
"build",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"checkModified",
"(",
"$",
"build",
")",
";",
"$",
"this",
"->",
"frame",
"->",
"addResult",
"(",
"$",
"result",
")",
";",
"}"
] | abstract process of a modification set.
@param Xinc_Build_Interface $build The running build | [
"abstract",
"process",
"of",
"a",
"modification",
"set",
"."
] | 4bb69a6afe19e1186950a3122cbfe0989823e0d6 | https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Plugin/ModificationSet/BaseTask.php#L49-L53 |
935 | xinc-develop/xinc-core | src/Plugin/ModificationSet/BaseTask.php | BaseTask.validate | public function validate(&$msg = null)
{
if ($this->frame instanceof ModificationSetInterface) {
return true;
}
throw new MalformedConfigException($this->getName().
' must be inside of a "modificationset".');
} | php | public function validate(&$msg = null)
{
if ($this->frame instanceof ModificationSetInterface) {
return true;
}
throw new MalformedConfigException($this->getName().
' must be inside of a "modificationset".');
} | [
"public",
"function",
"validate",
"(",
"&",
"$",
"msg",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"frame",
"instanceof",
"ModificationSetInterface",
")",
"{",
"return",
"true",
";",
"}",
"throw",
"new",
"MalformedConfigException",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"' must be inside of a \"modificationset\".'",
")",
";",
"}"
] | Check necessary variables are set.
@throws Xinc::Core::Exception::MalformedConfigException | [
"Check",
"necessary",
"variables",
"are",
"set",
"."
] | 4bb69a6afe19e1186950a3122cbfe0989823e0d6 | https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Plugin/ModificationSet/BaseTask.php#L77-L84 |
936 | nirix/radium | src/Helpers/Time.php | Time.date | public static function date($format = "Y-m-d H:i:s", $time = null)
{
$time = ($time !== null ? $time : time());
if (!is_numeric($time)) {
$time = static::toUnix($time);
}
return date($format, $time);
} | php | public static function date($format = "Y-m-d H:i:s", $time = null)
{
$time = ($time !== null ? $time : time());
if (!is_numeric($time)) {
$time = static::toUnix($time);
}
return date($format, $time);
} | [
"public",
"static",
"function",
"date",
"(",
"$",
"format",
"=",
"\"Y-m-d H:i:s\"",
",",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"time",
"=",
"(",
"$",
"time",
"!==",
"null",
"?",
"$",
"time",
":",
"time",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"time",
")",
")",
"{",
"$",
"time",
"=",
"static",
"::",
"toUnix",
"(",
"$",
"time",
")",
";",
"}",
"return",
"date",
"(",
"$",
"format",
",",
"$",
"time",
")",
";",
"}"
] | Formats the date.
@param string $format Date format
@param mixed $time Date in unix time or date-time format.
@return string | [
"Formats",
"the",
"date",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Time.php#L40-L49 |
937 | nirix/radium | src/Helpers/Time.php | Time.toUnix | public static function toUnix($original)
{
if (is_numeric($original)) {
return $original;
}
// YYYY-MM-DD HH:MM:SS
if (preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+) (?P<hour>\d+):(?P<minute>\d+):(?P<second>\d+)/", $original, $match)) {
return mktime($match['hour'], $match['minute'], $match['second'], $match['month'], $match['day'], $match['year']);
}
// YYYY-MM-DD
elseif (preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)/", $original, $match)) {
return mktime(0, 0, 0, $match['month'], $match['day'], $match['year']);
}
// Fail
else {
return strtotime($original);
}
} | php | public static function toUnix($original)
{
if (is_numeric($original)) {
return $original;
}
// YYYY-MM-DD HH:MM:SS
if (preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+) (?P<hour>\d+):(?P<minute>\d+):(?P<second>\d+)/", $original, $match)) {
return mktime($match['hour'], $match['minute'], $match['second'], $match['month'], $match['day'], $match['year']);
}
// YYYY-MM-DD
elseif (preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)/", $original, $match)) {
return mktime(0, 0, 0, $match['month'], $match['day'], $match['year']);
}
// Fail
else {
return strtotime($original);
}
} | [
"public",
"static",
"function",
"toUnix",
"(",
"$",
"original",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"original",
")",
")",
"{",
"return",
"$",
"original",
";",
"}",
"// YYYY-MM-DD HH:MM:SS",
"if",
"(",
"preg_match",
"(",
"\"/(?P<year>\\d+)-(?P<month>\\d+)-(?P<day>\\d+) (?P<hour>\\d+):(?P<minute>\\d+):(?P<second>\\d+)/\"",
",",
"$",
"original",
",",
"$",
"match",
")",
")",
"{",
"return",
"mktime",
"(",
"$",
"match",
"[",
"'hour'",
"]",
",",
"$",
"match",
"[",
"'minute'",
"]",
",",
"$",
"match",
"[",
"'second'",
"]",
",",
"$",
"match",
"[",
"'month'",
"]",
",",
"$",
"match",
"[",
"'day'",
"]",
",",
"$",
"match",
"[",
"'year'",
"]",
")",
";",
"}",
"// YYYY-MM-DD",
"elseif",
"(",
"preg_match",
"(",
"\"/(?P<year>\\d+)-(?P<month>\\d+)-(?P<day>\\d+)/\"",
",",
"$",
"original",
",",
"$",
"match",
")",
")",
"{",
"return",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"$",
"match",
"[",
"'month'",
"]",
",",
"$",
"match",
"[",
"'day'",
"]",
",",
"$",
"match",
"[",
"'year'",
"]",
")",
";",
"}",
"// Fail",
"else",
"{",
"return",
"strtotime",
"(",
"$",
"original",
")",
";",
"}",
"}"
] | Converts a datetime timestamp into a unix timestamp.
@param datetime $original
@return mixed | [
"Converts",
"a",
"datetime",
"timestamp",
"into",
"a",
"unix",
"timestamp",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Time.php#L94-L112 |
938 | nirix/radium | src/Helpers/Time.php | Time.agoInWords | public static function agoInWords($original, $detailed = false)
{
// Check what kind of format we're dealing with, timestamp or datetime
// and convert it to a timestamp if it is in datetime form.
if (!is_numeric($original)) {
$original = static::toUnix($original);
}
$now = time(); // Get the time right now...
// Time chunks...
$chunks = array(
array(60 * 60 * 24 * 365, 'year', 'years'),
array(60 * 60 * 24 * 30, 'month', 'months'),
array(60 * 60 * 24 * 7, 'week', 'weeks'),
array(60 * 60 * 24, 'day', 'days'),
array(60 * 60, 'hour', 'hours'),
array(60, 'minute', 'minutes'),
array(1, 'second', 'seconds'),
);
// Get the difference
$difference = $now > $original ? ($now - $original) : ($original - $now);
// Loop around, get the time from
for ($i = 0, $c = count($chunks); $i < $c; $i++) {
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
$names = $chunks[$i][2];
if(0 != $count = floor($difference / $seconds)) break;
}
// Format the time from
$from = Language::current()->translate("time.x_{$name}", array($count));
// Get the detailed time from if the detail variable is true
if ($detailed && $i + 1 < $c) {
$seconds2 = $chunks[$i + 1][0];
$name2 = $chunks[$i + 1][1];
$names2 = $chunks[$i + 1][2];
if (0 != $count2 = floor(($difference - $seconds * $count) / $seconds2)) {
$from = Language::current()->translate('time.x_and_x', $from, Language::current()->translate("time.x_{$name2}", array($count2)));
}
}
// Return the time from
return $from;
} | php | public static function agoInWords($original, $detailed = false)
{
// Check what kind of format we're dealing with, timestamp or datetime
// and convert it to a timestamp if it is in datetime form.
if (!is_numeric($original)) {
$original = static::toUnix($original);
}
$now = time(); // Get the time right now...
// Time chunks...
$chunks = array(
array(60 * 60 * 24 * 365, 'year', 'years'),
array(60 * 60 * 24 * 30, 'month', 'months'),
array(60 * 60 * 24 * 7, 'week', 'weeks'),
array(60 * 60 * 24, 'day', 'days'),
array(60 * 60, 'hour', 'hours'),
array(60, 'minute', 'minutes'),
array(1, 'second', 'seconds'),
);
// Get the difference
$difference = $now > $original ? ($now - $original) : ($original - $now);
// Loop around, get the time from
for ($i = 0, $c = count($chunks); $i < $c; $i++) {
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
$names = $chunks[$i][2];
if(0 != $count = floor($difference / $seconds)) break;
}
// Format the time from
$from = Language::current()->translate("time.x_{$name}", array($count));
// Get the detailed time from if the detail variable is true
if ($detailed && $i + 1 < $c) {
$seconds2 = $chunks[$i + 1][0];
$name2 = $chunks[$i + 1][1];
$names2 = $chunks[$i + 1][2];
if (0 != $count2 = floor(($difference - $seconds * $count) / $seconds2)) {
$from = Language::current()->translate('time.x_and_x', $from, Language::current()->translate("time.x_{$name2}", array($count2)));
}
}
// Return the time from
return $from;
} | [
"public",
"static",
"function",
"agoInWords",
"(",
"$",
"original",
",",
"$",
"detailed",
"=",
"false",
")",
"{",
"// Check what kind of format we're dealing with, timestamp or datetime",
"// and convert it to a timestamp if it is in datetime form.",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"original",
")",
")",
"{",
"$",
"original",
"=",
"static",
"::",
"toUnix",
"(",
"$",
"original",
")",
";",
"}",
"$",
"now",
"=",
"time",
"(",
")",
";",
"// Get the time right now...",
"// Time chunks...",
"$",
"chunks",
"=",
"array",
"(",
"array",
"(",
"60",
"*",
"60",
"*",
"24",
"*",
"365",
",",
"'year'",
",",
"'years'",
")",
",",
"array",
"(",
"60",
"*",
"60",
"*",
"24",
"*",
"30",
",",
"'month'",
",",
"'months'",
")",
",",
"array",
"(",
"60",
"*",
"60",
"*",
"24",
"*",
"7",
",",
"'week'",
",",
"'weeks'",
")",
",",
"array",
"(",
"60",
"*",
"60",
"*",
"24",
",",
"'day'",
",",
"'days'",
")",
",",
"array",
"(",
"60",
"*",
"60",
",",
"'hour'",
",",
"'hours'",
")",
",",
"array",
"(",
"60",
",",
"'minute'",
",",
"'minutes'",
")",
",",
"array",
"(",
"1",
",",
"'second'",
",",
"'seconds'",
")",
",",
")",
";",
"// Get the difference",
"$",
"difference",
"=",
"$",
"now",
">",
"$",
"original",
"?",
"(",
"$",
"now",
"-",
"$",
"original",
")",
":",
"(",
"$",
"original",
"-",
"$",
"now",
")",
";",
"// Loop around, get the time from",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"c",
"=",
"count",
"(",
"$",
"chunks",
")",
";",
"$",
"i",
"<",
"$",
"c",
";",
"$",
"i",
"++",
")",
"{",
"$",
"seconds",
"=",
"$",
"chunks",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
";",
"$",
"name",
"=",
"$",
"chunks",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
";",
"$",
"names",
"=",
"$",
"chunks",
"[",
"$",
"i",
"]",
"[",
"2",
"]",
";",
"if",
"(",
"0",
"!=",
"$",
"count",
"=",
"floor",
"(",
"$",
"difference",
"/",
"$",
"seconds",
")",
")",
"break",
";",
"}",
"// Format the time from",
"$",
"from",
"=",
"Language",
"::",
"current",
"(",
")",
"->",
"translate",
"(",
"\"time.x_{$name}\"",
",",
"array",
"(",
"$",
"count",
")",
")",
";",
"// Get the detailed time from if the detail variable is true",
"if",
"(",
"$",
"detailed",
"&&",
"$",
"i",
"+",
"1",
"<",
"$",
"c",
")",
"{",
"$",
"seconds2",
"=",
"$",
"chunks",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"0",
"]",
";",
"$",
"name2",
"=",
"$",
"chunks",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"1",
"]",
";",
"$",
"names2",
"=",
"$",
"chunks",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"2",
"]",
";",
"if",
"(",
"0",
"!=",
"$",
"count2",
"=",
"floor",
"(",
"(",
"$",
"difference",
"-",
"$",
"seconds",
"*",
"$",
"count",
")",
"/",
"$",
"seconds2",
")",
")",
"{",
"$",
"from",
"=",
"Language",
"::",
"current",
"(",
")",
"->",
"translate",
"(",
"'time.x_and_x'",
",",
"$",
"from",
",",
"Language",
"::",
"current",
"(",
")",
"->",
"translate",
"(",
"\"time.x_{$name2}\"",
",",
"array",
"(",
"$",
"count2",
")",
")",
")",
";",
"}",
"}",
"// Return the time from",
"return",
"$",
"from",
";",
"}"
] | Returns time ago in words of the given date.
@param string $original
@param boolean $detailed
@return string | [
"Returns",
"time",
"ago",
"in",
"words",
"of",
"the",
"given",
"date",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Time.php#L122-L169 |
939 | pletfix/core | src/Services/Translator.php | Translator.find | private function find($locale, $dictionary, $keys)
{
if (!isset($this->entries[$locale][$dictionary])) {
if (!isset($this->entries[$locale])) {
$this->entries[$locale] = [];
}
$file = $this->dictionaryFile($dictionary, $locale);
/** @noinspection PhpIncludeInspection */
$this->entries[$locale][$dictionary] = $file !== null && file_exists($file) ? include $file : [];
}
$entries = $this->entries[$locale][$dictionary];
foreach ($keys as $key) {
if (!isset($entries[$key])) {
return null;
}
$entries = $entries[$key];
}
return $entries;
} | php | private function find($locale, $dictionary, $keys)
{
if (!isset($this->entries[$locale][$dictionary])) {
if (!isset($this->entries[$locale])) {
$this->entries[$locale] = [];
}
$file = $this->dictionaryFile($dictionary, $locale);
/** @noinspection PhpIncludeInspection */
$this->entries[$locale][$dictionary] = $file !== null && file_exists($file) ? include $file : [];
}
$entries = $this->entries[$locale][$dictionary];
foreach ($keys as $key) {
if (!isset($entries[$key])) {
return null;
}
$entries = $entries[$key];
}
return $entries;
} | [
"private",
"function",
"find",
"(",
"$",
"locale",
",",
"$",
"dictionary",
",",
"$",
"keys",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entries",
"[",
"$",
"locale",
"]",
"[",
"$",
"dictionary",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entries",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"$",
"this",
"->",
"entries",
"[",
"$",
"locale",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"file",
"=",
"$",
"this",
"->",
"dictionaryFile",
"(",
"$",
"dictionary",
",",
"$",
"locale",
")",
";",
"/** @noinspection PhpIncludeInspection */",
"$",
"this",
"->",
"entries",
"[",
"$",
"locale",
"]",
"[",
"$",
"dictionary",
"]",
"=",
"$",
"file",
"!==",
"null",
"&&",
"file_exists",
"(",
"$",
"file",
")",
"?",
"include",
"$",
"file",
":",
"[",
"]",
";",
"}",
"$",
"entries",
"=",
"$",
"this",
"->",
"entries",
"[",
"$",
"locale",
"]",
"[",
"$",
"dictionary",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entries",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"entries",
"=",
"$",
"entries",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"entries",
";",
"}"
] | Find the translation.
@param string $locale
@param string $dictionary
@param array $keys
@return string|array|null | [
"Find",
"the",
"translation",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Translator.php#L109-L129 |
940 | pletfix/core | src/Services/Translator.php | Translator.dictionaryFile | private function dictionaryFile($dictionary, $locale)
{
$file = $this->languagePath . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $dictionary . '.php';
if (file_exists($file)) {
return $file;
}
if ($this->manifest === null) {
/** @noinspection PhpIncludeInspection */
$this->manifest = file_exists($this->pluginManifestOfLanguages) ? include $this->pluginManifestOfLanguages : [];
}
return isset($this->manifest[$locale][$dictionary]) ? base_path($this->manifest[$locale][$dictionary]) : null;
} | php | private function dictionaryFile($dictionary, $locale)
{
$file = $this->languagePath . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $dictionary . '.php';
if (file_exists($file)) {
return $file;
}
if ($this->manifest === null) {
/** @noinspection PhpIncludeInspection */
$this->manifest = file_exists($this->pluginManifestOfLanguages) ? include $this->pluginManifestOfLanguages : [];
}
return isset($this->manifest[$locale][$dictionary]) ? base_path($this->manifest[$locale][$dictionary]) : null;
} | [
"private",
"function",
"dictionaryFile",
"(",
"$",
"dictionary",
",",
"$",
"locale",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"languagePath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"locale",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"dictionary",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"return",
"$",
"file",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"manifest",
"===",
"null",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"$",
"this",
"->",
"manifest",
"=",
"file_exists",
"(",
"$",
"this",
"->",
"pluginManifestOfLanguages",
")",
"?",
"include",
"$",
"this",
"->",
"pluginManifestOfLanguages",
":",
"[",
"]",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"manifest",
"[",
"$",
"locale",
"]",
"[",
"$",
"dictionary",
"]",
")",
"?",
"base_path",
"(",
"$",
"this",
"->",
"manifest",
"[",
"$",
"locale",
"]",
"[",
"$",
"dictionary",
"]",
")",
":",
"null",
";",
"}"
] | Get the full filename of the dictionary.
@param string $dictionary
@param string $locale
@return string | [
"Get",
"the",
"full",
"filename",
"of",
"the",
"dictionary",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Translator.php#L138-L151 |
941 | uthando-cms/uthando-newsletter | src/UthandoNewsletter/View/Strategy/NewsletterStrategy.php | NewsletterStrategy.selectRenderer | public function selectRenderer(ViewEvent $e)
{
$model = $e->getModel();
if ($model instanceof NewsletterViewModel) {
return $this->renderer;
}
return false;
} | php | public function selectRenderer(ViewEvent $e)
{
$model = $e->getModel();
if ($model instanceof NewsletterViewModel) {
return $this->renderer;
}
return false;
} | [
"public",
"function",
"selectRenderer",
"(",
"ViewEvent",
"$",
"e",
")",
"{",
"$",
"model",
"=",
"$",
"e",
"->",
"getModel",
"(",
")",
";",
"if",
"(",
"$",
"model",
"instanceof",
"NewsletterViewModel",
")",
"{",
"return",
"$",
"this",
"->",
"renderer",
";",
"}",
"return",
"false",
";",
"}"
] | Detect if we should use the NewsletterRenderer based on model type
@param ViewEvent $e
@return null|NewsletterRenderer | [
"Detect",
"if",
"we",
"should",
"use",
"the",
"NewsletterRenderer",
"based",
"on",
"model",
"type"
] | 0c61bb05133a77e6c323785177007326fdf3cc5d | https://github.com/uthando-cms/uthando-newsletter/blob/0c61bb05133a77e6c323785177007326fdf3cc5d/src/UthandoNewsletter/View/Strategy/NewsletterStrategy.php#L67-L76 |
942 | cundd/test-flight | src/Output/CodeFormatter.php | CodeFormatter.formatCode | public function formatCode(string $code, $enableColors): string
{
$block = [];
$codeLines = explode("\n", $code);
$this->enableColors = (bool)$enableColors;
$this->numberOfLines = count($codeLines);
$this->gutterWidth = strlen((string)$this->numberOfLines) + 1;
$i = 0;
foreach ($codeLines as $lineNumber => $line) {
$i += 1;
$this->prepareCodeLine($line, $block, $i);
}
return "\n" . $this->colorize(
self::NORMAL . self::LIGHT_GRAY_BACKGROUND . self::WHITE,
implode("\n", $block),
self::RED
);
} | php | public function formatCode(string $code, $enableColors): string
{
$block = [];
$codeLines = explode("\n", $code);
$this->enableColors = (bool)$enableColors;
$this->numberOfLines = count($codeLines);
$this->gutterWidth = strlen((string)$this->numberOfLines) + 1;
$i = 0;
foreach ($codeLines as $lineNumber => $line) {
$i += 1;
$this->prepareCodeLine($line, $block, $i);
}
return "\n" . $this->colorize(
self::NORMAL . self::LIGHT_GRAY_BACKGROUND . self::WHITE,
implode("\n", $block),
self::RED
);
} | [
"public",
"function",
"formatCode",
"(",
"string",
"$",
"code",
",",
"$",
"enableColors",
")",
":",
"string",
"{",
"$",
"block",
"=",
"[",
"]",
";",
"$",
"codeLines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"code",
")",
";",
"$",
"this",
"->",
"enableColors",
"=",
"(",
"bool",
")",
"$",
"enableColors",
";",
"$",
"this",
"->",
"numberOfLines",
"=",
"count",
"(",
"$",
"codeLines",
")",
";",
"$",
"this",
"->",
"gutterWidth",
"=",
"strlen",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"numberOfLines",
")",
"+",
"1",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"codeLines",
"as",
"$",
"lineNumber",
"=>",
"$",
"line",
")",
"{",
"$",
"i",
"+=",
"1",
";",
"$",
"this",
"->",
"prepareCodeLine",
"(",
"$",
"line",
",",
"$",
"block",
",",
"$",
"i",
")",
";",
"}",
"return",
"\"\\n\"",
".",
"$",
"this",
"->",
"colorize",
"(",
"self",
"::",
"NORMAL",
".",
"self",
"::",
"LIGHT_GRAY_BACKGROUND",
".",
"self",
"::",
"WHITE",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"block",
")",
",",
"self",
"::",
"RED",
")",
";",
"}"
] | Formats the given code
@example
$formatter = new \Cundd\TestFlight\Output\CodeFormatter(
new \Cundd\TestFlight\Cli\WindowHelper()
);
test_flight_assert_same('1 line 1', trim($formatter->formatCode('line 1', false)));
@param string $code
@param bool $enableColors
@return string | [
"Formats",
"the",
"given",
"code"
] | 9d8424dfb586f823f9dad2dcb81ff3986e255d56 | https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/Output/CodeFormatter.php#L56-L76 |
943 | novuso/common | src/Domain/Messaging/MetaData.php | MetaData.merge | public function merge(MetaData $data): void
{
foreach ($data->toArray() as $key => $value) {
$this->set($key, $value);
}
} | php | public function merge(MetaData $data): void
{
foreach ($data->toArray() as $key => $value) {
$this->set($key, $value);
}
} | [
"public",
"function",
"merge",
"(",
"MetaData",
"$",
"data",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"data",
"->",
"toArray",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Merges the given meta data
@param MetaData $data The meta data
@return void | [
"Merges",
"the",
"given",
"meta",
"data"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Messaging/MetaData.php#L233-L238 |
944 | novuso/common | src/Domain/Messaging/MetaData.php | MetaData.isValid | protected function isValid($value): bool
{
$type = gettype($value);
switch ($type) {
case 'string':
case 'integer':
case 'double':
case 'boolean':
case 'NULL':
return true;
break;
case 'array':
return ArrayCollection::create($value)->every(function ($v) {
return $this->isValid($v);
});
break;
default:
break;
}
return false;
} | php | protected function isValid($value): bool
{
$type = gettype($value);
switch ($type) {
case 'string':
case 'integer':
case 'double':
case 'boolean':
case 'NULL':
return true;
break;
case 'array':
return ArrayCollection::create($value)->every(function ($v) {
return $this->isValid($v);
});
break;
default:
break;
}
return false;
} | [
"protected",
"function",
"isValid",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"$",
"type",
"=",
"gettype",
"(",
"$",
"value",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'string'",
":",
"case",
"'integer'",
":",
"case",
"'double'",
":",
"case",
"'boolean'",
":",
"case",
"'NULL'",
":",
"return",
"true",
";",
"break",
";",
"case",
"'array'",
":",
"return",
"ArrayCollection",
"::",
"create",
"(",
"$",
"value",
")",
"->",
"every",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"$",
"this",
"->",
"isValid",
"(",
"$",
"v",
")",
";",
"}",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if a value is valid
@param mixed $value The value
@return bool | [
"Checks",
"if",
"a",
"value",
"is",
"valid"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Messaging/MetaData.php#L312-L333 |
945 | lciolecki/zf-extensions-library | library/Extlib/Validate/Doctrine/DoctrineAbstract.php | DoctrineAbstract.getConnection | public function getConnection()
{
if (null === $this->connection) {
$this->setConnection(\Doctrine_Manager::getInstance()->getCurrentConnection());
}
return $this->connection;
} | php | public function getConnection()
{
if (null === $this->connection) {
$this->setConnection(\Doctrine_Manager::getInstance()->getCurrentConnection());
}
return $this->connection;
} | [
"public",
"function",
"getConnection",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"connection",
")",
"{",
"$",
"this",
"->",
"setConnection",
"(",
"\\",
"Doctrine_Manager",
"::",
"getInstance",
"(",
")",
"->",
"getCurrentConnection",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"connection",
";",
"}"
] | Get doctrine connection
@return \Doctrine_Connection | [
"Get",
"doctrine",
"connection"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Validate/Doctrine/DoctrineAbstract.php#L111-L118 |
946 | lciolecki/zf-extensions-library | library/Extlib/Validate/Doctrine/DoctrineAbstract.php | DoctrineAbstract.prepeareQuery | protected function prepeareQuery($value)
{
$query = \Doctrine_Query::create($this->getConnection())
->select($this->getField())
->from($this->getTable())
->where(sprintf('%s = ?', $this->getField()), $value);
foreach ($this->getExclude() as $exclude => $value) {
$query->andWhere(sprintf('%s != ?', $exclude), $value);
}
foreach ($this->getInclude() as $include => $value) {
$query->andWhere(sprintf('%s = ?', $include), $value);
}
return $query;
} | php | protected function prepeareQuery($value)
{
$query = \Doctrine_Query::create($this->getConnection())
->select($this->getField())
->from($this->getTable())
->where(sprintf('%s = ?', $this->getField()), $value);
foreach ($this->getExclude() as $exclude => $value) {
$query->andWhere(sprintf('%s != ?', $exclude), $value);
}
foreach ($this->getInclude() as $include => $value) {
$query->andWhere(sprintf('%s = ?', $include), $value);
}
return $query;
} | [
"protected",
"function",
"prepeareQuery",
"(",
"$",
"value",
")",
"{",
"$",
"query",
"=",
"\\",
"Doctrine_Query",
"::",
"create",
"(",
"$",
"this",
"->",
"getConnection",
"(",
")",
")",
"->",
"select",
"(",
"$",
"this",
"->",
"getField",
"(",
")",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
")",
"->",
"where",
"(",
"sprintf",
"(",
"'%s = ?'",
",",
"$",
"this",
"->",
"getField",
"(",
")",
")",
",",
"$",
"value",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getExclude",
"(",
")",
"as",
"$",
"exclude",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"sprintf",
"(",
"'%s != ?'",
",",
"$",
"exclude",
")",
",",
"$",
"value",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getInclude",
"(",
")",
"as",
"$",
"include",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"sprintf",
"(",
"'%s = ?'",
",",
"$",
"include",
")",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Prepare validate query
@param mixed $value
@return \Doctrine_Query | [
"Prepare",
"validate",
"query"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Validate/Doctrine/DoctrineAbstract.php#L261-L277 |
947 | ciims/cii | widgets/CiiActiveForm.php | CiiActiveForm.passwordFieldRow | public function passwordFieldRow($model, $property, $htmlOptions=array(), $validators=NULL)
{
$htmlOptions['value'] = Cii::decrypt($model->$property);
$htmlOptions['type'] = 'password';
$htmlOptions['id'] = get_class($model) . '_' . $property;
$htmlOptions['name'] = get_class($model) . '[' . $property .']';
echo CHtml::tag('label', array(), $model->getAttributeLabel($property) . (Cii::get($htmlOptions, 'required', false) ? CHtml::tag('span', array('class' => 'required'), ' *') : NULL));
echo CHtml::tag('input', $htmlOptions);
} | php | public function passwordFieldRow($model, $property, $htmlOptions=array(), $validators=NULL)
{
$htmlOptions['value'] = Cii::decrypt($model->$property);
$htmlOptions['type'] = 'password';
$htmlOptions['id'] = get_class($model) . '_' . $property;
$htmlOptions['name'] = get_class($model) . '[' . $property .']';
echo CHtml::tag('label', array(), $model->getAttributeLabel($property) . (Cii::get($htmlOptions, 'required', false) ? CHtml::tag('span', array('class' => 'required'), ' *') : NULL));
echo CHtml::tag('input', $htmlOptions);
} | [
"public",
"function",
"passwordFieldRow",
"(",
"$",
"model",
",",
"$",
"property",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
",",
"$",
"validators",
"=",
"NULL",
")",
"{",
"$",
"htmlOptions",
"[",
"'value'",
"]",
"=",
"Cii",
"::",
"decrypt",
"(",
"$",
"model",
"->",
"$",
"property",
")",
";",
"$",
"htmlOptions",
"[",
"'type'",
"]",
"=",
"'password'",
";",
"$",
"htmlOptions",
"[",
"'id'",
"]",
"=",
"get_class",
"(",
"$",
"model",
")",
".",
"'_'",
".",
"$",
"property",
";",
"$",
"htmlOptions",
"[",
"'name'",
"]",
"=",
"get_class",
"(",
"$",
"model",
")",
".",
"'['",
".",
"$",
"property",
".",
"']'",
";",
"echo",
"CHtml",
"::",
"tag",
"(",
"'label'",
",",
"array",
"(",
")",
",",
"$",
"model",
"->",
"getAttributeLabel",
"(",
"$",
"property",
")",
".",
"(",
"Cii",
"::",
"get",
"(",
"$",
"htmlOptions",
",",
"'required'",
",",
"false",
")",
"?",
"CHtml",
"::",
"tag",
"(",
"'span'",
",",
"array",
"(",
"'class'",
"=>",
"'required'",
")",
",",
"' *'",
")",
":",
"NULL",
")",
")",
";",
"echo",
"CHtml",
"::",
"tag",
"(",
"'input'",
",",
"$",
"htmlOptions",
")",
";",
"}"
] | passwordFieldRow provides a password box that decrypts the database stored value since it will be encrypted in the db
@param CiiSettingsModel $model The model that we are operating on
@param string $property The name of the property we are working with
@param array $htmlOptions An array of HTML Options
@param CValidator $validators The Validator(s) for this property
Since we already have it, it's worth passing through | [
"passwordFieldRow",
"provides",
"a",
"password",
"box",
"that",
"decrypts",
"the",
"database",
"stored",
"value",
"since",
"it",
"will",
"be",
"encrypted",
"in",
"the",
"db"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/CiiActiveForm.php#L126-L134 |
948 | ciims/cii | widgets/CiiActiveForm.php | CiiActiveForm.numberFieldRow | public function numberFieldRow($model, $property, $htmlOptions=array(), $validators=NULL)
{
if ($validators !== NULL)
{
foreach ($validators as $k=>$v)
{
if (get_class($v) == "CNumberValidator")
{
$htmlOptions['min'] = $v->min;
$htmlOptions['step'] = 1;
}
if (get_class($v) == "CRequiredValidator")
$htmlOptions['required'] = true;
}
}
$htmlOptions['value'] = $model->$property;
$htmlOptions['type'] = 'number';
$htmlOptions['id'] = get_class($model) . '_' . $property;
$htmlOptions['name'] = get_class($model) . '[' . $property .']';
echo CHtml::tag('label', array(), $model->getAttributeLabel($property) . (Cii::get($htmlOptions, 'required', false) ? CHtml::tag('span', array('class' => 'required'), ' *') : NULL));
echo CHtml::tag('input', $htmlOptions);
} | php | public function numberFieldRow($model, $property, $htmlOptions=array(), $validators=NULL)
{
if ($validators !== NULL)
{
foreach ($validators as $k=>$v)
{
if (get_class($v) == "CNumberValidator")
{
$htmlOptions['min'] = $v->min;
$htmlOptions['step'] = 1;
}
if (get_class($v) == "CRequiredValidator")
$htmlOptions['required'] = true;
}
}
$htmlOptions['value'] = $model->$property;
$htmlOptions['type'] = 'number';
$htmlOptions['id'] = get_class($model) . '_' . $property;
$htmlOptions['name'] = get_class($model) . '[' . $property .']';
echo CHtml::tag('label', array(), $model->getAttributeLabel($property) . (Cii::get($htmlOptions, 'required', false) ? CHtml::tag('span', array('class' => 'required'), ' *') : NULL));
echo CHtml::tag('input', $htmlOptions);
} | [
"public",
"function",
"numberFieldRow",
"(",
"$",
"model",
",",
"$",
"property",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
",",
"$",
"validators",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"validators",
"!==",
"NULL",
")",
"{",
"foreach",
"(",
"$",
"validators",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"get_class",
"(",
"$",
"v",
")",
"==",
"\"CNumberValidator\"",
")",
"{",
"$",
"htmlOptions",
"[",
"'min'",
"]",
"=",
"$",
"v",
"->",
"min",
";",
"$",
"htmlOptions",
"[",
"'step'",
"]",
"=",
"1",
";",
"}",
"if",
"(",
"get_class",
"(",
"$",
"v",
")",
"==",
"\"CRequiredValidator\"",
")",
"$",
"htmlOptions",
"[",
"'required'",
"]",
"=",
"true",
";",
"}",
"}",
"$",
"htmlOptions",
"[",
"'value'",
"]",
"=",
"$",
"model",
"->",
"$",
"property",
";",
"$",
"htmlOptions",
"[",
"'type'",
"]",
"=",
"'number'",
";",
"$",
"htmlOptions",
"[",
"'id'",
"]",
"=",
"get_class",
"(",
"$",
"model",
")",
".",
"'_'",
".",
"$",
"property",
";",
"$",
"htmlOptions",
"[",
"'name'",
"]",
"=",
"get_class",
"(",
"$",
"model",
")",
".",
"'['",
".",
"$",
"property",
".",
"']'",
";",
"echo",
"CHtml",
"::",
"tag",
"(",
"'label'",
",",
"array",
"(",
")",
",",
"$",
"model",
"->",
"getAttributeLabel",
"(",
"$",
"property",
")",
".",
"(",
"Cii",
"::",
"get",
"(",
"$",
"htmlOptions",
",",
"'required'",
",",
"false",
")",
"?",
"CHtml",
"::",
"tag",
"(",
"'span'",
",",
"array",
"(",
"'class'",
"=>",
"'required'",
")",
",",
"' *'",
")",
":",
"NULL",
")",
")",
";",
"echo",
"CHtml",
"::",
"tag",
"(",
"'input'",
",",
"$",
"htmlOptions",
")",
";",
"}"
] | numberRow HTML5 number elemtn to work with
@param CiiSettingsModel $model The model that we are operating on
@param string $property The name of the property we are working with
@param array $htmlOptions An array of HTML Options
@param CValidator $validators The Validator(s) for this property
Since we already have it, it's worth passing through | [
"numberRow",
"HTML5",
"number",
"elemtn",
"to",
"work",
"with"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/CiiActiveForm.php#L144-L167 |
949 | ciims/cii | widgets/CiiActiveForm.php | CiiActiveForm.rangeFieldRow | public function rangeFieldRow($model, $property, $htmlOptions=array(), $validators=NULL)
{
if ($validators !== NULL)
{
foreach ($validators as $k=>$v)
{
if (get_class($v) == "CNumberValidator")
{
$htmlOptions['min'] = $v->min;
$htmlOptions['max'] = $v->max;
$htmlOptions['step'] = 1;
}
if (get_class($v) == "CRequiredValidator")
$htmlOptions['required'] = true;
}
}
echo CHtml::tag('label', array(), $model->getAttributeLabel($property) . (Cii::get($htmlOptions, 'required', false) ? CHtml::tag('span', array('class' => 'required'), ' *') : NULL));
echo $this->rangeField($model, $property, $htmlOptions);
echo CHtml::tag('div', array('class' => 'output'), NULL);
} | php | public function rangeFieldRow($model, $property, $htmlOptions=array(), $validators=NULL)
{
if ($validators !== NULL)
{
foreach ($validators as $k=>$v)
{
if (get_class($v) == "CNumberValidator")
{
$htmlOptions['min'] = $v->min;
$htmlOptions['max'] = $v->max;
$htmlOptions['step'] = 1;
}
if (get_class($v) == "CRequiredValidator")
$htmlOptions['required'] = true;
}
}
echo CHtml::tag('label', array(), $model->getAttributeLabel($property) . (Cii::get($htmlOptions, 'required', false) ? CHtml::tag('span', array('class' => 'required'), ' *') : NULL));
echo $this->rangeField($model, $property, $htmlOptions);
echo CHtml::tag('div', array('class' => 'output'), NULL);
} | [
"public",
"function",
"rangeFieldRow",
"(",
"$",
"model",
",",
"$",
"property",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
",",
"$",
"validators",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"validators",
"!==",
"NULL",
")",
"{",
"foreach",
"(",
"$",
"validators",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"get_class",
"(",
"$",
"v",
")",
"==",
"\"CNumberValidator\"",
")",
"{",
"$",
"htmlOptions",
"[",
"'min'",
"]",
"=",
"$",
"v",
"->",
"min",
";",
"$",
"htmlOptions",
"[",
"'max'",
"]",
"=",
"$",
"v",
"->",
"max",
";",
"$",
"htmlOptions",
"[",
"'step'",
"]",
"=",
"1",
";",
"}",
"if",
"(",
"get_class",
"(",
"$",
"v",
")",
"==",
"\"CRequiredValidator\"",
")",
"$",
"htmlOptions",
"[",
"'required'",
"]",
"=",
"true",
";",
"}",
"}",
"echo",
"CHtml",
"::",
"tag",
"(",
"'label'",
",",
"array",
"(",
")",
",",
"$",
"model",
"->",
"getAttributeLabel",
"(",
"$",
"property",
")",
".",
"(",
"Cii",
"::",
"get",
"(",
"$",
"htmlOptions",
",",
"'required'",
",",
"false",
")",
"?",
"CHtml",
"::",
"tag",
"(",
"'span'",
",",
"array",
"(",
"'class'",
"=>",
"'required'",
")",
",",
"' *'",
")",
":",
"NULL",
")",
")",
";",
"echo",
"$",
"this",
"->",
"rangeField",
"(",
"$",
"model",
",",
"$",
"property",
",",
"$",
"htmlOptions",
")",
";",
"echo",
"CHtml",
"::",
"tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'output'",
")",
",",
"NULL",
")",
";",
"}"
] | rangeRow provides a pretty ish range slider with view controls
@param CiiSettingsModel $model The model that we are operating on
@param string $property The name of the property we are working with
@param array $htmlOptions An array of HTML Options
@param CValidator $validators The Validator(s) for this property
Since we already have it, it's worth passing through | [
"rangeRow",
"provides",
"a",
"pretty",
"ish",
"range",
"slider",
"with",
"view",
"controls"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/CiiActiveForm.php#L177-L198 |
950 | singularphp/command | src/Singular/Command/Service/ComponentService.php | ComponentService.checkPerfilExists | private function checkPerfilExists($perfilId)
{
$db = $this->db;
$perfil = $db->fetchAssoc('SELECT * FROM singular_perfil WHERE id = '.$perfilId);
return is_array($perfil) ? true : false;
} | php | private function checkPerfilExists($perfilId)
{
$db = $this->db;
$perfil = $db->fetchAssoc('SELECT * FROM singular_perfil WHERE id = '.$perfilId);
return is_array($perfil) ? true : false;
} | [
"private",
"function",
"checkPerfilExists",
"(",
"$",
"perfilId",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"db",
";",
"$",
"perfil",
"=",
"$",
"db",
"->",
"fetchAssoc",
"(",
"'SELECT * FROM singular_perfil WHERE id = '",
".",
"$",
"perfilId",
")",
";",
"return",
"is_array",
"(",
"$",
"perfil",
")",
"?",
"true",
":",
"false",
";",
"}"
] | Verifica se um perfil existe.
@param integer $perfilId
@return bool | [
"Verifica",
"se",
"um",
"perfil",
"existe",
"."
] | 0accb3ae19f46882a9f790732dac586a82e0371d | https://github.com/singularphp/command/blob/0accb3ae19f46882a9f790732dac586a82e0371d/src/Singular/Command/Service/ComponentService.php#L220-L227 |
951 | judus/minimal-minimal | src/Apps/Eventual/Subscribers/Loader.php | Loader.registerMinimal | public function registerMinimal(string $filePath = null)
{
is_file($filePath) || $filePath = App::getBasePath() . $filePath;
if (is_file($filePath)) {
/** @noinspection PhpIncludeInspection */
$configItems = require_once $filePath;
!is_array($configItems) || Config::items($configItems);
ini_set('error_reporting',
Config::exists('errors.error_reporting', 0));
ini_set('display_errors',
Config::exists('errors.display_errors', 0));
Event::dispatch('minimal.loaded.minimal', [
$filePath,
is_array($configItems) ? $configItems : []
]);
}
} | php | public function registerMinimal(string $filePath = null)
{
is_file($filePath) || $filePath = App::getBasePath() . $filePath;
if (is_file($filePath)) {
/** @noinspection PhpIncludeInspection */
$configItems = require_once $filePath;
!is_array($configItems) || Config::items($configItems);
ini_set('error_reporting',
Config::exists('errors.error_reporting', 0));
ini_set('display_errors',
Config::exists('errors.display_errors', 0));
Event::dispatch('minimal.loaded.minimal', [
$filePath,
is_array($configItems) ? $configItems : []
]);
}
} | [
"public",
"function",
"registerMinimal",
"(",
"string",
"$",
"filePath",
"=",
"null",
")",
"{",
"is_file",
"(",
"$",
"filePath",
")",
"||",
"$",
"filePath",
"=",
"App",
"::",
"getBasePath",
"(",
")",
".",
"$",
"filePath",
";",
"if",
"(",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"$",
"configItems",
"=",
"require_once",
"$",
"filePath",
";",
"!",
"is_array",
"(",
"$",
"configItems",
")",
"||",
"Config",
"::",
"items",
"(",
"$",
"configItems",
")",
";",
"ini_set",
"(",
"'error_reporting'",
",",
"Config",
"::",
"exists",
"(",
"'errors.error_reporting'",
",",
"0",
")",
")",
";",
"ini_set",
"(",
"'display_errors'",
",",
"Config",
"::",
"exists",
"(",
"'errors.display_errors'",
",",
"0",
")",
")",
";",
"Event",
"::",
"dispatch",
"(",
"'minimal.loaded.minimal'",
",",
"[",
"$",
"filePath",
",",
"is_array",
"(",
"$",
"configItems",
")",
"?",
"$",
"configItems",
":",
"[",
"]",
"]",
")",
";",
"}",
"}"
] | Registers the minimal config file.
It stores the array items from the minimal config file in the Config
object and eventually sets the phpini error_reporting and display_errors.
@param string|null $filePath | [
"Registers",
"the",
"minimal",
"config",
"file",
".",
"It",
"stores",
"the",
"array",
"items",
"from",
"the",
"minimal",
"config",
"file",
"in",
"the",
"Config",
"object",
"and",
"eventually",
"sets",
"the",
"phpini",
"error_reporting",
"and",
"display_errors",
"."
] | 36db55c537175cead2ab412f166bf2574d0f9597 | https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/Apps/Eventual/Subscribers/Loader.php#L70-L90 |
952 | judus/minimal-minimal | src/Apps/Eventual/Subscribers/Loader.php | Loader.registerConfig | public function registerConfig(string $filePath = null)
{
is_file($filePath) || $filePath = App::getBasePath() . $filePath;
if (is_file($filePath)) {
/** @noinspection PhpIncludeInspection */
$configItems = require_once $filePath;
if (is_array($configItems)) {
foreach ($configItems as $key => $value) {
if (Config::exists($key)) {
Config::merge($key, $value);
} else {
Config::item($key, $value);
}
}
}
if ($value = Config::exists('errors.error_reporting', null)) {
ini_set('error_reporting', $value);
}
if ($value = Config::exists('errors.display_errors', null)) {
ini_set('display_errors', $value);
}
Event::dispatch('minimal.loaded.config', [$filePath,
is_array($configItems) ? $configItems : []
]);
}
} | php | public function registerConfig(string $filePath = null)
{
is_file($filePath) || $filePath = App::getBasePath() . $filePath;
if (is_file($filePath)) {
/** @noinspection PhpIncludeInspection */
$configItems = require_once $filePath;
if (is_array($configItems)) {
foreach ($configItems as $key => $value) {
if (Config::exists($key)) {
Config::merge($key, $value);
} else {
Config::item($key, $value);
}
}
}
if ($value = Config::exists('errors.error_reporting', null)) {
ini_set('error_reporting', $value);
}
if ($value = Config::exists('errors.display_errors', null)) {
ini_set('display_errors', $value);
}
Event::dispatch('minimal.loaded.config', [$filePath,
is_array($configItems) ? $configItems : []
]);
}
} | [
"public",
"function",
"registerConfig",
"(",
"string",
"$",
"filePath",
"=",
"null",
")",
"{",
"is_file",
"(",
"$",
"filePath",
")",
"||",
"$",
"filePath",
"=",
"App",
"::",
"getBasePath",
"(",
")",
".",
"$",
"filePath",
";",
"if",
"(",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"$",
"configItems",
"=",
"require_once",
"$",
"filePath",
";",
"if",
"(",
"is_array",
"(",
"$",
"configItems",
")",
")",
"{",
"foreach",
"(",
"$",
"configItems",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"Config",
"::",
"exists",
"(",
"$",
"key",
")",
")",
"{",
"Config",
"::",
"merge",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"Config",
"::",
"item",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"value",
"=",
"Config",
"::",
"exists",
"(",
"'errors.error_reporting'",
",",
"null",
")",
")",
"{",
"ini_set",
"(",
"'error_reporting'",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"value",
"=",
"Config",
"::",
"exists",
"(",
"'errors.display_errors'",
",",
"null",
")",
")",
"{",
"ini_set",
"(",
"'display_errors'",
",",
"$",
"value",
")",
";",
"}",
"Event",
"::",
"dispatch",
"(",
"'minimal.loaded.config'",
",",
"[",
"$",
"filePath",
",",
"is_array",
"(",
"$",
"configItems",
")",
"?",
"$",
"configItems",
":",
"[",
"]",
"]",
")",
";",
"}",
"}"
] | Registers the main config file.
It stores the array items from the main config file in the Config object.
It will merge recursively with other items in the Config object.
It eventually sets the phpini error_reporting and display_errors
@param null $filePath
@throws \Maduser\Minimal\Config\Exceptions\KeyDoesNotExistException | [
"Registers",
"the",
"main",
"config",
"file",
".",
"It",
"stores",
"the",
"array",
"items",
"from",
"the",
"main",
"config",
"file",
"in",
"the",
"Config",
"object",
".",
"It",
"will",
"merge",
"recursively",
"with",
"other",
"items",
"in",
"the",
"Config",
"object",
".",
"It",
"eventually",
"sets",
"the",
"phpini",
"error_reporting",
"and",
"display_errors"
] | 36db55c537175cead2ab412f166bf2574d0f9597 | https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/Apps/Eventual/Subscribers/Loader.php#L102-L132 |
953 | tekkla/core-framework | Core/Framework/Amvc/App/Language.php | Language.get | public function get(string $key)
{ //
$result = $this->strings[$key] ?? $key;
// Is there a redirection to another string?
if (is_string($result) && substr($result, 0, 2) == '@@') {
$result = $this->get(substr($result, 2));
}
if ($result == $key && isset($this->fallback_language)) {
$result = $this->fallback_language->get($key);
}
return $result;
} | php | public function get(string $key)
{ //
$result = $this->strings[$key] ?? $key;
// Is there a redirection to another string?
if (is_string($result) && substr($result, 0, 2) == '@@') {
$result = $this->get(substr($result, 2));
}
if ($result == $key && isset($this->fallback_language)) {
$result = $this->fallback_language->get($key);
}
return $result;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
")",
"{",
"//",
"$",
"result",
"=",
"$",
"this",
"->",
"strings",
"[",
"$",
"key",
"]",
"??",
"$",
"key",
";",
"// Is there a redirection to another string?",
"if",
"(",
"is_string",
"(",
"$",
"result",
")",
"&&",
"substr",
"(",
"$",
"result",
",",
"0",
",",
"2",
")",
"==",
"'@@'",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"get",
"(",
"substr",
"(",
"$",
"result",
",",
"2",
")",
")",
";",
"}",
"if",
"(",
"$",
"result",
"==",
"$",
"key",
"&&",
"isset",
"(",
"$",
"this",
"->",
"fallback_language",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"fallback_language",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the string of string of a specific language key or an array of strings flagge as preserved
You can create linked strings by setting '@@your.linked.string' as result in your language file.
Will query a set fallback language object when the requested key is not set in apps language strings.
This way it is possible to create a chain of fallback request from one app to another.
Important: Do not create circle requests!
@param string $key
@return string|array | [
"Returns",
"the",
"string",
"of",
"string",
"of",
"a",
"specific",
"language",
"key",
"or",
"an",
"array",
"of",
"strings",
"flagge",
"as",
"preserved"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/Language.php#L113-L127 |
954 | prototypemvc/prototypemvc | Core/Folder.php | Folder.create | public static function create($path = false, $mode = 0777) {
if($path && !self::isFolder(dirname($path)) && self::isWritable(dirname($path))) {
mkdir($path, $mode);
if(Folder::isFolder($path)) {
return true;
}
}
return false;
} | php | public static function create($path = false, $mode = 0777) {
if($path && !self::isFolder(dirname($path)) && self::isWritable(dirname($path))) {
mkdir($path, $mode);
if(Folder::isFolder($path)) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"path",
"=",
"false",
",",
"$",
"mode",
"=",
"0777",
")",
"{",
"if",
"(",
"$",
"path",
"&&",
"!",
"self",
"::",
"isFolder",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
"&&",
"self",
"::",
"isWritable",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
")",
"{",
"mkdir",
"(",
"$",
"path",
",",
"$",
"mode",
")",
";",
"if",
"(",
"Folder",
"::",
"isFolder",
"(",
"$",
"path",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Create an empty folder.
@param string path to file (including filename)
@param int folder permission
@example create('folder/newFolder')
@return boolean | [
"Create",
"an",
"empty",
"folder",
"."
] | 039e238857d4b627e40ba681a376583b0821cd36 | https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Folder.php#L14-L27 |
955 | prototypemvc/prototypemvc | Core/Folder.php | Folder.find | public static function find($fileName = false, $path = false) {
if($fileName) {
if(!$path) {
$path = __DIR__;
}
if(self::isFolder($path)) {
$dir = new \RecursiveDirectoryIterator($path);
foreach (new \RecursiveIteratorIterator($dir) as $filePath) {
if($fileName == basename($filePath)) {
return $filePath;
}
}
}
}
return false;
} | php | public static function find($fileName = false, $path = false) {
if($fileName) {
if(!$path) {
$path = __DIR__;
}
if(self::isFolder($path)) {
$dir = new \RecursiveDirectoryIterator($path);
foreach (new \RecursiveIteratorIterator($dir) as $filePath) {
if($fileName == basename($filePath)) {
return $filePath;
}
}
}
}
return false;
} | [
"public",
"static",
"function",
"find",
"(",
"$",
"fileName",
"=",
"false",
",",
"$",
"path",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"__DIR__",
";",
"}",
"if",
"(",
"self",
"::",
"isFolder",
"(",
"$",
"path",
")",
")",
"{",
"$",
"dir",
"=",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"$",
"dir",
")",
"as",
"$",
"filePath",
")",
"{",
"if",
"(",
"$",
"fileName",
"==",
"basename",
"(",
"$",
"filePath",
")",
")",
"{",
"return",
"$",
"filePath",
";",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Find file with a given name inside a given directory.
@param string name of the file to find
@param string directory to scan
@example find('log.txt', 'folder')
@return string full path to file | [
"Find",
"file",
"with",
"a",
"given",
"name",
"inside",
"a",
"given",
"directory",
"."
] | 039e238857d4b627e40ba681a376583b0821cd36 | https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Folder.php#L36-L59 |
956 | prototypemvc/prototypemvc | Core/Folder.php | Folder.get | public static function get($path = false) {
if ($path && self::isFolder($path)) {
$list = array();
$tmpList = scandir($path);
foreach ($tmpList as $k => $item) {
if ($item != '.' && $item != '..' && $item != '.DS_Store') {
$list[] = $item;
}
}
return $list;
}
return false;
} | php | public static function get($path = false) {
if ($path && self::isFolder($path)) {
$list = array();
$tmpList = scandir($path);
foreach ($tmpList as $k => $item) {
if ($item != '.' && $item != '..' && $item != '.DS_Store') {
$list[] = $item;
}
}
return $list;
}
return false;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"path",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"path",
"&&",
"self",
"::",
"isFolder",
"(",
"$",
"path",
")",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"tmpList",
"=",
"scandir",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"tmpList",
"as",
"$",
"k",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"!=",
"'.'",
"&&",
"$",
"item",
"!=",
"'..'",
"&&",
"$",
"item",
"!=",
"'.DS_Store'",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"list",
";",
"}",
"return",
"false",
";",
"}"
] | Get list of all files in a given directory.
@param string path to folder
@return array of files in the directory | [
"Get",
"list",
"of",
"all",
"files",
"in",
"a",
"given",
"directory",
"."
] | 039e238857d4b627e40ba681a376583b0821cd36 | https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Folder.php#L66-L85 |
957 | lasallecrm/lasallecrm-l5-lasallecrmcontact-pkg | src/Helpers/Helpers.php | Helpers.getPeopleIdFromFullName | public function getPeopleIdFromFullName($fullName) {
$result = DB::table('peoples')
->where('first_name', $this->getFirstName($fullName))
->where('middle_name', $this->getMiddleName($fullName))
->where('surname', $this->getLastName($fullName))
->first()
;
if (count($result) > 0) {
return $result->id;
}
return 0;
} | php | public function getPeopleIdFromFullName($fullName) {
$result = DB::table('peoples')
->where('first_name', $this->getFirstName($fullName))
->where('middle_name', $this->getMiddleName($fullName))
->where('surname', $this->getLastName($fullName))
->first()
;
if (count($result) > 0) {
return $result->id;
}
return 0;
} | [
"public",
"function",
"getPeopleIdFromFullName",
"(",
"$",
"fullName",
")",
"{",
"$",
"result",
"=",
"DB",
"::",
"table",
"(",
"'peoples'",
")",
"->",
"where",
"(",
"'first_name'",
",",
"$",
"this",
"->",
"getFirstName",
"(",
"$",
"fullName",
")",
")",
"->",
"where",
"(",
"'middle_name'",
",",
"$",
"this",
"->",
"getMiddleName",
"(",
"$",
"fullName",
")",
")",
"->",
"where",
"(",
"'surname'",
",",
"$",
"this",
"->",
"getLastName",
"(",
"$",
"fullName",
")",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"result",
")",
">",
"0",
")",
"{",
"return",
"$",
"result",
"->",
"id",
";",
"}",
"return",
"0",
";",
"}"
] | get the peoples' ID from the full name
@param string $fullName The full name in the URL in the form "Firstname@Middlename@Lastname"
@return int | [
"get",
"the",
"peoples",
"ID",
"from",
"the",
"full",
"name"
] | d0a66b457a0e544636d82d4f0e71a0859dd85ee6 | https://github.com/lasallecrm/lasallecrm-l5-lasallecrmcontact-pkg/blob/d0a66b457a0e544636d82d4f0e71a0859dd85ee6/src/Helpers/Helpers.php#L70-L82 |
958 | lasallecrm/lasallecrm-l5-lasallecrmcontact-pkg | src/Helpers/Helpers.php | Helpers.isAllowedPeopleIdSingleContactDisplay | public function isAllowedPeopleIdSingleContactDisplay($id) {
if ($id == 0) {
return false;
}
$allowedIDs = Config::get('lasallecrmcontact.single_contact_display_people_id_allowed');
foreach ($allowedIDs as $allowedID) {
if ($allowedID == $id) {
return true;
}
}
return false;
} | php | public function isAllowedPeopleIdSingleContactDisplay($id) {
if ($id == 0) {
return false;
}
$allowedIDs = Config::get('lasallecrmcontact.single_contact_display_people_id_allowed');
foreach ($allowedIDs as $allowedID) {
if ($allowedID == $id) {
return true;
}
}
return false;
} | [
"public",
"function",
"isAllowedPeopleIdSingleContactDisplay",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"allowedIDs",
"=",
"Config",
"::",
"get",
"(",
"'lasallecrmcontact.single_contact_display_people_id_allowed'",
")",
";",
"foreach",
"(",
"$",
"allowedIDs",
"as",
"$",
"allowedID",
")",
"{",
"if",
"(",
"$",
"allowedID",
"==",
"$",
"id",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Is this people ID allowed to be displayed in the single contact display?
@param int $id LaSalleCRM people ID
@return bool | [
"Is",
"this",
"people",
"ID",
"allowed",
"to",
"be",
"displayed",
"in",
"the",
"single",
"contact",
"display?"
] | d0a66b457a0e544636d82d4f0e71a0859dd85ee6 | https://github.com/lasallecrm/lasallecrm-l5-lasallecrmcontact-pkg/blob/d0a66b457a0e544636d82d4f0e71a0859dd85ee6/src/Helpers/Helpers.php#L135-L149 |
959 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/email/classes/email/driver/smtp.php | Email_Driver_Smtp._send | protected function _send()
{
$message = $this->build_message(true);
if(empty($this->config['smtp']['host']) or empty($this->config['smtp']['port']))
{
throw new \FuelException('Must supply a SMTP host and port, none given.');
}
// Use authentication?
$authenticate = (empty($this->smtp_connection) and ! empty($this->config['smtp']['username']) and ! empty($this->config['smtp']['password']));
// Connect
$this->smtp_connect();
// Authenticate when needed
$authenticate and $this->smtp_authenticate();
// Set from
$this->smtp_send('MAIL FROM:<'.$this->config['from']['email'].'>', 250);
foreach(array('to', 'cc', 'bcc') as $list)
{
foreach($this->{$list} as $recipient)
{
$this->smtp_send('RCPT TO:<'.$recipient['email'].'>', array(250, 251));
}
}
// Prepare for data sending
$this->smtp_send('DATA', 354);
$lines = explode($this->config['newline'], $message['header'].preg_replace('/^\./m', '..$1', $message['body']));
foreach($lines as $line)
{
if(substr($line, 0, 1) === '.')
{
$line = '.'.$line;
}
fputs($this->smtp_connection, $line.$this->config['newline']);
}
// Finish the message
$this->smtp_send('.', 250);
// Close the connection if we're not using pipelining
$this->pipelining or $this->smtp_disconnect();
return true;
} | php | protected function _send()
{
$message = $this->build_message(true);
if(empty($this->config['smtp']['host']) or empty($this->config['smtp']['port']))
{
throw new \FuelException('Must supply a SMTP host and port, none given.');
}
// Use authentication?
$authenticate = (empty($this->smtp_connection) and ! empty($this->config['smtp']['username']) and ! empty($this->config['smtp']['password']));
// Connect
$this->smtp_connect();
// Authenticate when needed
$authenticate and $this->smtp_authenticate();
// Set from
$this->smtp_send('MAIL FROM:<'.$this->config['from']['email'].'>', 250);
foreach(array('to', 'cc', 'bcc') as $list)
{
foreach($this->{$list} as $recipient)
{
$this->smtp_send('RCPT TO:<'.$recipient['email'].'>', array(250, 251));
}
}
// Prepare for data sending
$this->smtp_send('DATA', 354);
$lines = explode($this->config['newline'], $message['header'].preg_replace('/^\./m', '..$1', $message['body']));
foreach($lines as $line)
{
if(substr($line, 0, 1) === '.')
{
$line = '.'.$line;
}
fputs($this->smtp_connection, $line.$this->config['newline']);
}
// Finish the message
$this->smtp_send('.', 250);
// Close the connection if we're not using pipelining
$this->pipelining or $this->smtp_disconnect();
return true;
} | [
"protected",
"function",
"_send",
"(",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"build_message",
"(",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'host'",
"]",
")",
"or",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'port'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"FuelException",
"(",
"'Must supply a SMTP host and port, none given.'",
")",
";",
"}",
"// Use authentication?",
"$",
"authenticate",
"=",
"(",
"empty",
"(",
"$",
"this",
"->",
"smtp_connection",
")",
"and",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'username'",
"]",
")",
"and",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'password'",
"]",
")",
")",
";",
"// Connect",
"$",
"this",
"->",
"smtp_connect",
"(",
")",
";",
"// Authenticate when needed",
"$",
"authenticate",
"and",
"$",
"this",
"->",
"smtp_authenticate",
"(",
")",
";",
"// Set from",
"$",
"this",
"->",
"smtp_send",
"(",
"'MAIL FROM:<'",
".",
"$",
"this",
"->",
"config",
"[",
"'from'",
"]",
"[",
"'email'",
"]",
".",
"'>'",
",",
"250",
")",
";",
"foreach",
"(",
"array",
"(",
"'to'",
",",
"'cc'",
",",
"'bcc'",
")",
"as",
"$",
"list",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"list",
"}",
"as",
"$",
"recipient",
")",
"{",
"$",
"this",
"->",
"smtp_send",
"(",
"'RCPT TO:<'",
".",
"$",
"recipient",
"[",
"'email'",
"]",
".",
"'>'",
",",
"array",
"(",
"250",
",",
"251",
")",
")",
";",
"}",
"}",
"// Prepare for data sending",
"$",
"this",
"->",
"smtp_send",
"(",
"'DATA'",
",",
"354",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"$",
"this",
"->",
"config",
"[",
"'newline'",
"]",
",",
"$",
"message",
"[",
"'header'",
"]",
".",
"preg_replace",
"(",
"'/^\\./m'",
",",
"'..$1'",
",",
"$",
"message",
"[",
"'body'",
"]",
")",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"line",
",",
"0",
",",
"1",
")",
"===",
"'.'",
")",
"{",
"$",
"line",
"=",
"'.'",
".",
"$",
"line",
";",
"}",
"fputs",
"(",
"$",
"this",
"->",
"smtp_connection",
",",
"$",
"line",
".",
"$",
"this",
"->",
"config",
"[",
"'newline'",
"]",
")",
";",
"}",
"// Finish the message",
"$",
"this",
"->",
"smtp_send",
"(",
"'.'",
",",
"250",
")",
";",
"// Close the connection if we're not using pipelining",
"$",
"this",
"->",
"pipelining",
"or",
"$",
"this",
"->",
"smtp_disconnect",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Initalted all needed for SMTP mailing.
@throws \FuelException Must supply a SMTP host and port, none given
@return bool Success boolean | [
"Initalted",
"all",
"needed",
"for",
"SMTP",
"mailing",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/smtp.php#L52-L103 |
960 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/email/classes/email/driver/smtp.php | Email_Driver_Smtp.smtp_connect | protected function smtp_connect()
{
// re-use the existing connection
if ( ! empty($this->smtp_connection))
{
return;
}
// add a transport if not given
if (strpos($this->config['smtp']['host'], '://') === false)
{
$this->config['smtp']['host'] = 'tcp://'.$this->config['smtp']['host'];
}
$this->smtp_connection = stream_socket_client(
$this->config['smtp']['host'].':'.$this->config['smtp']['port'],
$error_number,
$error_string,
$this->config['smtp']['timeout']
);
if(empty($this->smtp_connection))
{
throw new \SmtpConnectionException('Could not connect to SMTP: ('.$error_number.') '.$error_string);
}
// Clear the smtp response
$this->smtp_get_response();
// Just say hello!
try
{
$this->smtp_send('EHLO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
}
catch(\SmtpCommandFailureException $e)
{
// Didn't work? Try HELO
$this->smtp_send('HELO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
}
// Enable TLS encryption if needed, and we're connecting using TCP
if (\Arr::get($this->config, 'smtp.starttls', false) and strpos($this->config['smtp']['host'], 'tcp://') === 0)
{
try
{
$this->smtp_send('STARTTLS', 220);
if ( ! stream_socket_enable_crypto($this->smtp_connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
{
throw new \SmtpConnectionException('STARTTLS failed, Crypto client can not be enabled.');
}
}
catch(\SmtpCommandFailureException $e)
{
throw new \SmtpConnectionException('STARTTLS failed, invalid return code received from server.');
}
// Say hello again, the service list might be updated (see RFC 3207 section 4.2)
try
{
$this->smtp_send('EHLO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
}
catch(\SmtpCommandFailureException $e)
{
// Didn't work? Try HELO
$this->smtp_send('HELO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
}
}
try
{
$this->smtp_send('HELP', 214);
}
catch(\SmtpCommandFailureException $e)
{
// Let this pass as some servers don't support this.
}
} | php | protected function smtp_connect()
{
// re-use the existing connection
if ( ! empty($this->smtp_connection))
{
return;
}
// add a transport if not given
if (strpos($this->config['smtp']['host'], '://') === false)
{
$this->config['smtp']['host'] = 'tcp://'.$this->config['smtp']['host'];
}
$this->smtp_connection = stream_socket_client(
$this->config['smtp']['host'].':'.$this->config['smtp']['port'],
$error_number,
$error_string,
$this->config['smtp']['timeout']
);
if(empty($this->smtp_connection))
{
throw new \SmtpConnectionException('Could not connect to SMTP: ('.$error_number.') '.$error_string);
}
// Clear the smtp response
$this->smtp_get_response();
// Just say hello!
try
{
$this->smtp_send('EHLO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
}
catch(\SmtpCommandFailureException $e)
{
// Didn't work? Try HELO
$this->smtp_send('HELO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
}
// Enable TLS encryption if needed, and we're connecting using TCP
if (\Arr::get($this->config, 'smtp.starttls', false) and strpos($this->config['smtp']['host'], 'tcp://') === 0)
{
try
{
$this->smtp_send('STARTTLS', 220);
if ( ! stream_socket_enable_crypto($this->smtp_connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
{
throw new \SmtpConnectionException('STARTTLS failed, Crypto client can not be enabled.');
}
}
catch(\SmtpCommandFailureException $e)
{
throw new \SmtpConnectionException('STARTTLS failed, invalid return code received from server.');
}
// Say hello again, the service list might be updated (see RFC 3207 section 4.2)
try
{
$this->smtp_send('EHLO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
}
catch(\SmtpCommandFailureException $e)
{
// Didn't work? Try HELO
$this->smtp_send('HELO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
}
}
try
{
$this->smtp_send('HELP', 214);
}
catch(\SmtpCommandFailureException $e)
{
// Let this pass as some servers don't support this.
}
} | [
"protected",
"function",
"smtp_connect",
"(",
")",
"{",
"// re-use the existing connection",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"smtp_connection",
")",
")",
"{",
"return",
";",
"}",
"// add a transport if not given",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'host'",
"]",
",",
"'://'",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'host'",
"]",
"=",
"'tcp://'",
".",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'host'",
"]",
";",
"}",
"$",
"this",
"->",
"smtp_connection",
"=",
"stream_socket_client",
"(",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'host'",
"]",
".",
"':'",
".",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'port'",
"]",
",",
"$",
"error_number",
",",
"$",
"error_string",
",",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'timeout'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"smtp_connection",
")",
")",
"{",
"throw",
"new",
"\\",
"SmtpConnectionException",
"(",
"'Could not connect to SMTP: ('",
".",
"$",
"error_number",
".",
"') '",
".",
"$",
"error_string",
")",
";",
"}",
"// Clear the smtp response",
"$",
"this",
"->",
"smtp_get_response",
"(",
")",
";",
"// Just say hello!",
"try",
"{",
"$",
"this",
"->",
"smtp_send",
"(",
"'EHLO'",
".",
"' '",
".",
"\\",
"Input",
"::",
"server",
"(",
"'SERVER_NAME'",
",",
"'localhost.local'",
")",
",",
"250",
")",
";",
"}",
"catch",
"(",
"\\",
"SmtpCommandFailureException",
"$",
"e",
")",
"{",
"// Didn't work? Try HELO",
"$",
"this",
"->",
"smtp_send",
"(",
"'HELO'",
".",
"' '",
".",
"\\",
"Input",
"::",
"server",
"(",
"'SERVER_NAME'",
",",
"'localhost.local'",
")",
",",
"250",
")",
";",
"}",
"// Enable TLS encryption if needed, and we're connecting using TCP",
"if",
"(",
"\\",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"'smtp.starttls'",
",",
"false",
")",
"and",
"strpos",
"(",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'host'",
"]",
",",
"'tcp://'",
")",
"===",
"0",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"smtp_send",
"(",
"'STARTTLS'",
",",
"220",
")",
";",
"if",
"(",
"!",
"stream_socket_enable_crypto",
"(",
"$",
"this",
"->",
"smtp_connection",
",",
"true",
",",
"STREAM_CRYPTO_METHOD_TLS_CLIENT",
")",
")",
"{",
"throw",
"new",
"\\",
"SmtpConnectionException",
"(",
"'STARTTLS failed, Crypto client can not be enabled.'",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"SmtpCommandFailureException",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"SmtpConnectionException",
"(",
"'STARTTLS failed, invalid return code received from server.'",
")",
";",
"}",
"// Say hello again, the service list might be updated (see RFC 3207 section 4.2)",
"try",
"{",
"$",
"this",
"->",
"smtp_send",
"(",
"'EHLO'",
".",
"' '",
".",
"\\",
"Input",
"::",
"server",
"(",
"'SERVER_NAME'",
",",
"'localhost.local'",
")",
",",
"250",
")",
";",
"}",
"catch",
"(",
"\\",
"SmtpCommandFailureException",
"$",
"e",
")",
"{",
"// Didn't work? Try HELO",
"$",
"this",
"->",
"smtp_send",
"(",
"'HELO'",
".",
"' '",
".",
"\\",
"Input",
"::",
"server",
"(",
"'SERVER_NAME'",
",",
"'localhost.local'",
")",
",",
"250",
")",
";",
"}",
"}",
"try",
"{",
"$",
"this",
"->",
"smtp_send",
"(",
"'HELP'",
",",
"214",
")",
";",
"}",
"catch",
"(",
"\\",
"SmtpCommandFailureException",
"$",
"e",
")",
"{",
"// Let this pass as some servers don't support this.",
"}",
"}"
] | Connects to the given smtp and says hello to the other server. | [
"Connects",
"to",
"the",
"given",
"smtp",
"and",
"says",
"hello",
"to",
"the",
"other",
"server",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/smtp.php#L108-L184 |
961 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/email/classes/email/driver/smtp.php | Email_Driver_Smtp.smtp_authenticate | protected function smtp_authenticate()
{
// Encode login data
$username = base64_encode($this->config['smtp']['username']);
$password = base64_encode($this->config['smtp']['password']);
try
{
// Prepare login
$this->smtp_send('AUTH LOGIN', 334);
// Send username
$this->smtp_send($username, 334);
// Send password
$this->smtp_send($password, 235);
}
catch(\SmtpCommandFailureException $e)
{
throw new \SmtpAuthenticationFailedException('Failed authentication.');
}
} | php | protected function smtp_authenticate()
{
// Encode login data
$username = base64_encode($this->config['smtp']['username']);
$password = base64_encode($this->config['smtp']['password']);
try
{
// Prepare login
$this->smtp_send('AUTH LOGIN', 334);
// Send username
$this->smtp_send($username, 334);
// Send password
$this->smtp_send($password, 235);
}
catch(\SmtpCommandFailureException $e)
{
throw new \SmtpAuthenticationFailedException('Failed authentication.');
}
} | [
"protected",
"function",
"smtp_authenticate",
"(",
")",
"{",
"// Encode login data",
"$",
"username",
"=",
"base64_encode",
"(",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'username'",
"]",
")",
";",
"$",
"password",
"=",
"base64_encode",
"(",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'password'",
"]",
")",
";",
"try",
"{",
"// Prepare login",
"$",
"this",
"->",
"smtp_send",
"(",
"'AUTH LOGIN'",
",",
"334",
")",
";",
"// Send username",
"$",
"this",
"->",
"smtp_send",
"(",
"$",
"username",
",",
"334",
")",
";",
"// Send password",
"$",
"this",
"->",
"smtp_send",
"(",
"$",
"password",
",",
"235",
")",
";",
"}",
"catch",
"(",
"\\",
"SmtpCommandFailureException",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"SmtpAuthenticationFailedException",
"(",
"'Failed authentication.'",
")",
";",
"}",
"}"
] | Performs authentication with the SMTP host | [
"Performs",
"authentication",
"with",
"the",
"SMTP",
"host"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/smtp.php#L199-L222 |
962 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/email/classes/email/driver/smtp.php | Email_Driver_Smtp.smtp_send | protected function smtp_send($data, $expecting, $return_number = false)
{
! is_array($expecting) and $expecting !== false and $expecting = array($expecting);
stream_set_timeout($this->smtp_connection, $this->config['smtp']['timeout']);
if ( ! fputs($this->smtp_connection, $data . $this->config['newline']))
{
if($expecting === false)
{
return false;
}
throw new \SmtpCommandFailureException('Failed executing command: '. $data);
}
$info = stream_get_meta_data($this->smtp_connection);
if($info['timed_out'])
{
throw new \SmtpTimeoutException('SMTP connection timed out.');
}
// Get the reponse
$response = $this->smtp_get_response();
// Get the reponse number
$number = (int) substr(trim($response), 0, 3);
// Check against expected result
if($expecting !== false and ! in_array($number, $expecting))
{
throw new \SmtpCommandFailureException('Got an unexpected response from host on command: ['.$data.'] expecting: '.join(' or ',$expecting).' received: '.$response);
}
if($return_number)
{
return $number;
}
return $response;
} | php | protected function smtp_send($data, $expecting, $return_number = false)
{
! is_array($expecting) and $expecting !== false and $expecting = array($expecting);
stream_set_timeout($this->smtp_connection, $this->config['smtp']['timeout']);
if ( ! fputs($this->smtp_connection, $data . $this->config['newline']))
{
if($expecting === false)
{
return false;
}
throw new \SmtpCommandFailureException('Failed executing command: '. $data);
}
$info = stream_get_meta_data($this->smtp_connection);
if($info['timed_out'])
{
throw new \SmtpTimeoutException('SMTP connection timed out.');
}
// Get the reponse
$response = $this->smtp_get_response();
// Get the reponse number
$number = (int) substr(trim($response), 0, 3);
// Check against expected result
if($expecting !== false and ! in_array($number, $expecting))
{
throw new \SmtpCommandFailureException('Got an unexpected response from host on command: ['.$data.'] expecting: '.join(' or ',$expecting).' received: '.$response);
}
if($return_number)
{
return $number;
}
return $response;
} | [
"protected",
"function",
"smtp_send",
"(",
"$",
"data",
",",
"$",
"expecting",
",",
"$",
"return_number",
"=",
"false",
")",
"{",
"!",
"is_array",
"(",
"$",
"expecting",
")",
"and",
"$",
"expecting",
"!==",
"false",
"and",
"$",
"expecting",
"=",
"array",
"(",
"$",
"expecting",
")",
";",
"stream_set_timeout",
"(",
"$",
"this",
"->",
"smtp_connection",
",",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'timeout'",
"]",
")",
";",
"if",
"(",
"!",
"fputs",
"(",
"$",
"this",
"->",
"smtp_connection",
",",
"$",
"data",
".",
"$",
"this",
"->",
"config",
"[",
"'newline'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"expecting",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"throw",
"new",
"\\",
"SmtpCommandFailureException",
"(",
"'Failed executing command: '",
".",
"$",
"data",
")",
";",
"}",
"$",
"info",
"=",
"stream_get_meta_data",
"(",
"$",
"this",
"->",
"smtp_connection",
")",
";",
"if",
"(",
"$",
"info",
"[",
"'timed_out'",
"]",
")",
"{",
"throw",
"new",
"\\",
"SmtpTimeoutException",
"(",
"'SMTP connection timed out.'",
")",
";",
"}",
"// Get the reponse",
"$",
"response",
"=",
"$",
"this",
"->",
"smtp_get_response",
"(",
")",
";",
"// Get the reponse number",
"$",
"number",
"=",
"(",
"int",
")",
"substr",
"(",
"trim",
"(",
"$",
"response",
")",
",",
"0",
",",
"3",
")",
";",
"// Check against expected result",
"if",
"(",
"$",
"expecting",
"!==",
"false",
"and",
"!",
"in_array",
"(",
"$",
"number",
",",
"$",
"expecting",
")",
")",
"{",
"throw",
"new",
"\\",
"SmtpCommandFailureException",
"(",
"'Got an unexpected response from host on command: ['",
".",
"$",
"data",
".",
"'] expecting: '",
".",
"join",
"(",
"' or '",
",",
"$",
"expecting",
")",
".",
"' received: '",
".",
"$",
"response",
")",
";",
"}",
"if",
"(",
"$",
"return_number",
")",
"{",
"return",
"$",
"number",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Sends data to the SMTP host
@param string $data The SMTP command
@param string|bool|string $expecting The expected response
@param bool $return_number Set to true to return the status number
@throws \SmtpCommandFailureException When the command failed an expecting is not set to false.
@throws \SmtpTimeoutException SMTP connection timed out
@return mixed Result or result number, false when expecting is false | [
"Sends",
"data",
"to",
"the",
"SMTP",
"host"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/smtp.php#L236-L274 |
963 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/email/classes/email/driver/smtp.php | Email_Driver_Smtp.smtp_get_response | protected function smtp_get_response()
{
$data = '';
// set the timeout.
stream_set_timeout($this->smtp_connection, $this->config['smtp']['timeout']);
while($str = fgets($this->smtp_connection, 512))
{
$info = stream_get_meta_data($this->smtp_connection);
if($info['timed_out'])
{
throw new \SmtpTimeoutException('SMTP connection timed out.');
}
$data .= $str;
if (substr($str, 3, 1) === ' ')
{
break;
}
}
return $data;
} | php | protected function smtp_get_response()
{
$data = '';
// set the timeout.
stream_set_timeout($this->smtp_connection, $this->config['smtp']['timeout']);
while($str = fgets($this->smtp_connection, 512))
{
$info = stream_get_meta_data($this->smtp_connection);
if($info['timed_out'])
{
throw new \SmtpTimeoutException('SMTP connection timed out.');
}
$data .= $str;
if (substr($str, 3, 1) === ' ')
{
break;
}
}
return $data;
} | [
"protected",
"function",
"smtp_get_response",
"(",
")",
"{",
"$",
"data",
"=",
"''",
";",
"// set the timeout.",
"stream_set_timeout",
"(",
"$",
"this",
"->",
"smtp_connection",
",",
"$",
"this",
"->",
"config",
"[",
"'smtp'",
"]",
"[",
"'timeout'",
"]",
")",
";",
"while",
"(",
"$",
"str",
"=",
"fgets",
"(",
"$",
"this",
"->",
"smtp_connection",
",",
"512",
")",
")",
"{",
"$",
"info",
"=",
"stream_get_meta_data",
"(",
"$",
"this",
"->",
"smtp_connection",
")",
";",
"if",
"(",
"$",
"info",
"[",
"'timed_out'",
"]",
")",
"{",
"throw",
"new",
"\\",
"SmtpTimeoutException",
"(",
"'SMTP connection timed out.'",
")",
";",
"}",
"$",
"data",
".=",
"$",
"str",
";",
"if",
"(",
"substr",
"(",
"$",
"str",
",",
"3",
",",
"1",
")",
"===",
"' '",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] | Get SMTP response
@throws \SmtpTimeoutException
@return string SMTP response | [
"Get",
"SMTP",
"response"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/smtp.php#L283-L307 |
964 | letrunghieu/taki | src/Traits/TakiSocial.php | TakiSocial.getOauthCallback | public function getOauthCallback($service)
{
$user = \Socialite::driver($service)->user();
$email = $user->getEmail();
$dbUser = \User::where('email', $email)->first();
if (!$dbUser) {
$userInfo = [
'name' => $user->getName(),
config('taki.field.email') => $user->getEmail(),
'avatar' => $user->getAvatar(),
'provider' => $service,
];
if (config('taki.social.password_required') || config('taki.social.username_required')) {
\Taki::saveOauthUser($service, $user->getEmail());
return redirect($this->getOauthCompletePath())->with($userInfo);
} else {
$userInfo['password'] = false;
$userInfo['token'] = false;
$userInfo[config('taki.field.username')] = $this->generateUsername($service, $user);
$dbUser = $this->create($userInfo);
}
}
Auth::login($dbUser, true);
return redirect()->intended();
} | php | public function getOauthCallback($service)
{
$user = \Socialite::driver($service)->user();
$email = $user->getEmail();
$dbUser = \User::where('email', $email)->first();
if (!$dbUser) {
$userInfo = [
'name' => $user->getName(),
config('taki.field.email') => $user->getEmail(),
'avatar' => $user->getAvatar(),
'provider' => $service,
];
if (config('taki.social.password_required') || config('taki.social.username_required')) {
\Taki::saveOauthUser($service, $user->getEmail());
return redirect($this->getOauthCompletePath())->with($userInfo);
} else {
$userInfo['password'] = false;
$userInfo['token'] = false;
$userInfo[config('taki.field.username')] = $this->generateUsername($service, $user);
$dbUser = $this->create($userInfo);
}
}
Auth::login($dbUser, true);
return redirect()->intended();
} | [
"public",
"function",
"getOauthCallback",
"(",
"$",
"service",
")",
"{",
"$",
"user",
"=",
"\\",
"Socialite",
"::",
"driver",
"(",
"$",
"service",
")",
"->",
"user",
"(",
")",
";",
"$",
"email",
"=",
"$",
"user",
"->",
"getEmail",
"(",
")",
";",
"$",
"dbUser",
"=",
"\\",
"User",
"::",
"where",
"(",
"'email'",
",",
"$",
"email",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"dbUser",
")",
"{",
"$",
"userInfo",
"=",
"[",
"'name'",
"=>",
"$",
"user",
"->",
"getName",
"(",
")",
",",
"config",
"(",
"'taki.field.email'",
")",
"=>",
"$",
"user",
"->",
"getEmail",
"(",
")",
",",
"'avatar'",
"=>",
"$",
"user",
"->",
"getAvatar",
"(",
")",
",",
"'provider'",
"=>",
"$",
"service",
",",
"]",
";",
"if",
"(",
"config",
"(",
"'taki.social.password_required'",
")",
"||",
"config",
"(",
"'taki.social.username_required'",
")",
")",
"{",
"\\",
"Taki",
"::",
"saveOauthUser",
"(",
"$",
"service",
",",
"$",
"user",
"->",
"getEmail",
"(",
")",
")",
";",
"return",
"redirect",
"(",
"$",
"this",
"->",
"getOauthCompletePath",
"(",
")",
")",
"->",
"with",
"(",
"$",
"userInfo",
")",
";",
"}",
"else",
"{",
"$",
"userInfo",
"[",
"'password'",
"]",
"=",
"false",
";",
"$",
"userInfo",
"[",
"'token'",
"]",
"=",
"false",
";",
"$",
"userInfo",
"[",
"config",
"(",
"'taki.field.username'",
")",
"]",
"=",
"$",
"this",
"->",
"generateUsername",
"(",
"$",
"service",
",",
"$",
"user",
")",
";",
"$",
"dbUser",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"userInfo",
")",
";",
"}",
"}",
"Auth",
"::",
"login",
"(",
"$",
"dbUser",
",",
"true",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"intended",
"(",
")",
";",
"}"
] | Create user or log the user in after success authentication
@param type $service
@return type | [
"Create",
"user",
"or",
"log",
"the",
"user",
"in",
"after",
"success",
"authentication"
] | c4af7345a4a9df6d83c84f04335da92b62debf17 | https://github.com/letrunghieu/taki/blob/c4af7345a4a9df6d83c84f04335da92b62debf17/src/Traits/TakiSocial.php#L35-L63 |
965 | bmdevel/php-index | classes/binarySearch/KeyReader.php | KeyReader.readKeys | public function readKeys($offset, $direction, $hints = Parser::HINT_NONE)
{
// If reading backwards, shift the offset left
$shiftedOffset = $direction == self::DIRECTION_BACKWARD
? $offset - $this->getReadLength()
: $offset;
//TODO shift to a blocksize chunk
// Don't shift too far
if ($shiftedOffset < 0) {
$shiftedOffset = 0;
}
// Read data
\fseek($this->index->getFile()->getFilePointer(), $shiftedOffset);
$data = \fread(
$this->index->getFile()->getFilePointer(),
$this->getReadLength()
);
if ($data === false) {
if (\feof($this->index->getFile()->getFilePointer())) {
return array();
} else {
throw new IOIndexException("Could not read file");
}
}
// Parse the read data
$keys = $this->index->getParser()->parseKeys($data, $shiftedOffset, $hints);
// Read more data if no keys were found
if (empty($keys)) {
// Only increase if there exists more data
if ($direction == self::DIRECTION_BACKWARD && $shiftedOffset == 0) {
return array();
} elseif ($direction == self::DIRECTION_FORWARD
&& $shiftedOffset + $this->getReadLength()
>= $this->index->getFile()->getFileSize()
) {
return array();
}
$this->increaseReadLength();
return $this->readKeys($offset, $direction);
}
return $keys;
} | php | public function readKeys($offset, $direction, $hints = Parser::HINT_NONE)
{
// If reading backwards, shift the offset left
$shiftedOffset = $direction == self::DIRECTION_BACKWARD
? $offset - $this->getReadLength()
: $offset;
//TODO shift to a blocksize chunk
// Don't shift too far
if ($shiftedOffset < 0) {
$shiftedOffset = 0;
}
// Read data
\fseek($this->index->getFile()->getFilePointer(), $shiftedOffset);
$data = \fread(
$this->index->getFile()->getFilePointer(),
$this->getReadLength()
);
if ($data === false) {
if (\feof($this->index->getFile()->getFilePointer())) {
return array();
} else {
throw new IOIndexException("Could not read file");
}
}
// Parse the read data
$keys = $this->index->getParser()->parseKeys($data, $shiftedOffset, $hints);
// Read more data if no keys were found
if (empty($keys)) {
// Only increase if there exists more data
if ($direction == self::DIRECTION_BACKWARD && $shiftedOffset == 0) {
return array();
} elseif ($direction == self::DIRECTION_FORWARD
&& $shiftedOffset + $this->getReadLength()
>= $this->index->getFile()->getFileSize()
) {
return array();
}
$this->increaseReadLength();
return $this->readKeys($offset, $direction);
}
return $keys;
} | [
"public",
"function",
"readKeys",
"(",
"$",
"offset",
",",
"$",
"direction",
",",
"$",
"hints",
"=",
"Parser",
"::",
"HINT_NONE",
")",
"{",
"// If reading backwards, shift the offset left",
"$",
"shiftedOffset",
"=",
"$",
"direction",
"==",
"self",
"::",
"DIRECTION_BACKWARD",
"?",
"$",
"offset",
"-",
"$",
"this",
"->",
"getReadLength",
"(",
")",
":",
"$",
"offset",
";",
"//TODO shift to a blocksize chunk",
"// Don't shift too far",
"if",
"(",
"$",
"shiftedOffset",
"<",
"0",
")",
"{",
"$",
"shiftedOffset",
"=",
"0",
";",
"}",
"// Read data",
"\\",
"fseek",
"(",
"$",
"this",
"->",
"index",
"->",
"getFile",
"(",
")",
"->",
"getFilePointer",
"(",
")",
",",
"$",
"shiftedOffset",
")",
";",
"$",
"data",
"=",
"\\",
"fread",
"(",
"$",
"this",
"->",
"index",
"->",
"getFile",
"(",
")",
"->",
"getFilePointer",
"(",
")",
",",
"$",
"this",
"->",
"getReadLength",
"(",
")",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"if",
"(",
"\\",
"feof",
"(",
"$",
"this",
"->",
"index",
"->",
"getFile",
"(",
")",
"->",
"getFilePointer",
"(",
")",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IOIndexException",
"(",
"\"Could not read file\"",
")",
";",
"}",
"}",
"// Parse the read data",
"$",
"keys",
"=",
"$",
"this",
"->",
"index",
"->",
"getParser",
"(",
")",
"->",
"parseKeys",
"(",
"$",
"data",
",",
"$",
"shiftedOffset",
",",
"$",
"hints",
")",
";",
"// Read more data if no keys were found",
"if",
"(",
"empty",
"(",
"$",
"keys",
")",
")",
"{",
"// Only increase if there exists more data",
"if",
"(",
"$",
"direction",
"==",
"self",
"::",
"DIRECTION_BACKWARD",
"&&",
"$",
"shiftedOffset",
"==",
"0",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"direction",
"==",
"self",
"::",
"DIRECTION_FORWARD",
"&&",
"$",
"shiftedOffset",
"+",
"$",
"this",
"->",
"getReadLength",
"(",
")",
">=",
"$",
"this",
"->",
"index",
"->",
"getFile",
"(",
")",
"->",
"getFileSize",
"(",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"increaseReadLength",
"(",
")",
";",
"return",
"$",
"this",
"->",
"readKeys",
"(",
"$",
"offset",
",",
"$",
"direction",
")",
";",
"}",
"return",
"$",
"keys",
";",
"}"
] | Returns keys from a offset
The read range will be increased until at least one key will be found
or the end of file was reached.
@param int $offset
@param int $direction
@return array
@throws IOIndexException | [
"Returns",
"keys",
"from",
"a",
"offset"
] | 6a6b476f1706b9524bfb34f6ce0963b1aea91259 | https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/binarySearch/KeyReader.php#L46-L100 |
966 | LastCallMedia/Mannequin-Drupal | Drupal/MannequinDrupalTwigExtension.php | MannequinDrupalTwigExtension.without | public function without($element)
{
if ($element instanceof \ArrayAccess) {
$filtered_element = clone $element;
} else {
$filtered_element = $element;
}
$args = func_get_args();
unset($args[0]);
foreach ($args as $arg) {
if (isset($filtered_element[$arg])) {
unset($filtered_element[$arg]);
}
}
return $filtered_element;
} | php | public function without($element)
{
if ($element instanceof \ArrayAccess) {
$filtered_element = clone $element;
} else {
$filtered_element = $element;
}
$args = func_get_args();
unset($args[0]);
foreach ($args as $arg) {
if (isset($filtered_element[$arg])) {
unset($filtered_element[$arg]);
}
}
return $filtered_element;
} | [
"public",
"function",
"without",
"(",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"\\",
"ArrayAccess",
")",
"{",
"$",
"filtered_element",
"=",
"clone",
"$",
"element",
";",
"}",
"else",
"{",
"$",
"filtered_element",
"=",
"$",
"element",
";",
"}",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"unset",
"(",
"$",
"args",
"[",
"0",
"]",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"filtered_element",
"[",
"$",
"arg",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"filtered_element",
"[",
"$",
"arg",
"]",
")",
";",
"}",
"}",
"return",
"$",
"filtered_element",
";",
"}"
] | This is a carbon copy of the drupal Twig without filter.
@param $element
@return \ArrayAccess | [
"This",
"is",
"a",
"carbon",
"copy",
"of",
"the",
"drupal",
"Twig",
"without",
"filter",
"."
] | 8dfcdf39a066f8697442376a3a72c36dc3733ffc | https://github.com/LastCallMedia/Mannequin-Drupal/blob/8dfcdf39a066f8697442376a3a72c36dc3733ffc/Drupal/MannequinDrupalTwigExtension.php#L129-L145 |
967 | ekyna/Characteristics | Schema/Loader/AbstractLoader.php | AbstractLoader.createSchemas | protected function createSchemas(array $configuration)
{
$processor = new Processor();
$processedConfiguration = $processor->processConfiguration(
new SchemaConfiguration(),
$configuration
);
$schemas = array();
foreach ($processedConfiguration as $schemaName => $schemaConfig) {
$schema = new Schema($schemaName, $schemaConfig['title']);
foreach ($schemaConfig['groups'] as $groupName => $groupConfig) {
$group = new Group($groupName, $groupConfig['title']);
foreach ($groupConfig['characteristics'] as $characteristicName => $characteristicConfig) {
$fullName = implode(':', array($schemaName, $groupName, $characteristicName));
$this->validateDefinitionConfig($fullName, $characteristicConfig);
$definition = new Definition();
$definition
->setName($characteristicName)
->setFullName($fullName)
->setType($characteristicConfig['type'])
->setTitle($characteristicConfig['title'])
->setShared($characteristicConfig['shared'])
->setVirtual($characteristicConfig['virtual'])
->setPropertyPaths($characteristicConfig['property_paths'])
->setFormat($characteristicConfig['format'])
->setDisplayGroups($characteristicConfig['display_groups'])
;
$group->addDefinition($definition);
}
$schema->addGroup($group);
}
$schemas[] = $schema;
}
return $schemas;
} | php | protected function createSchemas(array $configuration)
{
$processor = new Processor();
$processedConfiguration = $processor->processConfiguration(
new SchemaConfiguration(),
$configuration
);
$schemas = array();
foreach ($processedConfiguration as $schemaName => $schemaConfig) {
$schema = new Schema($schemaName, $schemaConfig['title']);
foreach ($schemaConfig['groups'] as $groupName => $groupConfig) {
$group = new Group($groupName, $groupConfig['title']);
foreach ($groupConfig['characteristics'] as $characteristicName => $characteristicConfig) {
$fullName = implode(':', array($schemaName, $groupName, $characteristicName));
$this->validateDefinitionConfig($fullName, $characteristicConfig);
$definition = new Definition();
$definition
->setName($characteristicName)
->setFullName($fullName)
->setType($characteristicConfig['type'])
->setTitle($characteristicConfig['title'])
->setShared($characteristicConfig['shared'])
->setVirtual($characteristicConfig['virtual'])
->setPropertyPaths($characteristicConfig['property_paths'])
->setFormat($characteristicConfig['format'])
->setDisplayGroups($characteristicConfig['display_groups'])
;
$group->addDefinition($definition);
}
$schema->addGroup($group);
}
$schemas[] = $schema;
}
return $schemas;
} | [
"protected",
"function",
"createSchemas",
"(",
"array",
"$",
"configuration",
")",
"{",
"$",
"processor",
"=",
"new",
"Processor",
"(",
")",
";",
"$",
"processedConfiguration",
"=",
"$",
"processor",
"->",
"processConfiguration",
"(",
"new",
"SchemaConfiguration",
"(",
")",
",",
"$",
"configuration",
")",
";",
"$",
"schemas",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"processedConfiguration",
"as",
"$",
"schemaName",
"=>",
"$",
"schemaConfig",
")",
"{",
"$",
"schema",
"=",
"new",
"Schema",
"(",
"$",
"schemaName",
",",
"$",
"schemaConfig",
"[",
"'title'",
"]",
")",
";",
"foreach",
"(",
"$",
"schemaConfig",
"[",
"'groups'",
"]",
"as",
"$",
"groupName",
"=>",
"$",
"groupConfig",
")",
"{",
"$",
"group",
"=",
"new",
"Group",
"(",
"$",
"groupName",
",",
"$",
"groupConfig",
"[",
"'title'",
"]",
")",
";",
"foreach",
"(",
"$",
"groupConfig",
"[",
"'characteristics'",
"]",
"as",
"$",
"characteristicName",
"=>",
"$",
"characteristicConfig",
")",
"{",
"$",
"fullName",
"=",
"implode",
"(",
"':'",
",",
"array",
"(",
"$",
"schemaName",
",",
"$",
"groupName",
",",
"$",
"characteristicName",
")",
")",
";",
"$",
"this",
"->",
"validateDefinitionConfig",
"(",
"$",
"fullName",
",",
"$",
"characteristicConfig",
")",
";",
"$",
"definition",
"=",
"new",
"Definition",
"(",
")",
";",
"$",
"definition",
"->",
"setName",
"(",
"$",
"characteristicName",
")",
"->",
"setFullName",
"(",
"$",
"fullName",
")",
"->",
"setType",
"(",
"$",
"characteristicConfig",
"[",
"'type'",
"]",
")",
"->",
"setTitle",
"(",
"$",
"characteristicConfig",
"[",
"'title'",
"]",
")",
"->",
"setShared",
"(",
"$",
"characteristicConfig",
"[",
"'shared'",
"]",
")",
"->",
"setVirtual",
"(",
"$",
"characteristicConfig",
"[",
"'virtual'",
"]",
")",
"->",
"setPropertyPaths",
"(",
"$",
"characteristicConfig",
"[",
"'property_paths'",
"]",
")",
"->",
"setFormat",
"(",
"$",
"characteristicConfig",
"[",
"'format'",
"]",
")",
"->",
"setDisplayGroups",
"(",
"$",
"characteristicConfig",
"[",
"'display_groups'",
"]",
")",
";",
"$",
"group",
"->",
"addDefinition",
"(",
"$",
"definition",
")",
";",
"}",
"$",
"schema",
"->",
"addGroup",
"(",
"$",
"group",
")",
";",
"}",
"$",
"schemas",
"[",
"]",
"=",
"$",
"schema",
";",
"}",
"return",
"$",
"schemas",
";",
"}"
] | Creates and returns a Schema from the given configuration array.
@param array $configuration
@return Schema[] | [
"Creates",
"and",
"returns",
"a",
"Schema",
"from",
"the",
"given",
"configuration",
"array",
"."
] | 118a349fd98a7c28721d3cbaba67ce79d1cffada | https://github.com/ekyna/Characteristics/blob/118a349fd98a7c28721d3cbaba67ce79d1cffada/Schema/Loader/AbstractLoader.php#L31-L69 |
968 | ekyna/Characteristics | Schema/Loader/AbstractLoader.php | AbstractLoader.validateDefinitionConfig | private function validateDefinitionConfig($name, array &$config)
{
if (true === $config['virtual'] && 0 === count($config['property_paths'])) {
throw new \InvalidArgumentException(sprintf('"property_paths" must be set for "virtual" characteristic "%s".', $name));
}
if ($config['type'] === 'datetime') {
if ($config['format'] === '%s') {
$config['format'] = 'd/m/Y';
}
} elseif (false === strpos($config['format'], '%s')) {
throw new \InvalidArgumentException(sprintf('"format" must contain "%%s" for characteristic "%s".', $name));
}
} | php | private function validateDefinitionConfig($name, array &$config)
{
if (true === $config['virtual'] && 0 === count($config['property_paths'])) {
throw new \InvalidArgumentException(sprintf('"property_paths" must be set for "virtual" characteristic "%s".', $name));
}
if ($config['type'] === 'datetime') {
if ($config['format'] === '%s') {
$config['format'] = 'd/m/Y';
}
} elseif (false === strpos($config['format'], '%s')) {
throw new \InvalidArgumentException(sprintf('"format" must contain "%%s" for characteristic "%s".', $name));
}
} | [
"private",
"function",
"validateDefinitionConfig",
"(",
"$",
"name",
",",
"array",
"&",
"$",
"config",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"config",
"[",
"'virtual'",
"]",
"&&",
"0",
"===",
"count",
"(",
"$",
"config",
"[",
"'property_paths'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"property_paths\" must be set for \"virtual\" characteristic \"%s\".'",
",",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"$",
"config",
"[",
"'type'",
"]",
"===",
"'datetime'",
")",
"{",
"if",
"(",
"$",
"config",
"[",
"'format'",
"]",
"===",
"'%s'",
")",
"{",
"$",
"config",
"[",
"'format'",
"]",
"=",
"'d/m/Y'",
";",
"}",
"}",
"elseif",
"(",
"false",
"===",
"strpos",
"(",
"$",
"config",
"[",
"'format'",
"]",
",",
"'%s'",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"format\" must contain \"%%s\" for characteristic \"%s\".'",
",",
"$",
"name",
")",
")",
";",
"}",
"}"
] | Validates the definition configuration.
@param string $name
@param array $config
@throws \InvalidArgumentException | [
"Validates",
"the",
"definition",
"configuration",
"."
] | 118a349fd98a7c28721d3cbaba67ce79d1cffada | https://github.com/ekyna/Characteristics/blob/118a349fd98a7c28721d3cbaba67ce79d1cffada/Schema/Loader/AbstractLoader.php#L78-L90 |
969 | loopsframework/base | src/Loops/Misc/WrappedObject.php | WrappedObject.getIterator | public function getIterator() {
$iterator = new AppendIterator;
if($this->wrapped_object instanceof IteratorAggregate) {
$iterator->append($element->getIterator());
}
else {
$iterator->append(new ArrayIterator($this->wrapped_object));
}
$iterator->append(parent::getIterator());
return $iterator;
} | php | public function getIterator() {
$iterator = new AppendIterator;
if($this->wrapped_object instanceof IteratorAggregate) {
$iterator->append($element->getIterator());
}
else {
$iterator->append(new ArrayIterator($this->wrapped_object));
}
$iterator->append(parent::getIterator());
return $iterator;
} | [
"public",
"function",
"getIterator",
"(",
")",
"{",
"$",
"iterator",
"=",
"new",
"AppendIterator",
";",
"if",
"(",
"$",
"this",
"->",
"wrapped_object",
"instanceof",
"IteratorAggregate",
")",
"{",
"$",
"iterator",
"->",
"append",
"(",
"$",
"element",
"->",
"getIterator",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"iterator",
"->",
"append",
"(",
"new",
"ArrayIterator",
"(",
"$",
"this",
"->",
"wrapped_object",
")",
")",
";",
"}",
"$",
"iterator",
"->",
"append",
"(",
"parent",
"::",
"getIterator",
"(",
")",
")",
";",
"return",
"$",
"iterator",
";",
"}"
] | Returns an AppendIterator that iterates over both the wrapped object and this object | [
"Returns",
"an",
"AppendIterator",
"that",
"iterates",
"over",
"both",
"the",
"wrapped",
"object",
"and",
"this",
"object"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc/WrappedObject.php#L49-L60 |
970 | easy-system/es-http | src/Factory/HeadersFactory.php | HeadersFactory.make | public static function make(array $server = null)
{
if (empty($server)) {
$server = $_SERVER;
}
$headers = [];
$content = [
'CONTENT_TYPE' => 'Content-Type',
'CONTENT_LENGTH' => 'Content-Length',
'CONTENT_MD5' => 'Content-Md5',
];
foreach ($server as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$key = substr($key, 5);
if (! isset($content[$key]) || ! isset($server[$key])) {
$key = str_replace('_', ' ', $key);
$key = ucwords(strtolower($key));
$key = str_replace(' ', '-', $key);
$headers[$key] = $value;
}
} elseif (isset($content[$key])) {
$headers[$content[$key]] = $value;
}
}
return $headers;
} | php | public static function make(array $server = null)
{
if (empty($server)) {
$server = $_SERVER;
}
$headers = [];
$content = [
'CONTENT_TYPE' => 'Content-Type',
'CONTENT_LENGTH' => 'Content-Length',
'CONTENT_MD5' => 'Content-Md5',
];
foreach ($server as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$key = substr($key, 5);
if (! isset($content[$key]) || ! isset($server[$key])) {
$key = str_replace('_', ' ', $key);
$key = ucwords(strtolower($key));
$key = str_replace(' ', '-', $key);
$headers[$key] = $value;
}
} elseif (isset($content[$key])) {
$headers[$content[$key]] = $value;
}
}
return $headers;
} | [
"public",
"static",
"function",
"make",
"(",
"array",
"$",
"server",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"server",
")",
")",
"{",
"$",
"server",
"=",
"$",
"_SERVER",
";",
"}",
"$",
"headers",
"=",
"[",
"]",
";",
"$",
"content",
"=",
"[",
"'CONTENT_TYPE'",
"=>",
"'Content-Type'",
",",
"'CONTENT_LENGTH'",
"=>",
"'Content-Length'",
",",
"'CONTENT_MD5'",
"=>",
"'Content-Md5'",
",",
"]",
";",
"foreach",
"(",
"$",
"server",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"5",
")",
"===",
"'HTTP_'",
")",
"{",
"$",
"key",
"=",
"substr",
"(",
"$",
"key",
",",
"5",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"content",
"[",
"$",
"key",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"server",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"key",
")",
";",
"$",
"key",
"=",
"ucwords",
"(",
"strtolower",
"(",
"$",
"key",
")",
")",
";",
"$",
"key",
"=",
"str_replace",
"(",
"' '",
",",
"'-'",
",",
"$",
"key",
")",
";",
"$",
"headers",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"content",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"headers",
"[",
"$",
"content",
"[",
"$",
"key",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"headers",
";",
"}"
] | Makes an array of headers.
@param array $server Optional; null by default or empty array means
global $_SERVER. The source data
@return array The headers | [
"Makes",
"an",
"array",
"of",
"headers",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Factory/HeadersFactory.php#L25-L52 |
971 | sgoendoer/sonic | src/Request/URL.php | URL.getDomainFromURL | public static function getDomainFromURL($url)
{
$url = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
return explode('/', $url)[0];
} | php | public static function getDomainFromURL($url)
{
$url = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
return explode('/', $url)[0];
} | [
"public",
"static",
"function",
"getDomainFromURL",
"(",
"$",
"url",
")",
"{",
"$",
"url",
"=",
"str_replace",
"(",
"self",
"::",
"getProtocolFromURL",
"(",
"$",
"url",
")",
".",
"'://'",
",",
"''",
",",
"$",
"url",
")",
";",
"return",
"explode",
"(",
"'/'",
",",
"$",
"url",
")",
"[",
"0",
"]",
";",
"}"
] | Extracts the domain from a URL
@param $url string The URL
@return string The domain (with port) | [
"Extracts",
"the",
"domain",
"from",
"a",
"URL"
] | 2c32ebd78607dc3e8558f10a0b7bf881d37fc168 | https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Request/URL.php#L44-L49 |
972 | sgoendoer/sonic | src/Request/URL.php | URL.getPathFromURL | public static function getPathFromURL($url)
{
$path = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
$path = str_replace(self::getDomainFromURL($url), '', $path);
if($path == '') return '/';
return $path;
} | php | public static function getPathFromURL($url)
{
$path = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
$path = str_replace(self::getDomainFromURL($url), '', $path);
if($path == '') return '/';
return $path;
} | [
"public",
"static",
"function",
"getPathFromURL",
"(",
"$",
"url",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"self",
"::",
"getProtocolFromURL",
"(",
"$",
"url",
")",
".",
"'://'",
",",
"''",
",",
"$",
"url",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"self",
"::",
"getDomainFromURL",
"(",
"$",
"url",
")",
",",
"''",
",",
"$",
"path",
")",
";",
"if",
"(",
"$",
"path",
"==",
"''",
")",
"return",
"'/'",
";",
"return",
"$",
"path",
";",
"}"
] | Extracts the path from a URL
@param $url string The URL
@return string The path | [
"Extracts",
"the",
"path",
"from",
"a",
"URL"
] | 2c32ebd78607dc3e8558f10a0b7bf881d37fc168 | https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Request/URL.php#L58-L66 |
973 | qingbing/php-model | src/supports/validators/EmailValidator.php | EmailValidator.validateValue | public function validateValue($value)
{
// make sure string length is limited to avoid DOS attacks
$valid = is_string($value) && strlen($value) <= 254 && (preg_match($this->pattern, $value) || $this->allowName && preg_match($this->fullPattern, $value));
return $valid;
} | php | public function validateValue($value)
{
// make sure string length is limited to avoid DOS attacks
$valid = is_string($value) && strlen($value) <= 254 && (preg_match($this->pattern, $value) || $this->allowName && preg_match($this->fullPattern, $value));
return $valid;
} | [
"public",
"function",
"validateValue",
"(",
"$",
"value",
")",
"{",
"// make sure string length is limited to avoid DOS attacks\r",
"$",
"valid",
"=",
"is_string",
"(",
"$",
"value",
")",
"&&",
"strlen",
"(",
"$",
"value",
")",
"<=",
"254",
"&&",
"(",
"preg_match",
"(",
"$",
"this",
"->",
"pattern",
",",
"$",
"value",
")",
"||",
"$",
"this",
"->",
"allowName",
"&&",
"preg_match",
"(",
"$",
"this",
"->",
"fullPattern",
",",
"$",
"value",
")",
")",
";",
"return",
"$",
"valid",
";",
"}"
] | Validates a static value to see if it is a valid email.
@param mixed $value
@return bool | [
"Validates",
"a",
"static",
"value",
"to",
"see",
"if",
"it",
"is",
"a",
"valid",
"email",
"."
] | f685ca0500e444789ee77a0251b296a804c76f2d | https://github.com/qingbing/php-model/blob/f685ca0500e444789ee77a0251b296a804c76f2d/src/supports/validators/EmailValidator.php#L29-L34 |
974 | crisu83/yii-caviar | src/generators/ComponentGenerator.php | ComponentGenerator.validateClass | public function validateClass($attribute, $params)
{
$className = @\Yii::import($this->$attribute, true);
if (!is_string($className) || !$this->classExists($className)) {
$this->addError($attribute, "Class '$className' does not exist or has syntax error.");
} elseif (isset($params['extends'])
&& ltrim($className, '\\') !== ltrim($params['extends'], '\\')
&& !is_subclass_of($className, $params['extends'])) {
$this->addError('baseClass', "Class '$className' must extend from {$params['extends']}.");
}
} | php | public function validateClass($attribute, $params)
{
$className = @\Yii::import($this->$attribute, true);
if (!is_string($className) || !$this->classExists($className)) {
$this->addError($attribute, "Class '$className' does not exist or has syntax error.");
} elseif (isset($params['extends'])
&& ltrim($className, '\\') !== ltrim($params['extends'], '\\')
&& !is_subclass_of($className, $params['extends'])) {
$this->addError('baseClass', "Class '$className' must extend from {$params['extends']}.");
}
} | [
"public",
"function",
"validateClass",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"$",
"className",
"=",
"@",
"\\",
"Yii",
"::",
"import",
"(",
"$",
"this",
"->",
"$",
"attribute",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"className",
")",
"||",
"!",
"$",
"this",
"->",
"classExists",
"(",
"$",
"className",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"\"Class '$className' does not exist or has syntax error.\"",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"params",
"[",
"'extends'",
"]",
")",
"&&",
"ltrim",
"(",
"$",
"className",
",",
"'\\\\'",
")",
"!==",
"ltrim",
"(",
"$",
"params",
"[",
"'extends'",
"]",
",",
"'\\\\'",
")",
"&&",
"!",
"is_subclass_of",
"(",
"$",
"className",
",",
"$",
"params",
"[",
"'extends'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'baseClass'",
",",
"\"Class '$className' must extend from {$params['extends']}.\"",
")",
";",
"}",
"}"
] | Validates the base class to make sure that it exists and that it extends from the core class.
@param string $attribute the attribute to validate.
@param array $params validation parameters. | [
"Validates",
"the",
"base",
"class",
"to",
"make",
"sure",
"that",
"it",
"exists",
"and",
"that",
"it",
"extends",
"from",
"the",
"core",
"class",
"."
] | c85286b88e68558224e7f2ea7fff8f6975e46283 | https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/ComponentGenerator.php#L134-L145 |
975 | crisu83/yii-caviar | src/generators/ComponentGenerator.php | ComponentGenerator.validateReservedKeyword | public function validateReservedKeyword($attribute, $params)
{
if ($this->isReservedKeyword($this->$attribute)) {
$this->addError($attribute, $this->getAttributeLabel($attribute) . ' cannot be a reserved PHP keyword.');
}
} | php | public function validateReservedKeyword($attribute, $params)
{
if ($this->isReservedKeyword($this->$attribute)) {
$this->addError($attribute, $this->getAttributeLabel($attribute) . ' cannot be a reserved PHP keyword.');
}
} | [
"public",
"function",
"validateReservedKeyword",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isReservedKeyword",
"(",
"$",
"this",
"->",
"$",
"attribute",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"$",
"this",
"->",
"getAttributeLabel",
"(",
"$",
"attribute",
")",
".",
"' cannot be a reserved PHP keyword.'",
")",
";",
"}",
"}"
] | Validates an attribute to make sure it is not a reserved PHP keyword.
@param string $attribute the attribute to validate.
@param array $params validation parameters. | [
"Validates",
"an",
"attribute",
"to",
"make",
"sure",
"it",
"is",
"not",
"a",
"reserved",
"PHP",
"keyword",
"."
] | c85286b88e68558224e7f2ea7fff8f6975e46283 | https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/ComponentGenerator.php#L153-L158 |
976 | jeromeklam/freefw | src/FreeFW/Http/ApiParams.php | ApiParams.getApiModel | public function getApiModel(string $p_model) : \FreeFW\Core\Model
{
$class = str_replace('_', '::Model::', $p_model);
return \FreeFW\DI\DI::get($class);
} | php | public function getApiModel(string $p_model) : \FreeFW\Core\Model
{
$class = str_replace('_', '::Model::', $p_model);
return \FreeFW\DI\DI::get($class);
} | [
"public",
"function",
"getApiModel",
"(",
"string",
"$",
"p_model",
")",
":",
"\\",
"FreeFW",
"\\",
"Core",
"\\",
"Model",
"{",
"$",
"class",
"=",
"str_replace",
"(",
"'_'",
",",
"'::Model::'",
",",
"$",
"p_model",
")",
";",
"return",
"\\",
"FreeFW",
"\\",
"DI",
"\\",
"DI",
"::",
"get",
"(",
"$",
"class",
")",
";",
"}"
] | Get new model
@param string $p_model
@return \FreeFW\Core\Model | [
"Get",
"new",
"model"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Http/ApiParams.php#L55-L59 |
977 | joffreydemetz/database | src/Table/Table.php | Table.store | protected function store($updateNulls=false)
{
$row = TableRow::create();
foreach($this->getFields() as $fieldName => $fieldInfos){
$fieldValue = $this->row->get($fieldName);
switch($fieldInfos->Type){
case 'bigint':
case 'mediumint':
case 'smallint':
case 'tinyint':
$fieldValue = (int)$fieldValue;
break;
case 'datetime':
case 'timestamp':
if ( !$fieldValue ){
$fieldValue = $this->db->getNullDate(true);
}
break;
case 'date':
if ( !$fieldValue ){
$fieldValue = $this->db->getNullDate(false);
}
break;
case 'time':
if ( !$fieldValue ){
$fieldValue = '00:00:00';
}
break;
}
$row->set($fieldName, $fieldValue);
}
if ( $row->get($this->tbl_key) ){
$ret = $this->db->updateObject($this->tbl, $row, $this->tbl_key, $updateNulls);
}
else {
$ret = $this->db->insertObject($this->tbl, $row, $this->tbl_key);
$this->row->set($this->tbl_key, (int)$row->get($this->tbl_key));
}
if ( $ret ){
if ( $this->orderingAble() ){
$this->reorder( $this->getReorderConditions() );
}
return true;
}
return false;
} | php | protected function store($updateNulls=false)
{
$row = TableRow::create();
foreach($this->getFields() as $fieldName => $fieldInfos){
$fieldValue = $this->row->get($fieldName);
switch($fieldInfos->Type){
case 'bigint':
case 'mediumint':
case 'smallint':
case 'tinyint':
$fieldValue = (int)$fieldValue;
break;
case 'datetime':
case 'timestamp':
if ( !$fieldValue ){
$fieldValue = $this->db->getNullDate(true);
}
break;
case 'date':
if ( !$fieldValue ){
$fieldValue = $this->db->getNullDate(false);
}
break;
case 'time':
if ( !$fieldValue ){
$fieldValue = '00:00:00';
}
break;
}
$row->set($fieldName, $fieldValue);
}
if ( $row->get($this->tbl_key) ){
$ret = $this->db->updateObject($this->tbl, $row, $this->tbl_key, $updateNulls);
}
else {
$ret = $this->db->insertObject($this->tbl, $row, $this->tbl_key);
$this->row->set($this->tbl_key, (int)$row->get($this->tbl_key));
}
if ( $ret ){
if ( $this->orderingAble() ){
$this->reorder( $this->getReorderConditions() );
}
return true;
}
return false;
} | [
"protected",
"function",
"store",
"(",
"$",
"updateNulls",
"=",
"false",
")",
"{",
"$",
"row",
"=",
"TableRow",
"::",
"create",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFields",
"(",
")",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldInfos",
")",
"{",
"$",
"fieldValue",
"=",
"$",
"this",
"->",
"row",
"->",
"get",
"(",
"$",
"fieldName",
")",
";",
"switch",
"(",
"$",
"fieldInfos",
"->",
"Type",
")",
"{",
"case",
"'bigint'",
":",
"case",
"'mediumint'",
":",
"case",
"'smallint'",
":",
"case",
"'tinyint'",
":",
"$",
"fieldValue",
"=",
"(",
"int",
")",
"$",
"fieldValue",
";",
"break",
";",
"case",
"'datetime'",
":",
"case",
"'timestamp'",
":",
"if",
"(",
"!",
"$",
"fieldValue",
")",
"{",
"$",
"fieldValue",
"=",
"$",
"this",
"->",
"db",
"->",
"getNullDate",
"(",
"true",
")",
";",
"}",
"break",
";",
"case",
"'date'",
":",
"if",
"(",
"!",
"$",
"fieldValue",
")",
"{",
"$",
"fieldValue",
"=",
"$",
"this",
"->",
"db",
"->",
"getNullDate",
"(",
"false",
")",
";",
"}",
"break",
";",
"case",
"'time'",
":",
"if",
"(",
"!",
"$",
"fieldValue",
")",
"{",
"$",
"fieldValue",
"=",
"'00:00:00'",
";",
"}",
"break",
";",
"}",
"$",
"row",
"->",
"set",
"(",
"$",
"fieldName",
",",
"$",
"fieldValue",
")",
";",
"}",
"if",
"(",
"$",
"row",
"->",
"get",
"(",
"$",
"this",
"->",
"tbl_key",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"db",
"->",
"updateObject",
"(",
"$",
"this",
"->",
"tbl",
",",
"$",
"row",
",",
"$",
"this",
"->",
"tbl_key",
",",
"$",
"updateNulls",
")",
";",
"}",
"else",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"db",
"->",
"insertObject",
"(",
"$",
"this",
"->",
"tbl",
",",
"$",
"row",
",",
"$",
"this",
"->",
"tbl_key",
")",
";",
"$",
"this",
"->",
"row",
"->",
"set",
"(",
"$",
"this",
"->",
"tbl_key",
",",
"(",
"int",
")",
"$",
"row",
"->",
"get",
"(",
"$",
"this",
"->",
"tbl_key",
")",
")",
";",
"}",
"if",
"(",
"$",
"ret",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"orderingAble",
"(",
")",
")",
"{",
"$",
"this",
"->",
"reorder",
"(",
"$",
"this",
"->",
"getReorderConditions",
"(",
")",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Store the record
@param bool $updateNulls True to update properties that are null
@return bool True if the record was successfully stored. | [
"Store",
"the",
"record"
] | 627ef404914c06427159322da50700c1f2610a13 | https://github.com/joffreydemetz/database/blob/627ef404914c06427159322da50700c1f2610a13/src/Table/Table.php#L523-L577 |
978 | joffreydemetz/database | src/Table/Table.php | Table.hasBeenModified | protected function hasBeenModified(TableRow $oldRow)
{
$diff = $this->row->diff($oldRow);
$this->hasBeenModified = ( count($diff) > 0 );
return $this->hasBeenModified;
} | php | protected function hasBeenModified(TableRow $oldRow)
{
$diff = $this->row->diff($oldRow);
$this->hasBeenModified = ( count($diff) > 0 );
return $this->hasBeenModified;
} | [
"protected",
"function",
"hasBeenModified",
"(",
"TableRow",
"$",
"oldRow",
")",
"{",
"$",
"diff",
"=",
"$",
"this",
"->",
"row",
"->",
"diff",
"(",
"$",
"oldRow",
")",
";",
"$",
"this",
"->",
"hasBeenModified",
"=",
"(",
"count",
"(",
"$",
"diff",
")",
">",
"0",
")",
";",
"return",
"$",
"this",
"->",
"hasBeenModified",
";",
"}"
] | Chec if the record has been modified.
@param array $oldValues Key/Value pairs of old property values
@return bool True for a new record or if no modifications were found. | [
"Chec",
"if",
"the",
"record",
"has",
"been",
"modified",
"."
] | 627ef404914c06427159322da50700c1f2610a13 | https://github.com/joffreydemetz/database/blob/627ef404914c06427159322da50700c1f2610a13/src/Table/Table.php#L877-L882 |
979 | joffreydemetz/database | src/Table/Table.php | Table.getFields | protected function getFields()
{
$fields = $this->db->getTableColumns($this->tbl);
if ( empty($fields) ){
throw new TableException('Table columns not found');
}
return $fields;
} | php | protected function getFields()
{
$fields = $this->db->getTableColumns($this->tbl);
if ( empty($fields) ){
throw new TableException('Table columns not found');
}
return $fields;
} | [
"protected",
"function",
"getFields",
"(",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"db",
"->",
"getTableColumns",
"(",
"$",
"this",
"->",
"tbl",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"throw",
"new",
"TableException",
"(",
"'Table columns not found'",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
] | Get the object fields from database table columns
@return array The list of table properties | [
"Get",
"the",
"object",
"fields",
"from",
"database",
"table",
"columns"
] | 627ef404914c06427159322da50700c1f2610a13 | https://github.com/joffreydemetz/database/blob/627ef404914c06427159322da50700c1f2610a13/src/Table/Table.php#L889-L897 |
980 | joffreydemetz/database | src/Table/Table.php | Table.setFieldsTypeByName | protected function setFieldsTypeByName()
{
foreach($this->getFields() as $fieldName => $fieldInfos){
$v = $this->row->get($fieldName);
switch($fieldInfos->Type){
case 'bigint':
case 'mediumint':
case 'smallint':
case 'tinyint':
case 'int':
$this->row->set($fieldName, (int)$v);
break;
case 'datetime':
case 'timestamp':
if ( $v === $this->db->getNullDate(true) ){
$this->row->set($fieldName, '');
}
break;
case 'date':
if ( $v === $this->db->getNullDate(false) ){
$this->row->set($fieldName, '');
}
break;
case 'time':
if ( $v === '00:00:00' ){
$this->row->set($fieldName, '');
}
break;
}
if ( $fieldName === 'published' ){
$this->row->set($fieldName, (bool)$v);
}
}
} | php | protected function setFieldsTypeByName()
{
foreach($this->getFields() as $fieldName => $fieldInfos){
$v = $this->row->get($fieldName);
switch($fieldInfos->Type){
case 'bigint':
case 'mediumint':
case 'smallint':
case 'tinyint':
case 'int':
$this->row->set($fieldName, (int)$v);
break;
case 'datetime':
case 'timestamp':
if ( $v === $this->db->getNullDate(true) ){
$this->row->set($fieldName, '');
}
break;
case 'date':
if ( $v === $this->db->getNullDate(false) ){
$this->row->set($fieldName, '');
}
break;
case 'time':
if ( $v === '00:00:00' ){
$this->row->set($fieldName, '');
}
break;
}
if ( $fieldName === 'published' ){
$this->row->set($fieldName, (bool)$v);
}
}
} | [
"protected",
"function",
"setFieldsTypeByName",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getFields",
"(",
")",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldInfos",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"row",
"->",
"get",
"(",
"$",
"fieldName",
")",
";",
"switch",
"(",
"$",
"fieldInfos",
"->",
"Type",
")",
"{",
"case",
"'bigint'",
":",
"case",
"'mediumint'",
":",
"case",
"'smallint'",
":",
"case",
"'tinyint'",
":",
"case",
"'int'",
":",
"$",
"this",
"->",
"row",
"->",
"set",
"(",
"$",
"fieldName",
",",
"(",
"int",
")",
"$",
"v",
")",
";",
"break",
";",
"case",
"'datetime'",
":",
"case",
"'timestamp'",
":",
"if",
"(",
"$",
"v",
"===",
"$",
"this",
"->",
"db",
"->",
"getNullDate",
"(",
"true",
")",
")",
"{",
"$",
"this",
"->",
"row",
"->",
"set",
"(",
"$",
"fieldName",
",",
"''",
")",
";",
"}",
"break",
";",
"case",
"'date'",
":",
"if",
"(",
"$",
"v",
"===",
"$",
"this",
"->",
"db",
"->",
"getNullDate",
"(",
"false",
")",
")",
"{",
"$",
"this",
"->",
"row",
"->",
"set",
"(",
"$",
"fieldName",
",",
"''",
")",
";",
"}",
"break",
";",
"case",
"'time'",
":",
"if",
"(",
"$",
"v",
"===",
"'00:00:00'",
")",
"{",
"$",
"this",
"->",
"row",
"->",
"set",
"(",
"$",
"fieldName",
",",
"''",
")",
";",
"}",
"break",
";",
"}",
"if",
"(",
"$",
"fieldName",
"===",
"'published'",
")",
"{",
"$",
"this",
"->",
"row",
"->",
"set",
"(",
"$",
"fieldName",
",",
"(",
"bool",
")",
"$",
"v",
")",
";",
"}",
"}",
"}"
] | Set data type for known fields
@return void | [
"Set",
"data",
"type",
"for",
"known",
"fields"
] | 627ef404914c06427159322da50700c1f2610a13 | https://github.com/joffreydemetz/database/blob/627ef404914c06427159322da50700c1f2610a13/src/Table/Table.php#L914-L952 |
981 | joffreydemetz/database | src/Table/Table.php | Table.realPkSelection | protected function realPkSelection(&$pk)
{
if ( null === $pk ){
$pk = $this->row->get($this->tbl_key);
}
if ( null === $pk ){
$this->setError( DatabaseHelper::getTranslation('NO_ITEM_SELECTED') );
return false;
}
return true;
} | php | protected function realPkSelection(&$pk)
{
if ( null === $pk ){
$pk = $this->row->get($this->tbl_key);
}
if ( null === $pk ){
$this->setError( DatabaseHelper::getTranslation('NO_ITEM_SELECTED') );
return false;
}
return true;
} | [
"protected",
"function",
"realPkSelection",
"(",
"&",
"$",
"pk",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"pk",
")",
"{",
"$",
"pk",
"=",
"$",
"this",
"->",
"row",
"->",
"get",
"(",
"$",
"this",
"->",
"tbl_key",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"pk",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"DatabaseHelper",
"::",
"getTranslation",
"(",
"'NO_ITEM_SELECTED'",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Set the real pk request value
If no pk was requested it check if a row is currently loaded
@return bool | [
"Set",
"the",
"real",
"pk",
"request",
"value"
] | 627ef404914c06427159322da50700c1f2610a13 | https://github.com/joffreydemetz/database/blob/627ef404914c06427159322da50700c1f2610a13/src/Table/Table.php#L961-L973 |
982 | Flowpack/Flowpack.SingleSignOn.Client | Classes/Flowpack/SingleSignOn/Client/Controller/AuthenticationController.php | AuthenticationController.callbackAction | public function callbackAction($callbackUri) {
try {
$this->authenticationManager->authenticate();
} catch (\TYPO3\Flow\Security\Exception\AuthenticationRequiredException $exception) {
$authenticationException = $exception;
}
if ($this->authenticationManager->isAuthenticated()) {
$storedRequest = $this->securityContext->getInterceptedRequest();
if ($storedRequest !== NULL) {
$this->securityContext->setInterceptedRequest(NULL);
$this->redirectToRequest($storedRequest);
} else {
// TODO Do we have to check the URI?
$this->redirectToUri($callbackUri);
}
} else {
throw new \Flowpack\SingleSignOn\Client\Exception('Could not authenticate in callbackAction triggered by the SSO server.', 1366613161, (isset($authenticationException) ? $authenticationException : NULL));
}
} | php | public function callbackAction($callbackUri) {
try {
$this->authenticationManager->authenticate();
} catch (\TYPO3\Flow\Security\Exception\AuthenticationRequiredException $exception) {
$authenticationException = $exception;
}
if ($this->authenticationManager->isAuthenticated()) {
$storedRequest = $this->securityContext->getInterceptedRequest();
if ($storedRequest !== NULL) {
$this->securityContext->setInterceptedRequest(NULL);
$this->redirectToRequest($storedRequest);
} else {
// TODO Do we have to check the URI?
$this->redirectToUri($callbackUri);
}
} else {
throw new \Flowpack\SingleSignOn\Client\Exception('Could not authenticate in callbackAction triggered by the SSO server.', 1366613161, (isset($authenticationException) ? $authenticationException : NULL));
}
} | [
"public",
"function",
"callbackAction",
"(",
"$",
"callbackUri",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"authenticationManager",
"->",
"authenticate",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"TYPO3",
"\\",
"Flow",
"\\",
"Security",
"\\",
"Exception",
"\\",
"AuthenticationRequiredException",
"$",
"exception",
")",
"{",
"$",
"authenticationException",
"=",
"$",
"exception",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"authenticationManager",
"->",
"isAuthenticated",
"(",
")",
")",
"{",
"$",
"storedRequest",
"=",
"$",
"this",
"->",
"securityContext",
"->",
"getInterceptedRequest",
"(",
")",
";",
"if",
"(",
"$",
"storedRequest",
"!==",
"NULL",
")",
"{",
"$",
"this",
"->",
"securityContext",
"->",
"setInterceptedRequest",
"(",
"NULL",
")",
";",
"$",
"this",
"->",
"redirectToRequest",
"(",
"$",
"storedRequest",
")",
";",
"}",
"else",
"{",
"// TODO Do we have to check the URI?",
"$",
"this",
"->",
"redirectToUri",
"(",
"$",
"callbackUri",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Flowpack",
"\\",
"SingleSignOn",
"\\",
"Client",
"\\",
"Exception",
"(",
"'Could not authenticate in callbackAction triggered by the SSO server.'",
",",
"1366613161",
",",
"(",
"isset",
"(",
"$",
"authenticationException",
")",
"?",
"$",
"authenticationException",
":",
"NULL",
")",
")",
";",
"}",
"}"
] | Receive an SSO authentication callback and trigger authentication
through the SingleSignOnProvider.
GET /sso/authentication/callback?...
@param string $callbackUri
@return void | [
"Receive",
"an",
"SSO",
"authentication",
"callback",
"and",
"trigger",
"authentication",
"through",
"the",
"SingleSignOnProvider",
"."
] | 0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00 | https://github.com/Flowpack/Flowpack.SingleSignOn.Client/blob/0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00/Classes/Flowpack/SingleSignOn/Client/Controller/AuthenticationController.php#L41-L60 |
983 | phramz/staticfiles | src/Util/FileUtil.php | FileUtil.guessMimeType | public static function guessMimeType($filename, $default = 'application/octed-stream')
{
$guesser = new FileExtMimeTypeGuesser();
$mime = $guesser->guess($filename);
if (null === $mime) {
try {
$mime = MimeTypeGuesser::getInstance()->guess($filename);
} catch (FileNotFoundException $ex) {
// dont care
}
}
return null === $mime ? $default : $mime;
} | php | public static function guessMimeType($filename, $default = 'application/octed-stream')
{
$guesser = new FileExtMimeTypeGuesser();
$mime = $guesser->guess($filename);
if (null === $mime) {
try {
$mime = MimeTypeGuesser::getInstance()->guess($filename);
} catch (FileNotFoundException $ex) {
// dont care
}
}
return null === $mime ? $default : $mime;
} | [
"public",
"static",
"function",
"guessMimeType",
"(",
"$",
"filename",
",",
"$",
"default",
"=",
"'application/octed-stream'",
")",
"{",
"$",
"guesser",
"=",
"new",
"FileExtMimeTypeGuesser",
"(",
")",
";",
"$",
"mime",
"=",
"$",
"guesser",
"->",
"guess",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"null",
"===",
"$",
"mime",
")",
"{",
"try",
"{",
"$",
"mime",
"=",
"MimeTypeGuesser",
"::",
"getInstance",
"(",
")",
"->",
"guess",
"(",
"$",
"filename",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"$",
"ex",
")",
"{",
"// dont care",
"}",
"}",
"return",
"null",
"===",
"$",
"mime",
"?",
"$",
"default",
":",
"$",
"mime",
";",
"}"
] | Guesses the mimetype by the files extension ... or default
@param string $filename
@param string $default
@return string | [
"Guesses",
"the",
"mimetype",
"by",
"the",
"files",
"extension",
"...",
"or",
"default"
] | e636d75f5ae5d2a8a0f625f488199276d34af345 | https://github.com/phramz/staticfiles/blob/e636d75f5ae5d2a8a0f625f488199276d34af345/src/Util/FileUtil.php#L16-L30 |
984 | phramz/staticfiles | src/Util/FileUtil.php | FileUtil.containsDotfile | public static function containsDotfile($path)
{
$path = Path::canonicalize(Path::makeAbsolute($path, '/'));
return preg_match('#/\.#', $path) == 1;
} | php | public static function containsDotfile($path)
{
$path = Path::canonicalize(Path::makeAbsolute($path, '/'));
return preg_match('#/\.#', $path) == 1;
} | [
"public",
"static",
"function",
"containsDotfile",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"Path",
"::",
"canonicalize",
"(",
"Path",
"::",
"makeAbsolute",
"(",
"$",
"path",
",",
"'/'",
")",
")",
";",
"return",
"preg_match",
"(",
"'#/\\.#'",
",",
"$",
"path",
")",
"==",
"1",
";",
"}"
] | Returns true if the path conatains any dotfile access
@param string $path
@return bool | [
"Returns",
"true",
"if",
"the",
"path",
"conatains",
"any",
"dotfile",
"access"
] | e636d75f5ae5d2a8a0f625f488199276d34af345 | https://github.com/phramz/staticfiles/blob/e636d75f5ae5d2a8a0f625f488199276d34af345/src/Util/FileUtil.php#L37-L42 |
985 | joegreen88/zf1-components-base | src/Zend/Loader/Autoloader/Resource.php | Zend_Loader_Autoloader_Resource.getClassPath | public function getClassPath($class)
{
$segments = explode('_', $class);
$namespaceTopLevel = $this->getNamespace();
$namespace = '';
if (!empty($namespaceTopLevel)) {
$namespace = array();
$topLevelSegments = count(explode('_', $namespaceTopLevel));
for ($i = 0; $i < $topLevelSegments; $i++) {
$namespace[] = array_shift($segments);
}
$namespace = implode('_', $namespace);
if ($namespace != $namespaceTopLevel) {
// wrong prefix? we're done
return false;
}
}
if (count($segments) < 2) {
// assumes all resources have a component and class name, minimum
return false;
}
$final = array_pop($segments);
$component = $namespace;
$lastMatch = false;
do {
$segment = array_shift($segments);
$component .= empty($component) ? $segment : '_' . $segment;
if (isset($this->_components[$component])) {
$lastMatch = $component;
}
} while (count($segments));
if (!$lastMatch) {
return false;
}
$final = substr($class, strlen($lastMatch) + 1);
$path = $this->_components[$lastMatch];
$classPath = $path . '/' . str_replace('_', '/', $final) . '.php';
if (Zend_Loader::isReadable($classPath)) {
return $classPath;
}
return false;
} | php | public function getClassPath($class)
{
$segments = explode('_', $class);
$namespaceTopLevel = $this->getNamespace();
$namespace = '';
if (!empty($namespaceTopLevel)) {
$namespace = array();
$topLevelSegments = count(explode('_', $namespaceTopLevel));
for ($i = 0; $i < $topLevelSegments; $i++) {
$namespace[] = array_shift($segments);
}
$namespace = implode('_', $namespace);
if ($namespace != $namespaceTopLevel) {
// wrong prefix? we're done
return false;
}
}
if (count($segments) < 2) {
// assumes all resources have a component and class name, minimum
return false;
}
$final = array_pop($segments);
$component = $namespace;
$lastMatch = false;
do {
$segment = array_shift($segments);
$component .= empty($component) ? $segment : '_' . $segment;
if (isset($this->_components[$component])) {
$lastMatch = $component;
}
} while (count($segments));
if (!$lastMatch) {
return false;
}
$final = substr($class, strlen($lastMatch) + 1);
$path = $this->_components[$lastMatch];
$classPath = $path . '/' . str_replace('_', '/', $final) . '.php';
if (Zend_Loader::isReadable($classPath)) {
return $classPath;
}
return false;
} | [
"public",
"function",
"getClassPath",
"(",
"$",
"class",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"'_'",
",",
"$",
"class",
")",
";",
"$",
"namespaceTopLevel",
"=",
"$",
"this",
"->",
"getNamespace",
"(",
")",
";",
"$",
"namespace",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"namespaceTopLevel",
")",
")",
"{",
"$",
"namespace",
"=",
"array",
"(",
")",
";",
"$",
"topLevelSegments",
"=",
"count",
"(",
"explode",
"(",
"'_'",
",",
"$",
"namespaceTopLevel",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"topLevelSegments",
";",
"$",
"i",
"++",
")",
"{",
"$",
"namespace",
"[",
"]",
"=",
"array_shift",
"(",
"$",
"segments",
")",
";",
"}",
"$",
"namespace",
"=",
"implode",
"(",
"'_'",
",",
"$",
"namespace",
")",
";",
"if",
"(",
"$",
"namespace",
"!=",
"$",
"namespaceTopLevel",
")",
"{",
"// wrong prefix? we're done",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"segments",
")",
"<",
"2",
")",
"{",
"// assumes all resources have a component and class name, minimum",
"return",
"false",
";",
"}",
"$",
"final",
"=",
"array_pop",
"(",
"$",
"segments",
")",
";",
"$",
"component",
"=",
"$",
"namespace",
";",
"$",
"lastMatch",
"=",
"false",
";",
"do",
"{",
"$",
"segment",
"=",
"array_shift",
"(",
"$",
"segments",
")",
";",
"$",
"component",
".=",
"empty",
"(",
"$",
"component",
")",
"?",
"$",
"segment",
":",
"'_'",
".",
"$",
"segment",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_components",
"[",
"$",
"component",
"]",
")",
")",
"{",
"$",
"lastMatch",
"=",
"$",
"component",
";",
"}",
"}",
"while",
"(",
"count",
"(",
"$",
"segments",
")",
")",
";",
"if",
"(",
"!",
"$",
"lastMatch",
")",
"{",
"return",
"false",
";",
"}",
"$",
"final",
"=",
"substr",
"(",
"$",
"class",
",",
"strlen",
"(",
"$",
"lastMatch",
")",
"+",
"1",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"_components",
"[",
"$",
"lastMatch",
"]",
";",
"$",
"classPath",
"=",
"$",
"path",
".",
"'/'",
".",
"str_replace",
"(",
"'_'",
",",
"'/'",
",",
"$",
"final",
")",
".",
"'.php'",
";",
"if",
"(",
"Zend_Loader",
"::",
"isReadable",
"(",
"$",
"classPath",
")",
")",
"{",
"return",
"$",
"classPath",
";",
"}",
"return",
"false",
";",
"}"
] | Helper method to calculate the correct class path
@param string $class
@return False if not matched other wise the correct path | [
"Helper",
"method",
"to",
"calculate",
"the",
"correct",
"class",
"path"
] | d4591a2234c2db3094b54c08bcdc4303f7bf4819 | https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader/Resource.php#L140-L188 |
986 | joegreen88/zf1-components-base | src/Zend/Loader/Autoloader/Resource.php | Zend_Loader_Autoloader_Resource.setOptions | public function setOptions(array $options)
{
// Set namespace first, see ZF-10836
if (isset($options['namespace'])) {
$this->setNamespace($options['namespace']);
unset($options['namespace']);
}
$methods = get_class_methods($this);
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (in_array($method, $methods)) {
$this->$method($value);
}
}
return $this;
} | php | public function setOptions(array $options)
{
// Set namespace first, see ZF-10836
if (isset($options['namespace'])) {
$this->setNamespace($options['namespace']);
unset($options['namespace']);
}
$methods = get_class_methods($this);
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (in_array($method, $methods)) {
$this->$method($value);
}
}
return $this;
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
"{",
"// Set namespace first, see ZF-10836",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'namespace'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setNamespace",
"(",
"$",
"options",
"[",
"'namespace'",
"]",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'namespace'",
"]",
")",
";",
"}",
"$",
"methods",
"=",
"get_class_methods",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"method",
",",
"$",
"methods",
")",
")",
"{",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Set class state from options
@param array $options
@return Zend_Loader_Autoloader_Resource | [
"Set",
"class",
"state",
"from",
"options"
] | d4591a2234c2db3094b54c08bcdc4303f7bf4819 | https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader/Resource.php#L211-L227 |
987 | joegreen88/zf1-components-base | src/Zend/Loader/Autoloader/Resource.php | Zend_Loader_Autoloader_Resource.addResourceType | public function addResourceType($type, $path, $namespace = null)
{
$type = strtolower($type);
if (!isset($this->_resourceTypes[$type])) {
if (null === $namespace) {
throw new Zend_Loader_Exception('Initial definition of a resource type must include a namespace');
}
$namespaceTopLevel = $this->getNamespace();
$namespace = ucfirst(trim($namespace, '_'));
$this->_resourceTypes[$type] = array(
'namespace' => empty($namespaceTopLevel) ? $namespace : $namespaceTopLevel . '_' . $namespace,
);
}
if (!is_string($path)) {
throw new Zend_Loader_Exception('Invalid path specification provided; must be string');
}
$this->_resourceTypes[$type]['path'] = $this->getBasePath() . '/' . rtrim($path, '\/');
$component = $this->_resourceTypes[$type]['namespace'];
$this->_components[$component] = $this->_resourceTypes[$type]['path'];
return $this;
} | php | public function addResourceType($type, $path, $namespace = null)
{
$type = strtolower($type);
if (!isset($this->_resourceTypes[$type])) {
if (null === $namespace) {
throw new Zend_Loader_Exception('Initial definition of a resource type must include a namespace');
}
$namespaceTopLevel = $this->getNamespace();
$namespace = ucfirst(trim($namespace, '_'));
$this->_resourceTypes[$type] = array(
'namespace' => empty($namespaceTopLevel) ? $namespace : $namespaceTopLevel . '_' . $namespace,
);
}
if (!is_string($path)) {
throw new Zend_Loader_Exception('Invalid path specification provided; must be string');
}
$this->_resourceTypes[$type]['path'] = $this->getBasePath() . '/' . rtrim($path, '\/');
$component = $this->_resourceTypes[$type]['namespace'];
$this->_components[$component] = $this->_resourceTypes[$type]['path'];
return $this;
} | [
"public",
"function",
"addResourceType",
"(",
"$",
"type",
",",
"$",
"path",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_resourceTypes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"namespace",
")",
"{",
"throw",
"new",
"Zend_Loader_Exception",
"(",
"'Initial definition of a resource type must include a namespace'",
")",
";",
"}",
"$",
"namespaceTopLevel",
"=",
"$",
"this",
"->",
"getNamespace",
"(",
")",
";",
"$",
"namespace",
"=",
"ucfirst",
"(",
"trim",
"(",
"$",
"namespace",
",",
"'_'",
")",
")",
";",
"$",
"this",
"->",
"_resourceTypes",
"[",
"$",
"type",
"]",
"=",
"array",
"(",
"'namespace'",
"=>",
"empty",
"(",
"$",
"namespaceTopLevel",
")",
"?",
"$",
"namespace",
":",
"$",
"namespaceTopLevel",
".",
"'_'",
".",
"$",
"namespace",
",",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"Zend_Loader_Exception",
"(",
"'Invalid path specification provided; must be string'",
")",
";",
"}",
"$",
"this",
"->",
"_resourceTypes",
"[",
"$",
"type",
"]",
"[",
"'path'",
"]",
"=",
"$",
"this",
"->",
"getBasePath",
"(",
")",
".",
"'/'",
".",
"rtrim",
"(",
"$",
"path",
",",
"'\\/'",
")",
";",
"$",
"component",
"=",
"$",
"this",
"->",
"_resourceTypes",
"[",
"$",
"type",
"]",
"[",
"'namespace'",
"]",
";",
"$",
"this",
"->",
"_components",
"[",
"$",
"component",
"]",
"=",
"$",
"this",
"->",
"_resourceTypes",
"[",
"$",
"type",
"]",
"[",
"'path'",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Add resource type
@param string $type identifier for the resource type being loaded
@param string $path path relative to resource base path containing the resource types
@param null|string $namespace sub-component namespace to append to base namespace that qualifies this resource type
@return Zend_Loader_Autoloader_Resource | [
"Add",
"resource",
"type"
] | d4591a2234c2db3094b54c08bcdc4303f7bf4819 | https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader/Resource.php#L281-L304 |
988 | joegreen88/zf1-components-base | src/Zend/Loader/Autoloader/Resource.php | Zend_Loader_Autoloader_Resource.addResourceTypes | public function addResourceTypes(array $types)
{
foreach ($types as $type => $spec) {
if (!is_array($spec)) {
throw new Zend_Loader_Exception('addResourceTypes() expects an array of arrays');
}
if (!isset($spec['path'])) {
throw new Zend_Loader_Exception('addResourceTypes() expects each array to include a paths element');
}
$paths = $spec['path'];
$namespace = null;
if (isset($spec['namespace'])) {
$namespace = $spec['namespace'];
}
$this->addResourceType($type, $paths, $namespace);
}
return $this;
} | php | public function addResourceTypes(array $types)
{
foreach ($types as $type => $spec) {
if (!is_array($spec)) {
throw new Zend_Loader_Exception('addResourceTypes() expects an array of arrays');
}
if (!isset($spec['path'])) {
throw new Zend_Loader_Exception('addResourceTypes() expects each array to include a paths element');
}
$paths = $spec['path'];
$namespace = null;
if (isset($spec['namespace'])) {
$namespace = $spec['namespace'];
}
$this->addResourceType($type, $paths, $namespace);
}
return $this;
} | [
"public",
"function",
"addResourceTypes",
"(",
"array",
"$",
"types",
")",
"{",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
"=>",
"$",
"spec",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"spec",
")",
")",
"{",
"throw",
"new",
"Zend_Loader_Exception",
"(",
"'addResourceTypes() expects an array of arrays'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"spec",
"[",
"'path'",
"]",
")",
")",
"{",
"throw",
"new",
"Zend_Loader_Exception",
"(",
"'addResourceTypes() expects each array to include a paths element'",
")",
";",
"}",
"$",
"paths",
"=",
"$",
"spec",
"[",
"'path'",
"]",
";",
"$",
"namespace",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"spec",
"[",
"'namespace'",
"]",
")",
")",
"{",
"$",
"namespace",
"=",
"$",
"spec",
"[",
"'namespace'",
"]",
";",
"}",
"$",
"this",
"->",
"addResourceType",
"(",
"$",
"type",
",",
"$",
"paths",
",",
"$",
"namespace",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add multiple resources at once
$types should be an associative array of resource type => specification
pairs. Each specification should be an associative array containing
minimally the 'path' key (specifying the path relative to the resource
base path) and optionally the 'namespace' key (indicating the subcomponent
namespace to append to the resource namespace).
As an example:
<code>
$loader->addResourceTypes(array(
'model' => array(
'path' => 'models',
'namespace' => 'Model',
),
'form' => array(
'path' => 'forms',
'namespace' => 'Form',
),
));
</code>
@param array $types
@return Zend_Loader_Autoloader_Resource | [
"Add",
"multiple",
"resources",
"at",
"once"
] | d4591a2234c2db3094b54c08bcdc4303f7bf4819 | https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader/Resource.php#L332-L351 |
989 | joegreen88/zf1-components-base | src/Zend/Loader/Autoloader/Resource.php | Zend_Loader_Autoloader_Resource.removeResourceType | public function removeResourceType($type)
{
if ($this->hasResourceType($type)) {
$namespace = $this->_resourceTypes[$type]['namespace'];
unset($this->_components[$namespace]);
unset($this->_resourceTypes[$type]);
}
return $this;
} | php | public function removeResourceType($type)
{
if ($this->hasResourceType($type)) {
$namespace = $this->_resourceTypes[$type]['namespace'];
unset($this->_components[$namespace]);
unset($this->_resourceTypes[$type]);
}
return $this;
} | [
"public",
"function",
"removeResourceType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasResourceType",
"(",
"$",
"type",
")",
")",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"_resourceTypes",
"[",
"$",
"type",
"]",
"[",
"'namespace'",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"_components",
"[",
"$",
"namespace",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_resourceTypes",
"[",
"$",
"type",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove the requested resource type
@param string $type
@return Zend_Loader_Autoloader_Resource | [
"Remove",
"the",
"requested",
"resource",
"type"
] | d4591a2234c2db3094b54c08bcdc4303f7bf4819 | https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader/Resource.php#L393-L401 |
990 | joegreen88/zf1-components-base | src/Zend/Loader/Autoloader/Resource.php | Zend_Loader_Autoloader_Resource.load | public function load($resource, $type = null)
{
if (null === $type) {
$type = $this->getDefaultResourceType();
if (empty($type)) {
throw new Zend_Loader_Exception('No resource type specified');
}
}
if (!$this->hasResourceType($type)) {
throw new Zend_Loader_Exception('Invalid resource type specified');
}
$namespace = $this->_resourceTypes[$type]['namespace'];
$class = $namespace . '_' . ucfirst($resource);
if (!isset($this->_resources[$class])) {
$this->_resources[$class] = new $class;
}
return $this->_resources[$class];
} | php | public function load($resource, $type = null)
{
if (null === $type) {
$type = $this->getDefaultResourceType();
if (empty($type)) {
throw new Zend_Loader_Exception('No resource type specified');
}
}
if (!$this->hasResourceType($type)) {
throw new Zend_Loader_Exception('Invalid resource type specified');
}
$namespace = $this->_resourceTypes[$type]['namespace'];
$class = $namespace . '_' . ucfirst($resource);
if (!isset($this->_resources[$class])) {
$this->_resources[$class] = new $class;
}
return $this->_resources[$class];
} | [
"public",
"function",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getDefaultResourceType",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"Zend_Loader_Exception",
"(",
"'No resource type specified'",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasResourceType",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"Zend_Loader_Exception",
"(",
"'Invalid resource type specified'",
")",
";",
"}",
"$",
"namespace",
"=",
"$",
"this",
"->",
"_resourceTypes",
"[",
"$",
"type",
"]",
"[",
"'namespace'",
"]",
";",
"$",
"class",
"=",
"$",
"namespace",
".",
"'_'",
".",
"ucfirst",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_resources",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_resources",
"[",
"$",
"class",
"]",
"=",
"new",
"$",
"class",
";",
"}",
"return",
"$",
"this",
"->",
"_resources",
"[",
"$",
"class",
"]",
";",
"}"
] | Object registry and factory
Loads the requested resource of type $type (or uses the default resource
type if none provided). If the resource has been loaded previously,
returns the previous instance; otherwise, instantiates it.
@param string $resource
@param string $type
@return object
@throws Zend_Loader_Exception if resource type not specified or invalid | [
"Object",
"registry",
"and",
"factory"
] | d4591a2234c2db3094b54c08bcdc4303f7bf4819 | https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader/Resource.php#L451-L470 |
991 | frogsystem/legacy-bridge | src/BridgeApplication.php | BridgeApplication.setDebugMode | protected function setDebugMode($debug)
{
error_reporting(0);
// Enable error_reporting
if ($debug) {
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
}
} | php | protected function setDebugMode($debug)
{
error_reporting(0);
// Enable error_reporting
if ($debug) {
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
}
} | [
"protected",
"function",
"setDebugMode",
"(",
"$",
"debug",
")",
"{",
"error_reporting",
"(",
"0",
")",
";",
"// Enable error_reporting",
"if",
"(",
"$",
"debug",
")",
"{",
"error_reporting",
"(",
"E_ALL",
")",
";",
"ini_set",
"(",
"'display_errors'",
",",
"true",
")",
";",
"ini_set",
"(",
"'display_startup_errors'",
",",
"true",
")",
";",
"}",
"}"
] | Set old debug mode
@param $debug | [
"Set",
"old",
"debug",
"mode"
] | a4ea3bea701e2b737c119a5d89b7778e8745658c | https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/BridgeApplication.php#L46-L55 |
992 | lciolecki/zf-extensions-library | library/Extlib/Cli/CliAbstract.php | CliAbstract.buildErrors | protected function buildErrors()
{
if ($this->hasErrors()) {
echo implode(PHP_EOL, $this->getErrors());
echo PHP_EOL, $this->opts->getUsageMessage();
}
return $this;
} | php | protected function buildErrors()
{
if ($this->hasErrors()) {
echo implode(PHP_EOL, $this->getErrors());
echo PHP_EOL, $this->opts->getUsageMessage();
}
return $this;
} | [
"protected",
"function",
"buildErrors",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasErrors",
"(",
")",
")",
"{",
"echo",
"implode",
"(",
"PHP_EOL",
",",
"$",
"this",
"->",
"getErrors",
"(",
")",
")",
";",
"echo",
"PHP_EOL",
",",
"$",
"this",
"->",
"opts",
"->",
"getUsageMessage",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Method build and show error message
@return \Extlib\Cli\CliAbstract | [
"Method",
"build",
"and",
"show",
"error",
"message"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Cli/CliAbstract.php#L123-L131 |
993 | lciolecki/zf-extensions-library | library/Extlib/Cli/CliAbstract.php | CliAbstract.log | public function log($message, $priority, $extras = null)
{
if (null !== $this->getLogger()) {
$this->getLogger()->log($message, $priority, $extras);
}
return $this;
} | php | public function log($message, $priority, $extras = null)
{
if (null !== $this->getLogger()) {
$this->getLogger()->log($message, $priority, $extras);
}
return $this;
} | [
"public",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"priority",
",",
"$",
"extras",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"getLogger",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"$",
"message",
",",
"$",
"priority",
",",
"$",
"extras",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Alias for log on logger
@param string $message
@param int $priority
@param mixed $extras
@return \Extlib\Cli\CliAbstract | [
"Alias",
"for",
"log",
"on",
"logger"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Cli/CliAbstract.php#L229-L236 |
994 | nonetallt/jinitialize-core | src/ComposerScripts.php | ComposerScripts.generatePluginsManifest | public static function generatePluginsManifest(array $packages, string $outputPath, string $vendorDir = null)
{
$plugins = [];
foreach($packages as $package) {
/* Skip packages that do not define plugin in extra */
if(empty($package['extra']['jinitialize-plugin'])) continue;
/* Append plugin directory to info */
if(! is_null($vendorDir)) {
/* The directory where the plugin will be installed */
$path = $vendorDir .'/'. $package['name'];
$package['extra']['jinitialize-plugin']['path'] = $path;
}
$pluginInfo = $package['extra']['jinitialize-plugin'];
$plugins[] = $pluginInfo;
}
$content = '<?php return ' . var_export($plugins, true) . ';';
file_put_contents($outputPath, $content);
} | php | public static function generatePluginsManifest(array $packages, string $outputPath, string $vendorDir = null)
{
$plugins = [];
foreach($packages as $package) {
/* Skip packages that do not define plugin in extra */
if(empty($package['extra']['jinitialize-plugin'])) continue;
/* Append plugin directory to info */
if(! is_null($vendorDir)) {
/* The directory where the plugin will be installed */
$path = $vendorDir .'/'. $package['name'];
$package['extra']['jinitialize-plugin']['path'] = $path;
}
$pluginInfo = $package['extra']['jinitialize-plugin'];
$plugins[] = $pluginInfo;
}
$content = '<?php return ' . var_export($plugins, true) . ';';
file_put_contents($outputPath, $content);
} | [
"public",
"static",
"function",
"generatePluginsManifest",
"(",
"array",
"$",
"packages",
",",
"string",
"$",
"outputPath",
",",
"string",
"$",
"vendorDir",
"=",
"null",
")",
"{",
"$",
"plugins",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"package",
")",
"{",
"/* Skip packages that do not define plugin in extra */",
"if",
"(",
"empty",
"(",
"$",
"package",
"[",
"'extra'",
"]",
"[",
"'jinitialize-plugin'",
"]",
")",
")",
"continue",
";",
"/* Append plugin directory to info */",
"if",
"(",
"!",
"is_null",
"(",
"$",
"vendorDir",
")",
")",
"{",
"/* The directory where the plugin will be installed */",
"$",
"path",
"=",
"$",
"vendorDir",
".",
"'/'",
".",
"$",
"package",
"[",
"'name'",
"]",
";",
"$",
"package",
"[",
"'extra'",
"]",
"[",
"'jinitialize-plugin'",
"]",
"[",
"'path'",
"]",
"=",
"$",
"path",
";",
"}",
"$",
"pluginInfo",
"=",
"$",
"package",
"[",
"'extra'",
"]",
"[",
"'jinitialize-plugin'",
"]",
";",
"$",
"plugins",
"[",
"]",
"=",
"$",
"pluginInfo",
";",
"}",
"$",
"content",
"=",
"'<?php return '",
".",
"var_export",
"(",
"$",
"plugins",
",",
"true",
")",
".",
"';'",
";",
"file_put_contents",
"(",
"$",
"outputPath",
",",
"$",
"content",
")",
";",
"}"
] | Separate mehtod for testing puroposes | [
"Separate",
"mehtod",
"for",
"testing",
"puroposes"
] | 284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f | https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/ComposerScripts.php#L29-L51 |
995 | tekkla/core-html | Core/Html/Form/Traits/ValueTrait.php | ValueTrait.setValue | public function setValue($value)
{
switch (true) {
case ($this instanceof Select):
if (! is_array($value)) {
$value = (array) $value;
}
$this->value = $value;
break;
case ($this instanceof Textarea):
$this->inner = $value;
break;
default:
$this->attribute['value'] = $value;
break;
}
return $this;
} | php | public function setValue($value)
{
switch (true) {
case ($this instanceof Select):
if (! is_array($value)) {
$value = (array) $value;
}
$this->value = $value;
break;
case ($this instanceof Textarea):
$this->inner = $value;
break;
default:
$this->attribute['value'] = $value;
break;
}
return $this;
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"$",
"this",
"instanceof",
"Select",
")",
":",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"(",
"array",
")",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"break",
";",
"case",
"(",
"$",
"this",
"instanceof",
"Textarea",
")",
":",
"$",
"this",
"->",
"inner",
"=",
"$",
"value",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"attribute",
"[",
"'value'",
"]",
"=",
"$",
"value",
";",
"break",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets value attribute.
@param string|number $value | [
"Sets",
"value",
"attribute",
"."
] | 00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3 | https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Form/Traits/ValueTrait.php#L22-L41 |
996 | neonbug/meexo-common | src/Repositories/GoogleAnalyticsRepository.php | GoogleAnalyticsRepository.getProfileIdByTrackingId | protected function getProfileIdByTrackingId(&$analytics, $tracking_id)
{
$accounts = $analytics->management_accounts->listManagementAccounts();
foreach ($accounts->getItems() as $item)
{
$account_id = $item->getId();
if ($account_id != $tracking_id) continue;
$properties = $analytics->management_webproperties->listManagementWebproperties($account_id);
if (sizeof($properties->getItems()) > 0)
{
$items = $properties->getItems();
$first_property_id = $items[0]->getId();
$profiles = $analytics->management_profiles
->listManagementProfiles($account_id, $first_property_id);
if (sizeof($profiles->getItems()) > 0)
{
$items = $profiles->getItems();
return $items[0]->getId();
}
}
}
return null;
} | php | protected function getProfileIdByTrackingId(&$analytics, $tracking_id)
{
$accounts = $analytics->management_accounts->listManagementAccounts();
foreach ($accounts->getItems() as $item)
{
$account_id = $item->getId();
if ($account_id != $tracking_id) continue;
$properties = $analytics->management_webproperties->listManagementWebproperties($account_id);
if (sizeof($properties->getItems()) > 0)
{
$items = $properties->getItems();
$first_property_id = $items[0]->getId();
$profiles = $analytics->management_profiles
->listManagementProfiles($account_id, $first_property_id);
if (sizeof($profiles->getItems()) > 0)
{
$items = $profiles->getItems();
return $items[0]->getId();
}
}
}
return null;
} | [
"protected",
"function",
"getProfileIdByTrackingId",
"(",
"&",
"$",
"analytics",
",",
"$",
"tracking_id",
")",
"{",
"$",
"accounts",
"=",
"$",
"analytics",
"->",
"management_accounts",
"->",
"listManagementAccounts",
"(",
")",
";",
"foreach",
"(",
"$",
"accounts",
"->",
"getItems",
"(",
")",
"as",
"$",
"item",
")",
"{",
"$",
"account_id",
"=",
"$",
"item",
"->",
"getId",
"(",
")",
";",
"if",
"(",
"$",
"account_id",
"!=",
"$",
"tracking_id",
")",
"continue",
";",
"$",
"properties",
"=",
"$",
"analytics",
"->",
"management_webproperties",
"->",
"listManagementWebproperties",
"(",
"$",
"account_id",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"properties",
"->",
"getItems",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"items",
"=",
"$",
"properties",
"->",
"getItems",
"(",
")",
";",
"$",
"first_property_id",
"=",
"$",
"items",
"[",
"0",
"]",
"->",
"getId",
"(",
")",
";",
"$",
"profiles",
"=",
"$",
"analytics",
"->",
"management_profiles",
"->",
"listManagementProfiles",
"(",
"$",
"account_id",
",",
"$",
"first_property_id",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"profiles",
"->",
"getItems",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"items",
"=",
"$",
"profiles",
"->",
"getItems",
"(",
")",
";",
"return",
"$",
"items",
"[",
"0",
"]",
"->",
"getId",
"(",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | 41534519 -> 73241329 | [
"41534519",
"-",
">",
"73241329"
] | 8fe9a5d1b73311c65a7c5a0ce8a4e859d39351c6 | https://github.com/neonbug/meexo-common/blob/8fe9a5d1b73311c65a7c5a0ce8a4e859d39351c6/src/Repositories/GoogleAnalyticsRepository.php#L80-L108 |
997 | mikegibson/sentient | src/Route/UrlMatcher.php | UrlMatcher.matchRoute | protected function matchRoute($pathinfo, $name, BaseRoute $route) {
$compiledRoute = $route->compile();
// check the static prefix of the URL first. Only use the more expensive preg_match when it matches
if ('' !== $compiledRoute->getStaticPrefix() && 0 !== strpos($pathinfo, $compiledRoute->getStaticPrefix())) {
return null;
}
if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) {
return null;
}
$hostMatches = array();
if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) {
return null;
}
// check HTTP method requirement
if ($req = $route->getRequirement('_method')) {
// HEAD and GET are equivalent as per RFC
if ('HEAD' === $method = $this->context->getMethod()) {
$method = 'GET';
}
if (!in_array($method, $req = explode('|', strtoupper($req)))) {
$this->allow = array_merge($this->allow, $req);
return null;
}
}
$status = $this->handleRouteRequirements($pathinfo, $name, $route);
if (self::ROUTE_MATCH === $status[0]) {
return $status[1];
}
if (self::REQUIREMENT_MISMATCH === $status[0]) {
return null;
}
$attrs = $this->getAttributes($route, $name, array_replace($matches, $hostMatches));
if($route instanceof Route) {
foreach($route->getMatchCallbacks() as $callback) {
$ret = call_user_func($callback, $attrs);
if($ret === false) {
return null;
}
if(is_array($ret)) {
$attrs = $ret;
}
}
}
return $attrs;
} | php | protected function matchRoute($pathinfo, $name, BaseRoute $route) {
$compiledRoute = $route->compile();
// check the static prefix of the URL first. Only use the more expensive preg_match when it matches
if ('' !== $compiledRoute->getStaticPrefix() && 0 !== strpos($pathinfo, $compiledRoute->getStaticPrefix())) {
return null;
}
if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) {
return null;
}
$hostMatches = array();
if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) {
return null;
}
// check HTTP method requirement
if ($req = $route->getRequirement('_method')) {
// HEAD and GET are equivalent as per RFC
if ('HEAD' === $method = $this->context->getMethod()) {
$method = 'GET';
}
if (!in_array($method, $req = explode('|', strtoupper($req)))) {
$this->allow = array_merge($this->allow, $req);
return null;
}
}
$status = $this->handleRouteRequirements($pathinfo, $name, $route);
if (self::ROUTE_MATCH === $status[0]) {
return $status[1];
}
if (self::REQUIREMENT_MISMATCH === $status[0]) {
return null;
}
$attrs = $this->getAttributes($route, $name, array_replace($matches, $hostMatches));
if($route instanceof Route) {
foreach($route->getMatchCallbacks() as $callback) {
$ret = call_user_func($callback, $attrs);
if($ret === false) {
return null;
}
if(is_array($ret)) {
$attrs = $ret;
}
}
}
return $attrs;
} | [
"protected",
"function",
"matchRoute",
"(",
"$",
"pathinfo",
",",
"$",
"name",
",",
"BaseRoute",
"$",
"route",
")",
"{",
"$",
"compiledRoute",
"=",
"$",
"route",
"->",
"compile",
"(",
")",
";",
"// check the static prefix of the URL first. Only use the more expensive preg_match when it matches",
"if",
"(",
"''",
"!==",
"$",
"compiledRoute",
"->",
"getStaticPrefix",
"(",
")",
"&&",
"0",
"!==",
"strpos",
"(",
"$",
"pathinfo",
",",
"$",
"compiledRoute",
"->",
"getStaticPrefix",
"(",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"compiledRoute",
"->",
"getRegex",
"(",
")",
",",
"$",
"pathinfo",
",",
"$",
"matches",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"hostMatches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"compiledRoute",
"->",
"getHostRegex",
"(",
")",
"&&",
"!",
"preg_match",
"(",
"$",
"compiledRoute",
"->",
"getHostRegex",
"(",
")",
",",
"$",
"this",
"->",
"context",
"->",
"getHost",
"(",
")",
",",
"$",
"hostMatches",
")",
")",
"{",
"return",
"null",
";",
"}",
"// check HTTP method requirement",
"if",
"(",
"$",
"req",
"=",
"$",
"route",
"->",
"getRequirement",
"(",
"'_method'",
")",
")",
"{",
"// HEAD and GET are equivalent as per RFC",
"if",
"(",
"'HEAD'",
"===",
"$",
"method",
"=",
"$",
"this",
"->",
"context",
"->",
"getMethod",
"(",
")",
")",
"{",
"$",
"method",
"=",
"'GET'",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"method",
",",
"$",
"req",
"=",
"explode",
"(",
"'|'",
",",
"strtoupper",
"(",
"$",
"req",
")",
")",
")",
")",
"{",
"$",
"this",
"->",
"allow",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"allow",
",",
"$",
"req",
")",
";",
"return",
"null",
";",
"}",
"}",
"$",
"status",
"=",
"$",
"this",
"->",
"handleRouteRequirements",
"(",
"$",
"pathinfo",
",",
"$",
"name",
",",
"$",
"route",
")",
";",
"if",
"(",
"self",
"::",
"ROUTE_MATCH",
"===",
"$",
"status",
"[",
"0",
"]",
")",
"{",
"return",
"$",
"status",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"self",
"::",
"REQUIREMENT_MISMATCH",
"===",
"$",
"status",
"[",
"0",
"]",
")",
"{",
"return",
"null",
";",
"}",
"$",
"attrs",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
"$",
"route",
",",
"$",
"name",
",",
"array_replace",
"(",
"$",
"matches",
",",
"$",
"hostMatches",
")",
")",
";",
"if",
"(",
"$",
"route",
"instanceof",
"Route",
")",
"{",
"foreach",
"(",
"$",
"route",
"->",
"getMatchCallbacks",
"(",
")",
"as",
"$",
"callback",
")",
"{",
"$",
"ret",
"=",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"attrs",
")",
";",
"if",
"(",
"$",
"ret",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"ret",
")",
")",
"{",
"$",
"attrs",
"=",
"$",
"ret",
";",
"}",
"}",
"}",
"return",
"$",
"attrs",
";",
"}"
] | Tries to match a URL with an individual route.
@param $pathinfo
@param $name
@param BaseRoute $route
@return array|null | [
"Tries",
"to",
"match",
"a",
"URL",
"with",
"an",
"individual",
"route",
"."
] | 05aaaa0cd8e649d2b526df52a59c9fb53c114338 | https://github.com/mikegibson/sentient/blob/05aaaa0cd8e649d2b526df52a59c9fb53c114338/src/Route/UrlMatcher.php#L39-L96 |
998 | Dhii/data-state-abstract | src/TransitionCapableStateMachineTrait.php | TransitionCapableStateMachineTrait._transition | protected function _transition(StateAwareInterface $subject, $transition)
{
// Retrieve the state machine to use
$stateMachine = $this->_getStateMachineForTransition($subject, $transition);
// Ensure it is not null
if ($stateMachine === null) {
throw $this->_throwTransitionerException($this->__('State machine is null'));
}
// Normalize the transition before using it in the state machine
$nTransition = $this->_normalizeTransition($subject, $transition);
try {
// Attempt to transition using the state machine
$rStateMachine = $stateMachine->transition($nTransition);
} catch (SmCouldNotTransitionExceptionInterface $smtException) {
throw $this->_throwCouldNotTransitionException(
$this->__('Failed to apply "%1$s" transition', [$transition]),
null,
$smtException,
$subject,
$transition
);
} catch (StateMachineExceptionInterface $smException) {
throw $this->_throwTransitionerException(
$this->__('An error occurred during transition'), null, $smException
);
}
if (!($rStateMachine instanceof ReadableStateMachineInterface)) {
throw $this->_throwTransitionerException(
$this->__('Resulting state machine is not readable')
);
}
// Determine the new subject from the input arguments and the retrieved state machine
return $this->_getNewSubject($subject, $transition, $rStateMachine);
} | php | protected function _transition(StateAwareInterface $subject, $transition)
{
// Retrieve the state machine to use
$stateMachine = $this->_getStateMachineForTransition($subject, $transition);
// Ensure it is not null
if ($stateMachine === null) {
throw $this->_throwTransitionerException($this->__('State machine is null'));
}
// Normalize the transition before using it in the state machine
$nTransition = $this->_normalizeTransition($subject, $transition);
try {
// Attempt to transition using the state machine
$rStateMachine = $stateMachine->transition($nTransition);
} catch (SmCouldNotTransitionExceptionInterface $smtException) {
throw $this->_throwCouldNotTransitionException(
$this->__('Failed to apply "%1$s" transition', [$transition]),
null,
$smtException,
$subject,
$transition
);
} catch (StateMachineExceptionInterface $smException) {
throw $this->_throwTransitionerException(
$this->__('An error occurred during transition'), null, $smException
);
}
if (!($rStateMachine instanceof ReadableStateMachineInterface)) {
throw $this->_throwTransitionerException(
$this->__('Resulting state machine is not readable')
);
}
// Determine the new subject from the input arguments and the retrieved state machine
return $this->_getNewSubject($subject, $transition, $rStateMachine);
} | [
"protected",
"function",
"_transition",
"(",
"StateAwareInterface",
"$",
"subject",
",",
"$",
"transition",
")",
"{",
"// Retrieve the state machine to use",
"$",
"stateMachine",
"=",
"$",
"this",
"->",
"_getStateMachineForTransition",
"(",
"$",
"subject",
",",
"$",
"transition",
")",
";",
"// Ensure it is not null",
"if",
"(",
"$",
"stateMachine",
"===",
"null",
")",
"{",
"throw",
"$",
"this",
"->",
"_throwTransitionerException",
"(",
"$",
"this",
"->",
"__",
"(",
"'State machine is null'",
")",
")",
";",
"}",
"// Normalize the transition before using it in the state machine",
"$",
"nTransition",
"=",
"$",
"this",
"->",
"_normalizeTransition",
"(",
"$",
"subject",
",",
"$",
"transition",
")",
";",
"try",
"{",
"// Attempt to transition using the state machine",
"$",
"rStateMachine",
"=",
"$",
"stateMachine",
"->",
"transition",
"(",
"$",
"nTransition",
")",
";",
"}",
"catch",
"(",
"SmCouldNotTransitionExceptionInterface",
"$",
"smtException",
")",
"{",
"throw",
"$",
"this",
"->",
"_throwCouldNotTransitionException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Failed to apply \"%1$s\" transition'",
",",
"[",
"$",
"transition",
"]",
")",
",",
"null",
",",
"$",
"smtException",
",",
"$",
"subject",
",",
"$",
"transition",
")",
";",
"}",
"catch",
"(",
"StateMachineExceptionInterface",
"$",
"smException",
")",
"{",
"throw",
"$",
"this",
"->",
"_throwTransitionerException",
"(",
"$",
"this",
"->",
"__",
"(",
"'An error occurred during transition'",
")",
",",
"null",
",",
"$",
"smException",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"rStateMachine",
"instanceof",
"ReadableStateMachineInterface",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"_throwTransitionerException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Resulting state machine is not readable'",
")",
")",
";",
"}",
"// Determine the new subject from the input arguments and the retrieved state machine",
"return",
"$",
"this",
"->",
"_getNewSubject",
"(",
"$",
"subject",
",",
"$",
"transition",
",",
"$",
"rStateMachine",
")",
";",
"}"
] | Applies a transition to a subject via a state machine.
@since [*next-version*]
@param StateAwareInterface $subject The subject to transition.
@param string|Stringable|null $transition The transition to apply.
@return StateAwareInterface The transitioned subject. May or may not be the same instance as the first argument. | [
"Applies",
"a",
"transition",
"to",
"a",
"subject",
"via",
"a",
"state",
"machine",
"."
] | c335c37a939861659e657b995cfc657bb3bb2733 | https://github.com/Dhii/data-state-abstract/blob/c335c37a939861659e657b995cfc657bb3bb2733/src/TransitionCapableStateMachineTrait.php#L31-L68 |
999 | tekkla/core-html | Core/Html/Bootstrap/Navbar/Navbar.php | Navbar.isFluid | public function isFluid($fluid = null)
{
if (isset($fluid)) {
$this->fluid = (bool) $fluid;
return $this;
} else {
return $this->fluid;
}
} | php | public function isFluid($fluid = null)
{
if (isset($fluid)) {
$this->fluid = (bool) $fluid;
return $this;
} else {
return $this->fluid;
}
} | [
"public",
"function",
"isFluid",
"(",
"$",
"fluid",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"fluid",
")",
")",
"{",
"$",
"this",
"->",
"fluid",
"=",
"(",
"bool",
")",
"$",
"fluid",
";",
"return",
"$",
"this",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"fluid",
";",
"}",
"}"
] | Sets or gets fluid container flag.
@param bool $fluid
@return \Core\Html\Bootstrap\Navbar\Navbar|boolean | [
"Sets",
"or",
"gets",
"fluid",
"container",
"flag",
"."
] | 00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3 | https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Bootstrap/Navbar/Navbar.php#L89-L97 |