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
partition
stringclasses
1 value
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readInt24BE
final public function readInt24BE() { if ($this->isLittleEndian()) { return $this->fromInt24(strrev($this->read(3))); } else { return $this->fromInt24($this->read(3)); } }
php
final public function readInt24BE() { if ($this->isLittleEndian()) { return $this->fromInt24(strrev($this->read(3))); } else { return $this->fromInt24($this->read(3)); } }
[ "final", "public", "function", "readInt24BE", "(", ")", "{", "if", "(", "$", "this", "->", "isLittleEndian", "(", ")", ")", "{", "return", "$", "this", "->", "fromInt24", "(", "strrev", "(", "$", "this", "->", "read", "(", "3", ")", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "fromInt24", "(", "$", "this", "->", "read", "(", "3", ")", ")", ";", "}", "}" ]
Reads 3 bytes from the stream and returns big-endian ordered binary data as signed 24-bit integer. @return integer @throws InvalidStreamException if an I/O error occurs
[ "Reads", "3", "bytes", "from", "the", "stream", "and", "returns", "big", "-", "endian", "ordered", "binary", "data", "as", "signed", "24", "-", "bit", "integer", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L348-L355
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.fromUInt24
private function fromUInt24($value, $order = 0) { list(, $int) = unpack( ($order == self::BIG_ENDIAN_ORDER ? 'N' : ($order == self::LITTLE_ENDIAN_ORDER ? 'V' : 'L')) . '*', $this->isLittleEndian() ? ("\x00" . $value) : ($value . "\x00") ); return $int; }
php
private function fromUInt24($value, $order = 0) { list(, $int) = unpack( ($order == self::BIG_ENDIAN_ORDER ? 'N' : ($order == self::LITTLE_ENDIAN_ORDER ? 'V' : 'L')) . '*', $this->isLittleEndian() ? ("\x00" . $value) : ($value . "\x00") ); return $int; }
[ "private", "function", "fromUInt24", "(", "$", "value", ",", "$", "order", "=", "0", ")", "{", "list", "(", ",", "$", "int", ")", "=", "unpack", "(", "(", "$", "order", "==", "self", "::", "BIG_ENDIAN_ORDER", "?", "'N'", ":", "(", "$", "order", "==", "self", "::", "LITTLE_ENDIAN_ORDER", "?", "'V'", ":", "'L'", ")", ")", ".", "'*'", ",", "$", "this", "->", "isLittleEndian", "(", ")", "?", "(", "\"\\x00\"", ".", "$", "value", ")", ":", "(", "$", "value", ".", "\"\\x00\"", ")", ")", ";", "return", "$", "int", ";", "}" ]
Returns machine endian ordered binary data as unsigned 24-bit integer. @param string $value The binary data string. @param integer $order The byte order of the binary data string. @return integer
[ "Returns", "machine", "endian", "ordered", "binary", "data", "as", "unsigned", "24", "-", "bit", "integer", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L376-L383
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readInt32LE
final public function readInt32LE() { if ($this->isBigEndian()) { return $this->fromInt32(strrev($this->read(4))); } else { return $this->fromInt32($this->read(4)); } }
php
final public function readInt32LE() { if ($this->isBigEndian()) { return $this->fromInt32(strrev($this->read(4))); } else { return $this->fromInt32($this->read(4)); } }
[ "final", "public", "function", "readInt32LE", "(", ")", "{", "if", "(", "$", "this", "->", "isBigEndian", "(", ")", ")", "{", "return", "$", "this", "->", "fromInt32", "(", "strrev", "(", "$", "this", "->", "read", "(", "4", ")", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "fromInt32", "(", "$", "this", "->", "read", "(", "4", ")", ")", ";", "}", "}" ]
Reads 4 bytes from the stream and returns little-endian ordered binary data as signed 32-bit integer. @return integer @throws InvalidStreamException if an I/O error occurs
[ "Reads", "4", "bytes", "from", "the", "stream", "and", "returns", "little", "-", "endian", "ordered", "binary", "data", "as", "signed", "32", "-", "bit", "integer", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L440-L447
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readInt32BE
final public function readInt32BE() { if ($this->isLittleEndian()) { return $this->fromInt32(strrev($this->read(4))); } else { return $this->fromInt32($this->read(4)); } }
php
final public function readInt32BE() { if ($this->isLittleEndian()) { return $this->fromInt32(strrev($this->read(4))); } else { return $this->fromInt32($this->read(4)); } }
[ "final", "public", "function", "readInt32BE", "(", ")", "{", "if", "(", "$", "this", "->", "isLittleEndian", "(", ")", ")", "{", "return", "$", "this", "->", "fromInt32", "(", "strrev", "(", "$", "this", "->", "read", "(", "4", ")", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "fromInt32", "(", "$", "this", "->", "read", "(", "4", ")", ")", ";", "}", "}" ]
Reads 4 bytes from the stream and returns big-endian ordered binary data as signed 32-bit integer. @return integer @throws InvalidStreamException if an I/O error occurs
[ "Reads", "4", "bytes", "from", "the", "stream", "and", "returns", "big", "-", "endian", "ordered", "binary", "data", "as", "signed", "32", "-", "bit", "integer", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L456-L463
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readUInt32LE
final public function readUInt32LE() { if (PHP_INT_SIZE < 8) { // @codeCoverageIgnoreStart list(, $lo, $hi) = unpack('v*', $this->read(4)); return $hi * (0xffff+1) + $lo; // eq $hi << 16 | $lo // @codeCoverageIgnoreEnd } else { list(, $int) = unpack('V*', $this->read(4)); return $int; } }
php
final public function readUInt32LE() { if (PHP_INT_SIZE < 8) { // @codeCoverageIgnoreStart list(, $lo, $hi) = unpack('v*', $this->read(4)); return $hi * (0xffff+1) + $lo; // eq $hi << 16 | $lo // @codeCoverageIgnoreEnd } else { list(, $int) = unpack('V*', $this->read(4)); return $int; } }
[ "final", "public", "function", "readUInt32LE", "(", ")", "{", "if", "(", "PHP_INT_SIZE", "<", "8", ")", "{", "// @codeCoverageIgnoreStart", "list", "(", ",", "$", "lo", ",", "$", "hi", ")", "=", "unpack", "(", "'v*'", ",", "$", "this", "->", "read", "(", "4", ")", ")", ";", "return", "$", "hi", "*", "(", "0xffff", "+", "1", ")", "+", "$", "lo", ";", "// eq $hi << 16 | $lo", "// @codeCoverageIgnoreEnd", "}", "else", "{", "list", "(", ",", "$", "int", ")", "=", "unpack", "(", "'V*'", ",", "$", "this", "->", "read", "(", "4", ")", ")", ";", "return", "$", "int", ";", "}", "}" ]
Reads 4 bytes from the stream and returns little-endian ordered binary data as unsigned 32-bit integer. @return integer @throws InvalidStreamException if an I/O error occurs
[ "Reads", "4", "bytes", "from", "the", "stream", "and", "returns", "little", "-", "endian", "ordered", "binary", "data", "as", "unsigned", "32", "-", "bit", "integer", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L484-L495
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readUInt32
final public function readUInt32() { if (PHP_INT_SIZE < 8) { // @codeCoverageIgnoreStart if ($this->isLittleEndian()) { list(, $lo, $hi) = unpack('S*', $this->read(4)); } else { list(, $hi, $lo) = unpack('S*', $this->read(4)); } return $hi * (0xffff+1) + $lo; // eq $hi << 16 | $lo // @codeCoverageIgnoreEnd } else { list(, $int) = unpack('L*', $this->read(4)) + array(0, 0); return $int; } }
php
final public function readUInt32() { if (PHP_INT_SIZE < 8) { // @codeCoverageIgnoreStart if ($this->isLittleEndian()) { list(, $lo, $hi) = unpack('S*', $this->read(4)); } else { list(, $hi, $lo) = unpack('S*', $this->read(4)); } return $hi * (0xffff+1) + $lo; // eq $hi << 16 | $lo // @codeCoverageIgnoreEnd } else { list(, $int) = unpack('L*', $this->read(4)) + array(0, 0); return $int; } }
[ "final", "public", "function", "readUInt32", "(", ")", "{", "if", "(", "PHP_INT_SIZE", "<", "8", ")", "{", "// @codeCoverageIgnoreStart", "if", "(", "$", "this", "->", "isLittleEndian", "(", ")", ")", "{", "list", "(", ",", "$", "lo", ",", "$", "hi", ")", "=", "unpack", "(", "'S*'", ",", "$", "this", "->", "read", "(", "4", ")", ")", ";", "}", "else", "{", "list", "(", ",", "$", "hi", ",", "$", "lo", ")", "=", "unpack", "(", "'S*'", ",", "$", "this", "->", "read", "(", "4", ")", ")", ";", "}", "return", "$", "hi", "*", "(", "0xffff", "+", "1", ")", "+", "$", "lo", ";", "// eq $hi << 16 | $lo", "// @codeCoverageIgnoreEnd", "}", "else", "{", "list", "(", ",", "$", "int", ")", "=", "unpack", "(", "'L*'", ",", "$", "this", "->", "read", "(", "4", ")", ")", "+", "array", "(", "0", ",", "0", ")", ";", "return", "$", "int", ";", "}", "}" ]
Reads 4 bytes from the stream and returns machine ordered binary data as unsigned 32-bit integer. @return integer @throws InvalidStreamException if an I/O error occurs
[ "Reads", "4", "bytes", "from", "the", "stream", "and", "returns", "machine", "ordered", "binary", "data", "as", "unsigned", "32", "-", "bit", "integer", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L524-L539
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readInt64LE
final public function readInt64LE() { list(, $lolo, $lohi, $hilo, $hihi) = unpack('v*', $this->read(8)); return ($hihi * (0xffff+1) + $hilo) * (0xffffffff+1) + ($lohi * (0xffff+1) + $lolo); }
php
final public function readInt64LE() { list(, $lolo, $lohi, $hilo, $hihi) = unpack('v*', $this->read(8)); return ($hihi * (0xffff+1) + $hilo) * (0xffffffff+1) + ($lohi * (0xffff+1) + $lolo); }
[ "final", "public", "function", "readInt64LE", "(", ")", "{", "list", "(", ",", "$", "lolo", ",", "$", "lohi", ",", "$", "hilo", ",", "$", "hihi", ")", "=", "unpack", "(", "'v*'", ",", "$", "this", "->", "read", "(", "8", ")", ")", ";", "return", "(", "$", "hihi", "*", "(", "0xffff", "+", "1", ")", "+", "$", "hilo", ")", "*", "(", "0xffffffff", "+", "1", ")", "+", "(", "$", "lohi", "*", "(", "0xffff", "+", "1", ")", "+", "$", "lolo", ")", ";", "}" ]
Reads 8 bytes from the stream and returns little-endian ordered binary data as 64-bit float. {@internal PHP does not support 64-bit integers as the long integer is of 32-bits but using aritmetic operations it is implicitly converted into floating point which is of 64-bits long.}} @return integer @throws InvalidStreamException if an I/O error occurs
[ "Reads", "8", "bytes", "from", "the", "stream", "and", "returns", "little", "-", "endian", "ordered", "binary", "data", "as", "64", "-", "bit", "float", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L552-L556
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readFloatLE
final public function readFloatLE() { if ($this->isBigEndian()) { return $this->fromFloat(strrev($this->read(4))); } else { return $this->fromFloat($this->read(4)); } }
php
final public function readFloatLE() { if ($this->isBigEndian()) { return $this->fromFloat(strrev($this->read(4))); } else { return $this->fromFloat($this->read(4)); } }
[ "final", "public", "function", "readFloatLE", "(", ")", "{", "if", "(", "$", "this", "->", "isBigEndian", "(", ")", ")", "{", "return", "$", "this", "->", "fromFloat", "(", "strrev", "(", "$", "this", "->", "read", "(", "4", ")", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "fromFloat", "(", "$", "this", "->", "read", "(", "4", ")", ")", ";", "}", "}" ]
Reads 4 bytes from the stream and returns little-endian ordered binary data as a 32-bit float point number as defined by IEEE 754. @return float @throws InvalidStreamException if an I/O error occurs
[ "Reads", "4", "bytes", "from", "the", "stream", "and", "returns", "little", "-", "endian", "ordered", "binary", "data", "as", "a", "32", "-", "bit", "float", "point", "number", "as", "defined", "by", "IEEE", "754", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L595-L602
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readFloatBE
final public function readFloatBE() { if ($this->isLittleEndian()) { return $this->fromFloat(strrev($this->read(4))); } else { return $this->fromFloat($this->read(4)); } }
php
final public function readFloatBE() { if ($this->isLittleEndian()) { return $this->fromFloat(strrev($this->read(4))); } else { return $this->fromFloat($this->read(4)); } }
[ "final", "public", "function", "readFloatBE", "(", ")", "{", "if", "(", "$", "this", "->", "isLittleEndian", "(", ")", ")", "{", "return", "$", "this", "->", "fromFloat", "(", "strrev", "(", "$", "this", "->", "read", "(", "4", ")", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "fromFloat", "(", "$", "this", "->", "read", "(", "4", ")", ")", ";", "}", "}" ]
Reads 4 bytes from the stream and returns big-endian ordered binary data as a 32-bit float point number as defined by IEEE 754. @return float @throws InvalidStreamException if an I/O error occurs
[ "Reads", "4", "bytes", "from", "the", "stream", "and", "returns", "big", "-", "endian", "ordered", "binary", "data", "as", "a", "32", "-", "bit", "float", "point", "number", "as", "defined", "by", "IEEE", "754", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L611-L618
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readDoubleLE
final public function readDoubleLE() { if ($this->isBigEndian()) { return $this->fromDouble(strrev($this->read(8))); } else { return $this->fromDouble($this->read(8)); } }
php
final public function readDoubleLE() { if ($this->isBigEndian()) { return $this->fromDouble(strrev($this->read(8))); } else { return $this->fromDouble($this->read(8)); } }
[ "final", "public", "function", "readDoubleLE", "(", ")", "{", "if", "(", "$", "this", "->", "isBigEndian", "(", ")", ")", "{", "return", "$", "this", "->", "fromDouble", "(", "strrev", "(", "$", "this", "->", "read", "(", "8", ")", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "fromDouble", "(", "$", "this", "->", "read", "(", "8", ")", ")", ";", "}", "}" ]
Reads 8 bytes from the stream and returns little-endian ordered binary data as a 64-bit floating point number as defined by IEEE 754. @return float @throws InvalidStreamException if an I/O error occurs
[ "Reads", "8", "bytes", "from", "the", "stream", "and", "returns", "little", "-", "endian", "ordered", "binary", "data", "as", "a", "64", "-", "bit", "floating", "point", "number", "as", "defined", "by", "IEEE", "754", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L640-L647
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readDoubleBE
final public function readDoubleBE() { if ($this->isLittleEndian()) { return $this->fromDouble(strrev($this->read(8))); } else { return $this->fromDouble($this->read(8)); } }
php
final public function readDoubleBE() { if ($this->isLittleEndian()) { return $this->fromDouble(strrev($this->read(8))); } else { return $this->fromDouble($this->read(8)); } }
[ "final", "public", "function", "readDoubleBE", "(", ")", "{", "if", "(", "$", "this", "->", "isLittleEndian", "(", ")", ")", "{", "return", "$", "this", "->", "fromDouble", "(", "strrev", "(", "$", "this", "->", "read", "(", "8", ")", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "fromDouble", "(", "$", "this", "->", "read", "(", "8", ")", ")", ";", "}", "}" ]
Reads 8 bytes from the stream and returns big-endian ordered binary data as a 64-bit float point number as defined by IEEE 754. @return float @throws InvalidStreamException if an I/O error occurs
[ "Reads", "8", "bytes", "from", "the", "stream", "and", "returns", "big", "-", "endian", "ordered", "binary", "data", "as", "a", "64", "-", "bit", "float", "point", "number", "as", "defined", "by", "IEEE", "754", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L656-L663
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.readGuid
final public function readGuid() { $C = @unpack('V1V/v2v/N2N', $this->read(16)); list($hex) = @unpack('H*0', pack('NnnNN', $C['V'], $C['v1'], $C['v2'], $C['N1'], $C['N2'])); /* Fixes a bug in PHP versions earlier than Jan 25 2006 */ if (implode('', unpack('H*', pack('H*', 'a'))) == 'a00') { // @codeCoverageIgnoreStart $hex = substr($hex, 0, -1); } // @codeCoverageIgnoreEnd return preg_replace('/^(.{8})(.{4})(.{4})(.{4})/', "\\1-\\2-\\3-\\4-", $hex); }
php
final public function readGuid() { $C = @unpack('V1V/v2v/N2N', $this->read(16)); list($hex) = @unpack('H*0', pack('NnnNN', $C['V'], $C['v1'], $C['v2'], $C['N1'], $C['N2'])); /* Fixes a bug in PHP versions earlier than Jan 25 2006 */ if (implode('', unpack('H*', pack('H*', 'a'))) == 'a00') { // @codeCoverageIgnoreStart $hex = substr($hex, 0, -1); } // @codeCoverageIgnoreEnd return preg_replace('/^(.{8})(.{4})(.{4})(.{4})/', "\\1-\\2-\\3-\\4-", $hex); }
[ "final", "public", "function", "readGuid", "(", ")", "{", "$", "C", "=", "@", "unpack", "(", "'V1V/v2v/N2N'", ",", "$", "this", "->", "read", "(", "16", ")", ")", ";", "list", "(", "$", "hex", ")", "=", "@", "unpack", "(", "'H*0'", ",", "pack", "(", "'NnnNN'", ",", "$", "C", "[", "'V'", "]", ",", "$", "C", "[", "'v1'", "]", ",", "$", "C", "[", "'v2'", "]", ",", "$", "C", "[", "'N1'", "]", ",", "$", "C", "[", "'N2'", "]", ")", ")", ";", "/* Fixes a bug in PHP versions earlier than Jan 25 2006 */", "if", "(", "implode", "(", "''", ",", "unpack", "(", "'H*'", ",", "pack", "(", "'H*'", ",", "'a'", ")", ")", ")", "==", "'a00'", ")", "{", "// @codeCoverageIgnoreStart", "$", "hex", "=", "substr", "(", "$", "hex", ",", "0", ",", "-", "1", ")", ";", "}", "// @codeCoverageIgnoreEnd", "return", "preg_replace", "(", "'/^(.{8})(.{4})(.{4})(.{4})/'", ",", "\"\\\\1-\\\\2-\\\\3-\\\\4-\"", ",", "$", "hex", ")", ";", "}" ]
Reads 16 bytes from the stream and returns the little-endian ordered binary data as mixed-ordered hexadecimal GUID string. @return string @throws InvalidStreamException if an I/O error occurs
[ "Reads", "16", "bytes", "from", "the", "stream", "and", "returns", "the", "little", "-", "endian", "ordered", "binary", "data", "as", "mixed", "-", "ordered", "hexadecimal", "GUID", "string", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L758-L771
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.close
public function close() { if ($this->fileDescriptor !== null) { @fclose($this->fileDescriptor); $this->fileDescriptor = null; } }
php
public function close() { if ($this->fileDescriptor !== null) { @fclose($this->fileDescriptor); $this->fileDescriptor = null; } }
[ "public", "function", "close", "(", ")", "{", "if", "(", "$", "this", "->", "fileDescriptor", "!==", "null", ")", "{", "@", "fclose", "(", "$", "this", "->", "fileDescriptor", ")", ";", "$", "this", "->", "fileDescriptor", "=", "null", ";", "}", "}" ]
Closes the stream. Once a stream has been closed, further calls to read methods will throw an exception. Closing a previously-closed stream, however, has no effect. @return void
[ "Closes", "the", "stream", ".", "Once", "a", "stream", "has", "been", "closed", "further", "calls", "to", "read", "methods", "will", "throw", "an", "exception", ".", "Closing", "a", "previously", "-", "closed", "stream", "however", "has", "no", "effect", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L793-L799
train
MetaSyntactical/Io
src/MetaSyntactical/Io/Reader.php
Reader.getEndianess
private function getEndianess() { if (0 === self::$endianess) { self::$endianess = $this->fromInt32("\x01\x00\x00\x00") == 1 ? self::LITTLE_ENDIAN_ORDER : self::BIG_ENDIAN_ORDER; } return self::$endianess; }
php
private function getEndianess() { if (0 === self::$endianess) { self::$endianess = $this->fromInt32("\x01\x00\x00\x00") == 1 ? self::LITTLE_ENDIAN_ORDER : self::BIG_ENDIAN_ORDER; } return self::$endianess; }
[ "private", "function", "getEndianess", "(", ")", "{", "if", "(", "0", "===", "self", "::", "$", "endianess", ")", "{", "self", "::", "$", "endianess", "=", "$", "this", "->", "fromInt32", "(", "\"\\x01\\x00\\x00\\x00\"", ")", "==", "1", "?", "self", "::", "LITTLE_ENDIAN_ORDER", ":", "self", "::", "BIG_ENDIAN_ORDER", ";", "}", "return", "self", "::", "$", "endianess", ";", "}" ]
Returns the current machine endian order. @return integer
[ "Returns", "the", "current", "machine", "endian", "order", "." ]
d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c
https://github.com/MetaSyntactical/Io/blob/d9272c6cf7f3cf24cbd5e4069a6695b26ef0b50c/src/MetaSyntactical/Io/Reader.php#L806-L814
train
bkstg/schedule-bundle
Repository/InvitationRepository.php
InvitationRepository.findPendingInvitationsQuery
public function findPendingInvitationsQuery(UserInterface $user) { $qb = $this->createQueryBuilder('i'); return $qb ->join('i.event', 'e') // Add conditions. ->andWhere($qb->expr()->eq('e.active', ':active')) ->andWhere($qb->expr()->gt('e.end', ':now')) ->andWhere($qb->expr()->isNull('i.response')) ->andWhere($qb->expr()->eq('i.invitee', ':invitee')) // Add parameters. ->setParameter('active', true) ->setParameter('now', new \DateTime()) ->setParameter('invitee', $user->getUsername()) // Get query. ->getQuery(); }
php
public function findPendingInvitationsQuery(UserInterface $user) { $qb = $this->createQueryBuilder('i'); return $qb ->join('i.event', 'e') // Add conditions. ->andWhere($qb->expr()->eq('e.active', ':active')) ->andWhere($qb->expr()->gt('e.end', ':now')) ->andWhere($qb->expr()->isNull('i.response')) ->andWhere($qb->expr()->eq('i.invitee', ':invitee')) // Add parameters. ->setParameter('active', true) ->setParameter('now', new \DateTime()) ->setParameter('invitee', $user->getUsername()) // Get query. ->getQuery(); }
[ "public", "function", "findPendingInvitationsQuery", "(", "UserInterface", "$", "user", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'i'", ")", ";", "return", "$", "qb", "->", "join", "(", "'i.event'", ",", "'e'", ")", "// Add conditions.", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'e.active'", ",", "':active'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "gt", "(", "'e.end'", ",", "':now'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "isNull", "(", "'i.response'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'i.invitee'", ",", "':invitee'", ")", ")", "// Add parameters.", "->", "setParameter", "(", "'active'", ",", "true", ")", "->", "setParameter", "(", "'now'", ",", "new", "\\", "DateTime", "(", ")", ")", "->", "setParameter", "(", "'invitee'", ",", "$", "user", "->", "getUsername", "(", ")", ")", "// Get query.", "->", "getQuery", "(", ")", ";", "}" ]
Build query to find pending invitations for a user. @param UserInterface $user The user to find invitations for. @return Invitation[]
[ "Build", "query", "to", "find", "pending", "invitations", "for", "a", "user", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Repository/InvitationRepository.php#L26-L46
train
bkstg/schedule-bundle
Repository/InvitationRepository.php
InvitationRepository.findOtherInvitationsQuery
public function findOtherInvitationsQuery(UserInterface $user) { $qb = $this->createQueryBuilder('i'); return $qb ->join('i.event', 'e') // Add conditions. ->andWhere($qb->expr()->eq('e.active', ':active')) ->andWhere($qb->expr()->orX( $qb->expr()->lt('e.end', ':now'), $qb->expr()->isNotNull('i.response') )) ->andWhere($qb->expr()->eq('i.invitee', ':invitee')) // Add parameters. ->setParameter('active', true) ->setParameter('now', new \DateTime()) ->setParameter('invitee', $user->getUsername()) // Add order by. ->addOrderBy('e.end', 'DESC') // Get query. ->getQuery(); }
php
public function findOtherInvitationsQuery(UserInterface $user) { $qb = $this->createQueryBuilder('i'); return $qb ->join('i.event', 'e') // Add conditions. ->andWhere($qb->expr()->eq('e.active', ':active')) ->andWhere($qb->expr()->orX( $qb->expr()->lt('e.end', ':now'), $qb->expr()->isNotNull('i.response') )) ->andWhere($qb->expr()->eq('i.invitee', ':invitee')) // Add parameters. ->setParameter('active', true) ->setParameter('now', new \DateTime()) ->setParameter('invitee', $user->getUsername()) // Add order by. ->addOrderBy('e.end', 'DESC') // Get query. ->getQuery(); }
[ "public", "function", "findOtherInvitationsQuery", "(", "UserInterface", "$", "user", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'i'", ")", ";", "return", "$", "qb", "->", "join", "(", "'i.event'", ",", "'e'", ")", "// Add conditions.", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'e.active'", ",", "':active'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "orX", "(", "$", "qb", "->", "expr", "(", ")", "->", "lt", "(", "'e.end'", ",", "':now'", ")", ",", "$", "qb", "->", "expr", "(", ")", "->", "isNotNull", "(", "'i.response'", ")", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'i.invitee'", ",", "':invitee'", ")", ")", "// Add parameters.", "->", "setParameter", "(", "'active'", ",", "true", ")", "->", "setParameter", "(", "'now'", ",", "new", "\\", "DateTime", "(", ")", ")", "->", "setParameter", "(", "'invitee'", ",", "$", "user", "->", "getUsername", "(", ")", ")", "// Add order by.", "->", "addOrderBy", "(", "'e.end'", ",", "'DESC'", ")", "// Get query.", "->", "getQuery", "(", ")", ";", "}" ]
Build query to find other invitations for a user. @param UserInterface $user The user to find invitations for. @return Invitation[]
[ "Build", "query", "to", "find", "other", "invitations", "for", "a", "user", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Repository/InvitationRepository.php#L67-L92
train
SagittariusX/Beluga.IO
src/Beluga/IO/File.php
File.hasReadAccess
public function hasReadAccess() : bool { return $this->isOpen() && ( $this->access == static::ACCESS_READ || $this->access == static::ACCESS_READWRITE ); }
php
public function hasReadAccess() : bool { return $this->isOpen() && ( $this->access == static::ACCESS_READ || $this->access == static::ACCESS_READWRITE ); }
[ "public", "function", "hasReadAccess", "(", ")", ":", "bool", "{", "return", "$", "this", "->", "isOpen", "(", ")", "&&", "(", "$", "this", "->", "access", "==", "static", "::", "ACCESS_READ", "||", "$", "this", "->", "access", "==", "static", "::", "ACCESS_READWRITE", ")", ";", "}" ]
Returns if reading is enabled. @return boolean
[ "Returns", "if", "reading", "is", "enabled", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/File.php#L152-L161
train
SagittariusX/Beluga.IO
src/Beluga/IO/File.php
File.hasWriteAccess
public function hasWriteAccess() : bool { return $this->isOpen() && ( $this->access == static::ACCESS_WRITE || $this->access == static::ACCESS_READWRITE ); }
php
public function hasWriteAccess() : bool { return $this->isOpen() && ( $this->access == static::ACCESS_WRITE || $this->access == static::ACCESS_READWRITE ); }
[ "public", "function", "hasWriteAccess", "(", ")", ":", "bool", "{", "return", "$", "this", "->", "isOpen", "(", ")", "&&", "(", "$", "this", "->", "access", "==", "static", "::", "ACCESS_WRITE", "||", "$", "this", "->", "access", "==", "static", "::", "ACCESS_READWRITE", ")", ";", "}" ]
Returns if writing is enabled. @return boolean
[ "Returns", "if", "writing", "is", "enabled", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/File.php#L168-L177
train
SagittariusX/Beluga.IO
src/Beluga/IO/File.php
File.writeCsv
public function writeCsv( array $dataRow, string $delimiter = ',', bool $fast = false ) : bool { if ( ! $fast ) { // No fast (insecure) access = do the required checks if ( ! $this->isOpen() ) { return false; } if ( ! $this->hasWriteAccess() ) { throw FileAccessError::Write( 'IO', $this->file, \sprintf( 'Current mode of opened file is "%s" and not write!', $this->access ) ); } } try { \fputcsv( $this->fp, $dataRow, $delimiter ); } catch ( \Throwable $ex ) { throw new FileAccessError( 'IO', $this->file, FileAccessError::ACCESS_WRITE, 'Writing of CSV-Data fails.', \E_USER_ERROR, $ex ); } return true; }
php
public function writeCsv( array $dataRow, string $delimiter = ',', bool $fast = false ) : bool { if ( ! $fast ) { // No fast (insecure) access = do the required checks if ( ! $this->isOpen() ) { return false; } if ( ! $this->hasWriteAccess() ) { throw FileAccessError::Write( 'IO', $this->file, \sprintf( 'Current mode of opened file is "%s" and not write!', $this->access ) ); } } try { \fputcsv( $this->fp, $dataRow, $delimiter ); } catch ( \Throwable $ex ) { throw new FileAccessError( 'IO', $this->file, FileAccessError::ACCESS_WRITE, 'Writing of CSV-Data fails.', \E_USER_ERROR, $ex ); } return true; }
[ "public", "function", "writeCsv", "(", "array", "$", "dataRow", ",", "string", "$", "delimiter", "=", "','", ",", "bool", "$", "fast", "=", "false", ")", ":", "bool", "{", "if", "(", "!", "$", "fast", ")", "{", "// No fast (insecure) access = do the required checks", "if", "(", "!", "$", "this", "->", "isOpen", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "hasWriteAccess", "(", ")", ")", "{", "throw", "FileAccessError", "::", "Write", "(", "'IO'", ",", "$", "this", "->", "file", ",", "\\", "sprintf", "(", "'Current mode of opened file is \"%s\" and not write!'", ",", "$", "this", "->", "access", ")", ")", ";", "}", "}", "try", "{", "\\", "fputcsv", "(", "$", "this", "->", "fp", ",", "$", "dataRow", ",", "$", "delimiter", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "ex", ")", "{", "throw", "new", "FileAccessError", "(", "'IO'", ",", "$", "this", "->", "file", ",", "FileAccessError", "::", "ACCESS_WRITE", ",", "'Writing of CSV-Data fails.'", ",", "\\", "E_USER_ERROR", ",", "$", "ex", ")", ";", "}", "return", "true", ";", "}" ]
Write a csv format data row, defined as array. @param array $dataRow The data row to write (numeric indicated array) @param string $delimiter The CSV column delimiter char. (default=',') @param boolean $fast Write fast without some checks? (Defaults to FALSE) @return boolean @throws FileAccessError If writing is not allowed or if it fails.
[ "Write", "a", "csv", "format", "data", "row", "defined", "as", "array", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/File.php#L578-L613
train
SagittariusX/Beluga.IO
src/Beluga/IO/File.php
File.setPointerPosition
public function setPointerPosition( int $offset = 0 ) : bool { if ( ! \is_resource( $this->fp ) ) { return false; } return (bool) \fseek( $this->fp, $offset ); }
php
public function setPointerPosition( int $offset = 0 ) : bool { if ( ! \is_resource( $this->fp ) ) { return false; } return (bool) \fseek( $this->fp, $offset ); }
[ "public", "function", "setPointerPosition", "(", "int", "$", "offset", "=", "0", ")", ":", "bool", "{", "if", "(", "!", "\\", "is_resource", "(", "$", "this", "->", "fp", ")", ")", "{", "return", "false", ";", "}", "return", "(", "bool", ")", "\\", "fseek", "(", "$", "this", "->", "fp", ",", "$", "offset", ")", ";", "}" ]
Sets a new file pointer position. @param integer $offset @return boolean
[ "Sets", "a", "new", "file", "pointer", "position", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/File.php#L642-L652
train
SagittariusX/Beluga.IO
src/Beluga/IO/File.php
File.setPointerPositionToEndOfFile
public function setPointerPositionToEndOfFile() : bool { if ( ! \is_resource( $this->fp ) ) { return false; } return (bool) \fseek( $this->fp, 0, \SEEK_END ); }
php
public function setPointerPositionToEndOfFile() : bool { if ( ! \is_resource( $this->fp ) ) { return false; } return (bool) \fseek( $this->fp, 0, \SEEK_END ); }
[ "public", "function", "setPointerPositionToEndOfFile", "(", ")", ":", "bool", "{", "if", "(", "!", "\\", "is_resource", "(", "$", "this", "->", "fp", ")", ")", "{", "return", "false", ";", "}", "return", "(", "bool", ")", "\\", "fseek", "(", "$", "this", "->", "fp", ",", "0", ",", "\\", "SEEK_END", ")", ";", "}" ]
Sets the file pointer position to the end of the file. @return boolean
[ "Sets", "the", "file", "pointer", "position", "to", "the", "end", "of", "the", "file", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/File.php#L659-L669
train
SagittariusX/Beluga.IO
src/Beluga/IO/File.php
File.Create
public static function Create( string $file, $mode = 0750, bool $overwrite = true, $contents = '' ) { $f = File::CreateNew( $file, $overwrite, true, true, $mode ); $f->write( $contents ); $f->close(); }
php
public static function Create( string $file, $mode = 0750, bool $overwrite = true, $contents = '' ) { $f = File::CreateNew( $file, $overwrite, true, true, $mode ); $f->write( $contents ); $f->close(); }
[ "public", "static", "function", "Create", "(", "string", "$", "file", ",", "$", "mode", "=", "0750", ",", "bool", "$", "overwrite", "=", "true", ",", "$", "contents", "=", "''", ")", "{", "$", "f", "=", "File", "::", "CreateNew", "(", "$", "file", ",", "$", "overwrite", ",", "true", ",", "true", ",", "$", "mode", ")", ";", "$", "f", "->", "write", "(", "$", "contents", ")", ";", "$", "f", "->", "close", "(", ")", ";", "}" ]
Creates a new file with the defined content. If $overwrite is FALSE and the file already exists, a {@see \Beluga\IO\FileAlreadyExistsException} is thrown. @param string $file The path of the file to create. @param integer $mode The file access mode (only used by unixoids) (default=0750) @param boolean $overwrite Overwrite the file if it exists? (default=TRUE) @param string|array $contents The contents of the file (string or lines array) (default='') @throws FileAlreadyExistsError If file exists and overwriting is disabled. @throws FileAccessError On errors while opening the file pointer
[ "Creates", "a", "new", "file", "with", "the", "defined", "content", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/File.php#L885-L892
train
SagittariusX/Beluga.IO
src/Beluga/IO/File.php
File.Zip
public static function Zip( string $sourceFile, string $zipFile, string $workingDir = null ) { if ( ! \class_exists( '\\ZipArchive' ) ) { throw new MissingExtensionError( 'ZIP', 'IO', 'Can not ZIP the file "' . $sourceFile . '"!' ); } // Remember the original used working directory $owd = Path::Unixize( \getcwd() ); // Prepare the actual working directory if ( empty( $workingDir ) ) { $workingDir = Path::Unixize( \dirname( $sourceFile ) ); } else { $workingDir = Path::Unixize( $workingDir ); } if ( $workingDir == $owd ) { // Current working dir and original working dir are the same. $owd = null; } else { // Set the new working directory \chdir( $workingDir ); } // Remove the working directory from sourceFile (if it is contained) $sourceFile = \preg_replace( '~^' . \preg_quote( $workingDir, '~' ) . '/~', '', Path::Unixize( $sourceFile ) ); $oldFile = null; if ( \file_exists( $zipFile ) ) { // The target ZIP file exists. Rename it to *.zip.old $oldFile = $zipFile . '.old'; try { static::Move( $zipFile, $oldFile ); } catch ( \Throwable $ex ) { // Renaming fails if ( ! \is_null( $owd ) ) { // Restore the original working directory \chdir( $owd ); } throw $ex; } } // Init the ZipArchive $zip = new \ZipArchive(); if ( true === ( $res = $zip->open( $zipFile, \ZipArchive::CREATE ) ) ) { // Successful opened the ZIP file writer // Add the source file to ZIP file writer $zip->addFile( $sourceFile ); // Setting the optional ZIP archive comment $zip->setArchiveComment( 'Archived Single-File' ); // Close the ZIP file if ( ! $zip->close() ) { // ZIP file closing fails if ( ! empty( $oldFile ) ) { // Restore the old zip file if defined static::Move( $oldFile, $zipFile ); } if ( ! \is_null( $owd ) ) { // Restore the original working directory \chdir( $owd ); } throw new FileAccessError( 'IO', $zipFile, FileAccessError::ACCESS_CREATE, 'ZIP file could not be created cause write could not be completed! (Closing file fails)' ); } if ( ! empty( $oldFile ) ) { // Delete the old zip file if defined static::Delete( $oldFile ); } if ( ! \is_null( $owd ) ) { // Restore the original working directory \chdir( $owd ); } } else { // Failed to open the ZIP file writer if ( ! \is_null( $owd ) ) { // Restore the original working directory \chdir( $owd ); } if ( ! empty( $oldFile ) ) { // Restore the old zip file if defined static::Move( $oldFile, $zipFile ); } throw new FileAccessError( 'IO', $zipFile, FileAccessError::ACCESS_CREATE, 'ZIP file could not be created cause ' . static::GetZipArchiveError( $res ) ); } }
php
public static function Zip( string $sourceFile, string $zipFile, string $workingDir = null ) { if ( ! \class_exists( '\\ZipArchive' ) ) { throw new MissingExtensionError( 'ZIP', 'IO', 'Can not ZIP the file "' . $sourceFile . '"!' ); } // Remember the original used working directory $owd = Path::Unixize( \getcwd() ); // Prepare the actual working directory if ( empty( $workingDir ) ) { $workingDir = Path::Unixize( \dirname( $sourceFile ) ); } else { $workingDir = Path::Unixize( $workingDir ); } if ( $workingDir == $owd ) { // Current working dir and original working dir are the same. $owd = null; } else { // Set the new working directory \chdir( $workingDir ); } // Remove the working directory from sourceFile (if it is contained) $sourceFile = \preg_replace( '~^' . \preg_quote( $workingDir, '~' ) . '/~', '', Path::Unixize( $sourceFile ) ); $oldFile = null; if ( \file_exists( $zipFile ) ) { // The target ZIP file exists. Rename it to *.zip.old $oldFile = $zipFile . '.old'; try { static::Move( $zipFile, $oldFile ); } catch ( \Throwable $ex ) { // Renaming fails if ( ! \is_null( $owd ) ) { // Restore the original working directory \chdir( $owd ); } throw $ex; } } // Init the ZipArchive $zip = new \ZipArchive(); if ( true === ( $res = $zip->open( $zipFile, \ZipArchive::CREATE ) ) ) { // Successful opened the ZIP file writer // Add the source file to ZIP file writer $zip->addFile( $sourceFile ); // Setting the optional ZIP archive comment $zip->setArchiveComment( 'Archived Single-File' ); // Close the ZIP file if ( ! $zip->close() ) { // ZIP file closing fails if ( ! empty( $oldFile ) ) { // Restore the old zip file if defined static::Move( $oldFile, $zipFile ); } if ( ! \is_null( $owd ) ) { // Restore the original working directory \chdir( $owd ); } throw new FileAccessError( 'IO', $zipFile, FileAccessError::ACCESS_CREATE, 'ZIP file could not be created cause write could not be completed! (Closing file fails)' ); } if ( ! empty( $oldFile ) ) { // Delete the old zip file if defined static::Delete( $oldFile ); } if ( ! \is_null( $owd ) ) { // Restore the original working directory \chdir( $owd ); } } else { // Failed to open the ZIP file writer if ( ! \is_null( $owd ) ) { // Restore the original working directory \chdir( $owd ); } if ( ! empty( $oldFile ) ) { // Restore the old zip file if defined static::Move( $oldFile, $zipFile ); } throw new FileAccessError( 'IO', $zipFile, FileAccessError::ACCESS_CREATE, 'ZIP file could not be created cause ' . static::GetZipArchiveError( $res ) ); } }
[ "public", "static", "function", "Zip", "(", "string", "$", "sourceFile", ",", "string", "$", "zipFile", ",", "string", "$", "workingDir", "=", "null", ")", "{", "if", "(", "!", "\\", "class_exists", "(", "'\\\\ZipArchive'", ")", ")", "{", "throw", "new", "MissingExtensionError", "(", "'ZIP'", ",", "'IO'", ",", "'Can not ZIP the file \"'", ".", "$", "sourceFile", ".", "'\"!'", ")", ";", "}", "// Remember the original used working directory", "$", "owd", "=", "Path", "::", "Unixize", "(", "\\", "getcwd", "(", ")", ")", ";", "// Prepare the actual working directory", "if", "(", "empty", "(", "$", "workingDir", ")", ")", "{", "$", "workingDir", "=", "Path", "::", "Unixize", "(", "\\", "dirname", "(", "$", "sourceFile", ")", ")", ";", "}", "else", "{", "$", "workingDir", "=", "Path", "::", "Unixize", "(", "$", "workingDir", ")", ";", "}", "if", "(", "$", "workingDir", "==", "$", "owd", ")", "{", "// Current working dir and original working dir are the same.", "$", "owd", "=", "null", ";", "}", "else", "{", "// Set the new working directory", "\\", "chdir", "(", "$", "workingDir", ")", ";", "}", "// Remove the working directory from sourceFile (if it is contained)", "$", "sourceFile", "=", "\\", "preg_replace", "(", "'~^'", ".", "\\", "preg_quote", "(", "$", "workingDir", ",", "'~'", ")", ".", "'/~'", ",", "''", ",", "Path", "::", "Unixize", "(", "$", "sourceFile", ")", ")", ";", "$", "oldFile", "=", "null", ";", "if", "(", "\\", "file_exists", "(", "$", "zipFile", ")", ")", "{", "// The target ZIP file exists. Rename it to *.zip.old", "$", "oldFile", "=", "$", "zipFile", ".", "'.old'", ";", "try", "{", "static", "::", "Move", "(", "$", "zipFile", ",", "$", "oldFile", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "ex", ")", "{", "// Renaming fails", "if", "(", "!", "\\", "is_null", "(", "$", "owd", ")", ")", "{", "// Restore the original working directory", "\\", "chdir", "(", "$", "owd", ")", ";", "}", "throw", "$", "ex", ";", "}", "}", "// Init the ZipArchive", "$", "zip", "=", "new", "\\", "ZipArchive", "(", ")", ";", "if", "(", "true", "===", "(", "$", "res", "=", "$", "zip", "->", "open", "(", "$", "zipFile", ",", "\\", "ZipArchive", "::", "CREATE", ")", ")", ")", "{", "// Successful opened the ZIP file writer", "// Add the source file to ZIP file writer", "$", "zip", "->", "addFile", "(", "$", "sourceFile", ")", ";", "// Setting the optional ZIP archive comment", "$", "zip", "->", "setArchiveComment", "(", "'Archived Single-File'", ")", ";", "// Close the ZIP file", "if", "(", "!", "$", "zip", "->", "close", "(", ")", ")", "{", "// ZIP file closing fails", "if", "(", "!", "empty", "(", "$", "oldFile", ")", ")", "{", "// Restore the old zip file if defined", "static", "::", "Move", "(", "$", "oldFile", ",", "$", "zipFile", ")", ";", "}", "if", "(", "!", "\\", "is_null", "(", "$", "owd", ")", ")", "{", "// Restore the original working directory", "\\", "chdir", "(", "$", "owd", ")", ";", "}", "throw", "new", "FileAccessError", "(", "'IO'", ",", "$", "zipFile", ",", "FileAccessError", "::", "ACCESS_CREATE", ",", "'ZIP file could not be created cause write could not be completed! (Closing file fails)'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "oldFile", ")", ")", "{", "// Delete the old zip file if defined", "static", "::", "Delete", "(", "$", "oldFile", ")", ";", "}", "if", "(", "!", "\\", "is_null", "(", "$", "owd", ")", ")", "{", "// Restore the original working directory", "\\", "chdir", "(", "$", "owd", ")", ";", "}", "}", "else", "{", "// Failed to open the ZIP file writer", "if", "(", "!", "\\", "is_null", "(", "$", "owd", ")", ")", "{", "// Restore the original working directory", "\\", "chdir", "(", "$", "owd", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "oldFile", ")", ")", "{", "// Restore the old zip file if defined", "static", "::", "Move", "(", "$", "oldFile", ",", "$", "zipFile", ")", ";", "}", "throw", "new", "FileAccessError", "(", "'IO'", ",", "$", "zipFile", ",", "FileAccessError", "::", "ACCESS_CREATE", ",", "'ZIP file could not be created cause '", ".", "static", "::", "GetZipArchiveError", "(", "$", "res", ")", ")", ";", "}", "}" ]
Compresses the defined source file to defined ZIP archive file. @param string $sourceFile This file will be compressed by the zip archive @param string $zipFile The target/destination ZIP file. (will be created or overwrite a existing) @param string $workingDir A optional working folder. (Usual its the folder, containing the $sourceFile) @throws \Beluga\MissingExtensionError If the require \ZipArchive class (ZIP extension) not exists @throws \Beluga\IO\FileAccessError @throws \Throwable
[ "Compresses", "the", "defined", "source", "file", "to", "defined", "ZIP", "archive", "file", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/File.php#L1097-L1227
train
SagittariusX/Beluga.IO
src/Beluga/IO/File.php
File.GetNameWithoutExtension
public static function GetNameWithoutExtension( string $file, bool $doubleExtension = false ) { if ( \FALSE === ( $ext = static::GetExtension( $file, $doubleExtension ) ) ) { return \basename( $file ); } return \substr( \basename( $file ), 0, -\strlen( $ext ) ); }
php
public static function GetNameWithoutExtension( string $file, bool $doubleExtension = false ) { if ( \FALSE === ( $ext = static::GetExtension( $file, $doubleExtension ) ) ) { return \basename( $file ); } return \substr( \basename( $file ), 0, -\strlen( $ext ) ); }
[ "public", "static", "function", "GetNameWithoutExtension", "(", "string", "$", "file", ",", "bool", "$", "doubleExtension", "=", "false", ")", "{", "if", "(", "\\", "FALSE", "===", "(", "$", "ext", "=", "static", "::", "GetExtension", "(", "$", "file", ",", "$", "doubleExtension", ")", ")", ")", "{", "return", "\\", "basename", "(", "$", "file", ")", ";", "}", "return", "\\", "substr", "(", "\\", "basename", "(", "$", "file", ")", ",", "0", ",", "-", "\\", "strlen", "(", "$", "ext", ")", ")", ";", "}" ]
Returns the file name without the file name extension. @param string $file The file name/path. @param boolean $doubleExtension If you require extensions, including also a single dot like '.abc.def' you have to set this parameter to TRUE. @return string|bool Name or bool FALSE.
[ "Returns", "the", "file", "name", "without", "the", "file", "name", "extension", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/File.php#L1526-L1533
train
Stinger-Soft/PhpCommons
src/StingerSoft/PhpCommons/Integer/Utils.php
Utils.intcmp
public static function intcmp($a, $b) { return ($a - $b) ? ($a - $b) / abs($a - $b) : 0; }
php
public static function intcmp($a, $b) { return ($a - $b) ? ($a - $b) / abs($a - $b) : 0; }
[ "public", "static", "function", "intcmp", "(", "$", "a", ",", "$", "b", ")", "{", "return", "(", "$", "a", "-", "$", "b", ")", "?", "(", "$", "a", "-", "$", "b", ")", "/", "abs", "(", "$", "a", "-", "$", "b", ")", ":", "0", ";", "}" ]
Returns an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. @param int $a @param int $b @return int
[ "Returns", "an", "integer", "less", "than", "equal", "to", "or", "greater", "than", "zero", "if", "the", "first", "argument", "is", "considered", "to", "be", "respectively", "less", "than", "equal", "to", "or", "greater", "than", "the", "second", "." ]
e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b
https://github.com/Stinger-Soft/PhpCommons/blob/e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b/src/StingerSoft/PhpCommons/Integer/Utils.php#L27-L29
train
Vectrex/vxPHP
src/File/FilesystemFolder.php
FilesystemFolder.getFolders
public function getFolders() { $result = []; $files = glob($this->path . '*', GLOB_ONLYDIR); if($files) { foreach($files as $f) { $result[] = self::getInstance($f); } } return $result; }
php
public function getFolders() { $result = []; $files = glob($this->path . '*', GLOB_ONLYDIR); if($files) { foreach($files as $f) { $result[] = self::getInstance($f); } } return $result; }
[ "public", "function", "getFolders", "(", ")", "{", "$", "result", "=", "[", "]", ";", "$", "files", "=", "glob", "(", "$", "this", "->", "path", ".", "'*'", ",", "GLOB_ONLYDIR", ")", ";", "if", "(", "$", "files", ")", "{", "foreach", "(", "$", "files", "as", "$", "f", ")", "{", "$", "result", "[", "]", "=", "self", "::", "getInstance", "(", "$", "f", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
returns all FilesystemFolder instances in folder @return Array
[ "returns", "all", "FilesystemFolder", "instances", "in", "folder" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/File/FilesystemFolder.php#L146-L159
train
Vectrex/vxPHP
src/File/FilesystemFolder.php
FilesystemFolder.getParentFolder
public function getParentFolder($force = FALSE) { if(!isset($this->parentFolder) || $force) { $parentPath = realpath($this->path . '..'); // flag parentFolder property, when $this is already the root folder if($parentPath === $this->path) { $this->parentFolder = FALSE; } else { $this->parentFolder = self::getInstance($parentPath); } } // return NULL (instead of FALSE) when there is no parent folder return $this->parentFolder ?: NULL; }
php
public function getParentFolder($force = FALSE) { if(!isset($this->parentFolder) || $force) { $parentPath = realpath($this->path . '..'); // flag parentFolder property, when $this is already the root folder if($parentPath === $this->path) { $this->parentFolder = FALSE; } else { $this->parentFolder = self::getInstance($parentPath); } } // return NULL (instead of FALSE) when there is no parent folder return $this->parentFolder ?: NULL; }
[ "public", "function", "getParentFolder", "(", "$", "force", "=", "FALSE", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "parentFolder", ")", "||", "$", "force", ")", "{", "$", "parentPath", "=", "realpath", "(", "$", "this", "->", "path", ".", "'..'", ")", ";", "// flag parentFolder property, when $this is already the root folder", "if", "(", "$", "parentPath", "===", "$", "this", "->", "path", ")", "{", "$", "this", "->", "parentFolder", "=", "FALSE", ";", "}", "else", "{", "$", "this", "->", "parentFolder", "=", "self", "::", "getInstance", "(", "$", "parentPath", ")", ";", "}", "}", "// return NULL (instead of FALSE) when there is no parent folder", "return", "$", "this", "->", "parentFolder", "?", ":", "NULL", ";", "}" ]
return parent FilesystemFolder of current folder returns NULL, when current folder is already the root folder @param boolean $force @return FilesystemFolder
[ "return", "parent", "FilesystemFolder", "of", "current", "folder", "returns", "NULL", "when", "current", "folder", "is", "already", "the", "root", "folder" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/File/FilesystemFolder.php#L168-L190
train
Vectrex/vxPHP
src/File/FilesystemFolder.php
FilesystemFolder.createFolder
public function createFolder($folderName) { // prefix folder path, when realpath fails (e.g. does not exist) if(!($path = realpath($folderName))) { $path = $this->path . $folderName; } // throw exception when $folderName cannot be established as subdirectory of current folder else if (strpos($path, $this->path) !== 0) { throw new FilesystemFolderException(sprintf("Folder %s cannot be created within folder %s.", $folderName, $this->path)); } // recursively create folder(s) when when path not already exists if(!is_dir($path)) { if(!@mkdir($path, 0777, TRUE)) { throw new FilesystemFolderException(sprintf("Folder %s could not be created!", $path)); } else { chmod($path, 0777); } $path = realpath($path); } return self::getInstance($path); }
php
public function createFolder($folderName) { // prefix folder path, when realpath fails (e.g. does not exist) if(!($path = realpath($folderName))) { $path = $this->path . $folderName; } // throw exception when $folderName cannot be established as subdirectory of current folder else if (strpos($path, $this->path) !== 0) { throw new FilesystemFolderException(sprintf("Folder %s cannot be created within folder %s.", $folderName, $this->path)); } // recursively create folder(s) when when path not already exists if(!is_dir($path)) { if(!@mkdir($path, 0777, TRUE)) { throw new FilesystemFolderException(sprintf("Folder %s could not be created!", $path)); } else { chmod($path, 0777); } $path = realpath($path); } return self::getInstance($path); }
[ "public", "function", "createFolder", "(", "$", "folderName", ")", "{", "// prefix folder path, when realpath fails (e.g. does not exist)", "if", "(", "!", "(", "$", "path", "=", "realpath", "(", "$", "folderName", ")", ")", ")", "{", "$", "path", "=", "$", "this", "->", "path", ".", "$", "folderName", ";", "}", "// throw exception when $folderName cannot be established as subdirectory of current folder", "else", "if", "(", "strpos", "(", "$", "path", ",", "$", "this", "->", "path", ")", "!==", "0", ")", "{", "throw", "new", "FilesystemFolderException", "(", "sprintf", "(", "\"Folder %s cannot be created within folder %s.\"", ",", "$", "folderName", ",", "$", "this", "->", "path", ")", ")", ";", "}", "// recursively create folder(s) when when path not already exists", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "if", "(", "!", "@", "mkdir", "(", "$", "path", ",", "0777", ",", "TRUE", ")", ")", "{", "throw", "new", "FilesystemFolderException", "(", "sprintf", "(", "\"Folder %s could not be created!\"", ",", "$", "path", ")", ")", ";", "}", "else", "{", "chmod", "(", "$", "path", ",", "0777", ")", ";", "}", "$", "path", "=", "realpath", "(", "$", "path", ")", ";", "}", "return", "self", "::", "getInstance", "(", "$", "path", ")", ";", "}" ]
create a new subdirectory returns newly created FilesystemFolder object @param string $folderName @return FilesystemFolder @throws FilesystemFolderException
[ "create", "a", "new", "subdirectory", "returns", "newly", "created", "FilesystemFolder", "object" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/File/FilesystemFolder.php#L231-L265
train
Vectrex/vxPHP
src/File/FilesystemFolder.php
FilesystemFolder.purgeCache
public function purgeCache($force = FALSE) { if(($path = $this->getCachePath($force))) { foreach(glob($path. '*') as $f) { if(!unlink($f)) { throw new FilesystemFolderException(sprintf('Cache folder %s could not be purged!', $this->path . self::CACHE_PATH)); } } } }
php
public function purgeCache($force = FALSE) { if(($path = $this->getCachePath($force))) { foreach(glob($path. '*') as $f) { if(!unlink($f)) { throw new FilesystemFolderException(sprintf('Cache folder %s could not be purged!', $this->path . self::CACHE_PATH)); } } } }
[ "public", "function", "purgeCache", "(", "$", "force", "=", "FALSE", ")", "{", "if", "(", "(", "$", "path", "=", "$", "this", "->", "getCachePath", "(", "$", "force", ")", ")", ")", "{", "foreach", "(", "glob", "(", "$", "path", ".", "'*'", ")", "as", "$", "f", ")", "{", "if", "(", "!", "unlink", "(", "$", "f", ")", ")", "{", "throw", "new", "FilesystemFolderException", "(", "sprintf", "(", "'Cache folder %s could not be purged!'", ",", "$", "this", "->", "path", ".", "self", "::", "CACHE_PATH", ")", ")", ";", "}", "}", "}", "}" ]
empties the cache when found @param boolean $force @throws FilesystemFolderException
[ "empties", "the", "cache", "when", "found" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/File/FilesystemFolder.php#L295-L305
train
hschletz/NADA
src/Table/Mysql.php
Mysql.setCharset
public function setCharset($charset) { $this->_database->exec( 'ALTER TABLE ' . $this->_database->prepareIdentifier($this->_name) . ' CONVERT TO CHARACTER SET ' . $this->_database->prepareValue($charset, Column::TYPE_VARCHAR) ); }
php
public function setCharset($charset) { $this->_database->exec( 'ALTER TABLE ' . $this->_database->prepareIdentifier($this->_name) . ' CONVERT TO CHARACTER SET ' . $this->_database->prepareValue($charset, Column::TYPE_VARCHAR) ); }
[ "public", "function", "setCharset", "(", "$", "charset", ")", "{", "$", "this", "->", "_database", "->", "exec", "(", "'ALTER TABLE '", ".", "$", "this", "->", "_database", "->", "prepareIdentifier", "(", "$", "this", "->", "_name", ")", ".", "' CONVERT TO CHARACTER SET '", ".", "$", "this", "->", "_database", "->", "prepareValue", "(", "$", "charset", ",", "Column", "::", "TYPE_VARCHAR", ")", ")", ";", "}" ]
Set character set and convert data to new character set @param string $charset Character set known to MySQL server @return void
[ "Set", "character", "set", "and", "convert", "data", "to", "new", "character", "set" ]
4ead798354089fd360f917ce64dd1432d5650df0
https://github.com/hschletz/NADA/blob/4ead798354089fd360f917ce64dd1432d5650df0/src/Table/Mysql.php#L142-L150
train
hschletz/NADA
src/Table/Mysql.php
Mysql.getEngine
public function getEngine() { if (!$this->_engine) { $table = $this->_database->query('SHOW TABLE STATUS LIKE ?', $this->_name); $this->_engine = $table[0]['engine']; } return $this->_engine; }
php
public function getEngine() { if (!$this->_engine) { $table = $this->_database->query('SHOW TABLE STATUS LIKE ?', $this->_name); $this->_engine = $table[0]['engine']; } return $this->_engine; }
[ "public", "function", "getEngine", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_engine", ")", "{", "$", "table", "=", "$", "this", "->", "_database", "->", "query", "(", "'SHOW TABLE STATUS LIKE ?'", ",", "$", "this", "->", "_name", ")", ";", "$", "this", "->", "_engine", "=", "$", "table", "[", "0", "]", "[", "'engine'", "]", ";", "}", "return", "$", "this", "->", "_engine", ";", "}" ]
Retrieve table engine @return string
[ "Retrieve", "table", "engine" ]
4ead798354089fd360f917ce64dd1432d5650df0
https://github.com/hschletz/NADA/blob/4ead798354089fd360f917ce64dd1432d5650df0/src/Table/Mysql.php#L157-L164
train
hschletz/NADA
src/Table/Mysql.php
Mysql.setEngine
public function setEngine($engine) { $this->_database->exec( 'ALTER TABLE ' . $this->_database->prepareIdentifier($this->_name) . ' ENGINE = ' . $this->_database->prepareValue($engine, Column::TYPE_VARCHAR) ); // MySQL ignores invalid engine names. Check explicitly. // The getEngine() also implicitly updates $_engine. if (strcasecmp($this->getEngine(), $engine) != 0) { throw new \RuntimeException('Unsupported table engine: ' . $engine); } }
php
public function setEngine($engine) { $this->_database->exec( 'ALTER TABLE ' . $this->_database->prepareIdentifier($this->_name) . ' ENGINE = ' . $this->_database->prepareValue($engine, Column::TYPE_VARCHAR) ); // MySQL ignores invalid engine names. Check explicitly. // The getEngine() also implicitly updates $_engine. if (strcasecmp($this->getEngine(), $engine) != 0) { throw new \RuntimeException('Unsupported table engine: ' . $engine); } }
[ "public", "function", "setEngine", "(", "$", "engine", ")", "{", "$", "this", "->", "_database", "->", "exec", "(", "'ALTER TABLE '", ".", "$", "this", "->", "_database", "->", "prepareIdentifier", "(", "$", "this", "->", "_name", ")", ".", "' ENGINE = '", ".", "$", "this", "->", "_database", "->", "prepareValue", "(", "$", "engine", ",", "Column", "::", "TYPE_VARCHAR", ")", ")", ";", "// MySQL ignores invalid engine names. Check explicitly.", "// The getEngine() also implicitly updates $_engine.", "if", "(", "strcasecmp", "(", "$", "this", "->", "getEngine", "(", ")", ",", "$", "engine", ")", "!=", "0", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Unsupported table engine: '", ".", "$", "engine", ")", ";", "}", "}" ]
Set table engine @param string $engine New table engine (MyISAM, InnoDB etc.) @throws \RuntimeException if $engine is not recognized by the server
[ "Set", "table", "engine" ]
4ead798354089fd360f917ce64dd1432d5650df0
https://github.com/hschletz/NADA/blob/4ead798354089fd360f917ce64dd1432d5650df0/src/Table/Mysql.php#L171-L184
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.unload
protected function unload() { foreach ($this->ial as $entry) { if (isset($entry['TIMER'])) { $this->removeTimer($entry['TIMER']); } } }
php
protected function unload() { foreach ($this->ial as $entry) { if (isset($entry['TIMER'])) { $this->removeTimer($entry['TIMER']); } } }
[ "protected", "function", "unload", "(", ")", "{", "foreach", "(", "$", "this", "->", "ial", "as", "$", "entry", ")", "{", "if", "(", "isset", "(", "$", "entry", "[", "'TIMER'", "]", ")", ")", "{", "$", "this", "->", "removeTimer", "(", "$", "entry", "[", "'TIMER'", "]", ")", ";", "}", "}", "}" ]
Frees the resources associated with this module.
[ "Frees", "the", "resources", "associated", "with", "this", "module", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L173-L180
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.updateUser
protected function updateUser($nick, $ident, $host) { $collator = $this->connection->getCollator(); $normNick = $collator->normalizeNick($nick); $key = array_search($normNick, $this->nicks); if ($key === false) { $key = $this->sequence++; $this->nicks[$key] = $normNick; } if (isset($this->ial[$key]['TIMER'])) { $this->removeTimer($this->ial[$key]['TIMER']); } if (!isset($this->ial[$key]) || $this->ial[$key]['ident'] === null) { $this->ial[$key] = array( 'nick' => $nick, 'ident' => $ident, 'host' => $host, 'ison' => true, 'TIMER' => null, ); return; } if ($ident !== null) { if ($this->ial[$key]['ident'] != $ident || $this->ial[$key]['host'] != $host) { unset($this->nicks[$key]); unset($this->ial[$key]); $key = $this->sequence++; $this->nicks[$key] = $normNick; } $this->ial[$key] = array( 'nick' => $nick, 'ident' => $ident, 'host' => $host, 'ison' => true, 'TIMER' => null, ); } }
php
protected function updateUser($nick, $ident, $host) { $collator = $this->connection->getCollator(); $normNick = $collator->normalizeNick($nick); $key = array_search($normNick, $this->nicks); if ($key === false) { $key = $this->sequence++; $this->nicks[$key] = $normNick; } if (isset($this->ial[$key]['TIMER'])) { $this->removeTimer($this->ial[$key]['TIMER']); } if (!isset($this->ial[$key]) || $this->ial[$key]['ident'] === null) { $this->ial[$key] = array( 'nick' => $nick, 'ident' => $ident, 'host' => $host, 'ison' => true, 'TIMER' => null, ); return; } if ($ident !== null) { if ($this->ial[$key]['ident'] != $ident || $this->ial[$key]['host'] != $host) { unset($this->nicks[$key]); unset($this->ial[$key]); $key = $this->sequence++; $this->nicks[$key] = $normNick; } $this->ial[$key] = array( 'nick' => $nick, 'ident' => $ident, 'host' => $host, 'ison' => true, 'TIMER' => null, ); } }
[ "protected", "function", "updateUser", "(", "$", "nick", ",", "$", "ident", ",", "$", "host", ")", "{", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "normNick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "nick", ")", ";", "$", "key", "=", "array_search", "(", "$", "normNick", ",", "$", "this", "->", "nicks", ")", ";", "if", "(", "$", "key", "===", "false", ")", "{", "$", "key", "=", "$", "this", "->", "sequence", "++", ";", "$", "this", "->", "nicks", "[", "$", "key", "]", "=", "$", "normNick", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "ial", "[", "$", "key", "]", "[", "'TIMER'", "]", ")", ")", "{", "$", "this", "->", "removeTimer", "(", "$", "this", "->", "ial", "[", "$", "key", "]", "[", "'TIMER'", "]", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "ial", "[", "$", "key", "]", ")", "||", "$", "this", "->", "ial", "[", "$", "key", "]", "[", "'ident'", "]", "===", "null", ")", "{", "$", "this", "->", "ial", "[", "$", "key", "]", "=", "array", "(", "'nick'", "=>", "$", "nick", ",", "'ident'", "=>", "$", "ident", ",", "'host'", "=>", "$", "host", ",", "'ison'", "=>", "true", ",", "'TIMER'", "=>", "null", ",", ")", ";", "return", ";", "}", "if", "(", "$", "ident", "!==", "null", ")", "{", "if", "(", "$", "this", "->", "ial", "[", "$", "key", "]", "[", "'ident'", "]", "!=", "$", "ident", "||", "$", "this", "->", "ial", "[", "$", "key", "]", "[", "'host'", "]", "!=", "$", "host", ")", "{", "unset", "(", "$", "this", "->", "nicks", "[", "$", "key", "]", ")", ";", "unset", "(", "$", "this", "->", "ial", "[", "$", "key", "]", ")", ";", "$", "key", "=", "$", "this", "->", "sequence", "++", ";", "$", "this", "->", "nicks", "[", "$", "key", "]", "=", "$", "normNick", ";", "}", "$", "this", "->", "ial", "[", "$", "key", "]", "=", "array", "(", "'nick'", "=>", "$", "nick", ",", "'ident'", "=>", "$", "ident", ",", "'host'", "=>", "$", "host", ",", "'ison'", "=>", "true", ",", "'TIMER'", "=>", "null", ",", ")", ";", "}", "}" ]
Updates the IAL with new information on some user. \param string $nick Some user's nickname whose IAL entry will be updated. \param string $ident Some user's identity, in the IRC sense of the term. \param string $host Some user's hostname.
[ "Updates", "the", "IAL", "with", "new", "information", "on", "some", "user", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L250-L292
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.realRemoveUser
protected function realRemoveUser($nick) { $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($nick); $key = array_search($nick, $this->nicks); if ($key === false) { return; } $this->ial[$key]['TIMER'] = null; if (!isset($this->nicks[$key]) || count($this->getCommonChans($nick))) { return; } unset($this->nicks[$key]); unset($this->ial[$key]); }
php
protected function realRemoveUser($nick) { $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($nick); $key = array_search($nick, $this->nicks); if ($key === false) { return; } $this->ial[$key]['TIMER'] = null; if (!isset($this->nicks[$key]) || count($this->getCommonChans($nick))) { return; } unset($this->nicks[$key]); unset($this->ial[$key]); }
[ "protected", "function", "realRemoveUser", "(", "$", "nick", ")", "{", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "nick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "nick", ")", ";", "$", "key", "=", "array_search", "(", "$", "nick", ",", "$", "this", "->", "nicks", ")", ";", "if", "(", "$", "key", "===", "false", ")", "{", "return", ";", "}", "$", "this", "->", "ial", "[", "$", "key", "]", "[", "'TIMER'", "]", "=", "null", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "nicks", "[", "$", "key", "]", ")", "||", "count", "(", "$", "this", "->", "getCommonChans", "(", "$", "nick", ")", ")", ")", "{", "return", ";", "}", "unset", "(", "$", "this", "->", "nicks", "[", "$", "key", "]", ")", ";", "unset", "(", "$", "this", "->", "ial", "[", "$", "key", "]", ")", ";", "}" ]
Removes some user from the IAL. \param string $nick Nickname of the user that is to be removed from the IAL.
[ "Removes", "some", "user", "from", "the", "IAL", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L301-L318
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.handleNick
public function handleNick( \Erebot\Interfaces\EventHandler $handler, \Erebot\Interfaces\Event\Nick $event ) { $oldNick = (string) $event->getSource(); $newNick = (string) $event->getTarget(); $collator = $this->connection->getCollator(); $normOldNick = $collator->normalizeNick($oldNick); $normNewNick = $collator->normalizeNick($newNick); $key = array_search($normOldNick, $this->nicks); if ($key === false) { return; } $this->realRemoveUser($normNewNick); $this->nicks[$key] = $normNewNick; $this->ial[$key]['nick'] = $newNick; }
php
public function handleNick( \Erebot\Interfaces\EventHandler $handler, \Erebot\Interfaces\Event\Nick $event ) { $oldNick = (string) $event->getSource(); $newNick = (string) $event->getTarget(); $collator = $this->connection->getCollator(); $normOldNick = $collator->normalizeNick($oldNick); $normNewNick = $collator->normalizeNick($newNick); $key = array_search($normOldNick, $this->nicks); if ($key === false) { return; } $this->realRemoveUser($normNewNick); $this->nicks[$key] = $normNewNick; $this->ial[$key]['nick'] = $newNick; }
[ "public", "function", "handleNick", "(", "\\", "Erebot", "\\", "Interfaces", "\\", "EventHandler", "$", "handler", ",", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Nick", "$", "event", ")", "{", "$", "oldNick", "=", "(", "string", ")", "$", "event", "->", "getSource", "(", ")", ";", "$", "newNick", "=", "(", "string", ")", "$", "event", "->", "getTarget", "(", ")", ";", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "normOldNick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "oldNick", ")", ";", "$", "normNewNick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "newNick", ")", ";", "$", "key", "=", "array_search", "(", "$", "normOldNick", ",", "$", "this", "->", "nicks", ")", ";", "if", "(", "$", "key", "===", "false", ")", "{", "return", ";", "}", "$", "this", "->", "realRemoveUser", "(", "$", "normNewNick", ")", ";", "$", "this", "->", "nicks", "[", "$", "key", "]", "=", "$", "normNewNick", ";", "$", "this", "->", "ial", "[", "$", "key", "]", "[", "'nick'", "]", "=", "$", "newNick", ";", "}" ]
Handles a nick change. \param Erebot::Interfaces::EventHandler $handler Handler that triggered this event. \param Erebot::Interfaces::Event::Nick $event Nick change event. @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Handles", "a", "nick", "change", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L378-L396
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.handleLeaving
public function handleLeaving( \Erebot\Interfaces\EventHandler $handler, \Erebot\Interfaces\Event\Base\Generic $event ) { if ($event instanceof \Erebot\Interfaces\Event\Kick) { $nick = (string) $event->getTarget(); } else { $nick = (string) $event->getSource(); } $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($nick); $key = array_search($nick, $this->nicks); if ($event instanceof \Erebot\Interfaces\Event\Quit) { foreach ($this->chans as $chan => $data) { if (isset($data[$key])) { unset($this->chans[$chan][$key]); } } } else { unset($this->chans[$event->getChan()][$key]); } if (!count($this->getCommonChans($nick))) { $this->ial[$key]['ison'] = false; $delay = $this->parseInt('expire_delay', 60); if ($delay < 0) { $delay = 0; } if (!$delay) { $this->realRemoveUser($nick); } else { $timerCls = $this->getFactory('!Timer'); $timer = new $timerCls( array($this, 'removeUser'), $delay, false, array($nick) ); $this->addTimer($timer); } } }
php
public function handleLeaving( \Erebot\Interfaces\EventHandler $handler, \Erebot\Interfaces\Event\Base\Generic $event ) { if ($event instanceof \Erebot\Interfaces\Event\Kick) { $nick = (string) $event->getTarget(); } else { $nick = (string) $event->getSource(); } $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($nick); $key = array_search($nick, $this->nicks); if ($event instanceof \Erebot\Interfaces\Event\Quit) { foreach ($this->chans as $chan => $data) { if (isset($data[$key])) { unset($this->chans[$chan][$key]); } } } else { unset($this->chans[$event->getChan()][$key]); } if (!count($this->getCommonChans($nick))) { $this->ial[$key]['ison'] = false; $delay = $this->parseInt('expire_delay', 60); if ($delay < 0) { $delay = 0; } if (!$delay) { $this->realRemoveUser($nick); } else { $timerCls = $this->getFactory('!Timer'); $timer = new $timerCls( array($this, 'removeUser'), $delay, false, array($nick) ); $this->addTimer($timer); } } }
[ "public", "function", "handleLeaving", "(", "\\", "Erebot", "\\", "Interfaces", "\\", "EventHandler", "$", "handler", ",", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Base", "\\", "Generic", "$", "event", ")", "{", "if", "(", "$", "event", "instanceof", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Kick", ")", "{", "$", "nick", "=", "(", "string", ")", "$", "event", "->", "getTarget", "(", ")", ";", "}", "else", "{", "$", "nick", "=", "(", "string", ")", "$", "event", "->", "getSource", "(", ")", ";", "}", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "nick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "nick", ")", ";", "$", "key", "=", "array_search", "(", "$", "nick", ",", "$", "this", "->", "nicks", ")", ";", "if", "(", "$", "event", "instanceof", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Quit", ")", "{", "foreach", "(", "$", "this", "->", "chans", "as", "$", "chan", "=>", "$", "data", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "chans", "[", "$", "chan", "]", "[", "$", "key", "]", ")", ";", "}", "}", "}", "else", "{", "unset", "(", "$", "this", "->", "chans", "[", "$", "event", "->", "getChan", "(", ")", "]", "[", "$", "key", "]", ")", ";", "}", "if", "(", "!", "count", "(", "$", "this", "->", "getCommonChans", "(", "$", "nick", ")", ")", ")", "{", "$", "this", "->", "ial", "[", "$", "key", "]", "[", "'ison'", "]", "=", "false", ";", "$", "delay", "=", "$", "this", "->", "parseInt", "(", "'expire_delay'", ",", "60", ")", ";", "if", "(", "$", "delay", "<", "0", ")", "{", "$", "delay", "=", "0", ";", "}", "if", "(", "!", "$", "delay", ")", "{", "$", "this", "->", "realRemoveUser", "(", "$", "nick", ")", ";", "}", "else", "{", "$", "timerCls", "=", "$", "this", "->", "getFactory", "(", "'!Timer'", ")", ";", "$", "timer", "=", "new", "$", "timerCls", "(", "array", "(", "$", "this", ",", "'removeUser'", ")", ",", "$", "delay", ",", "false", ",", "array", "(", "$", "nick", ")", ")", ";", "$", "this", "->", "addTimer", "(", "$", "timer", ")", ";", "}", "}", "}" ]
Handles some user leaving an IRC channel. This may result from either a QUIT or KICK command. \param Erebot::Interfaces::EventHandler $handler Handler that triggered this event. \param Erebot::Interfaces::Event::Base::Generic $event An event indicating that some user is leaving an IRC channel the bot is on. @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Handles", "some", "user", "leaving", "an", "IRC", "channel", ".", "This", "may", "result", "from", "either", "a", "QUIT", "or", "KICK", "command", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L411-L455
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.handleCapabilities
public function handleCapabilities( \Erebot\Interfaces\EventHandler $handler, \Erebot\Event\ServerCapabilities $event ) { $module = $event->getModule(); if ($module->hasExtendedNames()) { $this->sendCommand('PROTOCTL NAMESX'); } if ($module->hasUserHostNames()) { $this->sendCommand('PROTOCTL UHNAMES'); $this->hasUHNAMES = true; } }
php
public function handleCapabilities( \Erebot\Interfaces\EventHandler $handler, \Erebot\Event\ServerCapabilities $event ) { $module = $event->getModule(); if ($module->hasExtendedNames()) { $this->sendCommand('PROTOCTL NAMESX'); } if ($module->hasUserHostNames()) { $this->sendCommand('PROTOCTL UHNAMES'); $this->hasUHNAMES = true; } }
[ "public", "function", "handleCapabilities", "(", "\\", "Erebot", "\\", "Interfaces", "\\", "EventHandler", "$", "handler", ",", "\\", "Erebot", "\\", "Event", "\\", "ServerCapabilities", "$", "event", ")", "{", "$", "module", "=", "$", "event", "->", "getModule", "(", ")", ";", "if", "(", "$", "module", "->", "hasExtendedNames", "(", ")", ")", "{", "$", "this", "->", "sendCommand", "(", "'PROTOCTL NAMESX'", ")", ";", "}", "if", "(", "$", "module", "->", "hasUserHostNames", "(", ")", ")", "{", "$", "this", "->", "sendCommand", "(", "'PROTOCTL UHNAMES'", ")", ";", "$", "this", "->", "hasUHNAMES", "=", "true", ";", "}", "}" ]
Handles server capabilities. \param Erebot::Interfaces::EventHandler $handler Handler that triggered this event. \param Erebot::Event::ServerCapabilities $event An event referencing a module that can determine the IRC server's capabilities, such as Erebot::Module::ServerCapabilities. @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Handles", "server", "capabilities", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L470-L482
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.handleNames
public function handleNames( \Erebot\Interfaces\NumericHandler $handler, \Erebot\Interfaces\Event\Numeric $numeric ) { $text = $numeric->getText(); $chan = $text[1]; $users = new \Erebot\TextWrapper( ltrim($numeric->getText()->getTokens(2), ':') ); try { $caps = $this->connection->getModule( '\\Erebot\\Module\\ServerCapabilities' ); } catch (\Erebot\NotFoundException $e) { return; } if (!$this->hasUHNAMES) { $this->sendCommand('WHO '.$chan); } foreach ($users as $user) { $modes = array(); for ($i = 0, $len = strlen($user); $i < $len; $i++) { try { $modes[] = $caps->getChanModeForPrefix($user[$i]); } catch (\Erebot\NotFoundException $e) { break; } } $user = substr($user, count($modes)); if ($user === false) { continue; } $identityCls = $this->getFactory('!Identity'); $identity = new $identityCls($user); $nick = $identity->getNick(); $collator = $this->connection->getCollator(); $normNick = $collator->normalizeNick($nick); $this->updateUser( $nick, $identity->getIdent(), $identity->getHost(\Erebot\Interfaces\Identity::CANON_IPV6) ); $key = array_search($normNick, $this->nicks); $this->chans[$chan][$key] = $modes; } }
php
public function handleNames( \Erebot\Interfaces\NumericHandler $handler, \Erebot\Interfaces\Event\Numeric $numeric ) { $text = $numeric->getText(); $chan = $text[1]; $users = new \Erebot\TextWrapper( ltrim($numeric->getText()->getTokens(2), ':') ); try { $caps = $this->connection->getModule( '\\Erebot\\Module\\ServerCapabilities' ); } catch (\Erebot\NotFoundException $e) { return; } if (!$this->hasUHNAMES) { $this->sendCommand('WHO '.$chan); } foreach ($users as $user) { $modes = array(); for ($i = 0, $len = strlen($user); $i < $len; $i++) { try { $modes[] = $caps->getChanModeForPrefix($user[$i]); } catch (\Erebot\NotFoundException $e) { break; } } $user = substr($user, count($modes)); if ($user === false) { continue; } $identityCls = $this->getFactory('!Identity'); $identity = new $identityCls($user); $nick = $identity->getNick(); $collator = $this->connection->getCollator(); $normNick = $collator->normalizeNick($nick); $this->updateUser( $nick, $identity->getIdent(), $identity->getHost(\Erebot\Interfaces\Identity::CANON_IPV6) ); $key = array_search($normNick, $this->nicks); $this->chans[$chan][$key] = $modes; } }
[ "public", "function", "handleNames", "(", "\\", "Erebot", "\\", "Interfaces", "\\", "NumericHandler", "$", "handler", ",", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Numeric", "$", "numeric", ")", "{", "$", "text", "=", "$", "numeric", "->", "getText", "(", ")", ";", "$", "chan", "=", "$", "text", "[", "1", "]", ";", "$", "users", "=", "new", "\\", "Erebot", "\\", "TextWrapper", "(", "ltrim", "(", "$", "numeric", "->", "getText", "(", ")", "->", "getTokens", "(", "2", ")", ",", "':'", ")", ")", ";", "try", "{", "$", "caps", "=", "$", "this", "->", "connection", "->", "getModule", "(", "'\\\\Erebot\\\\Module\\\\ServerCapabilities'", ")", ";", "}", "catch", "(", "\\", "Erebot", "\\", "NotFoundException", "$", "e", ")", "{", "return", ";", "}", "if", "(", "!", "$", "this", "->", "hasUHNAMES", ")", "{", "$", "this", "->", "sendCommand", "(", "'WHO '", ".", "$", "chan", ")", ";", "}", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "modes", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ",", "$", "len", "=", "strlen", "(", "$", "user", ")", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "try", "{", "$", "modes", "[", "]", "=", "$", "caps", "->", "getChanModeForPrefix", "(", "$", "user", "[", "$", "i", "]", ")", ";", "}", "catch", "(", "\\", "Erebot", "\\", "NotFoundException", "$", "e", ")", "{", "break", ";", "}", "}", "$", "user", "=", "substr", "(", "$", "user", ",", "count", "(", "$", "modes", ")", ")", ";", "if", "(", "$", "user", "===", "false", ")", "{", "continue", ";", "}", "$", "identityCls", "=", "$", "this", "->", "getFactory", "(", "'!Identity'", ")", ";", "$", "identity", "=", "new", "$", "identityCls", "(", "$", "user", ")", ";", "$", "nick", "=", "$", "identity", "->", "getNick", "(", ")", ";", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "normNick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "nick", ")", ";", "$", "this", "->", "updateUser", "(", "$", "nick", ",", "$", "identity", "->", "getIdent", "(", ")", ",", "$", "identity", "->", "getHost", "(", "\\", "Erebot", "\\", "Interfaces", "\\", "Identity", "::", "CANON_IPV6", ")", ")", ";", "$", "key", "=", "array_search", "(", "$", "normNick", ",", "$", "this", "->", "nicks", ")", ";", "$", "this", "->", "chans", "[", "$", "chan", "]", "[", "$", "key", "]", "=", "$", "modes", ";", "}", "}" ]
Handles a list with the nicknames of all users in a given IRC channel. \param Erebot::Interfaces::NumericHandler $handler Handler that triggered this event. \param Erebot::Interfaces::Event::Numeric $numeric A numeric event with the nicknames of users in an IRC channel the bot just joined. This is the same type of numeric event as when the NAMES command is issued. @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Handles", "a", "list", "with", "the", "nicknames", "of", "all", "users", "in", "a", "given", "IRC", "channel", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L499-L550
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.handleWho
public function handleWho( \Erebot\Interfaces\NumericHandler $handler, \Erebot\Interfaces\Event\Numeric $numeric ) { $text = $numeric->getText(); $this->updateUser($text[4], $text[1], $text[2]); }
php
public function handleWho( \Erebot\Interfaces\NumericHandler $handler, \Erebot\Interfaces\Event\Numeric $numeric ) { $text = $numeric->getText(); $this->updateUser($text[4], $text[1], $text[2]); }
[ "public", "function", "handleWho", "(", "\\", "Erebot", "\\", "Interfaces", "\\", "NumericHandler", "$", "handler", ",", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Numeric", "$", "numeric", ")", "{", "$", "text", "=", "$", "numeric", "->", "getText", "(", ")", ";", "$", "this", "->", "updateUser", "(", "$", "text", "[", "4", "]", ",", "$", "text", "[", "1", "]", ",", "$", "text", "[", "2", "]", ")", ";", "}" ]
Handles information about some user. \param Erebot::Interfaces::NumericHandler $handler Handler that triggered this event. \param Erebot::Interfaces::Event::Numeric $numeric Numeric event containing some user's nickname, IRC identity and hostname. @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Handles", "information", "about", "some", "user", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L564-L570
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.handleJoin
public function handleJoin( \Erebot\Interfaces\EventHandler $handler, \Erebot\Interfaces\Event\Join $event ) { $user = $event->getSource(); $nick = $user->getNick(); $collator = $this->connection->getCollator(); $normNick = $collator->normalizeNick($nick); $this->updateUser( $nick, $user->getIdent(), $user->getHost(\Erebot\Interfaces\Identity::CANON_IPV6) ); $key = array_search($normNick, $this->nicks); $this->chans[$event->getChan()][$key] = array(); }
php
public function handleJoin( \Erebot\Interfaces\EventHandler $handler, \Erebot\Interfaces\Event\Join $event ) { $user = $event->getSource(); $nick = $user->getNick(); $collator = $this->connection->getCollator(); $normNick = $collator->normalizeNick($nick); $this->updateUser( $nick, $user->getIdent(), $user->getHost(\Erebot\Interfaces\Identity::CANON_IPV6) ); $key = array_search($normNick, $this->nicks); $this->chans[$event->getChan()][$key] = array(); }
[ "public", "function", "handleJoin", "(", "\\", "Erebot", "\\", "Interfaces", "\\", "EventHandler", "$", "handler", ",", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Join", "$", "event", ")", "{", "$", "user", "=", "$", "event", "->", "getSource", "(", ")", ";", "$", "nick", "=", "$", "user", "->", "getNick", "(", ")", ";", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "normNick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "nick", ")", ";", "$", "this", "->", "updateUser", "(", "$", "nick", ",", "$", "user", "->", "getIdent", "(", ")", ",", "$", "user", "->", "getHost", "(", "\\", "Erebot", "\\", "Interfaces", "\\", "Identity", "::", "CANON_IPV6", ")", ")", ";", "$", "key", "=", "array_search", "(", "$", "normNick", ",", "$", "this", "->", "nicks", ")", ";", "$", "this", "->", "chans", "[", "$", "event", "->", "getChan", "(", ")", "]", "[", "$", "key", "]", "=", "array", "(", ")", ";", "}" ]
Handles some user joining an IRC channel the bot is currently on. \param Erebot::Interfaces::EventHandler $handler Handler that triggered this event. \param Erebot::Interfaces::Event::Join $event Event indicating that some user joined a channel the bot is on. @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Handles", "some", "user", "joining", "an", "IRC", "channel", "the", "bot", "is", "currently", "on", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L585-L601
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.handleChanModeAddition
public function handleChanModeAddition( \Erebot\Interfaces\EventHandler $handler, \Erebot\Interfaces\Event\Base\ChanModeGiven $event ) { $user = $event->getTarget(); $nick = self::extractNick($user); $collator = $this->connection->getCollator(); $normNick = $collator->normalizeNick($nick); $key = array_search($normNick, $this->nicks); if ($key === false) { return; } $this->chans[$event->getChan()][$key][] = \Erebot\Utils::getVStatic($event, 'MODE_LETTER'); }
php
public function handleChanModeAddition( \Erebot\Interfaces\EventHandler $handler, \Erebot\Interfaces\Event\Base\ChanModeGiven $event ) { $user = $event->getTarget(); $nick = self::extractNick($user); $collator = $this->connection->getCollator(); $normNick = $collator->normalizeNick($nick); $key = array_search($normNick, $this->nicks); if ($key === false) { return; } $this->chans[$event->getChan()][$key][] = \Erebot\Utils::getVStatic($event, 'MODE_LETTER'); }
[ "public", "function", "handleChanModeAddition", "(", "\\", "Erebot", "\\", "Interfaces", "\\", "EventHandler", "$", "handler", ",", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Base", "\\", "ChanModeGiven", "$", "event", ")", "{", "$", "user", "=", "$", "event", "->", "getTarget", "(", ")", ";", "$", "nick", "=", "self", "::", "extractNick", "(", "$", "user", ")", ";", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "normNick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "nick", ")", ";", "$", "key", "=", "array_search", "(", "$", "normNick", ",", "$", "this", "->", "nicks", ")", ";", "if", "(", "$", "key", "===", "false", ")", "{", "return", ";", "}", "$", "this", "->", "chans", "[", "$", "event", "->", "getChan", "(", ")", "]", "[", "$", "key", "]", "[", "]", "=", "\\", "Erebot", "\\", "Utils", "::", "getVStatic", "(", "$", "event", ",", "'MODE_LETTER'", ")", ";", "}" ]
Handles someone receiving a new status on an IRC channel, for example, when someone is OPped. \param Erebot::Interfaces::EventHandler $handler Handler that triggered this event. \param Erebot::Interfaces::Event::Base::ChanModeGiven $event Event indicating someone's status changed on an IRC channel the bot is currently on, giving that person new privileges. @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Handles", "someone", "receiving", "a", "new", "status", "on", "an", "IRC", "channel", "for", "example", "when", "someone", "is", "OPped", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L617-L632
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.startTracking
public function startTracking($nick, $cls = '\\Erebot\\Module\\IrcTracker\\Token') { $identityCls = $this->getFactory('!Identity'); $fmt = $this->getFormatter(null); if ($nick instanceof \Erebot\Interfaces\Identity) { $identity = $nick; } else { if (!is_string($nick)) { throw new \Erebot\InvalidValueException( $fmt->_('Not a valid nick') ); } $identity = new $identityCls($nick); } $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($identity->getNick()); $key = array_search($nick, $this->nicks); if ($key === false) { throw new \Erebot\NotFoundException($fmt->_('No such user')); } return new $cls($this, $key); }
php
public function startTracking($nick, $cls = '\\Erebot\\Module\\IrcTracker\\Token') { $identityCls = $this->getFactory('!Identity'); $fmt = $this->getFormatter(null); if ($nick instanceof \Erebot\Interfaces\Identity) { $identity = $nick; } else { if (!is_string($nick)) { throw new \Erebot\InvalidValueException( $fmt->_('Not a valid nick') ); } $identity = new $identityCls($nick); } $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($identity->getNick()); $key = array_search($nick, $this->nicks); if ($key === false) { throw new \Erebot\NotFoundException($fmt->_('No such user')); } return new $cls($this, $key); }
[ "public", "function", "startTracking", "(", "$", "nick", ",", "$", "cls", "=", "'\\\\Erebot\\\\Module\\\\IrcTracker\\\\Token'", ")", "{", "$", "identityCls", "=", "$", "this", "->", "getFactory", "(", "'!Identity'", ")", ";", "$", "fmt", "=", "$", "this", "->", "getFormatter", "(", "null", ")", ";", "if", "(", "$", "nick", "instanceof", "\\", "Erebot", "\\", "Interfaces", "\\", "Identity", ")", "{", "$", "identity", "=", "$", "nick", ";", "}", "else", "{", "if", "(", "!", "is_string", "(", "$", "nick", ")", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "$", "fmt", "->", "_", "(", "'Not a valid nick'", ")", ")", ";", "}", "$", "identity", "=", "new", "$", "identityCls", "(", "$", "nick", ")", ";", "}", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "nick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "identity", "->", "getNick", "(", ")", ")", ";", "$", "key", "=", "array_search", "(", "$", "nick", ",", "$", "this", "->", "nicks", ")", ";", "if", "(", "$", "key", "===", "false", ")", "{", "throw", "new", "\\", "Erebot", "\\", "NotFoundException", "(", "$", "fmt", "->", "_", "(", "'No such user'", ")", ")", ";", "}", "return", "new", "$", "cls", "(", "$", "this", ",", "$", "key", ")", ";", "}" ]
Returns a tracking token for some user. \param string $nick The nickname of some user we want to start tracking. \param string $cls (optional) Class to use to create the token. Defaults to Erebot::Module::IrcTracker::Token. \retval mixed A token that can later be used to return information on that user (such as his/her nickname, IRC identity, hostname and whether that person is still online or not). \throw Erebot::NotFoundException There is currently no user connected on an IRC channel the bot is on matching the given nickname. \throw Erebot::InvalidValueException The given nick is invalid.
[ "Returns", "a", "tracking", "token", "for", "some", "user", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L695-L718
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.getInfo
public function getInfo($token, $info, $args = array()) { if ($token instanceof \Erebot\Module\IrcTracker\Token) { $methods = array( self::INFO_ISON => 'isOn', self::INFO_MASK => 'getMask', self::INFO_NICK => 'getNick', self::INFO_IDENT => 'getIdent', self::INFO_HOST => 'getHost', ); if (!isset($methods[$info])) { throw new \Erebot\InvalidValueException('No such information'); } array_unshift($args, $token, $methods[$info]); return call_user_func($args); } $fmt = $this->getFormatter(null); if (is_string($token)) { $collator = $this->connection->getCollator(); $token = $collator->normalizeNick( self::extractNick($token) ); $token = array_search($token, $this->nicks); if ($token === false) { throw new \Erebot\NotFoundException( $fmt->_('No such user') ); } } if (!isset($this->ial[$token])) { throw new \Erebot\NotFoundException($fmt->_('No such token')); } $info = strtolower($info); if ($info == 'mask') { if ($this->ial[$token]['ident'] === null) { return $this->ial[$token]['nick'].'!*@*'; } return $this->ial[$token]['nick'].'!'. $this->ial[$token]['ident'].'@'. $this->ial[$token]['host']; } if (!array_key_exists($info, $this->ial[$token])) { throw new \Erebot\InvalidValueException( $fmt->_('No such information') ); } return $this->ial[$token][$info]; }
php
public function getInfo($token, $info, $args = array()) { if ($token instanceof \Erebot\Module\IrcTracker\Token) { $methods = array( self::INFO_ISON => 'isOn', self::INFO_MASK => 'getMask', self::INFO_NICK => 'getNick', self::INFO_IDENT => 'getIdent', self::INFO_HOST => 'getHost', ); if (!isset($methods[$info])) { throw new \Erebot\InvalidValueException('No such information'); } array_unshift($args, $token, $methods[$info]); return call_user_func($args); } $fmt = $this->getFormatter(null); if (is_string($token)) { $collator = $this->connection->getCollator(); $token = $collator->normalizeNick( self::extractNick($token) ); $token = array_search($token, $this->nicks); if ($token === false) { throw new \Erebot\NotFoundException( $fmt->_('No such user') ); } } if (!isset($this->ial[$token])) { throw new \Erebot\NotFoundException($fmt->_('No such token')); } $info = strtolower($info); if ($info == 'mask') { if ($this->ial[$token]['ident'] === null) { return $this->ial[$token]['nick'].'!*@*'; } return $this->ial[$token]['nick'].'!'. $this->ial[$token]['ident'].'@'. $this->ial[$token]['host']; } if (!array_key_exists($info, $this->ial[$token])) { throw new \Erebot\InvalidValueException( $fmt->_('No such information') ); } return $this->ial[$token][$info]; }
[ "public", "function", "getInfo", "(", "$", "token", ",", "$", "info", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "$", "token", "instanceof", "\\", "Erebot", "\\", "Module", "\\", "IrcTracker", "\\", "Token", ")", "{", "$", "methods", "=", "array", "(", "self", "::", "INFO_ISON", "=>", "'isOn'", ",", "self", "::", "INFO_MASK", "=>", "'getMask'", ",", "self", "::", "INFO_NICK", "=>", "'getNick'", ",", "self", "::", "INFO_IDENT", "=>", "'getIdent'", ",", "self", "::", "INFO_HOST", "=>", "'getHost'", ",", ")", ";", "if", "(", "!", "isset", "(", "$", "methods", "[", "$", "info", "]", ")", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "'No such information'", ")", ";", "}", "array_unshift", "(", "$", "args", ",", "$", "token", ",", "$", "methods", "[", "$", "info", "]", ")", ";", "return", "call_user_func", "(", "$", "args", ")", ";", "}", "$", "fmt", "=", "$", "this", "->", "getFormatter", "(", "null", ")", ";", "if", "(", "is_string", "(", "$", "token", ")", ")", "{", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "token", "=", "$", "collator", "->", "normalizeNick", "(", "self", "::", "extractNick", "(", "$", "token", ")", ")", ";", "$", "token", "=", "array_search", "(", "$", "token", ",", "$", "this", "->", "nicks", ")", ";", "if", "(", "$", "token", "===", "false", ")", "{", "throw", "new", "\\", "Erebot", "\\", "NotFoundException", "(", "$", "fmt", "->", "_", "(", "'No such user'", ")", ")", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "ial", "[", "$", "token", "]", ")", ")", "{", "throw", "new", "\\", "Erebot", "\\", "NotFoundException", "(", "$", "fmt", "->", "_", "(", "'No such token'", ")", ")", ";", "}", "$", "info", "=", "strtolower", "(", "$", "info", ")", ";", "if", "(", "$", "info", "==", "'mask'", ")", "{", "if", "(", "$", "this", "->", "ial", "[", "$", "token", "]", "[", "'ident'", "]", "===", "null", ")", "{", "return", "$", "this", "->", "ial", "[", "$", "token", "]", "[", "'nick'", "]", ".", "'!*@*'", ";", "}", "return", "$", "this", "->", "ial", "[", "$", "token", "]", "[", "'nick'", "]", ".", "'!'", ".", "$", "this", "->", "ial", "[", "$", "token", "]", "[", "'ident'", "]", ".", "'@'", ".", "$", "this", "->", "ial", "[", "$", "token", "]", "[", "'host'", "]", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "info", ",", "$", "this", "->", "ial", "[", "$", "token", "]", ")", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "$", "fmt", "->", "_", "(", "'No such information'", ")", ")", ";", "}", "return", "$", "this", "->", "ial", "[", "$", "token", "]", "[", "$", "info", "]", ";", "}" ]
Returns information about some user given a token associated with that user. \param opaque $token Token associated with the user. \param opaque $info The type of information we're interested in. This is one of the INFO_* constants provided by this class. \param array $args (optional) Additional arguments for the query. Defaults to an empty array. At present time, this argument is only useful when you pass one of Erebot::Module::IrcTracker::INFO_HOST or Erebot::Module::IrcTracker::INFO_MASK as the value for $info. In this case, you may pass an array containing a boolean ($canonical) indicating the type of hostname canonicalization to apply. See also Erebot::Interfaces::Identity::getHost() for more information on the $canonical parameter. \retval mixed Requested information about that user. This may be \b null if the requested information has not been obtained yet. \throw Erebot::InvalidValueException The value for $info is invalid. \throw Erebot::NotFoundException The given $token does not match any known user. \warning This method is not meant to be called directly. Instead, you should call the equivalent methods (getNick(), getHost(), etc.) from the token returned by Erebot::Module::IrcTracker::startTracking().
[ "Returns", "information", "about", "some", "user", "given", "a", "token", "associated", "with", "that", "user", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L761-L812
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.isOn
public function isOn($chan, $nick = null) { if ($nick === null) { return isset($this->chans[$chan]); } $nick = self::extractNick($nick); $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($nick); $key = array_search($nick, $this->nicks); if ($key === false) { return false; } return isset($this->chans[$chan][$key]); }
php
public function isOn($chan, $nick = null) { if ($nick === null) { return isset($this->chans[$chan]); } $nick = self::extractNick($nick); $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($nick); $key = array_search($nick, $this->nicks); if ($key === false) { return false; } return isset($this->chans[$chan][$key]); }
[ "public", "function", "isOn", "(", "$", "chan", ",", "$", "nick", "=", "null", ")", "{", "if", "(", "$", "nick", "===", "null", ")", "{", "return", "isset", "(", "$", "this", "->", "chans", "[", "$", "chan", "]", ")", ";", "}", "$", "nick", "=", "self", "::", "extractNick", "(", "$", "nick", ")", ";", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "nick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "nick", ")", ";", "$", "key", "=", "array_search", "(", "$", "nick", ",", "$", "this", "->", "nicks", ")", ";", "if", "(", "$", "key", "===", "false", ")", "{", "return", "false", ";", "}", "return", "isset", "(", "$", "this", "->", "chans", "[", "$", "chan", "]", "[", "$", "key", "]", ")", ";", "}" ]
Indicates whether some user is present on a given IRC channel. \param string $chan IRC channel that user must be on. \param mixed $nick (optional) Either some user's nickname (a string) or \b null. Defaults to \b null. When this parameter is \b null, this method tests whether the bot is on the given IRC channel or not. \retval bool \b true is the given user is on that IRC channel, \b false otherwise.
[ "Indicates", "whether", "some", "user", "is", "present", "on", "a", "given", "IRC", "channel", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L832-L846
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.getCommonChans
public function getCommonChans($nick) { $nick = self::extractNick($nick); $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($nick); $key = array_search($nick, $this->nicks); if ($key === false) { throw new \Erebot\NotFoundException('No such user'); } $results = array(); foreach ($this->chans as $chan => $users) { if (isset($users[$key])) { $results[] = $chan; } } return $results; }
php
public function getCommonChans($nick) { $nick = self::extractNick($nick); $collator = $this->connection->getCollator(); $nick = $collator->normalizeNick($nick); $key = array_search($nick, $this->nicks); if ($key === false) { throw new \Erebot\NotFoundException('No such user'); } $results = array(); foreach ($this->chans as $chan => $users) { if (isset($users[$key])) { $results[] = $chan; } } return $results; }
[ "public", "function", "getCommonChans", "(", "$", "nick", ")", "{", "$", "nick", "=", "self", "::", "extractNick", "(", "$", "nick", ")", ";", "$", "collator", "=", "$", "this", "->", "connection", "->", "getCollator", "(", ")", ";", "$", "nick", "=", "$", "collator", "->", "normalizeNick", "(", "$", "nick", ")", ";", "$", "key", "=", "array_search", "(", "$", "nick", ",", "$", "this", "->", "nicks", ")", ";", "if", "(", "$", "key", "===", "false", ")", "{", "throw", "new", "\\", "Erebot", "\\", "NotFoundException", "(", "'No such user'", ")", ";", "}", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "chans", "as", "$", "chan", "=>", "$", "users", ")", "{", "if", "(", "isset", "(", "$", "users", "[", "$", "key", "]", ")", ")", "{", "$", "results", "[", "]", "=", "$", "chan", ";", "}", "}", "return", "$", "results", ";", "}" ]
Returns a list of IRC channels the bot and some other user have in common. \param string $nick Nickname of the user for which we want to know what channels (s)he shares with the bot. \retval list A list with the names of all IRC channels that user and the bot have in common. \throw Erebot::NotFoundException The given nickname does not match any known user.
[ "Returns", "a", "list", "of", "IRC", "channels", "the", "bot", "and", "some", "other", "user", "have", "in", "common", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L863-L880
train
Erebot/Module_IrcTracker
src/IrcTracker.php
IrcTracker.userPrivileges
public function userPrivileges($chan, $nick) { if (!isset($this->chans[$chan][$nick])) { throw new \Erebot\NotFoundException('No such channel or user'); } return $this->chans[$chan][$nick]; }
php
public function userPrivileges($chan, $nick) { if (!isset($this->chans[$chan][$nick])) { throw new \Erebot\NotFoundException('No such channel or user'); } return $this->chans[$chan][$nick]; }
[ "public", "function", "userPrivileges", "(", "$", "chan", ",", "$", "nick", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "chans", "[", "$", "chan", "]", "[", "$", "nick", "]", ")", ")", "{", "throw", "new", "\\", "Erebot", "\\", "NotFoundException", "(", "'No such channel or user'", ")", ";", "}", "return", "$", "this", "->", "chans", "[", "$", "chan", "]", "[", "$", "nick", "]", ";", "}" ]
Returns channel status associated with the given user. \param string $chan The IRC channel we're interested in. \param string $nick Nickname of the user whose status on the given channel we're interested in. \retval list A list with the status/privileges for that user on the given channel. Each status is given by the letter for the channel mode that refers to it (eg. "o" for "operator status"). \throw Erebot::NotFoundException The given channel or nickname is not not known to the bot.
[ "Returns", "channel", "status", "associated", "with", "the", "given", "user", "." ]
50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d
https://github.com/Erebot/Module_IrcTracker/blob/50eaf5d3e35cf4bb31259819cd3d4fba3279bc5d/src/IrcTracker.php#L974-L980
train
andres-montanez/FragmentCacheBundle
EventListener/FragmentCacheListener.php
FragmentCacheListener.onKernelController
public function onKernelController(FilterControllerEvent $event) { if (!is_array($controller = $event->getController())) { return; } // Only for SubRequests $subRequest = $event->getRequest(); if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { return; } // Check if Annotation is present if (!$configuration = $subRequest->attributes->get('_andres_montanez_fragment_cache', false)) { return; } // Calculate Request Key $key = $this->getKey($configuration, $subRequest, $this->masterRequest); if (!$this->enabled) { return; } // If content is cached, return it $content = $this->cache->get($key); if ($content !== false) { $fragment = ''; if ($this->debug) { $fragment .= '<!-- HIT - Begin Fragment Cache for KEY: ' . $key . ' -->'; } $fragment .= $content; if ($this->debug) { $fragment .= '<!-- End Fragment Cache for KEY: ' . $key . ' -->'; } $response = new Response($fragment); $event->setController(function () use ($response) { return $response; }); } else { $subRequest->attributes->set('_andres_montanez_fragment_cache_key', $key); } return; }
php
public function onKernelController(FilterControllerEvent $event) { if (!is_array($controller = $event->getController())) { return; } // Only for SubRequests $subRequest = $event->getRequest(); if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { return; } // Check if Annotation is present if (!$configuration = $subRequest->attributes->get('_andres_montanez_fragment_cache', false)) { return; } // Calculate Request Key $key = $this->getKey($configuration, $subRequest, $this->masterRequest); if (!$this->enabled) { return; } // If content is cached, return it $content = $this->cache->get($key); if ($content !== false) { $fragment = ''; if ($this->debug) { $fragment .= '<!-- HIT - Begin Fragment Cache for KEY: ' . $key . ' -->'; } $fragment .= $content; if ($this->debug) { $fragment .= '<!-- End Fragment Cache for KEY: ' . $key . ' -->'; } $response = new Response($fragment); $event->setController(function () use ($response) { return $response; }); } else { $subRequest->attributes->set('_andres_montanez_fragment_cache_key', $key); } return; }
[ "public", "function", "onKernelController", "(", "FilterControllerEvent", "$", "event", ")", "{", "if", "(", "!", "is_array", "(", "$", "controller", "=", "$", "event", "->", "getController", "(", ")", ")", ")", "{", "return", ";", "}", "// Only for SubRequests", "$", "subRequest", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "$", "event", "->", "getRequestType", "(", ")", "==", "HttpKernelInterface", "::", "MASTER_REQUEST", ")", "{", "return", ";", "}", "// Check if Annotation is present", "if", "(", "!", "$", "configuration", "=", "$", "subRequest", "->", "attributes", "->", "get", "(", "'_andres_montanez_fragment_cache'", ",", "false", ")", ")", "{", "return", ";", "}", "// Calculate Request Key", "$", "key", "=", "$", "this", "->", "getKey", "(", "$", "configuration", ",", "$", "subRequest", ",", "$", "this", "->", "masterRequest", ")", ";", "if", "(", "!", "$", "this", "->", "enabled", ")", "{", "return", ";", "}", "// If content is cached, return it", "$", "content", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "key", ")", ";", "if", "(", "$", "content", "!==", "false", ")", "{", "$", "fragment", "=", "''", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "$", "fragment", ".=", "'<!-- HIT - Begin Fragment Cache for KEY: '", ".", "$", "key", ".", "' -->'", ";", "}", "$", "fragment", ".=", "$", "content", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "$", "fragment", ".=", "'<!-- End Fragment Cache for KEY: '", ".", "$", "key", ".", "' -->'", ";", "}", "$", "response", "=", "new", "Response", "(", "$", "fragment", ")", ";", "$", "event", "->", "setController", "(", "function", "(", ")", "use", "(", "$", "response", ")", "{", "return", "$", "response", ";", "}", ")", ";", "}", "else", "{", "$", "subRequest", "->", "attributes", "->", "set", "(", "'_andres_montanez_fragment_cache_key'", ",", "$", "key", ")", ";", "}", "return", ";", "}" ]
Listener for the Controller call @param \Symfony\Component\HttpKernel\Event\FilterControllerEvent $event @return void
[ "Listener", "for", "the", "Controller", "call" ]
90f9511e275fd78990f6b90cd52052078c53253a
https://github.com/andres-montanez/FragmentCacheBundle/blob/90f9511e275fd78990f6b90cd52052078c53253a/EventListener/FragmentCacheListener.php#L99-L147
train
andres-montanez/FragmentCacheBundle
EventListener/FragmentCacheListener.php
FragmentCacheListener.onKernelResponse
public function onKernelResponse(FilterResponseEvent $event) { // Only for Sub Requests $subRequest = $event->getRequest(); if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { return; } // Check if Annotation is present if (!$configuration = $subRequest->attributes->get('_andres_montanez_fragment_cache', false)) { return; } // If Key is present, save content for that key, expiration saved in seconds retreived in minutes if (($key = $subRequest->attributes->get('_andres_montanez_fragment_cache_key', false)) !== false) { if ($this->enabled) { $this->cache->set( $key, $event->getResponse()->getContent(), $configuration->getExpiration() * 60 ); $fragment = ''; if ($this->debug) { $fragment .= '<!-- MISS - Begin Fragment Cache for KEY: ' . $key . ' -->'; } $fragment .= $event->getResponse()->getContent(); if ($this->debug) { $fragment .= '<!-- End Fragment Cache for KEY: ' . $key . ' -->'; } $event->getResponse()->setContent($fragment); } else if (!$this->enabled) { $fragment = ''; if ($this->debug) { $fragment .= '<!-- DISABLED - Begin Fragment Cache for KEY: ' . $key . ' -->'; } $fragment .= $event->getResponse()->getContent(); if ($this->debug) { $fragment .= '<!-- End Fragment Cache for KEY: ' . $key . ' -->'; } $event->getResponse()->setContent($fragment); } } return; }
php
public function onKernelResponse(FilterResponseEvent $event) { // Only for Sub Requests $subRequest = $event->getRequest(); if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { return; } // Check if Annotation is present if (!$configuration = $subRequest->attributes->get('_andres_montanez_fragment_cache', false)) { return; } // If Key is present, save content for that key, expiration saved in seconds retreived in minutes if (($key = $subRequest->attributes->get('_andres_montanez_fragment_cache_key', false)) !== false) { if ($this->enabled) { $this->cache->set( $key, $event->getResponse()->getContent(), $configuration->getExpiration() * 60 ); $fragment = ''; if ($this->debug) { $fragment .= '<!-- MISS - Begin Fragment Cache for KEY: ' . $key . ' -->'; } $fragment .= $event->getResponse()->getContent(); if ($this->debug) { $fragment .= '<!-- End Fragment Cache for KEY: ' . $key . ' -->'; } $event->getResponse()->setContent($fragment); } else if (!$this->enabled) { $fragment = ''; if ($this->debug) { $fragment .= '<!-- DISABLED - Begin Fragment Cache for KEY: ' . $key . ' -->'; } $fragment .= $event->getResponse()->getContent(); if ($this->debug) { $fragment .= '<!-- End Fragment Cache for KEY: ' . $key . ' -->'; } $event->getResponse()->setContent($fragment); } } return; }
[ "public", "function", "onKernelResponse", "(", "FilterResponseEvent", "$", "event", ")", "{", "// Only for Sub Requests", "$", "subRequest", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "$", "event", "->", "getRequestType", "(", ")", "==", "HttpKernelInterface", "::", "MASTER_REQUEST", ")", "{", "return", ";", "}", "// Check if Annotation is present", "if", "(", "!", "$", "configuration", "=", "$", "subRequest", "->", "attributes", "->", "get", "(", "'_andres_montanez_fragment_cache'", ",", "false", ")", ")", "{", "return", ";", "}", "// If Key is present, save content for that key, expiration saved in seconds retreived in minutes", "if", "(", "(", "$", "key", "=", "$", "subRequest", "->", "attributes", "->", "get", "(", "'_andres_montanez_fragment_cache_key'", ",", "false", ")", ")", "!==", "false", ")", "{", "if", "(", "$", "this", "->", "enabled", ")", "{", "$", "this", "->", "cache", "->", "set", "(", "$", "key", ",", "$", "event", "->", "getResponse", "(", ")", "->", "getContent", "(", ")", ",", "$", "configuration", "->", "getExpiration", "(", ")", "*", "60", ")", ";", "$", "fragment", "=", "''", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "$", "fragment", ".=", "'<!-- MISS - Begin Fragment Cache for KEY: '", ".", "$", "key", ".", "' -->'", ";", "}", "$", "fragment", ".=", "$", "event", "->", "getResponse", "(", ")", "->", "getContent", "(", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "$", "fragment", ".=", "'<!-- End Fragment Cache for KEY: '", ".", "$", "key", ".", "' -->'", ";", "}", "$", "event", "->", "getResponse", "(", ")", "->", "setContent", "(", "$", "fragment", ")", ";", "}", "else", "if", "(", "!", "$", "this", "->", "enabled", ")", "{", "$", "fragment", "=", "''", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "$", "fragment", ".=", "'<!-- DISABLED - Begin Fragment Cache for KEY: '", ".", "$", "key", ".", "' -->'", ";", "}", "$", "fragment", ".=", "$", "event", "->", "getResponse", "(", ")", "->", "getContent", "(", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "$", "fragment", ".=", "'<!-- End Fragment Cache for KEY: '", ".", "$", "key", ".", "' -->'", ";", "}", "$", "event", "->", "getResponse", "(", ")", "->", "setContent", "(", "$", "fragment", ")", ";", "}", "}", "return", ";", "}" ]
Listener for the Response call @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event @return void
[ "Listener", "for", "the", "Response", "call" ]
90f9511e275fd78990f6b90cd52052078c53253a
https://github.com/andres-montanez/FragmentCacheBundle/blob/90f9511e275fd78990f6b90cd52052078c53253a/EventListener/FragmentCacheListener.php#L155-L207
train
andres-montanez/FragmentCacheBundle
EventListener/FragmentCacheListener.php
FragmentCacheListener.getKey
protected function getKey(FragmentCache $configuration, Request $subRequest, Request $masterRequest) { $event = new KeyGenerationEvent($configuration, $subRequest, $masterRequest); $keyRequest = sha1($subRequest->getRequestUri()) . ':' . sha1($masterRequest->getRequestUri()); $key = array( 'AndresMontanezFragmentCache', $this->environment, 'v' . $configuration->getVersion(), $keyRequest ); $this->dispatcher->dispatch(KeyGenerationEvent::NAME, $event); if (count($event->getKeys()) > 0) { $key = array_merge($key, $event->getKeys()); } $key = implode(':', $key); return $key; }
php
protected function getKey(FragmentCache $configuration, Request $subRequest, Request $masterRequest) { $event = new KeyGenerationEvent($configuration, $subRequest, $masterRequest); $keyRequest = sha1($subRequest->getRequestUri()) . ':' . sha1($masterRequest->getRequestUri()); $key = array( 'AndresMontanezFragmentCache', $this->environment, 'v' . $configuration->getVersion(), $keyRequest ); $this->dispatcher->dispatch(KeyGenerationEvent::NAME, $event); if (count($event->getKeys()) > 0) { $key = array_merge($key, $event->getKeys()); } $key = implode(':', $key); return $key; }
[ "protected", "function", "getKey", "(", "FragmentCache", "$", "configuration", ",", "Request", "$", "subRequest", ",", "Request", "$", "masterRequest", ")", "{", "$", "event", "=", "new", "KeyGenerationEvent", "(", "$", "configuration", ",", "$", "subRequest", ",", "$", "masterRequest", ")", ";", "$", "keyRequest", "=", "sha1", "(", "$", "subRequest", "->", "getRequestUri", "(", ")", ")", ".", "':'", ".", "sha1", "(", "$", "masterRequest", "->", "getRequestUri", "(", ")", ")", ";", "$", "key", "=", "array", "(", "'AndresMontanezFragmentCache'", ",", "$", "this", "->", "environment", ",", "'v'", ".", "$", "configuration", "->", "getVersion", "(", ")", ",", "$", "keyRequest", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "KeyGenerationEvent", "::", "NAME", ",", "$", "event", ")", ";", "if", "(", "count", "(", "$", "event", "->", "getKeys", "(", ")", ")", ">", "0", ")", "{", "$", "key", "=", "array_merge", "(", "$", "key", ",", "$", "event", "->", "getKeys", "(", ")", ")", ";", "}", "$", "key", "=", "implode", "(", "':'", ",", "$", "key", ")", ";", "return", "$", "key", ";", "}" ]
Calculates the cache Key of the Fragment @param \AndresMontanez\FragmentCacheBundle\Library\Configuration\FragmentCache $configuration @param \Symfony\Component\HttpFoundation\Request $subRequest @param \Symfony\Component\HttpFoundation\Request $masterRequest @return string
[ "Calculates", "the", "cache", "Key", "of", "the", "Fragment" ]
90f9511e275fd78990f6b90cd52052078c53253a
https://github.com/andres-montanez/FragmentCacheBundle/blob/90f9511e275fd78990f6b90cd52052078c53253a/EventListener/FragmentCacheListener.php#L217-L239
train
realboard/DBInstance
src/Realboard/Component/Database/DBInstance/Authentication.php
Authentication.setAuthMode
public function setAuthMode($mode) { if (!class_exists($mode)) { throw new \Exception(sprintf( "Class %s doesn't exists", $mode )); } $this->authMode = $mode; $authClass = is_string($mode) ? new $mode() : $mode; if (!$authClass instanceof SecurityInterface) { throw new \Exception(sprintf( 'Auth mode must be intstance of %s', SecurityInterface::class )); exit; } $this->security = $authClass; $this->authMode = get_class($this->security); if ($this->authDir) { $this->security->setPath($this->authDir); } }
php
public function setAuthMode($mode) { if (!class_exists($mode)) { throw new \Exception(sprintf( "Class %s doesn't exists", $mode )); } $this->authMode = $mode; $authClass = is_string($mode) ? new $mode() : $mode; if (!$authClass instanceof SecurityInterface) { throw new \Exception(sprintf( 'Auth mode must be intstance of %s', SecurityInterface::class )); exit; } $this->security = $authClass; $this->authMode = get_class($this->security); if ($this->authDir) { $this->security->setPath($this->authDir); } }
[ "public", "function", "setAuthMode", "(", "$", "mode", ")", "{", "if", "(", "!", "class_exists", "(", "$", "mode", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "\"Class %s doesn't exists\"", ",", "$", "mode", ")", ")", ";", "}", "$", "this", "->", "authMode", "=", "$", "mode", ";", "$", "authClass", "=", "is_string", "(", "$", "mode", ")", "?", "new", "$", "mode", "(", ")", ":", "$", "mode", ";", "if", "(", "!", "$", "authClass", "instanceof", "SecurityInterface", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Auth mode must be intstance of %s'", ",", "SecurityInterface", "::", "class", ")", ")", ";", "exit", ";", "}", "$", "this", "->", "security", "=", "$", "authClass", ";", "$", "this", "->", "authMode", "=", "get_class", "(", "$", "this", "->", "security", ")", ";", "if", "(", "$", "this", "->", "authDir", ")", "{", "$", "this", "->", "security", "->", "setPath", "(", "$", "this", "->", "authDir", ")", ";", "}", "}" ]
Set Authentication Mode. @param string $mode
[ "Set", "Authentication", "Mode", "." ]
f2cde7fdf480d5eb5a491a5cf81ff7f4b3be0a35
https://github.com/realboard/DBInstance/blob/f2cde7fdf480d5eb5a491a5cf81ff7f4b3be0a35/src/Realboard/Component/Database/DBInstance/Authentication.php#L45-L71
train
realboard/DBInstance
src/Realboard/Component/Database/DBInstance/Authentication.php
Authentication.setAuthDir
public function setAuthDir($dir) { if (!file_exists($dir)) { throw new \Exception('Auth directory is not exists!'); } if (!is_dir($dir)) { throw new \Exception('Auth directory is not exists!'); } if ($this->security && $this->security->getKey()) { throw new \Exception('Auth directory must be set before key sets!'); } $this->authDir = $dir; $this->security->setPath($dir); }
php
public function setAuthDir($dir) { if (!file_exists($dir)) { throw new \Exception('Auth directory is not exists!'); } if (!is_dir($dir)) { throw new \Exception('Auth directory is not exists!'); } if ($this->security && $this->security->getKey()) { throw new \Exception('Auth directory must be set before key sets!'); } $this->authDir = $dir; $this->security->setPath($dir); }
[ "public", "function", "setAuthDir", "(", "$", "dir", ")", "{", "if", "(", "!", "file_exists", "(", "$", "dir", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Auth directory is not exists!'", ")", ";", "}", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Auth directory is not exists!'", ")", ";", "}", "if", "(", "$", "this", "->", "security", "&&", "$", "this", "->", "security", "->", "getKey", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Auth directory must be set before key sets!'", ")", ";", "}", "$", "this", "->", "authDir", "=", "$", "dir", ";", "$", "this", "->", "security", "->", "setPath", "(", "$", "dir", ")", ";", "}" ]
Set Authencation Directory. @param string $dir Directory
[ "Set", "Authencation", "Directory", "." ]
f2cde7fdf480d5eb5a491a5cf81ff7f4b3be0a35
https://github.com/realboard/DBInstance/blob/f2cde7fdf480d5eb5a491a5cf81ff7f4b3be0a35/src/Realboard/Component/Database/DBInstance/Authentication.php#L88-L104
train
kaiohken1982/Neobazaar
src/Neobazaar/Controller/IndexController.php
IndexController.breadcrumbsAction
public function breadcrumbsAction() { $default = 'dashboard'; $id = $this->getRequest()->getQuery('id', $default); $pos = strpos($id, '/'); $id = false !== $pos ? substr($id, 0, $pos) : $id; $view = $this->getServiceLocator()->get('Zend\View\Renderer\PhpRenderer'); $navigation = $view->navigation('navigation'); $container = $navigation->getContainer(); $page = $container->findOneBy('fragment', $id); $page = null === $page ? $container->findOneBy('fragment', $default) : $page; $page->setActive(true); $viewModel = new ViewModel(array( 'breadcrumbs' => $navigation->breadcrumbs() ->setPartial('breadcrumbs')->setRenderInvisible(true)->setMinDepth(0) )); $viewModel->setTerminal(true); return $viewModel; }
php
public function breadcrumbsAction() { $default = 'dashboard'; $id = $this->getRequest()->getQuery('id', $default); $pos = strpos($id, '/'); $id = false !== $pos ? substr($id, 0, $pos) : $id; $view = $this->getServiceLocator()->get('Zend\View\Renderer\PhpRenderer'); $navigation = $view->navigation('navigation'); $container = $navigation->getContainer(); $page = $container->findOneBy('fragment', $id); $page = null === $page ? $container->findOneBy('fragment', $default) : $page; $page->setActive(true); $viewModel = new ViewModel(array( 'breadcrumbs' => $navigation->breadcrumbs() ->setPartial('breadcrumbs')->setRenderInvisible(true)->setMinDepth(0) )); $viewModel->setTerminal(true); return $viewModel; }
[ "public", "function", "breadcrumbsAction", "(", ")", "{", "$", "default", "=", "'dashboard'", ";", "$", "id", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getQuery", "(", "'id'", ",", "$", "default", ")", ";", "$", "pos", "=", "strpos", "(", "$", "id", ",", "'/'", ")", ";", "$", "id", "=", "false", "!==", "$", "pos", "?", "substr", "(", "$", "id", ",", "0", ",", "$", "pos", ")", ":", "$", "id", ";", "$", "view", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Zend\\View\\Renderer\\PhpRenderer'", ")", ";", "$", "navigation", "=", "$", "view", "->", "navigation", "(", "'navigation'", ")", ";", "$", "container", "=", "$", "navigation", "->", "getContainer", "(", ")", ";", "$", "page", "=", "$", "container", "->", "findOneBy", "(", "'fragment'", ",", "$", "id", ")", ";", "$", "page", "=", "null", "===", "$", "page", "?", "$", "container", "->", "findOneBy", "(", "'fragment'", ",", "$", "default", ")", ":", "$", "page", ";", "$", "page", "->", "setActive", "(", "true", ")", ";", "$", "viewModel", "=", "new", "ViewModel", "(", "array", "(", "'breadcrumbs'", "=>", "$", "navigation", "->", "breadcrumbs", "(", ")", "->", "setPartial", "(", "'breadcrumbs'", ")", "->", "setRenderInvisible", "(", "true", ")", "->", "setMinDepth", "(", "0", ")", ")", ")", ";", "$", "viewModel", "->", "setTerminal", "(", "true", ")", ";", "return", "$", "viewModel", ";", "}" ]
Web service per la restituzione di un breadcrumbs in base ad un id @return ViewModel
[ "Web", "service", "per", "la", "restituzione", "di", "un", "breadcrumbs", "in", "base", "ad", "un", "id" ]
288c972dea981d715c4e136edb5dba0318c9e6cb
https://github.com/kaiohken1982/Neobazaar/blob/288c972dea981d715c4e136edb5dba0318c9e6cb/src/Neobazaar/Controller/IndexController.php#L36-L56
train
kaiohken1982/Neobazaar
src/Neobazaar/Controller/IndexController.php
IndexController.categoriesAction
public function categoriesAction() { $main = $this->getServiceLocator()->get('neobazaar.service.main'); $categories = $main->getDocumentEntityRepository() ->getCategoryMultioptionsNoSlug($this->getServiceLocator()); return new JsonModel(array('data' => $categories)); }
php
public function categoriesAction() { $main = $this->getServiceLocator()->get('neobazaar.service.main'); $categories = $main->getDocumentEntityRepository() ->getCategoryMultioptionsNoSlug($this->getServiceLocator()); return new JsonModel(array('data' => $categories)); }
[ "public", "function", "categoriesAction", "(", ")", "{", "$", "main", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'neobazaar.service.main'", ")", ";", "$", "categories", "=", "$", "main", "->", "getDocumentEntityRepository", "(", ")", "->", "getCategoryMultioptionsNoSlug", "(", "$", "this", "->", "getServiceLocator", "(", ")", ")", ";", "return", "new", "JsonModel", "(", "array", "(", "'data'", "=>", "$", "categories", ")", ")", ";", "}" ]
Web service per la restituzione delle categorie @return JsonModel
[ "Web", "service", "per", "la", "restituzione", "delle", "categorie" ]
288c972dea981d715c4e136edb5dba0318c9e6cb
https://github.com/kaiohken1982/Neobazaar/blob/288c972dea981d715c4e136edb5dba0318c9e6cb/src/Neobazaar/Controller/IndexController.php#L63-L70
train
kaiohken1982/Neobazaar
src/Neobazaar/Controller/IndexController.php
IndexController.locationsAction
public function locationsAction() { $main = $this->getServiceLocator()->get('neobazaar.service.main'); $locations = $main->getGeonamesEntityRepository() ->getLocationMultioptions($this->getServiceLocator()); return new JsonModel(array('data' => $locations)); }
php
public function locationsAction() { $main = $this->getServiceLocator()->get('neobazaar.service.main'); $locations = $main->getGeonamesEntityRepository() ->getLocationMultioptions($this->getServiceLocator()); return new JsonModel(array('data' => $locations)); }
[ "public", "function", "locationsAction", "(", ")", "{", "$", "main", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'neobazaar.service.main'", ")", ";", "$", "locations", "=", "$", "main", "->", "getGeonamesEntityRepository", "(", ")", "->", "getLocationMultioptions", "(", "$", "this", "->", "getServiceLocator", "(", ")", ")", ";", "return", "new", "JsonModel", "(", "array", "(", "'data'", "=>", "$", "locations", ")", ")", ";", "}" ]
Web service per la restituzione delle locations @return JsonModel
[ "Web", "service", "per", "la", "restituzione", "delle", "locations" ]
288c972dea981d715c4e136edb5dba0318c9e6cb
https://github.com/kaiohken1982/Neobazaar/blob/288c972dea981d715c4e136edb5dba0318c9e6cb/src/Neobazaar/Controller/IndexController.php#L77-L84
train
kaiohken1982/Neobazaar
src/Neobazaar/Controller/IndexController.php
IndexController.activationEmailResendAction
public function activationEmailResendAction() { $classifiedService = $this->getServiceLocator()->get('document.service.classified'); try { $ids = $classifiedService->activationEmailResend(1); $data = array( 'status' => 'success', 'message' => implode(", ", $ids) ); } catch(\Exception $e) { $this->getResponse() ->setStatusCode(Response::STATUS_CODE_500); $data = array( 'status' => 'danger', 'message' => $e->getMessage() ); } return new JsonModel($data); }
php
public function activationEmailResendAction() { $classifiedService = $this->getServiceLocator()->get('document.service.classified'); try { $ids = $classifiedService->activationEmailResend(1); $data = array( 'status' => 'success', 'message' => implode(", ", $ids) ); } catch(\Exception $e) { $this->getResponse() ->setStatusCode(Response::STATUS_CODE_500); $data = array( 'status' => 'danger', 'message' => $e->getMessage() ); } return new JsonModel($data); }
[ "public", "function", "activationEmailResendAction", "(", ")", "{", "$", "classifiedService", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'document.service.classified'", ")", ";", "try", "{", "$", "ids", "=", "$", "classifiedService", "->", "activationEmailResend", "(", "1", ")", ";", "$", "data", "=", "array", "(", "'status'", "=>", "'success'", ",", "'message'", "=>", "implode", "(", "\", \"", ",", "$", "ids", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setStatusCode", "(", "Response", "::", "STATUS_CODE_500", ")", ";", "$", "data", "=", "array", "(", "'status'", "=>", "'danger'", ",", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "new", "JsonModel", "(", "$", "data", ")", ";", "}" ]
This is needed because of mailserver goes down. Will resend activation email to those classifieds where date_insert = date_edit and state = 2. Dispatch a classified created event with data
[ "This", "is", "needed", "because", "of", "mailserver", "goes", "down", ".", "Will", "resend", "activation", "email", "to", "those", "classifieds", "where", "date_insert", "=", "date_edit", "and", "state", "=", "2", ".", "Dispatch", "a", "classified", "created", "event", "with", "data" ]
288c972dea981d715c4e136edb5dba0318c9e6cb
https://github.com/kaiohken1982/Neobazaar/blob/288c972dea981d715c4e136edb5dba0318c9e6cb/src/Neobazaar/Controller/IndexController.php#L124-L144
train
cubicmushroom/valueobjects
src/Number/Real.php
Real.sameValueAs
public function sameValueAs(ValueObjectInterface $real) { if (false === Util::classEquals($this, $real)) { return false; } return $this->toNative() === $real->toNative(); }
php
public function sameValueAs(ValueObjectInterface $real) { if (false === Util::classEquals($this, $real)) { return false; } return $this->toNative() === $real->toNative(); }
[ "public", "function", "sameValueAs", "(", "ValueObjectInterface", "$", "real", ")", "{", "if", "(", "false", "===", "Util", "::", "classEquals", "(", "$", "this", ",", "$", "real", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "toNative", "(", ")", "===", "$", "real", "->", "toNative", "(", ")", ";", "}" ]
Tells whether two Real are equal by comparing their values @param ValueObjectInterface $real @return bool
[ "Tells", "whether", "two", "Real", "are", "equal", "by", "comparing", "their", "values" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Number/Real.php#L58-L65
train
cubicmushroom/valueobjects
src/Number/Real.php
Real.toInteger
public function toInteger(RoundingMode $rounding_mode = null) { if (null === $rounding_mode) { $rounding_mode = RoundingMode::HALF_UP(); } $value = $this->toNative(); $integerValue = \round($value, 0, $rounding_mode->toNative()); $integer = new Integer($integerValue); return $integer; }
php
public function toInteger(RoundingMode $rounding_mode = null) { if (null === $rounding_mode) { $rounding_mode = RoundingMode::HALF_UP(); } $value = $this->toNative(); $integerValue = \round($value, 0, $rounding_mode->toNative()); $integer = new Integer($integerValue); return $integer; }
[ "public", "function", "toInteger", "(", "RoundingMode", "$", "rounding_mode", "=", "null", ")", "{", "if", "(", "null", "===", "$", "rounding_mode", ")", "{", "$", "rounding_mode", "=", "RoundingMode", "::", "HALF_UP", "(", ")", ";", "}", "$", "value", "=", "$", "this", "->", "toNative", "(", ")", ";", "$", "integerValue", "=", "\\", "round", "(", "$", "value", ",", "0", ",", "$", "rounding_mode", "->", "toNative", "(", ")", ")", ";", "$", "integer", "=", "new", "Integer", "(", "$", "integerValue", ")", ";", "return", "$", "integer", ";", "}" ]
Returns the integer part of the Real number as a Integer @param RoundingMode $rounding_mode Rounding mode of the conversion. Defaults to RoundingMode::HALF_UP. @return Integer
[ "Returns", "the", "integer", "part", "of", "the", "Real", "number", "as", "a", "Integer" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Number/Real.php#L73-L84
train
cubicmushroom/valueobjects
src/Number/Real.php
Real.toNatural
public function toNatural(RoundingMode $rounding_mode = null) { $integerValue = $this->toInteger($rounding_mode)->toNative(); $naturalValue = \abs($integerValue); $natural = new Natural($naturalValue); return $natural; }
php
public function toNatural(RoundingMode $rounding_mode = null) { $integerValue = $this->toInteger($rounding_mode)->toNative(); $naturalValue = \abs($integerValue); $natural = new Natural($naturalValue); return $natural; }
[ "public", "function", "toNatural", "(", "RoundingMode", "$", "rounding_mode", "=", "null", ")", "{", "$", "integerValue", "=", "$", "this", "->", "toInteger", "(", "$", "rounding_mode", ")", "->", "toNative", "(", ")", ";", "$", "naturalValue", "=", "\\", "abs", "(", "$", "integerValue", ")", ";", "$", "natural", "=", "new", "Natural", "(", "$", "naturalValue", ")", ";", "return", "$", "natural", ";", "}" ]
Returns the absolute integer part of the Real number as a Natural @param RoundingMode $rounding_mode Rounding mode of the conversion. Defaults to RoundingMode::HALF_UP. @return Natural
[ "Returns", "the", "absolute", "integer", "part", "of", "the", "Real", "number", "as", "a", "Natural" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Number/Real.php#L92-L99
train
NukaCode/core
src/NukaCode/Core/View/ViewBuilder.php
ViewBuilder.missingMethod
public function missingMethod($parameters) { if (! app()->runningInConsole()) { $this->viewPath->missingMethod($this->layout->layout, $parameters); } return $this; }
php
public function missingMethod($parameters) { if (! app()->runningInConsole()) { $this->viewPath->missingMethod($this->layout->layout, $parameters); } return $this; }
[ "public", "function", "missingMethod", "(", "$", "parameters", ")", "{", "if", "(", "!", "app", "(", ")", "->", "runningInConsole", "(", ")", ")", "{", "$", "this", "->", "viewPath", "->", "missingMethod", "(", "$", "this", "->", "layout", "->", "layout", ",", "$", "parameters", ")", ";", "}", "return", "$", "this", ";", "}" ]
If a method is not defined, try to find it's view. @param array $parameters @return $this
[ "If", "a", "method", "is", "not", "defined", "try", "to", "find", "it", "s", "view", "." ]
75b20903fb068a7df22cdec34ae729279fbaab3c
https://github.com/NukaCode/core/blob/75b20903fb068a7df22cdec34ae729279fbaab3c/src/NukaCode/Core/View/ViewBuilder.php#L74-L81
train
NukaCode/core
src/NukaCode/Core/View/ViewBuilder.php
ViewBuilder.setViewLayout
public function setViewLayout($view) { $this->layout = $this->viewLayout->change($view); $this->layout->layout = $this->viewPath->setUp($this->layout->layout, null); }
php
public function setViewLayout($view) { $this->layout = $this->viewLayout->change($view); $this->layout->layout = $this->viewPath->setUp($this->layout->layout, null); }
[ "public", "function", "setViewLayout", "(", "$", "view", ")", "{", "$", "this", "->", "layout", "=", "$", "this", "->", "viewLayout", "->", "change", "(", "$", "view", ")", ";", "$", "this", "->", "layout", "->", "layout", "=", "$", "this", "->", "viewPath", "->", "setUp", "(", "$", "this", "->", "layout", "->", "layout", ",", "null", ")", ";", "}" ]
Set a custom layout for a page. @param string $view
[ "Set", "a", "custom", "layout", "for", "a", "page", "." ]
75b20903fb068a7df22cdec34ae729279fbaab3c
https://github.com/NukaCode/core/blob/75b20903fb068a7df22cdec34ae729279fbaab3c/src/NukaCode/Core/View/ViewBuilder.php#L88-L92
train
NukaCode/core
src/NukaCode/Core/View/ViewBuilder.php
ViewBuilder.setViewPath
public function setViewPath($view) { $this->layout->layout = $this->viewPath->setUp($this->layout->layout, $view); return $this; }
php
public function setViewPath($view) { $this->layout->layout = $this->viewPath->setUp($this->layout->layout, $view); return $this; }
[ "public", "function", "setViewPath", "(", "$", "view", ")", "{", "$", "this", "->", "layout", "->", "layout", "=", "$", "this", "->", "viewPath", "->", "setUp", "(", "$", "this", "->", "layout", "->", "layout", ",", "$", "view", ")", ";", "return", "$", "this", ";", "}" ]
Override the automatically resolved view. @param string $view @return $this
[ "Override", "the", "automatically", "resolved", "view", "." ]
75b20903fb068a7df22cdec34ae729279fbaab3c
https://github.com/NukaCode/core/blob/75b20903fb068a7df22cdec34ae729279fbaab3c/src/NukaCode/Core/View/ViewBuilder.php#L101-L106
train
Dhii/factory-base
src/FactoryAwareTrait.php
FactoryAwareTrait._setFactory
protected function _setFactory($factory) { if ($factory !== null && !($factory instanceof FactoryInterface)) { throw $this->_createInvalidArgumentException( $this->__('Argument is not a valid factory instance'), null, null, $factory ); } $this->factory = $factory; }
php
protected function _setFactory($factory) { if ($factory !== null && !($factory instanceof FactoryInterface)) { throw $this->_createInvalidArgumentException( $this->__('Argument is not a valid factory instance'), null, null, $factory ); } $this->factory = $factory; }
[ "protected", "function", "_setFactory", "(", "$", "factory", ")", "{", "if", "(", "$", "factory", "!==", "null", "&&", "!", "(", "$", "factory", "instanceof", "FactoryInterface", ")", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Argument is not a valid factory instance'", ")", ",", "null", ",", "null", ",", "$", "factory", ")", ";", "}", "$", "this", "->", "factory", "=", "$", "factory", ";", "}" ]
Sets the factory for this instance. @since [*next-version*] @param FactoryInterface|null $factory The factory instance to set, if any.
[ "Sets", "the", "factory", "for", "this", "instance", "." ]
eb6694178068ec58e0f2de9243f0eb98844511de
https://github.com/Dhii/factory-base/blob/eb6694178068ec58e0f2de9243f0eb98844511de/src/FactoryAwareTrait.php#L44-L55
train
railken/lem
src/Repository.php
Repository.findWhereIn
public function findWhereIn(array $parameters) { $q = $this->getQuery(); foreach ($parameters as $name => $value) { $q->whereIn($name, $value); } return $q->get(); }
php
public function findWhereIn(array $parameters) { $q = $this->getQuery(); foreach ($parameters as $name => $value) { $q->whereIn($name, $value); } return $q->get(); }
[ "public", "function", "findWhereIn", "(", "array", "$", "parameters", ")", "{", "$", "q", "=", "$", "this", "->", "getQuery", "(", ")", ";", "foreach", "(", "$", "parameters", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "q", "->", "whereIn", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "q", "->", "get", "(", ")", ";", "}" ]
Find where in. @param array $parameters @return \Illuminate\Support\Collection
[ "Find", "where", "in", "." ]
cff1efcd090a9504b2faf5594121885786dea67a
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Repository.php#L109-L118
train
squareproton/Bond
src/Bond/RecordManager/Task/NormalityCollection.php
NormalityCollection.getClassFromCollection
protected static function getClassFromCollection( array $collection ) { // Make sure everything in this container is of __exactly__ the same type. // This is a stronger check than the entity container performs (child entities are ok in the container) $classes = array_unique( array_map( 'get_class', $collection ) ); if( count( $classes ) > 1 ) { // TODO this could fallback to persisting every entity individually. That would work. throw new \Exception( sprintf( "Can't manage entities in a container with multiple types, these are %s.", implode( ", ", $classes ) ) ); } return array_pop( $classes ); }
php
protected static function getClassFromCollection( array $collection ) { // Make sure everything in this container is of __exactly__ the same type. // This is a stronger check than the entity container performs (child entities are ok in the container) $classes = array_unique( array_map( 'get_class', $collection ) ); if( count( $classes ) > 1 ) { // TODO this could fallback to persisting every entity individually. That would work. throw new \Exception( sprintf( "Can't manage entities in a container with multiple types, these are %s.", implode( ", ", $classes ) ) ); } return array_pop( $classes ); }
[ "protected", "static", "function", "getClassFromCollection", "(", "array", "$", "collection", ")", "{", "// Make sure everything in this container is of __exactly__ the same type.", "// This is a stronger check than the entity container performs (child entities are ok in the container)", "$", "classes", "=", "array_unique", "(", "array_map", "(", "'get_class'", ",", "$", "collection", ")", ")", ";", "if", "(", "count", "(", "$", "classes", ")", ">", "1", ")", "{", "// TODO this could fallback to persisting every entity individually. That would work.", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "\"Can't manage entities in a container with multiple types, these are %s.\"", ",", "implode", "(", "\", \"", ",", "$", "classes", ")", ")", ")", ";", "}", "return", "array_pop", "(", "$", "classes", ")", ";", "}" ]
Check a collection only has one class. Determine this and return it. @param array $collection @return string
[ "Check", "a", "collection", "only", "has", "one", "class", ".", "Determine", "this", "and", "return", "it", "." ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/RecordManager/Task/NormalityCollection.php#L25-L42
train
EdwinDayot/shorty-framework
src/Framework/Application.php
Application.addRouteMiddleware
public function addRouteMiddleware(string $name): void { if (!array_key_exists($name, $this->getConfigRouteMiddlewares())) { throw new InvalidArgumentException('The middleware [' . $name . '] does not exists.'); } $this->routeMiddlewares[] = $this->getConfigRouteMiddlewares()[$name]; }
php
public function addRouteMiddleware(string $name): void { if (!array_key_exists($name, $this->getConfigRouteMiddlewares())) { throw new InvalidArgumentException('The middleware [' . $name . '] does not exists.'); } $this->routeMiddlewares[] = $this->getConfigRouteMiddlewares()[$name]; }
[ "public", "function", "addRouteMiddleware", "(", "string", "$", "name", ")", ":", "void", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "getConfigRouteMiddlewares", "(", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The middleware ['", ".", "$", "name", ".", "'] does not exists.'", ")", ";", "}", "$", "this", "->", "routeMiddlewares", "[", "]", "=", "$", "this", "->", "getConfigRouteMiddlewares", "(", ")", "[", "$", "name", "]", ";", "}" ]
Add a route middleware to the list of executed middlewares. @param string $name
[ "Add", "a", "route", "middleware", "to", "the", "list", "of", "executed", "middlewares", "." ]
e03c991ea86aedbd87674d1ee2f9041b55b5e578
https://github.com/EdwinDayot/shorty-framework/blob/e03c991ea86aedbd87674d1ee2f9041b55b5e578/src/Framework/Application.php#L172-L179
train
EdwinDayot/shorty-framework
src/Framework/Application.php
Application.createEnv
private function createEnv(): void { if (file_exists(base_dir('.env'))) { $dotEnv = new Dotenv(); $dotEnv->load(base_dir('.env')); $this->env = $dotEnv; } }
php
private function createEnv(): void { if (file_exists(base_dir('.env'))) { $dotEnv = new Dotenv(); $dotEnv->load(base_dir('.env')); $this->env = $dotEnv; } }
[ "private", "function", "createEnv", "(", ")", ":", "void", "{", "if", "(", "file_exists", "(", "base_dir", "(", "'.env'", ")", ")", ")", "{", "$", "dotEnv", "=", "new", "Dotenv", "(", ")", ";", "$", "dotEnv", "->", "load", "(", "base_dir", "(", "'.env'", ")", ")", ";", "$", "this", "->", "env", "=", "$", "dotEnv", ";", "}", "}" ]
Create environment.
[ "Create", "environment", "." ]
e03c991ea86aedbd87674d1ee2f9041b55b5e578
https://github.com/EdwinDayot/shorty-framework/blob/e03c991ea86aedbd87674d1ee2f9041b55b5e578/src/Framework/Application.php#L184-L191
train
EdwinDayot/shorty-framework
src/Framework/Application.php
Application.createRequest
private function createRequest(Request $request = null): void { if (!$this->request && is_null($request)) { $request = ServerRequest::fromGlobals() ->withParsedBody(json_decode(file_get_contents('php://input'))); } $this->container->set(Request::class, $request); $this->request = $request; }
php
private function createRequest(Request $request = null): void { if (!$this->request && is_null($request)) { $request = ServerRequest::fromGlobals() ->withParsedBody(json_decode(file_get_contents('php://input'))); } $this->container->set(Request::class, $request); $this->request = $request; }
[ "private", "function", "createRequest", "(", "Request", "$", "request", "=", "null", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "request", "&&", "is_null", "(", "$", "request", ")", ")", "{", "$", "request", "=", "ServerRequest", "::", "fromGlobals", "(", ")", "->", "withParsedBody", "(", "json_decode", "(", "file_get_contents", "(", "'php://input'", ")", ")", ")", ";", "}", "$", "this", "->", "container", "->", "set", "(", "Request", "::", "class", ",", "$", "request", ")", ";", "$", "this", "->", "request", "=", "$", "request", ";", "}" ]
Create the request object.
[ "Create", "the", "request", "object", "." ]
e03c991ea86aedbd87674d1ee2f9041b55b5e578
https://github.com/EdwinDayot/shorty-framework/blob/e03c991ea86aedbd87674d1ee2f9041b55b5e578/src/Framework/Application.php#L196-L205
train
EdwinDayot/shorty-framework
src/Framework/Application.php
Application.registerErrorHandler
private function registerErrorHandler(): void { $whoops = new Run(); $whoops->pushHandler(new PrettyPageHandler()); $whoops->register(); $this->errorHandler = $whoops; }
php
private function registerErrorHandler(): void { $whoops = new Run(); $whoops->pushHandler(new PrettyPageHandler()); $whoops->register(); $this->errorHandler = $whoops; }
[ "private", "function", "registerErrorHandler", "(", ")", ":", "void", "{", "$", "whoops", "=", "new", "Run", "(", ")", ";", "$", "whoops", "->", "pushHandler", "(", "new", "PrettyPageHandler", "(", ")", ")", ";", "$", "whoops", "->", "register", "(", ")", ";", "$", "this", "->", "errorHandler", "=", "$", "whoops", ";", "}" ]
Register the error handler.
[ "Register", "the", "error", "handler", "." ]
e03c991ea86aedbd87674d1ee2f9041b55b5e578
https://github.com/EdwinDayot/shorty-framework/blob/e03c991ea86aedbd87674d1ee2f9041b55b5e578/src/Framework/Application.php#L233-L240
train
EdwinDayot/shorty-framework
src/Framework/Application.php
Application.registerProviders
private function registerProviders(): void { $this->providers = array_merge($this->providers, $this->getConfigProviders()); foreach ($this->providers as $provider) { $provider = $this->container->get($provider); $provider->boot(); } }
php
private function registerProviders(): void { $this->providers = array_merge($this->providers, $this->getConfigProviders()); foreach ($this->providers as $provider) { $provider = $this->container->get($provider); $provider->boot(); } }
[ "private", "function", "registerProviders", "(", ")", ":", "void", "{", "$", "this", "->", "providers", "=", "array_merge", "(", "$", "this", "->", "providers", ",", "$", "this", "->", "getConfigProviders", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "providers", "as", "$", "provider", ")", "{", "$", "provider", "=", "$", "this", "->", "container", "->", "get", "(", "$", "provider", ")", ";", "$", "provider", "->", "boot", "(", ")", ";", "}", "}" ]
Registers the providers by booting them.
[ "Registers", "the", "providers", "by", "booting", "them", "." ]
e03c991ea86aedbd87674d1ee2f9041b55b5e578
https://github.com/EdwinDayot/shorty-framework/blob/e03c991ea86aedbd87674d1ee2f9041b55b5e578/src/Framework/Application.php#L245-L253
train
EdwinDayot/shorty-framework
src/Framework/Application.php
Application.handleRequest
private function handleRequest(array $middlewares): void { $requestHandler = new RequestHandler($this->container, $middlewares); $this->response = $requestHandler->handle($this->request); }
php
private function handleRequest(array $middlewares): void { $requestHandler = new RequestHandler($this->container, $middlewares); $this->response = $requestHandler->handle($this->request); }
[ "private", "function", "handleRequest", "(", "array", "$", "middlewares", ")", ":", "void", "{", "$", "requestHandler", "=", "new", "RequestHandler", "(", "$", "this", "->", "container", ",", "$", "middlewares", ")", ";", "$", "this", "->", "response", "=", "$", "requestHandler", "->", "handle", "(", "$", "this", "->", "request", ")", ";", "}" ]
Handles the request and triggers middlewares. @param array $middlewares
[ "Handles", "the", "request", "and", "triggers", "middlewares", "." ]
e03c991ea86aedbd87674d1ee2f9041b55b5e578
https://github.com/EdwinDayot/shorty-framework/blob/e03c991ea86aedbd87674d1ee2f9041b55b5e578/src/Framework/Application.php#L260-L265
train
EdwinDayot/shorty-framework
src/Framework/Application.php
Application.prepareResponse
public function prepareResponse() { try { $this->setBaseMiddlewares(); $this->handleRequest($this->middlewares); $this->router->build(); $this->handleRequest($this->routeMiddlewares); $this->response = $this->router->run(); } catch (Exception $exception) { $response = $this->container->call([$this->getExceptionHandler(), 'render'], [$exception]); $this->response = $response ?: $this->response; } }
php
public function prepareResponse() { try { $this->setBaseMiddlewares(); $this->handleRequest($this->middlewares); $this->router->build(); $this->handleRequest($this->routeMiddlewares); $this->response = $this->router->run(); } catch (Exception $exception) { $response = $this->container->call([$this->getExceptionHandler(), 'render'], [$exception]); $this->response = $response ?: $this->response; } }
[ "public", "function", "prepareResponse", "(", ")", "{", "try", "{", "$", "this", "->", "setBaseMiddlewares", "(", ")", ";", "$", "this", "->", "handleRequest", "(", "$", "this", "->", "middlewares", ")", ";", "$", "this", "->", "router", "->", "build", "(", ")", ";", "$", "this", "->", "handleRequest", "(", "$", "this", "->", "routeMiddlewares", ")", ";", "$", "this", "->", "response", "=", "$", "this", "->", "router", "->", "run", "(", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "response", "=", "$", "this", "->", "container", "->", "call", "(", "[", "$", "this", "->", "getExceptionHandler", "(", ")", ",", "'render'", "]", ",", "[", "$", "exception", "]", ")", ";", "$", "this", "->", "response", "=", "$", "response", "?", ":", "$", "this", "->", "response", ";", "}", "}" ]
Prepare the response object.
[ "Prepare", "the", "response", "object", "." ]
e03c991ea86aedbd87674d1ee2f9041b55b5e578
https://github.com/EdwinDayot/shorty-framework/blob/e03c991ea86aedbd87674d1ee2f9041b55b5e578/src/Framework/Application.php#L358-L370
train
phpgears/event-async
src/Serializer/JsonEventSerializer.php
JsonEventSerializer.getEventDefinition
private function getEventDefinition(string $serialized): array { $definition = $this->getDeserializationDefinition($serialized); if (!isset($definition['class'], $definition['payload'], $definition['attributes']) || \count(\array_diff(\array_keys($definition), ['class', 'payload', 'attributes'])) !== 0 || !\is_string($definition['class']) || !\is_array($definition['payload']) || !\is_array($definition['attributes']) ) { throw new EventSerializationException('Malformed JSON serialized event'); } return $definition; }
php
private function getEventDefinition(string $serialized): array { $definition = $this->getDeserializationDefinition($serialized); if (!isset($definition['class'], $definition['payload'], $definition['attributes']) || \count(\array_diff(\array_keys($definition), ['class', 'payload', 'attributes'])) !== 0 || !\is_string($definition['class']) || !\is_array($definition['payload']) || !\is_array($definition['attributes']) ) { throw new EventSerializationException('Malformed JSON serialized event'); } return $definition; }
[ "private", "function", "getEventDefinition", "(", "string", "$", "serialized", ")", ":", "array", "{", "$", "definition", "=", "$", "this", "->", "getDeserializationDefinition", "(", "$", "serialized", ")", ";", "if", "(", "!", "isset", "(", "$", "definition", "[", "'class'", "]", ",", "$", "definition", "[", "'payload'", "]", ",", "$", "definition", "[", "'attributes'", "]", ")", "||", "\\", "count", "(", "\\", "array_diff", "(", "\\", "array_keys", "(", "$", "definition", ")", ",", "[", "'class'", ",", "'payload'", ",", "'attributes'", "]", ")", ")", "!==", "0", "||", "!", "\\", "is_string", "(", "$", "definition", "[", "'class'", "]", ")", "||", "!", "\\", "is_array", "(", "$", "definition", "[", "'payload'", "]", ")", "||", "!", "\\", "is_array", "(", "$", "definition", "[", "'attributes'", "]", ")", ")", "{", "throw", "new", "EventSerializationException", "(", "'Malformed JSON serialized event'", ")", ";", "}", "return", "$", "definition", ";", "}" ]
Get event definition from serialization. @param string $serialized @throws EventSerializationException @return array<string, mixed>
[ "Get", "event", "definition", "from", "serialization", "." ]
e2d72b32e8852ec3926636af1c686a7c582b0bca
https://github.com/phpgears/event-async/blob/e2d72b32e8852ec3926636af1c686a7c582b0bca/src/Serializer/JsonEventSerializer.php#L126-L140
train
phpgears/event-async
src/Serializer/JsonEventSerializer.php
JsonEventSerializer.getDeserializationDefinition
private function getDeserializationDefinition(string $serialized): array { if (\trim($serialized) === '') { throw new EventSerializationException('Malformed JSON serialized event: empty string'); } $definition = \json_decode($serialized, true, 512, static::JSON_DECODE_OPTIONS); // @codeCoverageIgnoreStart if ($definition === null || \json_last_error() !== \JSON_ERROR_NONE) { throw new EventSerializationException(\sprintf( 'Event deserialization failed due to error %s: %s', \json_last_error(), \lcfirst(\json_last_error_msg()) )); } // @codeCoverageIgnoreEnd return $definition; }
php
private function getDeserializationDefinition(string $serialized): array { if (\trim($serialized) === '') { throw new EventSerializationException('Malformed JSON serialized event: empty string'); } $definition = \json_decode($serialized, true, 512, static::JSON_DECODE_OPTIONS); // @codeCoverageIgnoreStart if ($definition === null || \json_last_error() !== \JSON_ERROR_NONE) { throw new EventSerializationException(\sprintf( 'Event deserialization failed due to error %s: %s', \json_last_error(), \lcfirst(\json_last_error_msg()) )); } // @codeCoverageIgnoreEnd return $definition; }
[ "private", "function", "getDeserializationDefinition", "(", "string", "$", "serialized", ")", ":", "array", "{", "if", "(", "\\", "trim", "(", "$", "serialized", ")", "===", "''", ")", "{", "throw", "new", "EventSerializationException", "(", "'Malformed JSON serialized event: empty string'", ")", ";", "}", "$", "definition", "=", "\\", "json_decode", "(", "$", "serialized", ",", "true", ",", "512", ",", "static", "::", "JSON_DECODE_OPTIONS", ")", ";", "// @codeCoverageIgnoreStart", "if", "(", "$", "definition", "===", "null", "||", "\\", "json_last_error", "(", ")", "!==", "\\", "JSON_ERROR_NONE", ")", "{", "throw", "new", "EventSerializationException", "(", "\\", "sprintf", "(", "'Event deserialization failed due to error %s: %s'", ",", "\\", "json_last_error", "(", ")", ",", "\\", "lcfirst", "(", "\\", "json_last_error_msg", "(", ")", ")", ")", ")", ";", "}", "// @codeCoverageIgnoreEnd", "return", "$", "definition", ";", "}" ]
Get deserialization definition. @param string $serialized @return array<string, mixed>
[ "Get", "deserialization", "definition", "." ]
e2d72b32e8852ec3926636af1c686a7c582b0bca
https://github.com/phpgears/event-async/blob/e2d72b32e8852ec3926636af1c686a7c582b0bca/src/Serializer/JsonEventSerializer.php#L149-L168
train
itcreator/custom-cmf
Module/Language/src/Cmf/Language/Factory.php
Factory.init
private static function init() { if (!self::$defaultLng) { $config = Application::getConfigManager()->loadForModule('Cmf\Language'); self::$defaultLng = strtolower($config->defaultLanguage); $currentLng = $config->currentLanguage; self::$currentLng = $currentLng ? strtolower($currentLng) : strtolower($config->defaultLanguage); } }
php
private static function init() { if (!self::$defaultLng) { $config = Application::getConfigManager()->loadForModule('Cmf\Language'); self::$defaultLng = strtolower($config->defaultLanguage); $currentLng = $config->currentLanguage; self::$currentLng = $currentLng ? strtolower($currentLng) : strtolower($config->defaultLanguage); } }
[ "private", "static", "function", "init", "(", ")", "{", "if", "(", "!", "self", "::", "$", "defaultLng", ")", "{", "$", "config", "=", "Application", "::", "getConfigManager", "(", ")", "->", "loadForModule", "(", "'Cmf\\Language'", ")", ";", "self", "::", "$", "defaultLng", "=", "strtolower", "(", "$", "config", "->", "defaultLanguage", ")", ";", "$", "currentLng", "=", "$", "config", "->", "currentLanguage", ";", "self", "::", "$", "currentLng", "=", "$", "currentLng", "?", "strtolower", "(", "$", "currentLng", ")", ":", "strtolower", "(", "$", "config", "->", "defaultLanguage", ")", ";", "}", "}" ]
Initialization of language manager @return void
[ "Initialization", "of", "language", "manager" ]
42fc0535dfa0f641856f06673f6ab596b2020c40
https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/Language/src/Cmf/Language/Factory.php#L33-L41
train
jyokum/healthgraph
src/HealthGraph/Authorization.php
Authorization.getAuthorizationButton
public static function getAuthorizationButton( $client_id, $redirect_url, $state = '', $text = 'connect', $color = 'blue', $caption = 'white', $size = 200, $url = 'https://runkeeper.com/apps/authorize' ) { $link = self::getAuthorizationLink($client_id, $redirect_url, $state); $text = (in_array($text, array('connect', 'login'))) ? $text : 'connect'; $color = (in_array($color, array('blue', 'grey', 'black'))) ? $color : 'blue'; $caption = (in_array($caption, array('white', 'black'))) ? $caption : 'white'; switch ($size) { case '300': $size = '300x57'; break; case '600': $size = '600x114'; break; default: $size = '200x38'; break; } $image = "http://static1.runkeeper.com/images/assets/$text-$color-$caption-$size.png"; $button = array( 'link' => $link, 'image' => $image, 'html' => "<a href='$link'><img src='$image' /></a>", ); return $button; }
php
public static function getAuthorizationButton( $client_id, $redirect_url, $state = '', $text = 'connect', $color = 'blue', $caption = 'white', $size = 200, $url = 'https://runkeeper.com/apps/authorize' ) { $link = self::getAuthorizationLink($client_id, $redirect_url, $state); $text = (in_array($text, array('connect', 'login'))) ? $text : 'connect'; $color = (in_array($color, array('blue', 'grey', 'black'))) ? $color : 'blue'; $caption = (in_array($caption, array('white', 'black'))) ? $caption : 'white'; switch ($size) { case '300': $size = '300x57'; break; case '600': $size = '600x114'; break; default: $size = '200x38'; break; } $image = "http://static1.runkeeper.com/images/assets/$text-$color-$caption-$size.png"; $button = array( 'link' => $link, 'image' => $image, 'html' => "<a href='$link'><img src='$image' /></a>", ); return $button; }
[ "public", "static", "function", "getAuthorizationButton", "(", "$", "client_id", ",", "$", "redirect_url", ",", "$", "state", "=", "''", ",", "$", "text", "=", "'connect'", ",", "$", "color", "=", "'blue'", ",", "$", "caption", "=", "'white'", ",", "$", "size", "=", "200", ",", "$", "url", "=", "'https://runkeeper.com/apps/authorize'", ")", "{", "$", "link", "=", "self", "::", "getAuthorizationLink", "(", "$", "client_id", ",", "$", "redirect_url", ",", "$", "state", ")", ";", "$", "text", "=", "(", "in_array", "(", "$", "text", ",", "array", "(", "'connect'", ",", "'login'", ")", ")", ")", "?", "$", "text", ":", "'connect'", ";", "$", "color", "=", "(", "in_array", "(", "$", "color", ",", "array", "(", "'blue'", ",", "'grey'", ",", "'black'", ")", ")", ")", "?", "$", "color", ":", "'blue'", ";", "$", "caption", "=", "(", "in_array", "(", "$", "caption", ",", "array", "(", "'white'", ",", "'black'", ")", ")", ")", "?", "$", "caption", ":", "'white'", ";", "switch", "(", "$", "size", ")", "{", "case", "'300'", ":", "$", "size", "=", "'300x57'", ";", "break", ";", "case", "'600'", ":", "$", "size", "=", "'600x114'", ";", "break", ";", "default", ":", "$", "size", "=", "'200x38'", ";", "break", ";", "}", "$", "image", "=", "\"http://static1.runkeeper.com/images/assets/$text-$color-$caption-$size.png\"", ";", "$", "button", "=", "array", "(", "'link'", "=>", "$", "link", ",", "'image'", "=>", "$", "image", ",", "'html'", "=>", "\"<a href='$link'><img src='$image' /></a>\"", ",", ")", ";", "return", "$", "button", ";", "}" ]
Generates a button for establishing a connection with a RunKeeper account. @param string $client_id The unique identifier that your application received upon registration. @param string $redirect_url The page on your site where the user will be redirected after accepting or denying the access request. @param string $text Type of button to generate. Default is "connect", valid options are: connect, login @param string $color Color to use for button text. Default is "blue", valid options are: blue, grey, black @param string $caption Color to use for button caption. Default is 200, valid options are: white, black @param int $size Width of the button. Valid options are: 200, 300, 600 @param string $url @return array
[ "Generates", "a", "button", "for", "establishing", "a", "connection", "with", "a", "RunKeeper", "account", "." ]
6b3b4c4eb797f1fcf056024c8b15a16665bf8758
https://github.com/jyokum/healthgraph/blob/6b3b4c4eb797f1fcf056024c8b15a16665bf8758/src/HealthGraph/Authorization.php#L27-L61
train
jyokum/healthgraph
src/HealthGraph/Authorization.php
Authorization.getAuthorizationLink
public static function getAuthorizationLink( $client_id, $redirect_url, $state = '', $url = 'https://runkeeper.com/apps/authorize' ) { $data = array( 'client_id' => $client_id, 'response_type' => 'code', 'redirect_uri' => $redirect_url, 'state' => $state, ); return (string) \Guzzle\Http\Url::factory($url)->setQuery($data); }
php
public static function getAuthorizationLink( $client_id, $redirect_url, $state = '', $url = 'https://runkeeper.com/apps/authorize' ) { $data = array( 'client_id' => $client_id, 'response_type' => 'code', 'redirect_uri' => $redirect_url, 'state' => $state, ); return (string) \Guzzle\Http\Url::factory($url)->setQuery($data); }
[ "public", "static", "function", "getAuthorizationLink", "(", "$", "client_id", ",", "$", "redirect_url", ",", "$", "state", "=", "''", ",", "$", "url", "=", "'https://runkeeper.com/apps/authorize'", ")", "{", "$", "data", "=", "array", "(", "'client_id'", "=>", "$", "client_id", ",", "'response_type'", "=>", "'code'", ",", "'redirect_uri'", "=>", "$", "redirect_url", ",", "'state'", "=>", "$", "state", ",", ")", ";", "return", "(", "string", ")", "\\", "Guzzle", "\\", "Http", "\\", "Url", "::", "factory", "(", "$", "url", ")", "->", "setQuery", "(", "$", "data", ")", ";", "}" ]
Generates a link for establishing a connection with a RunKeeper account. @param string $client_id The unique identifier that your application received upon registration. @param string $redirect_url The page on your site where the user will be redirected after accepting or denying the access request. @param string $url @return string
[ "Generates", "a", "link", "for", "establishing", "a", "connection", "with", "a", "RunKeeper", "account", "." ]
6b3b4c4eb797f1fcf056024c8b15a16665bf8758
https://github.com/jyokum/healthgraph/blob/6b3b4c4eb797f1fcf056024c8b15a16665bf8758/src/HealthGraph/Authorization.php#L74-L87
train
vperyod/vperyod.session-handler
src/SessionAwareTrait.php
SessionAwareTrait.getSession
protected function getSession(Request $request) : Session\Session { $session = $request->getAttribute(SessionHandler::SESSION_ATTRIBUTE); if (! $session instanceof Session\Session) { throw new \Exception( 'Session not available in request at: ' . SessionHandler::SESSION_ATTRIBUTE ); } return $session; }
php
protected function getSession(Request $request) : Session\Session { $session = $request->getAttribute(SessionHandler::SESSION_ATTRIBUTE); if (! $session instanceof Session\Session) { throw new \Exception( 'Session not available in request at: ' . SessionHandler::SESSION_ATTRIBUTE ); } return $session; }
[ "protected", "function", "getSession", "(", "Request", "$", "request", ")", ":", "Session", "\\", "Session", "{", "$", "session", "=", "$", "request", "->", "getAttribute", "(", "SessionHandler", "::", "SESSION_ATTRIBUTE", ")", ";", "if", "(", "!", "$", "session", "instanceof", "Session", "\\", "Session", ")", "{", "throw", "new", "\\", "Exception", "(", "'Session not available in request at: '", ".", "SessionHandler", "::", "SESSION_ATTRIBUTE", ")", ";", "}", "return", "$", "session", ";", "}" ]
Get session from request @param Request $request PSR7 Request @return Session\Session @throws Exception if session attribute is invalid @access protected
[ "Get", "session", "from", "request" ]
61a607be009296b69bdb328ed3a26940e1b925bb
https://github.com/vperyod/vperyod.session-handler/blob/61a607be009296b69bdb328ed3a26940e1b925bb/src/SessionAwareTrait.php#L50-L61
train
itkg/core
src/Itkg/Core/Config.php
Config.load
public function load(array $files = array()) { $loader = new YamlLoader(new FileLocator, new YamlParser); foreach ($files as $file) { $configValues = $loader->load($file); $configValues = $this->loadImports($loader, $file, $configValues); $this->params = array_replace_recursive($this->params, $configValues); } }
php
public function load(array $files = array()) { $loader = new YamlLoader(new FileLocator, new YamlParser); foreach ($files as $file) { $configValues = $loader->load($file); $configValues = $this->loadImports($loader, $file, $configValues); $this->params = array_replace_recursive($this->params, $configValues); } }
[ "public", "function", "load", "(", "array", "$", "files", "=", "array", "(", ")", ")", "{", "$", "loader", "=", "new", "YamlLoader", "(", "new", "FileLocator", ",", "new", "YamlParser", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "configValues", "=", "$", "loader", "->", "load", "(", "$", "file", ")", ";", "$", "configValues", "=", "$", "this", "->", "loadImports", "(", "$", "loader", ",", "$", "file", ",", "$", "configValues", ")", ";", "$", "this", "->", "params", "=", "array_replace_recursive", "(", "$", "this", "->", "params", ",", "$", "configValues", ")", ";", "}", "}" ]
Load config files @param array $files
[ "Load", "config", "files" ]
e5e4efb05feb4d23b0df41f2b21fd095103e593b
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Config.php#L45-L56
train
itkg/core
src/Itkg/Core/Config.php
Config.get
public function get($key) { if ($this->has($key)) { return $this->params[$key]; } throw new \InvalidArgumentException(sprintf("Config key %s doest not exist", $key)); }
php
public function get($key) { if ($this->has($key)) { return $this->params[$key]; } throw new \InvalidArgumentException(sprintf("Config key %s doest not exist", $key)); }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "params", "[", "$", "key", "]", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Config key %s doest not exist\"", ",", "$", "key", ")", ")", ";", "}" ]
Get a config value for a key @param $key @return mixed @throws \InvalidArgumentException
[ "Get", "a", "config", "value", "for", "a", "key" ]
e5e4efb05feb4d23b0df41f2b21fd095103e593b
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Config.php#L86-L93
train
agentmedia/phine-core
src/Core/Snippets/TreeBranches/Base/ContentBranch.php
ContentBranch.CreateInUrl
final protected function CreateInUrl() { $args = $this->EditParams(); $args['parent'] = $this->item->GetID(); return BackendRouter::ModuleUrl(new ModuleForm(), $args); }
php
final protected function CreateInUrl() { $args = $this->EditParams(); $args['parent'] = $this->item->GetID(); return BackendRouter::ModuleUrl(new ModuleForm(), $args); }
[ "final", "protected", "function", "CreateInUrl", "(", ")", "{", "$", "args", "=", "$", "this", "->", "EditParams", "(", ")", ";", "$", "args", "[", "'parent'", "]", "=", "$", "this", "->", "item", "->", "GetID", "(", ")", ";", "return", "BackendRouter", "::", "ModuleUrl", "(", "new", "ModuleForm", "(", ")", ",", "$", "args", ")", ";", "}" ]
The url for creating content in the current item @return string
[ "The", "url", "for", "creating", "content", "in", "the", "current", "item" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Snippets/TreeBranches/Base/ContentBranch.php#L119-L124
train
agentmedia/phine-core
src/Core/Snippets/TreeBranches/Base/ContentBranch.php
ContentBranch.CanEdit
final protected function CanEdit() { $form = $this->module->ContentForm(); return BackendModule::Guard()->Allow(BackendAction::Edit(), $this->content) && BackendModule::Guard()->Allow(BackendAction::Read(), $form); }
php
final protected function CanEdit() { $form = $this->module->ContentForm(); return BackendModule::Guard()->Allow(BackendAction::Edit(), $this->content) && BackendModule::Guard()->Allow(BackendAction::Read(), $form); }
[ "final", "protected", "function", "CanEdit", "(", ")", "{", "$", "form", "=", "$", "this", "->", "module", "->", "ContentForm", "(", ")", ";", "return", "BackendModule", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "Edit", "(", ")", ",", "$", "this", "->", "content", ")", "&&", "BackendModule", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "Read", "(", ")", ",", "$", "form", ")", ";", "}" ]
True if the the content can be edited @return Boolean
[ "True", "if", "the", "the", "content", "can", "be", "edited" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Snippets/TreeBranches/Base/ContentBranch.php#L178-L183
train
agentmedia/phine-core
src/Core/Snippets/TreeBranches/Base/ContentBranch.php
ContentBranch.CanCreateIn
final protected function CanCreateIn() { return $this->AllowChildren() && BackendModule::Guard()->Allow(BackendAction::Create(), $this->content); }
php
final protected function CanCreateIn() { return $this->AllowChildren() && BackendModule::Guard()->Allow(BackendAction::Create(), $this->content); }
[ "final", "protected", "function", "CanCreateIn", "(", ")", "{", "return", "$", "this", "->", "AllowChildren", "(", ")", "&&", "BackendModule", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "Create", "(", ")", ",", "$", "this", "->", "content", ")", ";", "}" ]
True if the content can be created in @return Boolean
[ "True", "if", "the", "content", "can", "be", "created", "in" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Snippets/TreeBranches/Base/ContentBranch.php#L198-L202
train
agentmedia/phine-core
src/Core/Snippets/TreeBranches/Base/ContentBranch.php
ContentBranch.CanCreateAfter
final protected function CanCreateAfter() { $parentItem = $this->tree->ParentOf($this->item); if ($parentItem) { $parent = $this->tree->ContentByItem($parentItem); return BackendModule::Guard()->Allow(BackendAction::Create(), $parent); } return $this->GrantCreateInRoot()->ToBool(); }
php
final protected function CanCreateAfter() { $parentItem = $this->tree->ParentOf($this->item); if ($parentItem) { $parent = $this->tree->ContentByItem($parentItem); return BackendModule::Guard()->Allow(BackendAction::Create(), $parent); } return $this->GrantCreateInRoot()->ToBool(); }
[ "final", "protected", "function", "CanCreateAfter", "(", ")", "{", "$", "parentItem", "=", "$", "this", "->", "tree", "->", "ParentOf", "(", "$", "this", "->", "item", ")", ";", "if", "(", "$", "parentItem", ")", "{", "$", "parent", "=", "$", "this", "->", "tree", "->", "ContentByItem", "(", "$", "parentItem", ")", ";", "return", "BackendModule", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "Create", "(", ")", ",", "$", "parent", ")", ";", "}", "return", "$", "this", "->", "GrantCreateInRoot", "(", ")", "->", "ToBool", "(", ")", ";", "}" ]
True if there can be content created after @return boolean
[ "True", "if", "there", "can", "be", "content", "created", "after" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Snippets/TreeBranches/Base/ContentBranch.php#L217-L226
train
Polosa/shade-framework-core
app/NestedContainer.php
NestedContainer.__isset
public function __isset($name) { return isset($this->children[$name]) && !is_null($this->children[$name]->getValue()); }
php
public function __isset($name) { return isset($this->children[$name]) && !is_null($this->children[$name]->getValue()); }
[ "public", "function", "__isset", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "children", "[", "$", "name", "]", ")", "&&", "!", "is_null", "(", "$", "this", "->", "children", "[", "$", "name", "]", "->", "getValue", "(", ")", ")", ";", "}" ]
Check if child set @param string $name Child name @return bool
[ "Check", "if", "child", "set" ]
d735d3e8e0616fb9cf4ffc25b8425762ed07940f
https://github.com/Polosa/shade-framework-core/blob/d735d3e8e0616fb9cf4ffc25b8425762ed07940f/app/NestedContainer.php#L118-L121
train
Polosa/shade-framework-core
app/NestedContainer.php
NestedContainer.overwrite
public function overwrite($container) { $originalValue = $this->getValue(); $newValue = $container->getValue(); if (is_null($newValue)) { $resultValue = $originalValue; } elseif (is_array($newValue) && is_array($originalValue)) { $resultValue = array_replace_recursive($originalValue, $newValue); } else { $resultValue = $newValue; } $this->setValue($resultValue); return $this; }
php
public function overwrite($container) { $originalValue = $this->getValue(); $newValue = $container->getValue(); if (is_null($newValue)) { $resultValue = $originalValue; } elseif (is_array($newValue) && is_array($originalValue)) { $resultValue = array_replace_recursive($originalValue, $newValue); } else { $resultValue = $newValue; } $this->setValue($resultValue); return $this; }
[ "public", "function", "overwrite", "(", "$", "container", ")", "{", "$", "originalValue", "=", "$", "this", "->", "getValue", "(", ")", ";", "$", "newValue", "=", "$", "container", "->", "getValue", "(", ")", ";", "if", "(", "is_null", "(", "$", "newValue", ")", ")", "{", "$", "resultValue", "=", "$", "originalValue", ";", "}", "elseif", "(", "is_array", "(", "$", "newValue", ")", "&&", "is_array", "(", "$", "originalValue", ")", ")", "{", "$", "resultValue", "=", "array_replace_recursive", "(", "$", "originalValue", ",", "$", "newValue", ")", ";", "}", "else", "{", "$", "resultValue", "=", "$", "newValue", ";", "}", "$", "this", "->", "setValue", "(", "$", "resultValue", ")", ";", "return", "$", "this", ";", "}" ]
Overwrite Container's data @param self $container Container to overwrite by @return self
[ "Overwrite", "Container", "s", "data" ]
d735d3e8e0616fb9cf4ffc25b8425762ed07940f
https://github.com/Polosa/shade-framework-core/blob/d735d3e8e0616fb9cf4ffc25b8425762ed07940f/app/NestedContainer.php#L154-L170
train
freialib/hlin.tools
src/Request.php
Request.input
function input(array $formats, $output = 'array') { if (in_array('post', $formats)) { $post = $this->context->web->requestPostData(); if ( ! empty($post)) { if ($output == 'array') { return $post; } } } if (in_array('json', $formats)) { $input = $this->context->web->requestBody(); if ( ! empty($input)) { if ($output == 'array') { return json_decode($input, true); } } } if (in_array('query', $formats) || in_array('get', $formats)) { $get = $this->context->web->requestQueryData(); if ( ! empty($get)) { if ($output == 'array') { return $get; } } } if (in_array('raw-query', $formats)) { $rawquery = $this->context->web->requestRawQueryData(); if ( ! empty($rawquery)) { return $rawquery; } } if (in_array('files', $formats)) { $files = $this->context->web->requestFiles(); if ( ! empty($files)) { if ($output == 'array') { return $files; } } } // failed to resolve input return null; }
php
function input(array $formats, $output = 'array') { if (in_array('post', $formats)) { $post = $this->context->web->requestPostData(); if ( ! empty($post)) { if ($output == 'array') { return $post; } } } if (in_array('json', $formats)) { $input = $this->context->web->requestBody(); if ( ! empty($input)) { if ($output == 'array') { return json_decode($input, true); } } } if (in_array('query', $formats) || in_array('get', $formats)) { $get = $this->context->web->requestQueryData(); if ( ! empty($get)) { if ($output == 'array') { return $get; } } } if (in_array('raw-query', $formats)) { $rawquery = $this->context->web->requestRawQueryData(); if ( ! empty($rawquery)) { return $rawquery; } } if (in_array('files', $formats)) { $files = $this->context->web->requestFiles(); if ( ! empty($files)) { if ($output == 'array') { return $files; } } } // failed to resolve input return null; }
[ "function", "input", "(", "array", "$", "formats", ",", "$", "output", "=", "'array'", ")", "{", "if", "(", "in_array", "(", "'post'", ",", "$", "formats", ")", ")", "{", "$", "post", "=", "$", "this", "->", "context", "->", "web", "->", "requestPostData", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "post", ")", ")", "{", "if", "(", "$", "output", "==", "'array'", ")", "{", "return", "$", "post", ";", "}", "}", "}", "if", "(", "in_array", "(", "'json'", ",", "$", "formats", ")", ")", "{", "$", "input", "=", "$", "this", "->", "context", "->", "web", "->", "requestBody", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "input", ")", ")", "{", "if", "(", "$", "output", "==", "'array'", ")", "{", "return", "json_decode", "(", "$", "input", ",", "true", ")", ";", "}", "}", "}", "if", "(", "in_array", "(", "'query'", ",", "$", "formats", ")", "||", "in_array", "(", "'get'", ",", "$", "formats", ")", ")", "{", "$", "get", "=", "$", "this", "->", "context", "->", "web", "->", "requestQueryData", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "get", ")", ")", "{", "if", "(", "$", "output", "==", "'array'", ")", "{", "return", "$", "get", ";", "}", "}", "}", "if", "(", "in_array", "(", "'raw-query'", ",", "$", "formats", ")", ")", "{", "$", "rawquery", "=", "$", "this", "->", "context", "->", "web", "->", "requestRawQueryData", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "rawquery", ")", ")", "{", "return", "$", "rawquery", ";", "}", "}", "if", "(", "in_array", "(", "'files'", ",", "$", "formats", ")", ")", "{", "$", "files", "=", "$", "this", "->", "context", "->", "web", "->", "requestFiles", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "files", ")", ")", "{", "if", "(", "$", "output", "==", "'array'", ")", "{", "return", "$", "files", ";", "}", "}", "}", "// failed to resolve input", "return", "null", ";", "}" ]
Given a set of acceptable formats the system tries to retrieve the data format specified and return it in the specified output format. If there is no input the method will return null. Supported formats: - post - json - query (alias: get) - raw-query - files Supported output formats: - array @return mixed|null input
[ "Given", "a", "set", "of", "acceptable", "formats", "the", "system", "tries", "to", "retrieve", "the", "data", "format", "specified", "and", "return", "it", "in", "the", "specified", "output", "format", ".", "If", "there", "is", "no", "input", "the", "method", "will", "return", "null", "." ]
42ad9e9fe081918d2ee5d52b72d174ccdcf7cbe7
https://github.com/freialib/hlin.tools/blob/42ad9e9fe081918d2ee5d52b72d174ccdcf7cbe7/src/Request.php#L43-L90
train
bandama-framework/bandama-framework
src/foundation/router/Route.php
Route.match
public function match($url) { // Remove the start and end slash of URL $url = trim($url, '/'); // Replace path parameters (:parameter) by $path = preg_replace_callback('#:([\w]+)#', [$this, 'paramMatch'], $this->path); // Define the regex patterb with the new path after replaced the parameters of path $regex = "#^$path$#i"; // Check if the url matchs the path if (!preg_match($regex, $url, $matches)) { return false; } // Keep only the parameters array_shift($matches); return $matches; }
php
public function match($url) { // Remove the start and end slash of URL $url = trim($url, '/'); // Replace path parameters (:parameter) by $path = preg_replace_callback('#:([\w]+)#', [$this, 'paramMatch'], $this->path); // Define the regex patterb with the new path after replaced the parameters of path $regex = "#^$path$#i"; // Check if the url matchs the path if (!preg_match($regex, $url, $matches)) { return false; } // Keep only the parameters array_shift($matches); return $matches; }
[ "public", "function", "match", "(", "$", "url", ")", "{", "// Remove the start and end slash of URL", "$", "url", "=", "trim", "(", "$", "url", ",", "'/'", ")", ";", "// Replace path parameters (:parameter) by", "$", "path", "=", "preg_replace_callback", "(", "'#:([\\w]+)#'", ",", "[", "$", "this", ",", "'paramMatch'", "]", ",", "$", "this", "->", "path", ")", ";", "// Define the regex patterb with the new path after replaced the parameters of path", "$", "regex", "=", "\"#^$path$#i\"", ";", "// Check if the url matchs the path", "if", "(", "!", "preg_match", "(", "$", "regex", ",", "$", "url", ",", "$", "matches", ")", ")", "{", "return", "false", ";", "}", "// Keep only the parameters", "array_shift", "(", "$", "matches", ")", ";", "return", "$", "matches", ";", "}" ]
Test if the current route matches the URL @param string $url @return boolean|mixed
[ "Test", "if", "the", "current", "route", "matches", "the", "URL" ]
234ed703baf9e31268941c9d5f6d5e004cc53066
https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/foundation/router/Route.php#L102-L119
train
bandama-framework/bandama-framework
src/foundation/router/Route.php
Route.execute
public function execute($matches) { if (is_string($this->callable)) { // If the callable is a string, call the action of controller $params = explode('#', $this->callable); if (count($params) == 2) { $controllerPrefix = $params[0]; $controllerPrefix = str_replace(':', '\\', $controllerPrefix); $controller = $controllerPrefix."Controller"; $controller = new $controller(); $action = $params[1].'Action'; return call_user_func_array(array($controller, $action), $matches); return $controller->$action(); } else { throw new RouterException('Invalid controller name '.$this->callable); } } else { // If the callable is a function, execute the function return call_user_func_array($this->callable, $matches); } }
php
public function execute($matches) { if (is_string($this->callable)) { // If the callable is a string, call the action of controller $params = explode('#', $this->callable); if (count($params) == 2) { $controllerPrefix = $params[0]; $controllerPrefix = str_replace(':', '\\', $controllerPrefix); $controller = $controllerPrefix."Controller"; $controller = new $controller(); $action = $params[1].'Action'; return call_user_func_array(array($controller, $action), $matches); return $controller->$action(); } else { throw new RouterException('Invalid controller name '.$this->callable); } } else { // If the callable is a function, execute the function return call_user_func_array($this->callable, $matches); } }
[ "public", "function", "execute", "(", "$", "matches", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "callable", ")", ")", "{", "// If the callable is a string, call the action of controller", "$", "params", "=", "explode", "(", "'#'", ",", "$", "this", "->", "callable", ")", ";", "if", "(", "count", "(", "$", "params", ")", "==", "2", ")", "{", "$", "controllerPrefix", "=", "$", "params", "[", "0", "]", ";", "$", "controllerPrefix", "=", "str_replace", "(", "':'", ",", "'\\\\'", ",", "$", "controllerPrefix", ")", ";", "$", "controller", "=", "$", "controllerPrefix", ".", "\"Controller\"", ";", "$", "controller", "=", "new", "$", "controller", "(", ")", ";", "$", "action", "=", "$", "params", "[", "1", "]", ".", "'Action'", ";", "return", "call_user_func_array", "(", "array", "(", "$", "controller", ",", "$", "action", ")", ",", "$", "matches", ")", ";", "return", "$", "controller", "->", "$", "action", "(", ")", ";", "}", "else", "{", "throw", "new", "RouterException", "(", "'Invalid controller name '", ".", "$", "this", "->", "callable", ")", ";", "}", "}", "else", "{", "// If the callable is a function, execute the function", "return", "call_user_func_array", "(", "$", "this", "->", "callable", ",", "$", "matches", ")", ";", "}", "}" ]
Execute the callable of route @param array $matches URL parameters @return mixed
[ "Execute", "the", "callable", "of", "route" ]
234ed703baf9e31268941c9d5f6d5e004cc53066
https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/foundation/router/Route.php#L128-L153
train
bandama-framework/bandama-framework
src/foundation/router/Route.php
Route.getUrl
public function getUrl($params) { $path = $this->path; foreach ($params as $k => $v) { $path = str_replace(":$k", $v, $path); } return $path; }
php
public function getUrl($params) { $path = $this->path; foreach ($params as $k => $v) { $path = str_replace(":$k", $v, $path); } return $path; }
[ "public", "function", "getUrl", "(", "$", "params", ")", "{", "$", "path", "=", "$", "this", "->", "path", ";", "foreach", "(", "$", "params", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "path", "=", "str_replace", "(", "\":$k\"", ",", "$", "v", ",", "$", "path", ")", ";", "}", "return", "$", "path", ";", "}" ]
Generate the URL with the parameters @param array $params Route parameters @return string
[ "Generate", "the", "URL", "with", "the", "parameters" ]
234ed703baf9e31268941c9d5f6d5e004cc53066
https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/foundation/router/Route.php#L162-L170
train
yuncms/yii2-article
backend/controllers/ArticleController.php
ArticleController.actionAudit
public function actionAudit($id) { $model = $this->findModel($id); $model->setPublished(); Yii::$app->getSession()->setFlash('success', Yii::t('article', 'Update success.')); return $this->redirect(Url::previous('actions-redirect')); }
php
public function actionAudit($id) { $model = $this->findModel($id); $model->setPublished(); Yii::$app->getSession()->setFlash('success', Yii::t('article', 'Update success.')); return $this->redirect(Url::previous('actions-redirect')); }
[ "public", "function", "actionAudit", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "model", "->", "setPublished", "(", ")", ";", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "setFlash", "(", "'success'", ",", "Yii", "::", "t", "(", "'article'", ",", "'Update success.'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "Url", "::", "previous", "(", "'actions-redirect'", ")", ")", ";", "}" ]
Audit an existing Comment model. If Audit is successful, the browser will be redirected to the 'index' page. @param integer $id @return mixed
[ "Audit", "an", "existing", "Comment", "model", ".", "If", "Audit", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "index", "page", "." ]
177ec4d3d143b2f2a69bce760e873485cf3df192
https://github.com/yuncms/yii2-article/blob/177ec4d3d143b2f2a69bce760e873485cf3df192/backend/controllers/ArticleController.php#L112-L118
train
PenoaksDev/Milky-Framework
src/Milky/Account/AccountManager.php
AccountManager.resolveGuard
public function resolveGuard( $name ) { $config = Config::get( 'auth.guards.' . $name ); if ( is_null( $config ) ) throw new AccountException( "Auth guard [" . $name . "] is not defined in the configuration" ); $uses = $config['uses']; $auth = $this->resolveAuth( $config['auth'] ?: $this->getDefaultAuth() ); $guard = null; switch ( $uses ) { case 'session': { $guard = new SessionGuard( $name, $auth, SessionManager::i()->driver(), Request::i(), CookieJar::i() ); break; } case 'token': { $guard = new TokenGuard( $auth, Request::i() ); break; } default: { $guard = UniversalBuilder::resolve( $uses ); if ( is_null( $guard ) ) throw new AccountException( "We could not resolve the guard [" . $uses . "]" ); if ( !is_subclass_of( $guard, Guard::class ) ) throw new \InvalidArgumentException( "The guard [" . $uses . "] must extend the [" . Guard::class . "] class" ); } } return $guard; }
php
public function resolveGuard( $name ) { $config = Config::get( 'auth.guards.' . $name ); if ( is_null( $config ) ) throw new AccountException( "Auth guard [" . $name . "] is not defined in the configuration" ); $uses = $config['uses']; $auth = $this->resolveAuth( $config['auth'] ?: $this->getDefaultAuth() ); $guard = null; switch ( $uses ) { case 'session': { $guard = new SessionGuard( $name, $auth, SessionManager::i()->driver(), Request::i(), CookieJar::i() ); break; } case 'token': { $guard = new TokenGuard( $auth, Request::i() ); break; } default: { $guard = UniversalBuilder::resolve( $uses ); if ( is_null( $guard ) ) throw new AccountException( "We could not resolve the guard [" . $uses . "]" ); if ( !is_subclass_of( $guard, Guard::class ) ) throw new \InvalidArgumentException( "The guard [" . $uses . "] must extend the [" . Guard::class . "] class" ); } } return $guard; }
[ "public", "function", "resolveGuard", "(", "$", "name", ")", "{", "$", "config", "=", "Config", "::", "get", "(", "'auth.guards.'", ".", "$", "name", ")", ";", "if", "(", "is_null", "(", "$", "config", ")", ")", "throw", "new", "AccountException", "(", "\"Auth guard [\"", ".", "$", "name", ".", "\"] is not defined in the configuration\"", ")", ";", "$", "uses", "=", "$", "config", "[", "'uses'", "]", ";", "$", "auth", "=", "$", "this", "->", "resolveAuth", "(", "$", "config", "[", "'auth'", "]", "?", ":", "$", "this", "->", "getDefaultAuth", "(", ")", ")", ";", "$", "guard", "=", "null", ";", "switch", "(", "$", "uses", ")", "{", "case", "'session'", ":", "{", "$", "guard", "=", "new", "SessionGuard", "(", "$", "name", ",", "$", "auth", ",", "SessionManager", "::", "i", "(", ")", "->", "driver", "(", ")", ",", "Request", "::", "i", "(", ")", ",", "CookieJar", "::", "i", "(", ")", ")", ";", "break", ";", "}", "case", "'token'", ":", "{", "$", "guard", "=", "new", "TokenGuard", "(", "$", "auth", ",", "Request", "::", "i", "(", ")", ")", ";", "break", ";", "}", "default", ":", "{", "$", "guard", "=", "UniversalBuilder", "::", "resolve", "(", "$", "uses", ")", ";", "if", "(", "is_null", "(", "$", "guard", ")", ")", "throw", "new", "AccountException", "(", "\"We could not resolve the guard [\"", ".", "$", "uses", ".", "\"]\"", ")", ";", "if", "(", "!", "is_subclass_of", "(", "$", "guard", ",", "Guard", "::", "class", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"The guard [\"", ".", "$", "uses", ".", "\"] must extend the [\"", ".", "Guard", "::", "class", ".", "\"] class\"", ")", ";", "}", "}", "return", "$", "guard", ";", "}" ]
Resolve the implemented Account Guard @param string $name
[ "Resolve", "the", "implemented", "Account", "Guard" ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/AccountManager.php#L64-L100
train
PenoaksDev/Milky-Framework
src/Milky/Account/AccountManager.php
AccountManager.resolveAuth
public function resolveAuth( $auth ) { $config = Config::get( 'auth.auths.' . $auth ); $uses = $config['uses']; switch ( $uses ) { case 'database': { $auth = new DatabaseAuth( $config['table'] ); break; } case 'eloquent': { $auth = new EloquentAuth( $config['usrModel'], $config['grpModel'] ); break; } default: { $auth = UniversalBuilder::resolve( $uses ); if ( is_null( $auth ) ) throw new AccountException( "We could not resolve the auth [" . $uses . "]" ); if ( !is_subclass_of( $auth, AccountAuth::class ) ) throw new \InvalidArgumentException( "The auth [" . $uses . "] must extend the [" . AccountAuth::class . "] class" ); } } return $auth; }
php
public function resolveAuth( $auth ) { $config = Config::get( 'auth.auths.' . $auth ); $uses = $config['uses']; switch ( $uses ) { case 'database': { $auth = new DatabaseAuth( $config['table'] ); break; } case 'eloquent': { $auth = new EloquentAuth( $config['usrModel'], $config['grpModel'] ); break; } default: { $auth = UniversalBuilder::resolve( $uses ); if ( is_null( $auth ) ) throw new AccountException( "We could not resolve the auth [" . $uses . "]" ); if ( !is_subclass_of( $auth, AccountAuth::class ) ) throw new \InvalidArgumentException( "The auth [" . $uses . "] must extend the [" . AccountAuth::class . "] class" ); } } return $auth; }
[ "public", "function", "resolveAuth", "(", "$", "auth", ")", "{", "$", "config", "=", "Config", "::", "get", "(", "'auth.auths.'", ".", "$", "auth", ")", ";", "$", "uses", "=", "$", "config", "[", "'uses'", "]", ";", "switch", "(", "$", "uses", ")", "{", "case", "'database'", ":", "{", "$", "auth", "=", "new", "DatabaseAuth", "(", "$", "config", "[", "'table'", "]", ")", ";", "break", ";", "}", "case", "'eloquent'", ":", "{", "$", "auth", "=", "new", "EloquentAuth", "(", "$", "config", "[", "'usrModel'", "]", ",", "$", "config", "[", "'grpModel'", "]", ")", ";", "break", ";", "}", "default", ":", "{", "$", "auth", "=", "UniversalBuilder", "::", "resolve", "(", "$", "uses", ")", ";", "if", "(", "is_null", "(", "$", "auth", ")", ")", "throw", "new", "AccountException", "(", "\"We could not resolve the auth [\"", ".", "$", "uses", ".", "\"]\"", ")", ";", "if", "(", "!", "is_subclass_of", "(", "$", "auth", ",", "AccountAuth", "::", "class", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"The auth [\"", ".", "$", "uses", ".", "\"] must extend the [\"", ".", "AccountAuth", "::", "class", ".", "\"] class\"", ")", ";", "}", "}", "return", "$", "auth", ";", "}" ]
Resolve the implemented Account Auth @param string $auth @return AccountAuth
[ "Resolve", "the", "implemented", "Account", "Auth" ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/AccountManager.php#L108-L138
train
PenoaksDev/Milky-Framework
src/Milky/Account/AccountManager.php
AccountManager.viaRequest
public function viaRequest( $name, callable $callback ) { $this->guards[$name] = new RequestGuard( $callback, Request::i() ); }
php
public function viaRequest( $name, callable $callback ) { $this->guards[$name] = new RequestGuard( $callback, Request::i() ); }
[ "public", "function", "viaRequest", "(", "$", "name", ",", "callable", "$", "callback", ")", "{", "$", "this", "->", "guards", "[", "$", "name", "]", "=", "new", "RequestGuard", "(", "$", "callback", ",", "Request", "::", "i", "(", ")", ")", ";", "}" ]
Register a callback based guard @param $name @param callable $callback
[ "Register", "a", "callback", "based", "guard" ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/AccountManager.php#L166-L169
train
CommonApi/Fieldhandler
FieldhandlerUsageTrait.php
FieldhandlerUsageTrait.editFieldhandlerMethod
protected function editFieldhandlerMethod() { if (in_array($this->method, array('validate', 'sanitize', 'format'))) { return $this; } throw new InvalidArgumentException( get_class($this) . ' passed in invalid Fieldhandler method ' . $this->method . ' in FieldhandlerUsageTrait::editFieldhandlerMethod.' ); }
php
protected function editFieldhandlerMethod() { if (in_array($this->method, array('validate', 'sanitize', 'format'))) { return $this; } throw new InvalidArgumentException( get_class($this) . ' passed in invalid Fieldhandler method ' . $this->method . ' in FieldhandlerUsageTrait::editFieldhandlerMethod.' ); }
[ "protected", "function", "editFieldhandlerMethod", "(", ")", "{", "if", "(", "in_array", "(", "$", "this", "->", "method", ",", "array", "(", "'validate'", ",", "'sanitize'", ",", "'format'", ")", ")", ")", "{", "return", "$", "this", ";", "}", "throw", "new", "InvalidArgumentException", "(", "get_class", "(", "$", "this", ")", ".", "' passed in invalid Fieldhandler method '", ".", "$", "this", "->", "method", ".", "' in FieldhandlerUsageTrait::editFieldhandlerMethod.'", ")", ";", "}" ]
Edit Method for Fieldhandler Method @return $this @since 1.0.0 @throws \CommonApi\Exception\InvalidArgumentException
[ "Edit", "Method", "for", "Fieldhandler", "Method" ]
38584132ab55cdf45ffa6a10fa7c78fa6f78984b
https://github.com/CommonApi/Fieldhandler/blob/38584132ab55cdf45ffa6a10fa7c78fa6f78984b/FieldhandlerUsageTrait.php#L117-L129
train
CommonApi/Fieldhandler
FieldhandlerUsageTrait.php
FieldhandlerUsageTrait.editFieldhandlerAttribute
protected function editFieldhandlerAttribute($attribute) { $field_name = 'field_' . $attribute; $this->$field_name = null; if (isset($this->field[$attribute])) { $this->$field_name = $this->field[$attribute]; return $this; } if ($attribute === 'value') { $this->$field_name = null; return $this; } throw new InvalidArgumentException( 'No field ' . $attribute . ' passed into ' . get_class($this) . ' FieldhandlerUsageTrait::editFieldhandlerAttribute ' ); }
php
protected function editFieldhandlerAttribute($attribute) { $field_name = 'field_' . $attribute; $this->$field_name = null; if (isset($this->field[$attribute])) { $this->$field_name = $this->field[$attribute]; return $this; } if ($attribute === 'value') { $this->$field_name = null; return $this; } throw new InvalidArgumentException( 'No field ' . $attribute . ' passed into ' . get_class($this) . ' FieldhandlerUsageTrait::editFieldhandlerAttribute ' ); }
[ "protected", "function", "editFieldhandlerAttribute", "(", "$", "attribute", ")", "{", "$", "field_name", "=", "'field_'", ".", "$", "attribute", ";", "$", "this", "->", "$", "field_name", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "field", "[", "$", "attribute", "]", ")", ")", "{", "$", "this", "->", "$", "field_name", "=", "$", "this", "->", "field", "[", "$", "attribute", "]", ";", "return", "$", "this", ";", "}", "if", "(", "$", "attribute", "===", "'value'", ")", "{", "$", "this", "->", "$", "field_name", "=", "null", ";", "return", "$", "this", ";", "}", "throw", "new", "InvalidArgumentException", "(", "'No field '", ".", "$", "attribute", ".", "' passed into '", ".", "get_class", "(", "$", "this", ")", ".", "' FieldhandlerUsageTrait::editFieldhandlerAttribute '", ")", ";", "}" ]
Edit Fieldhandler Attribute @param string $attribute @return $this @since 1.0.0 @throws \CommonApi\Exception\InvalidArgumentException
[ "Edit", "Fieldhandler", "Attribute" ]
38584132ab55cdf45ffa6a10fa7c78fa6f78984b
https://github.com/CommonApi/Fieldhandler/blob/38584132ab55cdf45ffa6a10fa7c78fa6f78984b/FieldhandlerUsageTrait.php#L140-L162
train
CommonApi/Fieldhandler
FieldhandlerUsageTrait.php
FieldhandlerUsageTrait.executeConstraint
protected function executeConstraint(array $options = array()) { try { $method = $this->method; return $this->fieldhandler->$method( $this->field_name, $this->field_value, ucfirst(strtolower($this->field_type)), $options ); } catch (Exception $e) { throw new RuntimeException ( 'FieldhandlerUsageTrait: executeConstraint method ' . ' used within class ' . get_class($this) . ' caught this exception: ' . $e->getMessage() ); } }
php
protected function executeConstraint(array $options = array()) { try { $method = $this->method; return $this->fieldhandler->$method( $this->field_name, $this->field_value, ucfirst(strtolower($this->field_type)), $options ); } catch (Exception $e) { throw new RuntimeException ( 'FieldhandlerUsageTrait: executeConstraint method ' . ' used within class ' . get_class($this) . ' caught this exception: ' . $e->getMessage() ); } }
[ "protected", "function", "executeConstraint", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "try", "{", "$", "method", "=", "$", "this", "->", "method", ";", "return", "$", "this", "->", "fieldhandler", "->", "$", "method", "(", "$", "this", "->", "field_name", ",", "$", "this", "->", "field_value", ",", "ucfirst", "(", "strtolower", "(", "$", "this", "->", "field_type", ")", ")", ",", "$", "options", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "RuntimeException", "(", "'FieldhandlerUsageTrait: executeConstraint method '", ".", "' used within class '", ".", "get_class", "(", "$", "this", ")", ".", "' caught this exception: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Execute Fieldhandler Method @param array $options @return $this @since 1.0.0 @throws \CommonApi\Exception\RuntimeException
[ "Execute", "Fieldhandler", "Method" ]
38584132ab55cdf45ffa6a10fa7c78fa6f78984b
https://github.com/CommonApi/Fieldhandler/blob/38584132ab55cdf45ffa6a10fa7c78fa6f78984b/FieldhandlerUsageTrait.php#L173-L195
train
t3v/t3v_core
Classes/Domain/Repository/AbstractRepository.php
AbstractRepository.initializeObject
public function initializeObject() { $querySettings = $this->objectManager->get(Typo3QuerySettings::class); $querySettings->setIgnoreEnableFields(false); $querySettings->setRespectStoragePage(false); $this->setDefaultQuerySettings($querySettings); }
php
public function initializeObject() { $querySettings = $this->objectManager->get(Typo3QuerySettings::class); $querySettings->setIgnoreEnableFields(false); $querySettings->setRespectStoragePage(false); $this->setDefaultQuerySettings($querySettings); }
[ "public", "function", "initializeObject", "(", ")", "{", "$", "querySettings", "=", "$", "this", "->", "objectManager", "->", "get", "(", "Typo3QuerySettings", "::", "class", ")", ";", "$", "querySettings", "->", "setIgnoreEnableFields", "(", "false", ")", ";", "$", "querySettings", "->", "setRespectStoragePage", "(", "false", ")", ";", "$", "this", "->", "setDefaultQuerySettings", "(", "$", "querySettings", ")", ";", "}" ]
The life cycle method.
[ "The", "life", "cycle", "method", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Domain/Repository/AbstractRepository.php#L40-L46
train
t3v/t3v_core
Classes/Domain/Repository/AbstractRepository.php
AbstractRepository.findByUid
public function findByUid($uid, array $querySettings = ['respectSysLanguage' => false]) { if ($uid && $uid > 0) { // Create a new query. $query = $this->createquery(); // Apply the passed query settings. $query = $this->applyQuerySettings($query, $querySettings); // Set the query constraints. $query->matching($query->equals('uid', $uid)); // Execute the query and get the first object. $result = $query->execute()->getFirst(); return $result; } return null; }
php
public function findByUid($uid, array $querySettings = ['respectSysLanguage' => false]) { if ($uid && $uid > 0) { // Create a new query. $query = $this->createquery(); // Apply the passed query settings. $query = $this->applyQuerySettings($query, $querySettings); // Set the query constraints. $query->matching($query->equals('uid', $uid)); // Execute the query and get the first object. $result = $query->execute()->getFirst(); return $result; } return null; }
[ "public", "function", "findByUid", "(", "$", "uid", ",", "array", "$", "querySettings", "=", "[", "'respectSysLanguage'", "=>", "false", "]", ")", "{", "if", "(", "$", "uid", "&&", "$", "uid", ">", "0", ")", "{", "// Create a new query.", "$", "query", "=", "$", "this", "->", "createquery", "(", ")", ";", "// Apply the passed query settings.", "$", "query", "=", "$", "this", "->", "applyQuerySettings", "(", "$", "query", ",", "$", "querySettings", ")", ";", "// Set the query constraints.", "$", "query", "->", "matching", "(", "$", "query", "->", "equals", "(", "'uid'", ",", "$", "uid", ")", ")", ";", "// Execute the query and get the first object.", "$", "result", "=", "$", "query", "->", "execute", "(", ")", "->", "getFirst", "(", ")", ";", "return", "$", "result", ";", "}", "return", "null", ";", "}" ]
Finds objects by UID, overrides the default one. @param int $uid The UID @param array $querySettings The optional query settings to apply @return object|null The found object or null if no object was found
[ "Finds", "objects", "by", "UID", "overrides", "the", "default", "one", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Domain/Repository/AbstractRepository.php#L55-L73
train
t3v/t3v_core
Classes/Domain/Repository/AbstractRepository.php
AbstractRepository.findByUids
public function findByUids($uids, array $querySettings = ['respectSysLanguage' => false]) { if (is_string($uids)) { $uids = GeneralUtility::intExplode(',', $uids, true); } if (!empty($uids)) { // Create a new query. $query = $this->createquery(); // Apply the passed query settings. $query = $this->applyQuerySettings($query, $querySettings); // Set the query constraints. $query->matching($query->in('uid', $uids)); // Execute the query. $result = $query->execute(); return $result; } return null; }
php
public function findByUids($uids, array $querySettings = ['respectSysLanguage' => false]) { if (is_string($uids)) { $uids = GeneralUtility::intExplode(',', $uids, true); } if (!empty($uids)) { // Create a new query. $query = $this->createquery(); // Apply the passed query settings. $query = $this->applyQuerySettings($query, $querySettings); // Set the query constraints. $query->matching($query->in('uid', $uids)); // Execute the query. $result = $query->execute(); return $result; } return null; }
[ "public", "function", "findByUids", "(", "$", "uids", ",", "array", "$", "querySettings", "=", "[", "'respectSysLanguage'", "=>", "false", "]", ")", "{", "if", "(", "is_string", "(", "$", "uids", ")", ")", "{", "$", "uids", "=", "GeneralUtility", "::", "intExplode", "(", "','", ",", "$", "uids", ",", "true", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "uids", ")", ")", "{", "// Create a new query.", "$", "query", "=", "$", "this", "->", "createquery", "(", ")", ";", "// Apply the passed query settings.", "$", "query", "=", "$", "this", "->", "applyQuerySettings", "(", "$", "query", ",", "$", "querySettings", ")", ";", "// Set the query constraints.", "$", "query", "->", "matching", "(", "$", "query", "->", "in", "(", "'uid'", ",", "$", "uids", ")", ")", ";", "// Execute the query.", "$", "result", "=", "$", "query", "->", "execute", "(", ")", ";", "return", "$", "result", ";", "}", "return", "null", ";", "}" ]
Finds objects by multiple UIDs. @param array|string $uids The UIDs as array or as string, seperated by `,` @param array $querySettings The optional query settings to apply @return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult|null The found objects or null if no objects were found
[ "Finds", "objects", "by", "multiple", "UIDs", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Domain/Repository/AbstractRepository.php#L82-L104
train