id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
33,200 | alterphp/components | src/AlterPHP/Component/Behavior/StatusableEntity.php | StatusableEntity.getStatusBetween | public static function getStatusBetween($from = null, $to = null, $strict = false, $strictTo = null)
{
$statusList = static::getStatusList();
$strictFrom = $strict;
$strictTo = isset($strictTo) ? (bool) $strictTo : $strict;
// Remove status before given $from
if (isset($fro... | php | public static function getStatusBetween($from = null, $to = null, $strict = false, $strictTo = null)
{
$statusList = static::getStatusList();
$strictFrom = $strict;
$strictTo = isset($strictTo) ? (bool) $strictTo : $strict;
// Remove status before given $from
if (isset($fro... | [
"public",
"static",
"function",
"getStatusBetween",
"(",
"$",
"from",
"=",
"null",
",",
"$",
"to",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"strictTo",
"=",
"null",
")",
"{",
"$",
"statusList",
"=",
"static",
"::",
"getStatusList",
"(",... | Returns list of status between a "from" and a "to" status.
@param string $from
@param string $to
@param bool $strict Is lower bound strict (or both bounds if $strictTo is null) ?
@param bool $strictTo Is higher bound strict ?
@return array | [
"Returns",
"list",
"of",
"status",
"between",
"a",
"from",
"and",
"a",
"to",
"status",
"."
] | a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5 | https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L97-L139 |
33,201 | alterphp/components | src/AlterPHP/Component/Behavior/StatusableEntity.php | StatusableEntity.isGreaterThan | public static function isGreaterThan($status1, $status2, $strict = true)
{
static::checkAllowedStatus($status1);
static::checkAllowedStatus($status2);
$entityStatusIdx = array_search($status1, static::getStatusList());
$comparedStatusIdx = array_search($status2, static::getStatusLis... | php | public static function isGreaterThan($status1, $status2, $strict = true)
{
static::checkAllowedStatus($status1);
static::checkAllowedStatus($status2);
$entityStatusIdx = array_search($status1, static::getStatusList());
$comparedStatusIdx = array_search($status2, static::getStatusLis... | [
"public",
"static",
"function",
"isGreaterThan",
"(",
"$",
"status1",
",",
"$",
"status2",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"static",
"::",
"checkAllowedStatus",
"(",
"$",
"status1",
")",
";",
"static",
"::",
"checkAllowedStatus",
"(",
"$",
"stat... | Compare first status to second passed status.
@param string $status1
@param string $status2
@param bool $strict
@return bool | [
"Compare",
"first",
"status",
"to",
"second",
"passed",
"status",
"."
] | a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5 | https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L166-L179 |
33,202 | alterphp/components | src/AlterPHP/Component/Behavior/StatusableEntity.php | StatusableEntity.getStatusLabel | public function getStatusLabel()
{
$statusList = array_flip($this->getStatusList(true));
return isset($statusList[$this->status]) ? $statusList[$this->status] : $this->status;
} | php | public function getStatusLabel()
{
$statusList = array_flip($this->getStatusList(true));
return isset($statusList[$this->status]) ? $statusList[$this->status] : $this->status;
} | [
"public",
"function",
"getStatusLabel",
"(",
")",
"{",
"$",
"statusList",
"=",
"array_flip",
"(",
"$",
"this",
"->",
"getStatusList",
"(",
"true",
")",
")",
";",
"return",
"isset",
"(",
"$",
"statusList",
"[",
"$",
"this",
"->",
"status",
"]",
")",
"?"... | Get statusLabel.
@return string | [
"Get",
"statusLabel",
"."
] | a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5 | https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L262-L267 |
33,203 | alterphp/components | src/AlterPHP/Component/Mailer/Mailer.php | Mailer.forceFlushForCommand | public function forceFlushForCommand()
{
// L'envoi des emails est déclenché sur une réponse du Kernel (inactif en mode commande)
$transport = $this->swift->getTransport();
if (!$transport instanceof \Swift_Transport_SpoolTransport) {
return;
}
$spool = $transport... | php | public function forceFlushForCommand()
{
// L'envoi des emails est déclenché sur une réponse du Kernel (inactif en mode commande)
$transport = $this->swift->getTransport();
if (!$transport instanceof \Swift_Transport_SpoolTransport) {
return;
}
$spool = $transport... | [
"public",
"function",
"forceFlushForCommand",
"(",
")",
"{",
"// L'envoi des emails est déclenché sur une réponse du Kernel (inactif en mode commande)",
"$",
"transport",
"=",
"$",
"this",
"->",
"swift",
"->",
"getTransport",
"(",
")",
";",
"if",
"(",
"!",
"$",
"transpo... | Force l'envoi des mails en mode Command
@return integer Number of emails sent | [
"Force",
"l",
"envoi",
"des",
"mails",
"en",
"mode",
"Command"
] | a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5 | https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Mailer/Mailer.php#L144-L157 |
33,204 | alterphp/components | src/AlterPHP/Component/ToolBox/PolylineEncoder.php | PolylineEncoder.dpEncode | public function dpEncode() {
if(count($this->points) > 2) {
$stack[] = array(0, count($this->points)-1);
while(count($stack) > 0) {
$current = array_pop($stack);
$maxDist = 0;
$absMaxDist = 0;
... | php | public function dpEncode() {
if(count($this->points) > 2) {
$stack[] = array(0, count($this->points)-1);
while(count($stack) > 0) {
$current = array_pop($stack);
$maxDist = 0;
$absMaxDist = 0;
... | [
"public",
"function",
"dpEncode",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"points",
")",
">",
"2",
")",
"{",
"$",
"stack",
"[",
"]",
"=",
"array",
"(",
"0",
",",
"count",
"(",
"$",
"this",
"->",
"points",
")",
"-",
"1",
")"... | It also returns the zoomFactor and numLevels | [
"It",
"also",
"returns",
"the",
"zoomFactor",
"and",
"numLevels"
] | a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5 | https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/ToolBox/PolylineEncoder.php#L102-L142 |
33,205 | box-project/box2-lib | src/lib/Herrera/Box/Box.php | Box.addFromString | public function addFromString($local, $contents)
{
$this->phar->addFromString(
$local,
$this->replaceValues($this->compactContents($local, $contents))
);
} | php | public function addFromString($local, $contents)
{
$this->phar->addFromString(
$local,
$this->replaceValues($this->compactContents($local, $contents))
);
} | [
"public",
"function",
"addFromString",
"(",
"$",
"local",
",",
"$",
"contents",
")",
"{",
"$",
"this",
"->",
"phar",
"->",
"addFromString",
"(",
"$",
"local",
",",
"$",
"this",
"->",
"replaceValues",
"(",
"$",
"this",
"->",
"compactContents",
"(",
"$",
... | Adds the contents from a file to the Phar, after compacting it and
replacing its placeholders.
@param string $local The local name.
@param string $contents The contents. | [
"Adds",
"the",
"contents",
"from",
"a",
"file",
"to",
"the",
"Phar",
"after",
"compacting",
"it",
"and",
"replacing",
"its",
"placeholders",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L115-L121 |
33,206 | box-project/box2-lib | src/lib/Herrera/Box/Box.php | Box.compactContents | public function compactContents($file, $contents)
{
foreach ($this->compactors as $compactor) {
/** @var $compactor CompactorInterface */
if ($compactor->supports($file)) {
$contents = $compactor->compact($contents);
}
}
return $contents;
... | php | public function compactContents($file, $contents)
{
foreach ($this->compactors as $compactor) {
/** @var $compactor CompactorInterface */
if ($compactor->supports($file)) {
$contents = $compactor->compact($contents);
}
}
return $contents;
... | [
"public",
"function",
"compactContents",
"(",
"$",
"file",
",",
"$",
"contents",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"compactors",
"as",
"$",
"compactor",
")",
"{",
"/** @var $compactor CompactorInterface */",
"if",
"(",
"$",
"compactor",
"->",
"suppo... | Compacts the file contents using the supported compactors.
@param string $file The file name.
@param string $contents The file contents.
@return string The compacted contents. | [
"Compacts",
"the",
"file",
"contents",
"using",
"the",
"supported",
"compactors",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L222-L232 |
33,207 | box-project/box2-lib | src/lib/Herrera/Box/Box.php | Box.create | public static function create($file, $flags = null, $alias = null)
{
return new Box(new Phar($file, $flags, $alias), $file);
} | php | public static function create($file, $flags = null, $alias = null)
{
return new Box(new Phar($file, $flags, $alias), $file);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"file",
",",
"$",
"flags",
"=",
"null",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"return",
"new",
"Box",
"(",
"new",
"Phar",
"(",
"$",
"file",
",",
"$",
"flags",
",",
"$",
"alias",
")",
",",
... | Creates a new Phar and Box instance.
@param string $file The file name.
@param integer $flags The RecursiveDirectoryIterator flags.
@param string $alias The Phar alias.
@return Box The Box instance. | [
"Creates",
"a",
"new",
"Phar",
"and",
"Box",
"instance",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L243-L246 |
33,208 | box-project/box2-lib | src/lib/Herrera/Box/Box.php | Box.replaceValues | public function replaceValues($contents)
{
return str_replace(
array_keys($this->values),
array_values($this->values),
$contents
);
} | php | public function replaceValues($contents)
{
return str_replace(
array_keys($this->values),
array_values($this->values),
$contents
);
} | [
"public",
"function",
"replaceValues",
"(",
"$",
"contents",
")",
"{",
"return",
"str_replace",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"values",
")",
",",
"array_values",
"(",
"$",
"this",
"->",
"values",
")",
",",
"$",
"contents",
")",
";",
"}"
] | Replaces the placeholders with their values.
@param string $contents The contents.
@return string The replaced contents. | [
"Replaces",
"the",
"placeholders",
"with",
"their",
"values",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L279-L286 |
33,209 | box-project/box2-lib | src/lib/Herrera/Box/Box.php | Box.setStubUsingFile | public function setStubUsingFile($file, $replace = false)
{
if (false === is_file($file)) {
throw FileException::create(
'The file "%s" does not exist or is not a file.',
$file
);
}
if (false === ($contents = @file_get_contents($file))... | php | public function setStubUsingFile($file, $replace = false)
{
if (false === is_file($file)) {
throw FileException::create(
'The file "%s" does not exist or is not a file.',
$file
);
}
if (false === ($contents = @file_get_contents($file))... | [
"public",
"function",
"setStubUsingFile",
"(",
"$",
"file",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"if",
"(",
"false",
"===",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"FileException",
"::",
"create",
"(",
"'The file \"%s\" does not exist or... | Sets the bootstrap loader stub using a file.
@param string $file The file path.
@param boolean $replace Replace placeholders?
@throws Exception\Exception
@throws FileException If the stub file could not be used. | [
"Sets",
"the",
"bootstrap",
"loader",
"stub",
"using",
"a",
"file",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L297-L315 |
33,210 | box-project/box2-lib | src/lib/Herrera/Box/Box.php | Box.setValues | public function setValues(array $values)
{
foreach ($values as $value) {
if (false === is_scalar($value)) {
throw InvalidArgumentException::create(
'Non-scalar values (such as %s) are not supported.',
gettype($value)
);
... | php | public function setValues(array $values)
{
foreach ($values as $value) {
if (false === is_scalar($value)) {
throw InvalidArgumentException::create(
'Non-scalar values (such as %s) are not supported.',
gettype($value)
);
... | [
"public",
"function",
"setValues",
"(",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"false",
"===",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"InvalidArgumentException",
"::",
... | Sets the placeholder values.
@param array $values The values.
@throws Exception\Exception
@throws InvalidArgumentException If a non-scalar value is used. | [
"Sets",
"the",
"placeholder",
"values",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L325-L337 |
33,211 | box-project/box2-lib | src/lib/Herrera/Box/Box.php | Box.sign | public function sign($key, $password = null)
{
OpenSslException::reset();
if (false === extension_loaded('openssl')) {
// @codeCoverageIgnoreStart
throw OpenSslException::create(
'The "openssl" extension is not available.'
);
// @codeC... | php | public function sign($key, $password = null)
{
OpenSslException::reset();
if (false === extension_loaded('openssl')) {
// @codeCoverageIgnoreStart
throw OpenSslException::create(
'The "openssl" extension is not available.'
);
// @codeC... | [
"public",
"function",
"sign",
"(",
"$",
"key",
",",
"$",
"password",
"=",
"null",
")",
"{",
"OpenSslException",
"::",
"reset",
"(",
")",
";",
"if",
"(",
"false",
"===",
"extension_loaded",
"(",
"'openssl'",
")",
")",
"{",
"// @codeCoverageIgnoreStart",
"th... | Signs the Phar using a private key.
@param string $key The private key.
@param string $password The private key password.
@throws Exception\Exception
@throws OpenSslException If the "openssl" extension could not be used
or has generated an error. | [
"Signs",
"the",
"Phar",
"using",
"a",
"private",
"key",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L349-L384 |
33,212 | box-project/box2-lib | src/lib/Herrera/Box/Box.php | Box.signUsingFile | public function signUsingFile($file, $password = null)
{
if (false === is_file($file)) {
throw FileException::create(
'The file "%s" does not exist or is not a file.',
$file
);
}
if (false === ($key = @file_get_contents($file))) {
... | php | public function signUsingFile($file, $password = null)
{
if (false === is_file($file)) {
throw FileException::create(
'The file "%s" does not exist or is not a file.',
$file
);
}
if (false === ($key = @file_get_contents($file))) {
... | [
"public",
"function",
"signUsingFile",
"(",
"$",
"file",
",",
"$",
"password",
"=",
"null",
")",
"{",
"if",
"(",
"false",
"===",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"FileException",
"::",
"create",
"(",
"'The file \"%s\" does not exist or is... | Signs the Phar using a private key file.
@param string $file The private key file name.
@param string $password The private key password.
@throws Exception\Exception
@throws FileException If the private key file could not be read. | [
"Signs",
"the",
"Phar",
"using",
"a",
"private",
"key",
"file",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Box.php#L395-L409 |
33,213 | box-project/box2-lib | src/lib/Herrera/Box/Signature.php | Signature.get | public function get($required = null)
{
if (null === $required) {
$required = (bool) ini_get('phar.require_hash');
}
$this->seek(-4, SEEK_END);
if ('GBMB' !== $this->read(4)) {
if ($required) {
throw new PharException(
spr... | php | public function get($required = null)
{
if (null === $required) {
$required = (bool) ini_get('phar.require_hash');
}
$this->seek(-4, SEEK_END);
if ('GBMB' !== $this->read(4)) {
if ($required) {
throw new PharException(
spr... | [
"public",
"function",
"get",
"(",
"$",
"required",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"required",
")",
"{",
"$",
"required",
"=",
"(",
"bool",
")",
"ini_get",
"(",
"'phar.require_hash'",
")",
";",
"}",
"$",
"this",
"->",
"seek",
... | Returns the signature for the phar.
The value returned is identical to that of `Phar->getSignature()`. If
$required is not given, it will default to the `phar.require_hash`
current value.
@param boolean $required Is the signature required?
@return array The signature.
@throws PharException If the phar is not valid. | [
"Returns",
"the",
"signature",
"for",
"the",
"phar",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Signature.php#L138-L202 |
33,214 | box-project/box2-lib | src/lib/Herrera/Box/Signature.php | Signature.verify | public function verify()
{
$signature = $this->get();
$size = $this->size;
$type = null;
foreach (self::$types as $type) {
if ($type['name'] === $signature['hash_type']) {
if (0x10 === $type['flag']) {
$this->seek(-12, SEEK_END);
... | php | public function verify()
{
$signature = $this->get();
$size = $this->size;
$type = null;
foreach (self::$types as $type) {
if ($type['name'] === $signature['hash_type']) {
if (0x10 === $type['flag']) {
$this->seek(-12, SEEK_END);
... | [
"public",
"function",
"verify",
"(",
")",
"{",
"$",
"signature",
"=",
"$",
"this",
"->",
"get",
"(",
")",
";",
"$",
"size",
"=",
"$",
"this",
"->",
"size",
";",
"$",
"type",
"=",
"null",
";",
"foreach",
"(",
"self",
"::",
"$",
"types",
"as",
"$... | Verifies the signature of the phar.
@return boolean TRUE if verified, FALSE if not.
@throws Exception
@throws FileException If the private key could not be read.
@throws OpenSslException If there is an OpenSSL error. | [
"Verifies",
"the",
"signature",
"of",
"the",
"phar",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Signature.php#L213-L258 |
33,215 | box-project/box2-lib | src/lib/Herrera/Box/Signature.php | Signature.handle | private function handle()
{
if (!$this->handle) {
if (!($this->handle = @fopen($this->file, 'rb'))) {
throw FileException::lastError();
}
}
return $this->handle;
} | php | private function handle()
{
if (!$this->handle) {
if (!($this->handle = @fopen($this->file, 'rb'))) {
throw FileException::lastError();
}
}
return $this->handle;
} | [
"private",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"handle",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"handle",
"=",
"@",
"fopen",
"(",
"$",
"this",
"->",
"file",
",",
"'rb'",
")",
")",
")",
"{",
"thro... | Returns the file handle.
If the file handle is not opened, it will be automatically opened.
@return resource The file handle.
@throws Exception
@throws FileException If the file could not be opened. | [
"Returns",
"the",
"file",
"handle",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Signature.php#L282-L291 |
33,216 | box-project/box2-lib | src/lib/Herrera/Box/Signature.php | Signature.read | private function read($bytes)
{
if (false === ($read = @fread($this->handle(), $bytes))) {
throw FileException::lastError();
}
if (($actual = strlen($read)) !== $bytes) {
throw FileException::create(
'Only read %d of %d bytes from "%s".',
... | php | private function read($bytes)
{
if (false === ($read = @fread($this->handle(), $bytes))) {
throw FileException::lastError();
}
if (($actual = strlen($read)) !== $bytes) {
throw FileException::create(
'Only read %d of %d bytes from "%s".',
... | [
"private",
"function",
"read",
"(",
"$",
"bytes",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"read",
"=",
"@",
"fread",
"(",
"$",
"this",
"->",
"handle",
"(",
")",
",",
"$",
"bytes",
")",
")",
")",
"{",
"throw",
"FileException",
"::",
"lastEr... | Reads a number of bytes from the file.
@param integer $bytes The number of bytes.
@return string The read bytes.
@throws Exception
@throws FileException If the file could not be read. | [
"Reads",
"a",
"number",
"of",
"bytes",
"from",
"the",
"file",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Signature.php#L303-L319 |
33,217 | box-project/box2-lib | src/lib/Herrera/Box/Compactor/Php.php | Php.setTokenizer | public function setTokenizer(Tokenizer $tokenizer)
{
if (null === $this->converter) {
$this->converter = new ToString();
}
$this->tokenizer = $tokenizer;
} | php | public function setTokenizer(Tokenizer $tokenizer)
{
if (null === $this->converter) {
$this->converter = new ToString();
}
$this->tokenizer = $tokenizer;
} | [
"public",
"function",
"setTokenizer",
"(",
"Tokenizer",
"$",
"tokenizer",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"converter",
")",
"{",
"$",
"this",
"->",
"converter",
"=",
"new",
"ToString",
"(",
")",
";",
"}",
"$",
"this",
"->",
"to... | Sets the annotations tokenizer.
@param Tokenizer $tokenizer The tokenizer. | [
"Sets",
"the",
"annotations",
"tokenizer",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Compactor/Php.php#L76-L83 |
33,218 | box-project/box2-lib | src/lib/Herrera/Box/Compactor/Php.php | Php.compactAnnotations | private function compactAnnotations($docblock)
{
$annotations = array();
$index = -1;
$inside = 0;
$tokens = $this->tokenizer->parse($docblock);
if (empty($tokens)) {
return str_repeat("\n", substr_count($docblock, "\n"));
}
foreach ($tokens as $... | php | private function compactAnnotations($docblock)
{
$annotations = array();
$index = -1;
$inside = 0;
$tokens = $this->tokenizer->parse($docblock);
if (empty($tokens)) {
return str_repeat("\n", substr_count($docblock, "\n"));
}
foreach ($tokens as $... | [
"private",
"function",
"compactAnnotations",
"(",
"$",
"docblock",
")",
"{",
"$",
"annotations",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"-",
"1",
";",
"$",
"inside",
"=",
"0",
";",
"$",
"tokens",
"=",
"$",
"this",
"->",
"tokenizer",
"->",
... | Compacts the docblock and its annotations.
@param string $docblock The docblock.
@return string The compacted docblock. | [
"Compacts",
"the",
"docblock",
"and",
"its",
"annotations",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Compactor/Php.php#L92-L137 |
33,219 | box-project/box2-lib | src/lib/Herrera/Box/Extract.php | Extract.findStubLength | public static function findStubLength(
$file,
$pattern = self::PATTERN_OPEN
) {
if (!($fp = fopen($file, 'rb'))) {
throw new RuntimeException(
sprintf(
'The phar "%s" could not be opened for reading.',
$file
... | php | public static function findStubLength(
$file,
$pattern = self::PATTERN_OPEN
) {
if (!($fp = fopen($file, 'rb'))) {
throw new RuntimeException(
sprintf(
'The phar "%s" could not be opened for reading.',
$file
... | [
"public",
"static",
"function",
"findStubLength",
"(",
"$",
"file",
",",
"$",
"pattern",
"=",
"self",
"::",
"PATTERN_OPEN",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"file",
",",
"'rb'",
")",
")",
")",
"{",
"throw",
"new",
... | Finds the phar's stub length using the end pattern.
A "pattern" is a sequence of characters that indicate the end of a
stub, and the beginning of a manifest. This determines the complete
size of a stub, and is used as an offset to begin parsing the data
contained in the phar's manifest.
The stub generated included wi... | [
"Finds",
"the",
"phar",
"s",
"stub",
"length",
"using",
"the",
"end",
"pattern",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L145-L188 |
33,220 | box-project/box2-lib | src/lib/Herrera/Box/Extract.php | Extract.go | public function go($dir = null)
{
// set up the output directory
if (null === $dir) {
$dir = rtrim(sys_get_temp_dir(), '\\/')
. DIRECTORY_SEPARATOR
. 'pharextract'
. DIRECTORY_SEPARATOR
. basename($this->file, '.phar');
... | php | public function go($dir = null)
{
// set up the output directory
if (null === $dir) {
$dir = rtrim(sys_get_temp_dir(), '\\/')
. DIRECTORY_SEPARATOR
. 'pharextract'
. DIRECTORY_SEPARATOR
. basename($this->file, '.phar');
... | [
"public",
"function",
"go",
"(",
"$",
"dir",
"=",
"null",
")",
"{",
"// set up the output directory",
"if",
"(",
"null",
"===",
"$",
"dir",
")",
"{",
"$",
"dir",
"=",
"rtrim",
"(",
"sys_get_temp_dir",
"(",
")",
",",
"'\\\\/'",
")",
".",
"DIRECTORY_SEPARA... | Extracts the phar to the directory path.
If no directory path is given, a temporary one will be generated and
returned. If a directory path is given, the returned directory path
will be the same.
@param string $dir The directory to extract to.
@return string The directory extracted to.
@throws LengthException
@thro... | [
"Extracts",
"the",
"phar",
"to",
"the",
"directory",
"path",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L204-L285 |
33,221 | box-project/box2-lib | src/lib/Herrera/Box/Extract.php | Extract.purge | public static function purge($path)
{
if (is_dir($path)) {
foreach (scandir($path) as $item) {
if (('.' === $item) || ('..' === $item)) {
continue;
}
self::purge($path . DIRECTORY_SEPARATOR . $item);
}
... | php | public static function purge($path)
{
if (is_dir($path)) {
foreach (scandir($path) as $item) {
if (('.' === $item) || ('..' === $item)) {
continue;
}
self::purge($path . DIRECTORY_SEPARATOR . $item);
}
... | [
"public",
"static",
"function",
"purge",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"foreach",
"(",
"scandir",
"(",
"$",
"path",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"(",
"'.'",
"===",
"$",
"item",... | Recursively deletes the directory or file path.
@param string $path The path to delete.
@throws RuntimeException If the path could not be deleted. | [
"Recursively",
"deletes",
"the",
"directory",
"or",
"file",
"path",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L294-L323 |
33,222 | box-project/box2-lib | src/lib/Herrera/Box/Extract.php | Extract.extractFile | private function extractFile($info)
{
if (0 === $info['size']) {
return '';
}
$data = $this->read($info['compressed_size']);
if ($info['flags'] & self::GZ) {
if (false === ($data = gzinflate($data))) {
throw new RuntimeException(
... | php | private function extractFile($info)
{
if (0 === $info['size']) {
return '';
}
$data = $this->read($info['compressed_size']);
if ($info['flags'] & self::GZ) {
if (false === ($data = gzinflate($data))) {
throw new RuntimeException(
... | [
"private",
"function",
"extractFile",
"(",
"$",
"info",
")",
"{",
"if",
"(",
"0",
"===",
"$",
"info",
"[",
"'size'",
"]",
")",
"{",
"return",
"''",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"info",
"[",
"'compressed_size'",
... | Extracts a single file from the phar.
@param array $info The file information.
@return string The file data.
@throws RuntimeException If the file could not be extracted.
@throws UnexpectedValueException If the crc32 checksum does not
match the expected value. | [
"Extracts",
"a",
"single",
"file",
"from",
"the",
"phar",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L388-L445 |
33,223 | box-project/box2-lib | src/lib/Herrera/Box/Extract.php | Extract.open | private function open()
{
if (null === ($this->handle = fopen($this->file, 'rb'))) {
$this->handle = null;
throw new RuntimeException(
sprintf(
'The file "%s" could not be opened for reading.',
$this->file
)
... | php | private function open()
{
if (null === ($this->handle = fopen($this->file, 'rb'))) {
$this->handle = null;
throw new RuntimeException(
sprintf(
'The file "%s" could not be opened for reading.',
$this->file
)
... | [
"private",
"function",
"open",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"(",
"$",
"this",
"->",
"handle",
"=",
"fopen",
"(",
"$",
"this",
"->",
"file",
",",
"'rb'",
")",
")",
")",
"{",
"$",
"this",
"->",
"handle",
"=",
"null",
";",
"throw",
"ne... | Opens the file for reading.
@throws RuntimeException If the file could not be opened. | [
"Opens",
"the",
"file",
"for",
"reading",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L452-L464 |
33,224 | box-project/box2-lib | src/lib/Herrera/Box/Extract.php | Extract.read | private function read($bytes)
{
$read = '';
$total = $bytes;
while (!feof($this->handle) && $bytes) {
if (false === ($chunk = fread($this->handle, $bytes))) {
throw new RuntimeException(
sprintf(
'Could not read %d byte... | php | private function read($bytes)
{
$read = '';
$total = $bytes;
while (!feof($this->handle) && $bytes) {
if (false === ($chunk = fread($this->handle, $bytes))) {
throw new RuntimeException(
sprintf(
'Could not read %d byte... | [
"private",
"function",
"read",
"(",
"$",
"bytes",
")",
"{",
"$",
"read",
"=",
"''",
";",
"$",
"total",
"=",
"$",
"bytes",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"this",
"->",
"handle",
")",
"&&",
"$",
"bytes",
")",
"{",
"if",
"(",
"false",
... | Reads the number of bytes from the file.
@param integer $bytes The number of bytes.
@return string The binary string read.
@throws RuntimeException If the read fails. | [
"Reads",
"the",
"number",
"of",
"bytes",
"from",
"the",
"file",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L475-L507 |
33,225 | box-project/box2-lib | src/lib/Herrera/Box/Extract.php | Extract.readManifest | private function readManifest()
{
$size = unpack('V', $this->read(4));
$size = $size[1];
$raw = $this->read($size);
// ++ start skip: API version, global flags, alias, and metadata
$count = unpack('V', substr($raw, 0, 4));
$count = $count[1];
$aliasSize = u... | php | private function readManifest()
{
$size = unpack('V', $this->read(4));
$size = $size[1];
$raw = $this->read($size);
// ++ start skip: API version, global flags, alias, and metadata
$count = unpack('V', substr($raw, 0, 4));
$count = $count[1];
$aliasSize = u... | [
"private",
"function",
"readManifest",
"(",
")",
"{",
"$",
"size",
"=",
"unpack",
"(",
"'V'",
",",
"$",
"this",
"->",
"read",
"(",
"4",
")",
")",
";",
"$",
"size",
"=",
"$",
"size",
"[",
"1",
"]",
";",
"$",
"raw",
"=",
"$",
"this",
"->",
"rea... | Reads and unpacks the manifest data from the phar.
@return array The manifest. | [
"Reads",
"and",
"unpacks",
"the",
"manifest",
"data",
"from",
"the",
"phar",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/Extract.php#L514-L567 |
33,226 | box-project/box2-lib | src/lib/Herrera/Box/StubGenerator.php | StubGenerator.extract | public function extract($extract, $force = false)
{
$this->extract = $extract;
$this->extractForce = $force;
if ($extract) {
$this->extractCode = array(
'constants' => array(),
'class' => array(),
);
$compactor = new Php()... | php | public function extract($extract, $force = false)
{
$this->extract = $extract;
$this->extractForce = $force;
if ($extract) {
$this->extractCode = array(
'constants' => array(),
'class' => array(),
);
$compactor = new Php()... | [
"public",
"function",
"extract",
"(",
"$",
"extract",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"extract",
"=",
"$",
"extract",
";",
"$",
"this",
"->",
"extractForce",
"=",
"$",
"force",
";",
"if",
"(",
"$",
"extract",
")",
"{",... | Embed the Extract class in the stub?
@param boolean $extract Embed the class?
@param boolean $force Force the use of the class?
@return StubGenerator The stub generator. | [
"Embed",
"the",
"Extract",
"class",
"in",
"the",
"stub?"
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/StubGenerator.php#L166-L198 |
33,227 | box-project/box2-lib | src/lib/Herrera/Box/StubGenerator.php | StubGenerator.mung | public function mung(array $list)
{
foreach ($list as $value) {
if (false === in_array($value, self::$allowedMung)) {
throw InvalidArgumentException::create(
'The $_SERVER variable "%s" is not allowed.',
$value
);
... | php | public function mung(array $list)
{
foreach ($list as $value) {
if (false === in_array($value, self::$allowedMung)) {
throw InvalidArgumentException::create(
'The $_SERVER variable "%s" is not allowed.',
$value
);
... | [
"public",
"function",
"mung",
"(",
"array",
"$",
"list",
")",
"{",
"foreach",
"(",
"$",
"list",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"false",
"===",
"in_array",
"(",
"$",
"value",
",",
"self",
"::",
"$",
"allowedMung",
")",
")",
"{",
"throw",
... | Sets the list of server variables to modify.
@param array $list The list.
@return StubGenerator The stub generator.
@throws Exception\Exception
@throws InvalidArgumentException If the list contains an invalid value. | [
"Sets",
"the",
"list",
"of",
"server",
"variables",
"to",
"modify",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/StubGenerator.php#L308-L322 |
33,228 | box-project/box2-lib | src/lib/Herrera/Box/StubGenerator.php | StubGenerator.getAlias | private function getAlias()
{
$stub = '';
$prefix = '';
if ($this->extractForce) {
$prefix = '$dir/';
}
if ($this->web) {
$stub .= 'Phar::webPhar(' . $this->arg($this->alias);
if ($this->index) {
$stub .= ', ' . $this->ar... | php | private function getAlias()
{
$stub = '';
$prefix = '';
if ($this->extractForce) {
$prefix = '$dir/';
}
if ($this->web) {
$stub .= 'Phar::webPhar(' . $this->arg($this->alias);
if ($this->index) {
$stub .= ', ' . $this->ar... | [
"private",
"function",
"getAlias",
"(",
")",
"{",
"$",
"stub",
"=",
"''",
";",
"$",
"prefix",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"extractForce",
")",
"{",
"$",
"prefix",
"=",
"'$dir/'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"web",
... | Returns the alias map.
@return string The alias map. | [
"Returns",
"the",
"alias",
"map",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/StubGenerator.php#L398-L435 |
33,229 | box-project/box2-lib | src/lib/Herrera/Box/StubGenerator.php | StubGenerator.getPharSections | private function getPharSections()
{
$stub = array(
'if (class_exists(\'Phar\')) {',
$this->getAlias(),
);
if ($this->intercept) {
$stub[] = "Phar::interceptFileFuncs();";
}
if ($this->mung) {
$stub[] = 'Phar::mungServer(' . v... | php | private function getPharSections()
{
$stub = array(
'if (class_exists(\'Phar\')) {',
$this->getAlias(),
);
if ($this->intercept) {
$stub[] = "Phar::interceptFileFuncs();";
}
if ($this->mung) {
$stub[] = 'Phar::mungServer(' . v... | [
"private",
"function",
"getPharSections",
"(",
")",
"{",
"$",
"stub",
"=",
"array",
"(",
"'if (class_exists(\\'Phar\\')) {'",
",",
"$",
"this",
"->",
"getAlias",
"(",
")",
",",
")",
";",
"if",
"(",
"$",
"this",
"->",
"intercept",
")",
"{",
"$",
"stub",
... | Returns the sections of the stub that use the Phar class.
@return array The stub sections. | [
"Returns",
"the",
"sections",
"of",
"the",
"stub",
"that",
"use",
"the",
"Phar",
"class",
"."
] | 1c5d528d0c44af9d084c2e68ed8b5863db9abe0c | https://github.com/box-project/box2-lib/blob/1c5d528d0c44af9d084c2e68ed8b5863db9abe0c/src/lib/Herrera/Box/StubGenerator.php#L475-L497 |
33,230 | desarrolla2/Cache | src/Packer/PackingTrait.php | PackingTrait.getPacker | protected function getPacker(): PackerInterface
{
if (!isset($this->packer)) {
$this->packer = static::createDefaultPacker();
}
return $this->packer;
} | php | protected function getPacker(): PackerInterface
{
if (!isset($this->packer)) {
$this->packer = static::createDefaultPacker();
}
return $this->packer;
} | [
"protected",
"function",
"getPacker",
"(",
")",
":",
"PackerInterface",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"packer",
")",
")",
"{",
"$",
"this",
"->",
"packer",
"=",
"static",
"::",
"createDefaultPacker",
"(",
")",
";",
"}",
"return"... | Get the packer
@return PackerInterface | [
"Get",
"the",
"packer"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Packer/PackingTrait.php#L55-L62 |
33,231 | desarrolla2/Cache | src/Option/FilenameTrait.php | FilenameTrait.setFilenameOption | protected function setFilenameOption($filename): void
{
if (is_string($filename)) {
$filename = new BasicFilename($filename);
}
if (!is_callable($filename)) {
throw new TypeError("Filename should be a string or callable");
}
$this->filename = $filena... | php | protected function setFilenameOption($filename): void
{
if (is_string($filename)) {
$filename = new BasicFilename($filename);
}
if (!is_callable($filename)) {
throw new TypeError("Filename should be a string or callable");
}
$this->filename = $filena... | [
"protected",
"function",
"setFilenameOption",
"(",
"$",
"filename",
")",
":",
"void",
"{",
"if",
"(",
"is_string",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"filename",
"=",
"new",
"BasicFilename",
"(",
"$",
"filename",
")",
";",
"}",
"if",
"(",
"!",
... | Filename format or callable.
The filename format will be applied using sprintf, replacing `%s` with the key.
@param string|callable $filename
@return void | [
"Filename",
"format",
"or",
"callable",
".",
"The",
"filename",
"format",
"will",
"be",
"applied",
"using",
"sprintf",
"replacing",
"%s",
"with",
"the",
"key",
"."
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Option/FilenameTrait.php#L39-L50 |
33,232 | desarrolla2/Cache | src/Option/FilenameTrait.php | FilenameTrait.getFilenameOption | protected function getFilenameOption(): callable
{
if (!isset($this->filename)) {
$this->filename = new BasicFilename('%s.' . $this->getPacker()->getType());
}
return $this->filename;
} | php | protected function getFilenameOption(): callable
{
if (!isset($this->filename)) {
$this->filename = new BasicFilename('%s.' . $this->getPacker()->getType());
}
return $this->filename;
} | [
"protected",
"function",
"getFilenameOption",
"(",
")",
":",
"callable",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"filename",
")",
")",
"{",
"$",
"this",
"->",
"filename",
"=",
"new",
"BasicFilename",
"(",
"'%s.'",
".",
"$",
"this",
"->",
... | Get the filename callable
@return callable | [
"Get",
"the",
"filename",
"callable"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Option/FilenameTrait.php#L57-L64 |
33,233 | desarrolla2/Cache | src/Option/FilenameTrait.php | FilenameTrait.getFilename | protected function getFilename($key): string
{
$id = $this->keyToId($key);
$generator = $this->getFilenameOption();
return $this->cacheDir . DIRECTORY_SEPARATOR . $generator($id);
} | php | protected function getFilename($key): string
{
$id = $this->keyToId($key);
$generator = $this->getFilenameOption();
return $this->cacheDir . DIRECTORY_SEPARATOR . $generator($id);
} | [
"protected",
"function",
"getFilename",
"(",
"$",
"key",
")",
":",
"string",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"keyToId",
"(",
"$",
"key",
")",
";",
"$",
"generator",
"=",
"$",
"this",
"->",
"getFilenameOption",
"(",
")",
";",
"return",
"$",
... | Create a filename based on the key
@param string|mixed $key
@return string | [
"Create",
"a",
"filename",
"based",
"on",
"the",
"key"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Option/FilenameTrait.php#L72-L78 |
33,234 | desarrolla2/Cache | src/File.php | File.getTtl | protected function getTtl(string $cacheFile)
{
switch ($this->ttlStrategy) {
case 'embed':
return (int)$this->readLine($cacheFile);
case 'file':
return file_exists("$cacheFile.ttl")
? (int)file_get_contents("$cacheFile.ttl")
... | php | protected function getTtl(string $cacheFile)
{
switch ($this->ttlStrategy) {
case 'embed':
return (int)$this->readLine($cacheFile);
case 'file':
return file_exists("$cacheFile.ttl")
? (int)file_get_contents("$cacheFile.ttl")
... | [
"protected",
"function",
"getTtl",
"(",
"string",
"$",
"cacheFile",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"ttlStrategy",
")",
"{",
"case",
"'embed'",
":",
"return",
"(",
"int",
")",
"$",
"this",
"->",
"readLine",
"(",
"$",
"cacheFile",
")",
";",
... | Get the TTL using one of the strategies
@param string $cacheFile
@return int | [
"Get",
"the",
"TTL",
"using",
"one",
"of",
"the",
"strategies"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/File.php#L76-L88 |
33,235 | desarrolla2/Cache | src/File.php | File.setTtl | protected function setTtl($expiration, $contents, $cacheFile)
{
switch ($this->ttlStrategy) {
case 'embed':
$contents = ($expiration ?? PHP_INT_MAX) . "\n" . $contents;
break;
case 'file':
if (isset($expiration)) {
f... | php | protected function setTtl($expiration, $contents, $cacheFile)
{
switch ($this->ttlStrategy) {
case 'embed':
$contents = ($expiration ?? PHP_INT_MAX) . "\n" . $contents;
break;
case 'file':
if (isset($expiration)) {
f... | [
"protected",
"function",
"setTtl",
"(",
"$",
"expiration",
",",
"$",
"contents",
",",
"$",
"cacheFile",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"ttlStrategy",
")",
"{",
"case",
"'embed'",
":",
"$",
"contents",
"=",
"(",
"$",
"expiration",
"??",
"PH... | Set the TTL using one of the strategies
@param int $expiration
@param string $contents
@param string $cacheFile
@return string The (modified) contents | [
"Set",
"the",
"TTL",
"using",
"one",
"of",
"the",
"strategies"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/File.php#L98-L115 |
33,236 | desarrolla2/Cache | src/AbstractFile.php | AbstractFile.readLine | protected function readLine(string $cacheFile): string
{
$fp = fopen($cacheFile, 'r');
$line = fgets($fp);
fclose($fp);
return $line;
} | php | protected function readLine(string $cacheFile): string
{
$fp = fopen($cacheFile, 'r');
$line = fgets($fp);
fclose($fp);
return $line;
} | [
"protected",
"function",
"readLine",
"(",
"string",
"$",
"cacheFile",
")",
":",
"string",
"{",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"cacheFile",
",",
"'r'",
")",
";",
"$",
"line",
"=",
"fgets",
"(",
"$",
"fp",
")",
";",
"fclose",
"(",
"$",
"fp",
")... | Read the first line of the cache file
@param string $cacheFile
@return string | [
"Read",
"the",
"first",
"line",
"of",
"the",
"cache",
"file"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractFile.php#L87-L94 |
33,237 | desarrolla2/Cache | src/AbstractFile.php | AbstractFile.writeFile | protected function writeFile(string $cacheFile, string $contents): bool
{
$dir = dirname($cacheFile);
if ($dir !== $this->cacheDir && !is_dir($dir)) {
mkdir($dir, 0775, true);
}
return (bool)file_put_contents($cacheFile, $contents);
} | php | protected function writeFile(string $cacheFile, string $contents): bool
{
$dir = dirname($cacheFile);
if ($dir !== $this->cacheDir && !is_dir($dir)) {
mkdir($dir, 0775, true);
}
return (bool)file_put_contents($cacheFile, $contents);
} | [
"protected",
"function",
"writeFile",
"(",
"string",
"$",
"cacheFile",
",",
"string",
"$",
"contents",
")",
":",
"bool",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"cacheFile",
")",
";",
"if",
"(",
"$",
"dir",
"!==",
"$",
"this",
"->",
"cacheDir",
"&... | Create a cache file
@param string $cacheFile
@param string $contents
@return bool | [
"Create",
"a",
"cache",
"file"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractFile.php#L103-L112 |
33,238 | desarrolla2/Cache | src/Memcached.php | Memcached.ttlToMemcachedTime | protected function ttlToMemcachedTime($ttl)
{
$seconds = $this->ttlToSeconds($ttl);
if ($seconds <= 0) {
return isset($seconds) ? false : 0;
}
/* 2592000 seconds = 30 days */
return $seconds <= 2592000 ? $seconds : $this->ttlToTimestamp($ttl);
} | php | protected function ttlToMemcachedTime($ttl)
{
$seconds = $this->ttlToSeconds($ttl);
if ($seconds <= 0) {
return isset($seconds) ? false : 0;
}
/* 2592000 seconds = 30 days */
return $seconds <= 2592000 ? $seconds : $this->ttlToTimestamp($ttl);
} | [
"protected",
"function",
"ttlToMemcachedTime",
"(",
"$",
"ttl",
")",
"{",
"$",
"seconds",
"=",
"$",
"this",
"->",
"ttlToSeconds",
"(",
"$",
"ttl",
")",
";",
"if",
"(",
"$",
"seconds",
"<=",
"0",
")",
"{",
"return",
"isset",
"(",
"$",
"seconds",
")",
... | Convert ttl to timestamp or seconds.
@see http://php.net/manual/en/memcached.expiration.php
@param null|int|DateInterval $ttl
@return int|null
@throws InvalidArgumentException | [
"Convert",
"ttl",
"to",
"timestamp",
"or",
"seconds",
"."
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Memcached.php#L207-L217 |
33,239 | desarrolla2/Cache | src/PhpFile.php | PhpFile.createScript | public function createScript($value, ?int $ttl): string
{
$macro = var_export($value, true);
if (strpos($macro, 'stdClass::__set_state') !== false) {
$macro = preg_replace_callback("/('([^'\\\\]++|''\\.)')|stdClass::__set_state/", $macro, function($match) {
return empty(... | php | public function createScript($value, ?int $ttl): string
{
$macro = var_export($value, true);
if (strpos($macro, 'stdClass::__set_state') !== false) {
$macro = preg_replace_callback("/('([^'\\\\]++|''\\.)')|stdClass::__set_state/", $macro, function($match) {
return empty(... | [
"public",
"function",
"createScript",
"(",
"$",
"value",
",",
"?",
"int",
"$",
"ttl",
")",
":",
"string",
"{",
"$",
"macro",
"=",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"macro",
",",
"'stdClass::__set_s... | Create a PHP script returning the cached value
@param mixed $value
@param int|null $ttl
@return string | [
"Create",
"a",
"PHP",
"script",
"returning",
"the",
"cached",
"value"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/PhpFile.php#L60-L73 |
33,240 | desarrolla2/Cache | src/AbstractCache.php | AbstractCache.assertKey | protected function assertKey($key): void
{
if (!is_string($key)) {
$type = (is_object($key) ? get_class($key) . ' ' : '') . gettype($key);
throw new InvalidArgumentException("Expected key to be a string, not $type");
}
if ($key === '' || preg_match('~[{}()/\\\\@:]~',... | php | protected function assertKey($key): void
{
if (!is_string($key)) {
$type = (is_object($key) ? get_class($key) . ' ' : '') . gettype($key);
throw new InvalidArgumentException("Expected key to be a string, not $type");
}
if ($key === '' || preg_match('~[{}()/\\\\@:]~',... | [
"protected",
"function",
"assertKey",
"(",
"$",
"key",
")",
":",
"void",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"type",
"=",
"(",
"is_object",
"(",
"$",
"key",
")",
"?",
"get_class",
"(",
"$",
"key",
")",
".",
"'... | Validate the key
@param string $key
@return void
@throws InvalidArgumentException | [
"Validate",
"the",
"key"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractCache.php#L99-L109 |
33,241 | desarrolla2/Cache | src/AbstractCache.php | AbstractCache.assertIterable | protected function assertIterable($subject, $msg): void
{
$iterable = function_exists('is_iterable')
? is_iterable($subject)
: is_array($subject) || $subject instanceof Traversable;
if (!$iterable) {
throw new InvalidArgumentException($msg);
}
... | php | protected function assertIterable($subject, $msg): void
{
$iterable = function_exists('is_iterable')
? is_iterable($subject)
: is_array($subject) || $subject instanceof Traversable;
if (!$iterable) {
throw new InvalidArgumentException($msg);
}
... | [
"protected",
"function",
"assertIterable",
"(",
"$",
"subject",
",",
"$",
"msg",
")",
":",
"void",
"{",
"$",
"iterable",
"=",
"function_exists",
"(",
"'is_iterable'",
")",
"?",
"is_iterable",
"(",
"$",
"subject",
")",
":",
"is_array",
"(",
"$",
"subject",
... | Assert that the keys are an array or traversable
@param iterable $subject
@param string $msg
@return void
@throws InvalidArgumentException if subject are not iterable | [
"Assert",
"that",
"the",
"keys",
"are",
"an",
"array",
"or",
"traversable"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractCache.php#L119-L128 |
33,242 | desarrolla2/Cache | src/AbstractCache.php | AbstractCache.keyToId | protected function keyToId($key): string
{
$this->assertKey($key);
return sprintf('%s%s', $this->prefix, $key);
} | php | protected function keyToId($key): string
{
$this->assertKey($key);
return sprintf('%s%s', $this->prefix, $key);
} | [
"protected",
"function",
"keyToId",
"(",
"$",
"key",
")",
":",
"string",
"{",
"$",
"this",
"->",
"assertKey",
"(",
"$",
"key",
")",
";",
"return",
"sprintf",
"(",
"'%s%s'",
",",
"$",
"this",
"->",
"prefix",
",",
"$",
"key",
")",
";",
"}"
] | Turn the key into a cache identifier
@param string $key
@return string
@throws InvalidArgumentException | [
"Turn",
"the",
"key",
"into",
"a",
"cache",
"identifier"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractCache.php#L137-L142 |
33,243 | desarrolla2/Cache | src/AbstractCache.php | AbstractCache.mapKeysToIds | protected function mapKeysToIds($keys): array
{
$this->assertIterable($keys, 'keys not iterable');
$map = [];
foreach ($keys as $key) {
$id = $this->keyToId($key);
$map[$id] = $key;
}
return $map;
} | php | protected function mapKeysToIds($keys): array
{
$this->assertIterable($keys, 'keys not iterable');
$map = [];
foreach ($keys as $key) {
$id = $this->keyToId($key);
$map[$id] = $key;
}
return $map;
} | [
"protected",
"function",
"mapKeysToIds",
"(",
"$",
"keys",
")",
":",
"array",
"{",
"$",
"this",
"->",
"assertIterable",
"(",
"$",
"keys",
",",
"'keys not iterable'",
")",
";",
"$",
"map",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"k... | Create a map with keys and ids
@param iterable $keys
@return array
@throws InvalidArgumentException | [
"Create",
"a",
"map",
"with",
"keys",
"and",
"ids"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractCache.php#L151-L163 |
33,244 | desarrolla2/Cache | src/AbstractCache.php | AbstractCache.ttlToSeconds | protected function ttlToSeconds($ttl): ?int
{
if (!isset($ttl)) {
return $this->ttl;
}
if ($ttl instanceof DateInterval) {
$reference = new DateTimeImmutable();
$endTime = $reference->add($ttl);
$ttl = $endTime->getTimestamp() - $reference->g... | php | protected function ttlToSeconds($ttl): ?int
{
if (!isset($ttl)) {
return $this->ttl;
}
if ($ttl instanceof DateInterval) {
$reference = new DateTimeImmutable();
$endTime = $reference->add($ttl);
$ttl = $endTime->getTimestamp() - $reference->g... | [
"protected",
"function",
"ttlToSeconds",
"(",
"$",
"ttl",
")",
":",
"?",
"int",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"ttl",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ttl",
";",
"}",
"if",
"(",
"$",
"ttl",
"instanceof",
"DateInterval",
")",
... | Convert TTL to seconds from now
@param null|int|DateInterval $ttl
@return int|null
@throws InvalidArgumentException | [
"Convert",
"TTL",
"to",
"seconds",
"from",
"now"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractCache.php#L252-L271 |
33,245 | desarrolla2/Cache | src/AbstractCache.php | AbstractCache.ttlToTimestamp | protected function ttlToTimestamp($ttl): ?int
{
if (!isset($ttl)) {
return isset($this->ttl) ? time() + $this->ttl : null;
}
if (is_int($ttl)) {
return time() + (isset($this->ttl) ? min($ttl, $this->ttl) : $ttl);
}
if ($ttl instanceof DateInterval) {... | php | protected function ttlToTimestamp($ttl): ?int
{
if (!isset($ttl)) {
return isset($this->ttl) ? time() + $this->ttl : null;
}
if (is_int($ttl)) {
return time() + (isset($this->ttl) ? min($ttl, $this->ttl) : $ttl);
}
if ($ttl instanceof DateInterval) {... | [
"protected",
"function",
"ttlToTimestamp",
"(",
"$",
"ttl",
")",
":",
"?",
"int",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"ttl",
")",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"ttl",
")",
"?",
"time",
"(",
")",
"+",
"$",
"this",
"->"... | Convert TTL to epoch timestamp
@param null|int|DateInterval $ttl
@return int|null
@throws InvalidArgumentException | [
"Convert",
"TTL",
"to",
"epoch",
"timestamp"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/AbstractCache.php#L280-L298 |
33,246 | desarrolla2/Cache | src/Mysqli.php | Mysqli.initialize | protected function initialize()
{
if ($this->initialized !== false) {
return;
}
$this->query(
"CREATE TABLE IF NOT EXISTS `{table}` "
. "( `key` VARCHAR(255), `value` TEXT, `ttl` INT UNSIGNED, PRIMARY KEY (`key`) )"
);
$this->query(
... | php | protected function initialize()
{
if ($this->initialized !== false) {
return;
}
$this->query(
"CREATE TABLE IF NOT EXISTS `{table}` "
. "( `key` VARCHAR(255), `value` TEXT, `ttl` INT UNSIGNED, PRIMARY KEY (`key`) )"
);
$this->query(
... | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
"!==",
"false",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"query",
"(",
"\"CREATE TABLE IF NOT EXISTS `{table}` \"",
".",
"\"( `key` VARCHAR(255), `value` TEX... | Initialize table.
Automatically delete old cache. | [
"Initialize",
"table",
".",
"Automatically",
"delete",
"old",
"cache",
"."
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Mysqli.php#L60-L78 |
33,247 | desarrolla2/Cache | src/Mysqli.php | Mysqli.query | protected function query($query, ...$params)
{
$saveParams = array_map([$this, 'quote'], $params);
$baseSql = str_replace('{table}', $this->table, $query);
$sql = vsprintf($baseSql, $saveParams);
$ret = $this->server->query($sql);
if ($ret === false) {
trigger_... | php | protected function query($query, ...$params)
{
$saveParams = array_map([$this, 'quote'], $params);
$baseSql = str_replace('{table}', $this->table, $query);
$sql = vsprintf($baseSql, $saveParams);
$ret = $this->server->query($sql);
if ($ret === false) {
trigger_... | [
"protected",
"function",
"query",
"(",
"$",
"query",
",",
"...",
"$",
"params",
")",
"{",
"$",
"saveParams",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'quote'",
"]",
",",
"$",
"params",
")",
";",
"$",
"baseSql",
"=",
"str_replace",
"(",
"'{table... | Query the MySQL server
@param string $query
@param mixed[] $params
@return \mysqli_result|false | [
"Query",
"the",
"MySQL",
"server"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Mysqli.php#L266-L280 |
33,248 | desarrolla2/Cache | src/Mysqli.php | Mysqli.quote | protected function quote($value)
{
if ($value === null) {
return 'NULL';
}
if (is_array($value)) {
return join(', ', array_map([$this, 'quote'], $value));
}
return is_string($value)
? ('"' . $this->server->real_escape_string($value) . '"'... | php | protected function quote($value)
{
if ($value === null) {
return 'NULL';
}
if (is_array($value)) {
return join(', ', array_map([$this, 'quote'], $value));
}
return is_string($value)
? ('"' . $this->server->real_escape_string($value) . '"'... | [
"protected",
"function",
"quote",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"'NULL'",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"join",
"(",
"', '",
",",
"array_map",... | Quote a value to be used in an array
@param mixed $value
@return mixed | [
"Quote",
"a",
"value",
"to",
"be",
"used",
"in",
"an",
"array"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Mysqli.php#L288-L301 |
33,249 | desarrolla2/Cache | src/Predis.php | Predis.execCommand | protected function execCommand(string $cmd, ...$args)
{
$command = $this->predis->createCommand($cmd, $args);
$response = $this->predis->executeCommand($command);
if ($response instanceof ErrorInterface) {
return false;
}
if ($response instanceof Status) {
... | php | protected function execCommand(string $cmd, ...$args)
{
$command = $this->predis->createCommand($cmd, $args);
$response = $this->predis->executeCommand($command);
if ($response instanceof ErrorInterface) {
return false;
}
if ($response instanceof Status) {
... | [
"protected",
"function",
"execCommand",
"(",
"string",
"$",
"cmd",
",",
"...",
"$",
"args",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"predis",
"->",
"createCommand",
"(",
"$",
"cmd",
",",
"$",
"args",
")",
";",
"$",
"response",
"=",
"$",
"... | Run a predis command.
@param string $cmd
@param mixed
@return mixed|bool | [
"Run",
"a",
"predis",
"command",
"."
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/Predis.php#L70-L84 |
33,250 | desarrolla2/Cache | src/MongoDB.php | MongoDB.filter | protected function filter($key)
{
if (is_array($key)) {
$key = ['$in' => $key];
}
return [
'_id' => $key,
'$or' => [
['ttl' => ['$gt' => new BSONUTCDateTime($this->currentTimestamp() * 1000)]],
['ttl' => null]
]... | php | protected function filter($key)
{
if (is_array($key)) {
$key = ['$in' => $key];
}
return [
'_id' => $key,
'$or' => [
['ttl' => ['$gt' => new BSONUTCDateTime($this->currentTimestamp() * 1000)]],
['ttl' => null]
]... | [
"protected",
"function",
"filter",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"$",
"key",
"=",
"[",
"'$in'",
"=>",
"$",
"key",
"]",
";",
"}",
"return",
"[",
"'_id'",
"=>",
"$",
"key",
",",
"'$or'",
"=>",
... | Get filter for key and ttl.
@param string|iterable $key
@return array | [
"Get",
"filter",
"for",
"key",
"and",
"ttl",
"."
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/MongoDB.php#L74-L87 |
33,251 | desarrolla2/Cache | src/MongoDB.php | MongoDB.getTtlBSON | protected function getTtlBSON($ttl): ?BSONUTCDatetime
{
return isset($ttl) ? new BSONUTCDateTime($this->ttlToTimestamp($ttl) * 1000) : null;
} | php | protected function getTtlBSON($ttl): ?BSONUTCDatetime
{
return isset($ttl) ? new BSONUTCDateTime($this->ttlToTimestamp($ttl) * 1000) : null;
} | [
"protected",
"function",
"getTtlBSON",
"(",
"$",
"ttl",
")",
":",
"?",
"BSONUTCDatetime",
"{",
"return",
"isset",
"(",
"$",
"ttl",
")",
"?",
"new",
"BSONUTCDateTime",
"(",
"$",
"this",
"->",
"ttlToTimestamp",
"(",
"$",
"ttl",
")",
"*",
"1000",
")",
":"... | Get TTL as Date type BSON object
@param null|int|DateInterval $ttl
@return BSONUTCDatetime|null | [
"Get",
"TTL",
"as",
"Date",
"type",
"BSON",
"object"
] | e25b51fe0f9b386161c9c35e1d591f587617fcfa | https://github.com/desarrolla2/Cache/blob/e25b51fe0f9b386161c9c35e1d591f587617fcfa/src/MongoDB.php#L269-L272 |
33,252 | fpoirotte/pssht | src/Transport.php | Transport.setAddress | public function setAddress($address)
{
if (!is_string($address)) {
throw new \InvalidArgumentException();
}
if ($this->address !== null) {
throw new \RuntimeException();
}
$this->address = $address;
return $this;
} | php | public function setAddress($address)
{
if (!is_string($address)) {
throw new \InvalidArgumentException();
}
if ($this->address !== null) {
throw new \RuntimeException();
}
$this->address = $address;
return $this;
} | [
"public",
"function",
"setAddress",
"(",
"$",
"address",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"address",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"address",
"!==",
... | Set the IP address of the client associated
with this transport layer.
\param string $address
IP address of the client.
\retval Transport
Returns this transport layer.
\note
This method is intended for use with
hostbased authentication methods.
Moreover, this method may only be called
once. Subsequent calls will res... | [
"Set",
"the",
"IP",
"address",
"of",
"the",
"client",
"associated",
"with",
"this",
"transport",
"layer",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Transport.php#L213-L225 |
33,253 | fpoirotte/pssht | src/Transport.php | Transport.updateWriteStats | public function updateWriteStats($written)
{
if (!is_int($written)) {
throw new \InvalidArgumentException('Not an integer');
}
$time = time();
$this->context['rekeyingBytes'] += $written;
if (isset($this->context['rekeying'])) {
// Do not restart key ... | php | public function updateWriteStats($written)
{
if (!is_int($written)) {
throw new \InvalidArgumentException('Not an integer');
}
$time = time();
$this->context['rekeyingBytes'] += $written;
if (isset($this->context['rekeying'])) {
// Do not restart key ... | [
"public",
"function",
"updateWriteStats",
"(",
"$",
"written",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"written",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Not an integer'",
")",
";",
"}",
"$",
"time",
"=",
"time",
"("... | Update statistics about the number of bytes
written to the client.
\param int $written
Number of additional bytes written.
\return
This method does not return anything. | [
"Update",
"statistics",
"about",
"the",
"number",
"of",
"bytes",
"written",
"to",
"the",
"client",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Transport.php#L251-L287 |
33,254 | fpoirotte/pssht | src/Transport.php | Transport.setCompressor | public function setCompressor(\fpoirotte\Pssht\CompressionInterface $compressor)
{
if ($compressor->getMode() !== \fpoirotte\Pssht\CompressionInterface::MODE_COMPRESS) {
throw new \InvalidArgumentException();
}
$this->compressor = $compressor;
return $this;
} | php | public function setCompressor(\fpoirotte\Pssht\CompressionInterface $compressor)
{
if ($compressor->getMode() !== \fpoirotte\Pssht\CompressionInterface::MODE_COMPRESS) {
throw new \InvalidArgumentException();
}
$this->compressor = $compressor;
return $this;
} | [
"public",
"function",
"setCompressor",
"(",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"CompressionInterface",
"$",
"compressor",
")",
"{",
"if",
"(",
"$",
"compressor",
"->",
"getMode",
"(",
")",
"!==",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"CompressionInterfa... | Set the object used to compress outgoing packets.
\param fpoirotte::Pssht::CompressionInterface $compressor
Outgoing packets' compressor.
\retval Transport
Return this transport layer. | [
"Set",
"the",
"object",
"used",
"to",
"compress",
"outgoing",
"packets",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Transport.php#L331-L339 |
33,255 | fpoirotte/pssht | src/Transport.php | Transport.setUncompressor | public function setUncompressor(\fpoirotte\Pssht\CompressionInterface $uncompressor)
{
if ($uncompressor->getMode() !== \fpoirotte\Pssht\CompressionInterface::MODE_UNCOMPRESS) {
throw new \InvalidArgumentException();
}
$this->uncompressor = $uncompressor;
return $this;
... | php | public function setUncompressor(\fpoirotte\Pssht\CompressionInterface $uncompressor)
{
if ($uncompressor->getMode() !== \fpoirotte\Pssht\CompressionInterface::MODE_UNCOMPRESS) {
throw new \InvalidArgumentException();
}
$this->uncompressor = $uncompressor;
return $this;
... | [
"public",
"function",
"setUncompressor",
"(",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"CompressionInterface",
"$",
"uncompressor",
")",
"{",
"if",
"(",
"$",
"uncompressor",
"->",
"getMode",
"(",
")",
"!==",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"CompressionI... | Set the object used to uncompress incoming packets.
\param fpoirotte::Pssht::CompressionInterface $uncompressor
Incoming packets' uncompressor.
\retval Transport
Return this transport layer. | [
"Set",
"the",
"object",
"used",
"to",
"uncompress",
"incoming",
"packets",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Transport.php#L361-L369 |
33,256 | fpoirotte/pssht | src/Transport.php | Transport.getHandler | public function getHandler($type)
{
if (!is_int($type) || $type < 0 || $type > 255) {
throw new \InvalidArgumentException();
}
if (isset($this->handlers[$type])) {
return $this->handlers[$type];
}
return null;
} | php | public function getHandler($type)
{
if (!is_int($type) || $type < 0 || $type > 255) {
throw new \InvalidArgumentException();
}
if (isset($this->handlers[$type])) {
return $this->handlers[$type];
}
return null;
} | [
"public",
"function",
"getHandler",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"type",
")",
"||",
"$",
"type",
"<",
"0",
"||",
"$",
"type",
">",
"255",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
... | Retrieve the current handler for a given message type.
\param int $type
Message type.
\retval fpoirotte::Pssht::HandlerInterface
Handler associated with the given message type.
\retval null
There is no handler currently registered
for the given message type. | [
"Retrieve",
"the",
"current",
"handler",
"for",
"a",
"given",
"message",
"type",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Transport.php#L547-L557 |
33,257 | fpoirotte/pssht | src/Transport.php | Transport.setHandler | public function setHandler($type, \fpoirotte\Pssht\HandlerInterface $handler)
{
if (!is_int($type) || $type < 0 || $type > 255) {
throw new \InvalidArgumentException();
}
$this->handlers[$type] = $handler;
return $this;
} | php | public function setHandler($type, \fpoirotte\Pssht\HandlerInterface $handler)
{
if (!is_int($type) || $type < 0 || $type > 255) {
throw new \InvalidArgumentException();
}
$this->handlers[$type] = $handler;
return $this;
} | [
"public",
"function",
"setHandler",
"(",
"$",
"type",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"HandlerInterface",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"type",
")",
"||",
"$",
"type",
"<",
"0",
"||",
"$",
"type",
">",
"... | Register a handler for a specific SSH message type.
\param int $type
Message type.
\param fpoirotte::Pssht::HandlerInterface $handler
Handler to register for that message type.
\retval Transport
Returns this transport layer.
\note
The given handler will overwrite any previously
registered handler for that message t... | [
"Register",
"a",
"handler",
"for",
"a",
"specific",
"SSH",
"message",
"type",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Transport.php#L575-L583 |
33,258 | fpoirotte/pssht | src/Transport.php | Transport.unsetHandler | public function unsetHandler($type, \fpoirotte\Pssht\HandlerInterface $handler)
{
if (!is_int($type) || $type < 0 || $type > 255) {
throw new \InvalidArgumentException();
}
if (isset($this->handlers[$type]) && $this->handlers[$type] === $handler) {
unset($this->handl... | php | public function unsetHandler($type, \fpoirotte\Pssht\HandlerInterface $handler)
{
if (!is_int($type) || $type < 0 || $type > 255) {
throw new \InvalidArgumentException();
}
if (isset($this->handlers[$type]) && $this->handlers[$type] === $handler) {
unset($this->handl... | [
"public",
"function",
"unsetHandler",
"(",
"$",
"type",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"HandlerInterface",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"type",
")",
"||",
"$",
"type",
"<",
"0",
"||",
"$",
"type",
">",
... | Unregister a handler for a specific SSH message type.
\param int $type
Message type.
\param fpoirotte::Pssht::HandlerInterface $handler
Handler to unregister for that message type.
\retval Transport
Returns this transport layer. | [
"Unregister",
"a",
"handler",
"for",
"a",
"specific",
"SSH",
"message",
"type",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Transport.php#L597-L607 |
33,259 | fpoirotte/pssht | src/Application/EchoService.php | EchoService.handle | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\CHANNEL\DATA::unserialize($decoder);
$channel = $message->getChannel();
$response ... | php | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\CHANNEL\DATA::unserialize($decoder);
$channel = $message->getChannel();
$response ... | [
"public",
"function",
"handle",
"(",
"$",
"msgType",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Decoder",
"$",
"decoder",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
")",... | SSH_MSG_CHANNEL_DATA = 94 | [
"SSH_MSG_CHANNEL_DATA",
"=",
"94"
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Application/EchoService.php#L24-L35 |
33,260 | fpoirotte/pssht | src/Handlers/DEBUG.php | DEBUG.handle | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\DEBUG::unserialize($decoder);
if ($message->mustAlwaysDisplay()) {
echo escape($messag... | php | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\DEBUG::unserialize($decoder);
if ($message->mustAlwaysDisplay()) {
echo escape($messag... | [
"public",
"function",
"handle",
"(",
"$",
"msgType",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Decoder",
"$",
"decoder",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
")",... | SSH_MSG_DEBUG = 4 | [
"SSH_MSG_DEBUG",
"=",
"4"
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Handlers/DEBUG.php#L20-L31 |
33,261 | fpoirotte/pssht | src/KeyStore.php | KeyStore.getIdentifier | protected function getIdentifier(\fpoirotte\Pssht\PublicKeyInterface $key)
{
$encoder = new \fpoirotte\Pssht\Wire\Encoder();
$key->serialize($encoder);
return $encoder->getBuffer()->get(0);
} | php | protected function getIdentifier(\fpoirotte\Pssht\PublicKeyInterface $key)
{
$encoder = new \fpoirotte\Pssht\Wire\Encoder();
$key->serialize($encoder);
return $encoder->getBuffer()->get(0);
} | [
"protected",
"function",
"getIdentifier",
"(",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"PublicKeyInterface",
"$",
"key",
")",
"{",
"$",
"encoder",
"=",
"new",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Encoder",
"(",
")",
";",
"$",
"key",
"->... | Return the identifier for a key.
\param fpoirotte::Pssht::PublicKeyInterface $key
Public or private key.
\retval string
SSH identifier for the key. | [
"Return",
"the",
"identifier",
"for",
"a",
"key",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/KeyStore.php#L39-L44 |
33,262 | fpoirotte/pssht | src/KeyStore.php | KeyStore.add | public function add($user, \fpoirotte\Pssht\PublicKeyInterface $key)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
$this->keys[$user][$this->getIdentifier($key)] = $key;
} | php | public function add($user, \fpoirotte\Pssht\PublicKeyInterface $key)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
$this->keys[$user][$this->getIdentifier($key)] = $key;
} | [
"public",
"function",
"add",
"(",
"$",
"user",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"PublicKeyInterface",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
... | Add a new key in the store.
\param string $user
User the key belongs to.
\param fpoirotte::Pssht::PublicKeyInterface $key
Public/private key to add. | [
"Add",
"a",
"new",
"key",
"in",
"the",
"store",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/KeyStore.php#L55-L62 |
33,263 | fpoirotte/pssht | src/KeyStore.php | KeyStore.get | public function get($user)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if (!isset($this->keys[$user])) {
return new \ArrayIterator();
}
return new \ArrayIterator($this->keys[$user]);
} | php | public function get($user)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if (!isset($this->keys[$user])) {
return new \ArrayIterator();
}
return new \ArrayIterator($this->keys[$user]);
} | [
"public",
"function",
"get",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"keys",
... | Retrieve a list of the keys currently
stored for the given user.
\param string $user
User whose keys should be retrieved.
\retval array
Public/private keys for the given user. | [
"Retrieve",
"a",
"list",
"of",
"the",
"keys",
"currently",
"stored",
"for",
"the",
"given",
"user",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/KeyStore.php#L92-L103 |
33,264 | fpoirotte/pssht | src/KeyStore.php | KeyStore.exists | public function exists($user, $key)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if ($key instanceof \fpoirotte\Pssht\PublicKeyInterface) {
$key = $this->getIdentifier($key);
}
if (!is_string($key)) {
throw new \Inva... | php | public function exists($user, $key)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if ($key instanceof \fpoirotte\Pssht\PublicKeyInterface) {
$key = $this->getIdentifier($key);
}
if (!is_string($key)) {
throw new \Inva... | [
"public",
"function",
"exists",
"(",
"$",
"user",
",",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"if",
"(",
"$",
"key",
"instanceof",
"\... | Test whether a given key as been registered
for a specific user.
\param string $user
User for which the key is tested.
\param string|fpoirotte::Pssht::PublicKeyInterface $key
Key to test.
\retval bool
\c true if the given key has been registered
for the given user, \c false otherwise. | [
"Test",
"whether",
"a",
"given",
"key",
"as",
"been",
"registered",
"for",
"a",
"specific",
"user",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/KeyStore.php#L119-L133 |
33,265 | fpoirotte/pssht | src/KeyStore.php | KeyStore.count | public function count($user)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if (!isset($this->keys[$user])) {
return 0;
}
return count($this->keys[$user]);
} | php | public function count($user)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if (!isset($this->keys[$user])) {
return 0;
}
return count($this->keys[$user]);
} | [
"public",
"function",
"count",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"keys",
... | Return the number of keys currently registered
for the given user.
\param string $user
User whose keys must be counted.
\retval int
Number of available keys for the given user. | [
"Return",
"the",
"number",
"of",
"keys",
"currently",
"registered",
"for",
"the",
"given",
"user",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/KeyStore.php#L145-L156 |
33,266 | fpoirotte/pssht | src/Handlers/CHANNEL/REQUEST.php | REQUEST.handle | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$encoder = new \fpoirotte\Pssht\Wire\Encoder();
$channel = $decoder->decodeUint32();
$type = $decoder->decodeString... | php | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$encoder = new \fpoirotte\Pssht\Wire\Encoder();
$channel = $decoder->decodeUint32();
$type = $decoder->decodeString... | [
"public",
"function",
"handle",
"(",
"$",
"msgType",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Decoder",
"$",
"decoder",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
")",... | SSH_MSG_CHANNEL_REQUEST = 98 | [
"SSH_MSG_CHANNEL_REQUEST",
"=",
"98"
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Handlers/CHANNEL/REQUEST.php#L20-L75 |
33,267 | fpoirotte/pssht | src/Handlers/KEXDH/INIT.php | INIT.handle | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$hostAlgo = null;
foreach ($context['kex']['client']->getServerHostKeyAlgos() as $algo) {
if (isset($context['serverKeys'... | php | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$hostAlgo = null;
foreach ($context['kex']['client']->getServerHostKeyAlgos() as $algo) {
if (isset($context['serverKeys'... | [
"public",
"function",
"handle",
"(",
"$",
"msgType",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Decoder",
"$",
"decoder",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
")",... | SSH_MSG_KEXDH_INIT = 30 | [
"SSH_MSG_KEXDH_INIT",
"=",
"30"
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Handlers/KEXDH/INIT.php#L20-L60 |
33,268 | fpoirotte/pssht | src/Handlers/USERAUTH/REQUEST.php | REQUEST.failure | protected function failure(
\fpoirotte\Pssht\Transport $transport,
array &$context,
$partial = false
) {
if (!is_bool($partial)) {
throw new \InvalidArgumentException();
}
$remaining = $context['authMethods'];
unset($remaining['none']);
$... | php | protected function failure(
\fpoirotte\Pssht\Transport $transport,
array &$context,
$partial = false
) {
if (!is_bool($partial)) {
throw new \InvalidArgumentException();
}
$remaining = $context['authMethods'];
unset($remaining['none']);
$... | [
"protected",
"function",
"failure",
"(",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
",",
"$",
"partial",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"partial",
")",
")",
... | Report an authentication failure.
\param fpoirotte::Pssht::Transport $transport
Transport layer used to report the failure.
\param array &$context
SSH session context (containing authentication methods
that may continue).
\param bool $partial
(optional) Indicates whether the request ended with
a partial success (\b ... | [
"Report",
"an",
"authentication",
"failure",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Handlers/USERAUTH/REQUEST.php#L165-L180 |
33,269 | fpoirotte/pssht | src/Handlers/SERVICE/REQUEST.php | REQUEST.handle | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\SERVICE\REQUEST::unserialize($decoder);
$service = $message->getServiceName();
if (... | php | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\SERVICE\REQUEST::unserialize($decoder);
$service = $message->getServiceName();
if (... | [
"public",
"function",
"handle",
"(",
"$",
"msgType",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Decoder",
"$",
"decoder",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
")",... | SSH_MSG_SERVICE_REQUEST = 5 | [
"SSH_MSG_SERVICE_REQUEST",
"=",
"5"
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Handlers/SERVICE/REQUEST.php#L36-L59 |
33,270 | fpoirotte/pssht | src/Connection.php | Connection.allocateChannel | public function allocateChannel(\fpoirotte\Pssht\Messages\CHANNEL\OPEN $message)
{
for ($i = 0; isset($this->channels[$i]); ++$i) {
// Do nothing.
}
$this->channels[$i] = $message->getChannel();
$this->handlers[$i] = array();
return $i;
} | php | public function allocateChannel(\fpoirotte\Pssht\Messages\CHANNEL\OPEN $message)
{
for ($i = 0; isset($this->channels[$i]); ++$i) {
// Do nothing.
}
$this->channels[$i] = $message->getChannel();
$this->handlers[$i] = array();
return $i;
} | [
"public",
"function",
"allocateChannel",
"(",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Messages",
"\\",
"CHANNEL",
"\\",
"OPEN",
"$",
"message",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"isset",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"i"... | Allocate a new communication channel.
\param fpoirotte::Pssht::Messages::CHANNEL::OPEN $message
Original message requesting channel allocation.
\return int
Newly allocated channel's identifier. | [
"Allocate",
"a",
"new",
"communication",
"channel",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Connection.php#L93-L101 |
33,271 | fpoirotte/pssht | src/Connection.php | Connection.freeChannel | public function freeChannel($id)
{
if (!is_int($id)) {
throw new \InvalidArgumentException();
}
unset($this->channels[$id]);
unset($this->handlers[$id]);
return $this;
} | php | public function freeChannel($id)
{
if (!is_int($id)) {
throw new \InvalidArgumentException();
}
unset($this->channels[$id]);
unset($this->handlers[$id]);
return $this;
} | [
"public",
"function",
"freeChannel",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"id... | Free a channel allocation.
\param int $id
Channel identifier.
\retval Connection
Returns this connection. | [
"Free",
"a",
"channel",
"allocation",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Connection.php#L112-L121 |
33,272 | fpoirotte/pssht | src/Connection.php | Connection.getChannel | public function getChannel($message)
{
if (is_int($message)) {
return $this->channels[$message];
}
return $this->channels[$message->getChannel()];
} | php | public function getChannel($message)
{
if (is_int($message)) {
return $this->channels[$message];
}
return $this->channels[$message->getChannel()];
} | [
"public",
"function",
"getChannel",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"channels",
"[",
"$",
"message",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"channels",
"[",
"... | Retrieve the channel associated with a message.
\param int|fpoirotte::Pssht::Messages::CHANNEL::REQUEST::Base $message
Either a message or the message's channel identifier.
\retval int
Remote channel associated with the message. | [
"Retrieve",
"the",
"channel",
"associated",
"with",
"a",
"message",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Connection.php#L132-L138 |
33,273 | fpoirotte/pssht | src/Connection.php | Connection.setHandler | public function setHandler(
$message,
$type,
\fpoirotte\Pssht\HandlerInterface $handler
) {
if (!is_int($type) || $type < 0 || $type > 255) {
throw new \InvalidArgumentException();
}
if (!is_int($message)) {
if (!($message instanceof \fpoirott... | php | public function setHandler(
$message,
$type,
\fpoirotte\Pssht\HandlerInterface $handler
) {
if (!is_int($type) || $type < 0 || $type > 255) {
throw new \InvalidArgumentException();
}
if (!is_int($message)) {
if (!($message instanceof \fpoirott... | [
"public",
"function",
"setHandler",
"(",
"$",
"message",
",",
"$",
"type",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"HandlerInterface",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"type",
")",
"||",
"$",
"type",
"<",
"0",
"||",
... | Register a handler.
\param int|fpoirotte::Pssht::Messages::CHANNEL::REQUEST::Base $message
Either a message or the message's channel identifier.
\param int $type
Message type.
\param fpoirotte::Pssht::HandlerInterface $handler
Handler to associate with the message. | [
"Register",
"a",
"handler",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Connection.php#L152-L170 |
33,274 | fpoirotte/pssht | src/Algorithms.php | Algorithms.getValidClass | protected function getValidClass($type, $name)
{
$logging = \Plop\Plop::getInstance();;
$w = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890\\';
if (!is_string($name) || strspn($name, $w) !== strlen($name)) {
$logging->debug(
'Skipping %(type)s al... | php | protected function getValidClass($type, $name)
{
$logging = \Plop\Plop::getInstance();;
$w = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890\\';
if (!is_string($name) || strspn($name, $w) !== strlen($name)) {
$logging->debug(
'Skipping %(type)s al... | [
"protected",
"function",
"getValidClass",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"$",
"logging",
"=",
"\\",
"Plop",
"\\",
"Plop",
"::",
"getInstance",
"(",
")",
";",
";",
"$",
"w",
"=",
"'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890\\\\... | Check for valid classnames.
\param string $type
Expected type of class (algorithm name).
\param string $name
Name of the class.
\retval string
Full classname (with namespace).
\retval null
No valid class found with this type and name. | [
"Check",
"for",
"valid",
"classnames",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Algorithms.php#L129-L181 |
33,275 | fpoirotte/pssht | src/Algorithms.php | Algorithms.getValidAlgorithm | protected function getValidAlgorithm($class)
{
$logging = \Plop\Plop::getInstance();;
$w = 'abcdefghijklmnopqrstuvwxyz' .
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
'1234567890-@.';
$name = $class::getName();
if (!is_string($name) || strspn($name, $w) !== strle... | php | protected function getValidAlgorithm($class)
{
$logging = \Plop\Plop::getInstance();;
$w = 'abcdefghijklmnopqrstuvwxyz' .
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
'1234567890-@.';
$name = $class::getName();
if (!is_string($name) || strspn($name, $w) !== strle... | [
"protected",
"function",
"getValidAlgorithm",
"(",
"$",
"class",
")",
"{",
"$",
"logging",
"=",
"\\",
"Plop",
"\\",
"Plop",
"::",
"getInstance",
"(",
")",
";",
";",
"$",
"w",
"=",
"'abcdefghijklmnopqrstuvwxyz'",
".",
"'ABCDEFGHIJKLMNOPQRSTUVWXYZ'",
".",
"'1234... | Check for valid algorithm names.
\param string $class
Name of the class whose algorithm name must be checked.
\retval string
The class' algorithm name.
\retval null
No valid algorithm name for the given class. | [
"Check",
"for",
"valid",
"algorithm",
"names",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Algorithms.php#L195-L210 |
33,276 | fpoirotte/pssht | src/Algorithms.php | Algorithms.register | public function register($type, $class)
{
if (is_object($class)) {
$class = get_class($class);
}
if (!is_string($class) || !class_exists($class)) {
throw new \InvalidArgumentException();
}
if (!is_string($type) || !isset($this->algos[$type])) {
... | php | public function register($type, $class)
{
if (is_object($class)) {
$class = get_class($class);
}
if (!is_string($class) || !class_exists($class)) {
throw new \InvalidArgumentException();
}
if (!is_string($type) || !isset($this->algos[$type])) {
... | [
"public",
"function",
"register",
"(",
"$",
"type",
",",
"$",
"class",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"class",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
... | Register a new algorithm.
\param string $type
Type of algorithm provided by the class.
\param string|object $class
Class or object that provides the algorithm.
\retval Algorithms
Returns the singleton.
\note
A class registered with this method will overwrite
any previously registered class with the same
algorithm n... | [
"Register",
"a",
"new",
"algorithm",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Algorithms.php#L229-L248 |
33,277 | fpoirotte/pssht | src/Algorithms.php | Algorithms.unregister | public function unregister($type, $name)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
if (!is_string($name)) {
throw new \InvalidArgumentException();
}
unset($this->algos[$type][$name]);
ret... | php | public function unregister($type, $name)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
if (!is_string($name)) {
throw new \InvalidArgumentException();
}
unset($this->algos[$type][$name]);
ret... | [
"public",
"function",
"unregister",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"algos",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"\\... | Unregister an algorithm.
\param string $type
Algorithm type.
\param string $name
Name of the algorithm to unregister.
\retval Algorithms
Returns the singleton. | [
"Unregister",
"an",
"algorithm",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Algorithms.php#L262-L272 |
33,278 | fpoirotte/pssht | src/Algorithms.php | Algorithms.restore | public function restore($type, $name)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
if (isset($this->savedAlgos[$type][$name])) {
$this->algos[$type][$name] = $this->savedAlgos[$type][$name];
}
retur... | php | public function restore($type, $name)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
if (isset($this->savedAlgos[$type][$name])) {
$this->algos[$type][$name] = $this->savedAlgos[$type][$name];
}
retur... | [
"public",
"function",
"restore",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"algos",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
... | Restore an algorithm.
Reset the class in charge of providing
a given algorithm to its initial value.
\param string $type
Algorithm type.
\param string $name
Name of the algorithm to restore.
\retval Algorithms
Returns the singleton. | [
"Restore",
"an",
"algorithm",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Algorithms.php#L289-L298 |
33,279 | fpoirotte/pssht | src/Algorithms.php | Algorithms.getAlgorithms | public function getAlgorithms($type)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
return array_keys($this->algos[$type]);
} | php | public function getAlgorithms($type)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
return array_keys($this->algos[$type]);
} | [
"public",
"function",
"getAlgorithms",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"algos",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgument... | Get a list of all registered algorithms
with the given type.
\param string $type
Type of algorithms to retrieve.
\retval array
A list with the names of all the algorithms
currently registered with the given type. | [
"Get",
"a",
"list",
"of",
"all",
"registered",
"algorithms",
"with",
"the",
"given",
"type",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Algorithms.php#L311-L317 |
33,280 | fpoirotte/pssht | src/Algorithms.php | Algorithms.getClasses | public function getClasses($type)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
return $this->algos[$type];
} | php | public function getClasses($type)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
return $this->algos[$type];
} | [
"public",
"function",
"getClasses",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"algos",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentExc... | Get a list of all registered classes
with the given type.
\param string $type
Type of algorithms to retrieve.
\retval array
A list with the names of the classes currently
registered providing algorithms of the given type. | [
"Get",
"a",
"list",
"of",
"all",
"registered",
"classes",
"with",
"the",
"given",
"type",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Algorithms.php#L330-L336 |
33,281 | fpoirotte/pssht | src/Algorithms.php | Algorithms.getClass | public function getClass($type, $name)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
if (!is_string($name)) {
throw new \InvalidArgumentException();
}
if (!isset($this->algos[$type][$name])) {
... | php | public function getClass($type, $name)
{
if (!is_string($type) || !isset($this->algos[$type])) {
throw new \InvalidArgumentException();
}
if (!is_string($name)) {
throw new \InvalidArgumentException();
}
if (!isset($this->algos[$type][$name])) {
... | [
"public",
"function",
"getClass",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"algos",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"\\",... | Get the class responsible for providing
the algorithm with the given type and name.
\param string $type
Type of algorithm to retrieve.
\param string $name
Name of the algorithm.
\retval string
Full name (with namespace) of the class
providing the given algorithm.
\retval null
No class provides an algorithm with the... | [
"Get",
"the",
"class",
"responsible",
"for",
"providing",
"the",
"algorithm",
"with",
"the",
"given",
"type",
"and",
"name",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Algorithms.php#L356-L368 |
33,282 | fpoirotte/pssht | src/Algorithms.php | Algorithms.sortAlgorithms | public static function sortAlgorithms($a, $b)
{
static $preferences = array(
// DH (KEX)
'curve25519-sha256@libssh.org',
'ecdh-sha2-nistp256',
'ecdh-sha2-nistp384',
'ecdh-sha2-nistp521',
'diffie-hellman-group-exchange-sha256',
... | php | public static function sortAlgorithms($a, $b)
{
static $preferences = array(
// DH (KEX)
'curve25519-sha256@libssh.org',
'ecdh-sha2-nistp256',
'ecdh-sha2-nistp384',
'ecdh-sha2-nistp521',
'diffie-hellman-group-exchange-sha256',
... | [
"public",
"static",
"function",
"sortAlgorithms",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"static",
"$",
"preferences",
"=",
"array",
"(",
"// DH (KEX)",
"'curve25519-sha256@libssh.org'",
",",
"'ecdh-sha2-nistp256'",
",",
"'ecdh-sha2-nistp384'",
",",
"'ecdh-sha2-nis... | Sort algorithms based on preferences.
\param string $a
Name of the first algorithm.
\param string $b
Name of the second algorithm.
\retval int
An integer that is less than zero if the first algorithm
should be preferred, equal to zero if both algorithms have
the same preference and greater than zero when the second
... | [
"Sort",
"algorithms",
"based",
"on",
"preferences",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Algorithms.php#L385-L468 |
33,283 | fpoirotte/pssht | src/Handlers/DISCONNECT.php | DISCONNECT.handle | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\DISCONNECT::unserialize($decoder);
throw new $message;
} | php | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\DISCONNECT::unserialize($decoder);
throw new $message;
} | [
"public",
"function",
"handle",
"(",
"$",
"msgType",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Decoder",
"$",
"decoder",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
")",... | SSH_MSG_DISCONNECT = 1 | [
"SSH_MSG_DISCONNECT",
"=",
"1"
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Handlers/DISCONNECT.php#L20-L28 |
33,284 | fpoirotte/pssht | src/Buffer.php | Buffer.getLength | protected function getLength($limit)
{
$size = strlen($this->data);
if ($limit <= 0) {
$limit += $size;
}
if ($limit > $size) {
return null;
}
$res = (string) substr($this->data, 0, $limit);
$this->data = (string) substr($this->data, ... | php | protected function getLength($limit)
{
$size = strlen($this->data);
if ($limit <= 0) {
$limit += $size;
}
if ($limit > $size) {
return null;
}
$res = (string) substr($this->data, 0, $limit);
$this->data = (string) substr($this->data, ... | [
"protected",
"function",
"getLength",
"(",
"$",
"limit",
")",
"{",
"$",
"size",
"=",
"strlen",
"(",
"$",
"this",
"->",
"data",
")",
";",
"if",
"(",
"$",
"limit",
"<=",
"0",
")",
"{",
"$",
"limit",
"+=",
"$",
"size",
";",
"}",
"if",
"(",
"$",
... | Return a limited amount of data from the buffer.
\param int $limit
Number of bytes to retrieve from the buffer.
\retval string
Exactly $limit bytes of data from the buffer.
\retval null
The buffer contains less than $limit bytes
of data. | [
"Return",
"a",
"limited",
"amount",
"of",
"data",
"from",
"the",
"buffer",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Buffer.php#L63-L77 |
33,285 | fpoirotte/pssht | src/Buffer.php | Buffer.getDelimiter | protected function getDelimiter($limit)
{
if ($limit === '') {
throw new \InvalidArgumentException();
}
$pos = strpos($this->data, $limit);
if ($pos === false) {
return null;
}
$pos += strlen($limit);
$res = substr($this->data, 0, $po... | php | protected function getDelimiter($limit)
{
if ($limit === '') {
throw new \InvalidArgumentException();
}
$pos = strpos($this->data, $limit);
if ($pos === false) {
return null;
}
$pos += strlen($limit);
$res = substr($this->data, 0, $po... | [
"protected",
"function",
"getDelimiter",
"(",
"$",
"limit",
")",
"{",
"if",
"(",
"$",
"limit",
"===",
"''",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"this",
"->",
"data",
","... | Return a delimited string from the buffer.
\param string $limit
Delimiter.
\retval string
All the data at the beginning of the buffer
up to (and including) the delimiter.
\retval null
The given delimiter does not appear
in the buffer. | [
"Return",
"a",
"delimited",
"string",
"from",
"the",
"buffer",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Buffer.php#L93-L108 |
33,286 | fpoirotte/pssht | src/Buffer.php | Buffer.get | public function get($limit)
{
if (is_int($limit)) {
return $this->getLength($limit);
}
if (is_string($limit)) {
return $this->getDelimiter($limit);
}
throw new \InvalidArgumentException();
} | php | public function get($limit)
{
if (is_int($limit)) {
return $this->getLength($limit);
}
if (is_string($limit)) {
return $this->getDelimiter($limit);
}
throw new \InvalidArgumentException();
} | [
"public",
"function",
"get",
"(",
"$",
"limit",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"limit",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getLength",
"(",
"$",
"limit",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"limit",
")",
")",
"{... | Get limited data from the beginning of the buffer.
\param int|string $limit
Either the number of bytes to retrieve
from the buffer, or a string delimiter
to look for.
\retval string
The data at the beginning of the buffer, until the given
limit is reached. For string delimiters, the delimiter
is part of the result. | [
"Get",
"limited",
"data",
"from",
"the",
"beginning",
"of",
"the",
"buffer",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Buffer.php#L123-L134 |
33,287 | fpoirotte/pssht | src/Buffer.php | Buffer.unget | public function unget($data)
{
if (!is_string($data)) {
throw new \InvalidArgumentException();
}
$this->data = $data . $this->data;
return $this;
} | php | public function unget($data)
{
if (!is_string($data)) {
throw new \InvalidArgumentException();
}
$this->data = $data . $this->data;
return $this;
} | [
"public",
"function",
"unget",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"data",
"=",
"$",
"data",
".",
"$",
... | Prepend data to the beginning of the buffer.
\param string $data
Data to prepend.
\retval Buffer
Returns this buffer. | [
"Prepend",
"data",
"to",
"the",
"beginning",
"of",
"the",
"buffer",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Buffer.php#L145-L153 |
33,288 | fpoirotte/pssht | src/Handlers/CHANNEL/CLOSE.php | CLOSE.handle | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\CHANNEL\CLOSE::unserialize($decoder);
$channel = $message->getChannel();
$response = new \... | php | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\CHANNEL\CLOSE::unserialize($decoder);
$channel = $message->getChannel();
$response = new \... | [
"public",
"function",
"handle",
"(",
"$",
"msgType",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Decoder",
"$",
"decoder",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
")",... | SSH_MSG_CHANNEL_CLOSE = 97 | [
"SSH_MSG_CHANNEL_CLOSE",
"=",
"97"
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Handlers/CHANNEL/CLOSE.php#L20-L34 |
33,289 | fpoirotte/pssht | src/KeyStoreLoader/File.php | File.load | public function load($user, $file)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if (!is_string($file)) {
throw new \InvalidArgumentException();
}
$algos = \fpoirotte\Pssht\Algorithms::factory();
$types = array(
... | php | public function load($user, $file)
{
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if (!is_string($file)) {
throw new \InvalidArgumentException();
}
$algos = \fpoirotte\Pssht\Algorithms::factory();
$types = array(
... | [
"public",
"function",
"load",
"(",
"$",
"user",
",",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
... | Load the keys in the given file as if they belonged
to the specified user.
\param string $user
User the keys belong to.
\param string $file
File containing the keys to load.
It should follow the format of OpenSSH's
authorized_keys file.
\retval File
Returns this loader. | [
"Load",
"the",
"keys",
"in",
"the",
"given",
"file",
"as",
"if",
"they",
"belonged",
"to",
"the",
"specified",
"user",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/KeyStoreLoader/File.php#L54-L86 |
33,290 | fpoirotte/pssht | src/KeyStoreLoader/File.php | File.loadBulk | public function loadBulk(array $bulk)
{
foreach ($bulk as $user => $files) {
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if (!is_array($files) && !is_string($files)) {
throw new \InvalidArgumentException();
... | php | public function loadBulk(array $bulk)
{
foreach ($bulk as $user => $files) {
if (!is_string($user)) {
throw new \InvalidArgumentException();
}
if (!is_array($files) && !is_string($files)) {
throw new \InvalidArgumentException();
... | [
"public",
"function",
"loadBulk",
"(",
"array",
"$",
"bulk",
")",
"{",
"foreach",
"(",
"$",
"bulk",
"as",
"$",
"user",
"=>",
"$",
"files",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumen... | Bulk-load keys.
\param array $bulk
An array with information on the keys to load.
The keys in the array indicate users while
the values contain (an array of) files containing
the keys to load.
\retval File
Returns this loader. | [
"Bulk",
"-",
"load",
"keys",
"."
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/KeyStoreLoader/File.php#L100-L117 |
33,291 | fpoirotte/pssht | src/Handlers/IGNORE.php | IGNORE.handle | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
return true;
} | php | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
return true;
} | [
"public",
"function",
"handle",
"(",
"$",
"msgType",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Decoder",
"$",
"decoder",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
")",... | SSH_MSG_IGNORE = 2 | [
"SSH_MSG_IGNORE",
"=",
"2"
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Handlers/IGNORE.php#L20-L27 |
33,292 | fpoirotte/pssht | src/Handlers/CHANNEL/OPEN.php | OPEN.handle | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\CHANNEL\OPEN::unserialize($decoder);
$recipientChannel = $message->getChannel();
... | php | public function handle(
$msgType,
\fpoirotte\Pssht\Wire\Decoder $decoder,
\fpoirotte\Pssht\Transport $transport,
array &$context
) {
$message = \fpoirotte\Pssht\Messages\CHANNEL\OPEN::unserialize($decoder);
$recipientChannel = $message->getChannel();
... | [
"public",
"function",
"handle",
"(",
"$",
"msgType",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Wire",
"\\",
"Decoder",
"$",
"decoder",
",",
"\\",
"fpoirotte",
"\\",
"Pssht",
"\\",
"Transport",
"$",
"transport",
",",
"array",
"&",
"$",
"context",
")",... | SSH_MSG_CHANNEL_OPEN = 90 | [
"SSH_MSG_CHANNEL_OPEN",
"=",
"90"
] | 26bbbc18956144e355317f1e2e468be24bbb3e35 | https://github.com/fpoirotte/pssht/blob/26bbbc18956144e355317f1e2e468be24bbb3e35/src/Handlers/CHANNEL/OPEN.php#L20-L45 |
33,293 | go1com/flood | Flood.php | Flood.isAllowed | public function isAllowed($name, $threshold, $window = 3600, $identifier = null)
{
return $threshold > $this->count($name, $window, $identifier);
} | php | public function isAllowed($name, $threshold, $window = 3600, $identifier = null)
{
return $threshold > $this->count($name, $window, $identifier);
} | [
"public",
"function",
"isAllowed",
"(",
"$",
"name",
",",
"$",
"threshold",
",",
"$",
"window",
"=",
"3600",
",",
"$",
"identifier",
"=",
"null",
")",
"{",
"return",
"$",
"threshold",
">",
"$",
"this",
"->",
"count",
"(",
"$",
"name",
",",
"$",
"wi... | Checks whether a user is allowed to proceed with the specified event.
Events can have thresholds saying that each user can only do that event
a certain number of times in a time window. This function verifies that the
current user has not exceeded this threshold.
@param string $name The unique name of the event... | [
"Checks",
"whether",
"a",
"user",
"is",
"allowed",
"to",
"proceed",
"with",
"the",
"specified",
"event",
"."
] | 2ac77219479f010b0290265ad5d0c02a4b34930a | https://github.com/go1com/flood/blob/2ac77219479f010b0290265ad5d0c02a4b34930a/Flood.php#L67-L70 |
33,294 | go1com/flood | Flood.php | Flood.register | public function register($name, $window = 3600, $identifier = null)
{
$this
->connection
->insert($this->tableName, [
'event' => $name,
'identifier' => $identifier ?: $this->ip(),
'timestamp' => time(),
'expiration... | php | public function register($name, $window = 3600, $identifier = null)
{
$this
->connection
->insert($this->tableName, [
'event' => $name,
'identifier' => $identifier ?: $this->ip(),
'timestamp' => time(),
'expiration... | [
"public",
"function",
"register",
"(",
"$",
"name",
",",
"$",
"window",
"=",
"3600",
",",
"$",
"identifier",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"insert",
"(",
"$",
"this",
"->",
"tableName",
",",
"[",
"'event'",
"=>",
"$",
... | Registers an event for the current visitor to the flood control mechanism.
@param string $name The name of an event.
@param int $window Time to live in seconds.
@param int $identifier Optional identifier (defaults to the current user's IP address). | [
"Registers",
"an",
"event",
"for",
"the",
"current",
"visitor",
"to",
"the",
"flood",
"control",
"mechanism",
"."
] | 2ac77219479f010b0290265ad5d0c02a4b34930a | https://github.com/go1com/flood/blob/2ac77219479f010b0290265ad5d0c02a4b34930a/Flood.php#L91-L101 |
33,295 | flash-global/entities | src/AbstractEntity.php | AbstractEntity.mapFrom | public function mapFrom($field)
{
return isset($this->mapping[$field]) ? $this->mapping[$field] : $field;
} | php | public function mapFrom($field)
{
return isset($this->mapping[$field]) ? $this->mapping[$field] : $field;
} | [
"public",
"function",
"mapFrom",
"(",
"$",
"field",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"mapping",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"this",
"->",
"mapping",
"[",
"$",
"field",
"]",
":",
"$",
"field",
";",
"}"
] | Map DB field name to property name
@param $field
@return mixed | [
"Map",
"DB",
"field",
"name",
"to",
"property",
"name"
] | 7469b60bb0bb5b63491a78872bf9c3f38d4c8e75 | https://github.com/flash-global/entities/blob/7469b60bb0bb5b63491a78872bf9c3f38d4c8e75/src/AbstractEntity.php#L127-L130 |
33,296 | flash-global/entities | src/AbstractEntity.php | AbstractEntity.mapTo | public function mapTo($property)
{
if (!$this->mappingTo) {
$this->mappingTo = array_flip($this->mapping);
}
return isset($this->mappingTo[$property]) ? $this->mappingTo[$property] : $property;
} | php | public function mapTo($property)
{
if (!$this->mappingTo) {
$this->mappingTo = array_flip($this->mapping);
}
return isset($this->mappingTo[$property]) ? $this->mappingTo[$property] : $property;
} | [
"public",
"function",
"mapTo",
"(",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"mappingTo",
")",
"{",
"$",
"this",
"->",
"mappingTo",
"=",
"array_flip",
"(",
"$",
"this",
"->",
"mapping",
")",
";",
"}",
"return",
"isset",
"(",
"$... | Map property name to DB field name
@param $property
@return mixed | [
"Map",
"property",
"name",
"to",
"DB",
"field",
"name"
] | 7469b60bb0bb5b63491a78872bf9c3f38d4c8e75 | https://github.com/flash-global/entities/blob/7469b60bb0bb5b63491a78872bf9c3f38d4c8e75/src/AbstractEntity.php#L153-L160 |
33,297 | flash-global/entities | src/Extractor/JsonApiExtractor.php | JsonApiExtractor.extract | public function extract(array $json)
{
if (!$this->hasData($json)) {
return null;
}
if (!$this->isCollection($json)) {
return $this->extractOne($json, $json['data']);
} else {
$data = $this->extractMultiple($json);
if ($this->isPaginate... | php | public function extract(array $json)
{
if (!$this->hasData($json)) {
return null;
}
if (!$this->isCollection($json)) {
return $this->extractOne($json, $json['data']);
} else {
$data = $this->extractMultiple($json);
if ($this->isPaginate... | [
"public",
"function",
"extract",
"(",
"array",
"$",
"json",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasData",
"(",
"$",
"json",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isCollection",
"(",
"$",
"json",
... | Extract entities form an JSON API data
@param array $json
@return EntityInterface|EntitySet|PaginatedEntitySet|null | [
"Extract",
"entities",
"form",
"an",
"JSON",
"API",
"data"
] | 7469b60bb0bb5b63491a78872bf9c3f38d4c8e75 | https://github.com/flash-global/entities/blob/7469b60bb0bb5b63491a78872bf9c3f38d4c8e75/src/Extractor/JsonApiExtractor.php#L23-L40 |
33,298 | flash-global/entities | src/Extractor/JsonApiExtractor.php | JsonApiExtractor.extractOne | protected function extractOne(array $json, array $data)
{
if ($this->dataHasType($data)) {
return $this->createInstanceWithRelations($json, $data);
}
throw new JsonApiExtractException('No data type provided');
} | php | protected function extractOne(array $json, array $data)
{
if ($this->dataHasType($data)) {
return $this->createInstanceWithRelations($json, $data);
}
throw new JsonApiExtractException('No data type provided');
} | [
"protected",
"function",
"extractOne",
"(",
"array",
"$",
"json",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dataHasType",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createInstanceWithRelations",
"(",
"$",
"... | Extract an entity from data
@param array $json
@param array $data
@return array|EntityInterface
@throws JsonApiExtractException | [
"Extract",
"an",
"entity",
"from",
"data"
] | 7469b60bb0bb5b63491a78872bf9c3f38d4c8e75 | https://github.com/flash-global/entities/blob/7469b60bb0bb5b63491a78872bf9c3f38d4c8e75/src/Extractor/JsonApiExtractor.php#L75-L81 |
33,299 | flash-global/entities | src/Extractor/JsonApiExtractor.php | JsonApiExtractor.isPaginated | protected function isPaginated(array $json)
{
if (!array_key_exists('links', $json) || !array_key_exists('meta', $json)) {
return false;
}
if (is_array($json['links'])
&& array_key_exists('self', $json['links'])
&& array_key_exists('first', $json['links'])... | php | protected function isPaginated(array $json)
{
if (!array_key_exists('links', $json) || !array_key_exists('meta', $json)) {
return false;
}
if (is_array($json['links'])
&& array_key_exists('self', $json['links'])
&& array_key_exists('first', $json['links'])... | [
"protected",
"function",
"isPaginated",
"(",
"array",
"$",
"json",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'links'",
",",
"$",
"json",
")",
"||",
"!",
"array_key_exists",
"(",
"'meta'",
",",
"$",
"json",
")",
")",
"{",
"return",
"false",
";... | Test if JSON API data provided is paginated
@param array $json
@return bool | [
"Test",
"if",
"JSON",
"API",
"data",
"provided",
"is",
"paginated"
] | 7469b60bb0bb5b63491a78872bf9c3f38d4c8e75 | https://github.com/flash-global/entities/blob/7469b60bb0bb5b63491a78872bf9c3f38d4c8e75/src/Extractor/JsonApiExtractor.php#L202-L222 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.