repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
agentmedia/phine-core
src/Core/Logic/Routing/Rewriter.php
Rewriter.AddIndexCommands
function AddIndexCommands() { $condition = new RewriteCondition('$1', '!^(index\\.php|files|phine|robots\\.txt)'); $this->writer->AddContent($condition); $rule = new RewriteRule('(.*)$', 'index.php'); $rule->AddFlag(new CommandFlag(FlagType::Qsa())); $rule->AddFlag(new CommandFlag(FlagType::L())); $this->writer->AddContent($rule); }
php
function AddIndexCommands() { $condition = new RewriteCondition('$1', '!^(index\\.php|files|phine|robots\\.txt)'); $this->writer->AddContent($condition); $rule = new RewriteRule('(.*)$', 'index.php'); $rule->AddFlag(new CommandFlag(FlagType::Qsa())); $rule->AddFlag(new CommandFlag(FlagType::L())); $this->writer->AddContent($rule); }
[ "function", "AddIndexCommands", "(", ")", "{", "$", "condition", "=", "new", "RewriteCondition", "(", "'$1'", ",", "'!^(index\\\\.php|files|phine|robots\\\\.txt)'", ")", ";", "$", "this", "->", "writer", "->", "AddContent", "(", "$", "condition", ")", ";", "$", "rule", "=", "new", "RewriteRule", "(", "'(.*)$'", ",", "'index.php'", ")", ";", "$", "rule", "->", "AddFlag", "(", "new", "CommandFlag", "(", "FlagType", "::", "Qsa", "(", ")", ")", ")", ";", "$", "rule", "->", "AddFlag", "(", "new", "CommandFlag", "(", "FlagType", "::", "L", "(", ")", ")", ")", ";", "$", "this", "->", "writer", "->", "AddContent", "(", "$", "rule", ")", ";", "}" ]
Adds the rules to rewrite anything to the index.php
[ "Adds", "the", "rules", "to", "rewrite", "anything", "to", "the", "index", ".", "php" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Routing/Rewriter.php#L98-L107
train
agentmedia/phine-core
src/Core/Logic/Routing/Rewriter.php
Rewriter.SiteHostCondition
private function SiteHostCondition(Site $site) { $siteUrl = $site->GetUrl(); $host = parse_url($siteUrl, PHP_URL_HOST); return new RewriteCondition(new Variable(ServerVariable::HttpHost()), $host); }
php
private function SiteHostCondition(Site $site) { $siteUrl = $site->GetUrl(); $host = parse_url($siteUrl, PHP_URL_HOST); return new RewriteCondition(new Variable(ServerVariable::HttpHost()), $host); }
[ "private", "function", "SiteHostCondition", "(", "Site", "$", "site", ")", "{", "$", "siteUrl", "=", "$", "site", "->", "GetUrl", "(", ")", ";", "$", "host", "=", "parse_url", "(", "$", "siteUrl", ",", "PHP_URL_HOST", ")", ";", "return", "new", "RewriteCondition", "(", "new", "Variable", "(", "ServerVariable", "::", "HttpHost", "(", ")", ")", ",", "$", "host", ")", ";", "}" ]
Gets the host condition for a page rewrite @param Site $site @return RewriteCondition
[ "Gets", "the", "host", "condition", "for", "a", "page", "rewrite" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Routing/Rewriter.php#L114-L119
train
agentmedia/phine-core
src/Core/Logic/Routing/Rewriter.php
Rewriter.SiteFolderCondition
private function SiteFolderCondition(Site $site) { $siteUrl = $site->GetUrl(); $siteFolder = parse_url($siteUrl, PHP_URL_PATH); if ($siteFolder != '' && $siteFolder != '/') { return new RewriteCondition(new Variable(ServerVariable::RequestUri()), '^' . rtrim($siteFolder, '/') . '/'); } else { return new RewriteCondition(new Variable(ServerVariable::RequestUri()), '^/'); } return null; }
php
private function SiteFolderCondition(Site $site) { $siteUrl = $site->GetUrl(); $siteFolder = parse_url($siteUrl, PHP_URL_PATH); if ($siteFolder != '' && $siteFolder != '/') { return new RewriteCondition(new Variable(ServerVariable::RequestUri()), '^' . rtrim($siteFolder, '/') . '/'); } else { return new RewriteCondition(new Variable(ServerVariable::RequestUri()), '^/'); } return null; }
[ "private", "function", "SiteFolderCondition", "(", "Site", "$", "site", ")", "{", "$", "siteUrl", "=", "$", "site", "->", "GetUrl", "(", ")", ";", "$", "siteFolder", "=", "parse_url", "(", "$", "siteUrl", ",", "PHP_URL_PATH", ")", ";", "if", "(", "$", "siteFolder", "!=", "''", "&&", "$", "siteFolder", "!=", "'/'", ")", "{", "return", "new", "RewriteCondition", "(", "new", "Variable", "(", "ServerVariable", "::", "RequestUri", "(", ")", ")", ",", "'^'", ".", "rtrim", "(", "$", "siteFolder", ",", "'/'", ")", ".", "'/'", ")", ";", "}", "else", "{", "return", "new", "RewriteCondition", "(", "new", "Variable", "(", "ServerVariable", "::", "RequestUri", "(", ")", ")", ",", "'^/'", ")", ";", "}", "return", "null", ";", "}" ]
Gets the rewrite condition for the site specific folder; if present @param Site $site @return RewriteCondition
[ "Gets", "the", "rewrite", "condition", "for", "the", "site", "specific", "folder", ";", "if", "present" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Routing/Rewriter.php#L125-L138
train
agentmedia/phine-core
src/Core/Logic/Routing/Rewriter.php
Rewriter.PageRule
private function PageRule(Page $page, array $params) { $lhs = $page->GetUrl(); foreach ($params as $param) { $lhs = str_replace('{' . $param . '}', self::PARAM_PATTERN, $lhs); } $rhs = 'index.php'; $idx = 1; foreach ($params as $param) { $rhs .= $idx > 1 ? '&' : '?'; $rhs .= $param . '=$' . $idx; ++$idx; } $rhs .= '&' . self::PAGE_URL_PARAM . '=' . $page->GetUrl(); $rule = new RewriteRule($lhs, $rhs); $rule->AddFlag(new CommandFlag(FlagType::Qsa())); $rule->AddFlag(new CommandFlag(FlagType::L())); return $rule; }
php
private function PageRule(Page $page, array $params) { $lhs = $page->GetUrl(); foreach ($params as $param) { $lhs = str_replace('{' . $param . '}', self::PARAM_PATTERN, $lhs); } $rhs = 'index.php'; $idx = 1; foreach ($params as $param) { $rhs .= $idx > 1 ? '&' : '?'; $rhs .= $param . '=$' . $idx; ++$idx; } $rhs .= '&' . self::PAGE_URL_PARAM . '=' . $page->GetUrl(); $rule = new RewriteRule($lhs, $rhs); $rule->AddFlag(new CommandFlag(FlagType::Qsa())); $rule->AddFlag(new CommandFlag(FlagType::L())); return $rule; }
[ "private", "function", "PageRule", "(", "Page", "$", "page", ",", "array", "$", "params", ")", "{", "$", "lhs", "=", "$", "page", "->", "GetUrl", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "lhs", "=", "str_replace", "(", "'{'", ".", "$", "param", ".", "'}'", ",", "self", "::", "PARAM_PATTERN", ",", "$", "lhs", ")", ";", "}", "$", "rhs", "=", "'index.php'", ";", "$", "idx", "=", "1", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "rhs", ".=", "$", "idx", ">", "1", "?", "'&'", ":", "'?'", ";", "$", "rhs", ".=", "$", "param", ".", "'=$'", ".", "$", "idx", ";", "++", "$", "idx", ";", "}", "$", "rhs", ".=", "'&'", ".", "self", "::", "PAGE_URL_PARAM", ".", "'='", ".", "$", "page", "->", "GetUrl", "(", ")", ";", "$", "rule", "=", "new", "RewriteRule", "(", "$", "lhs", ",", "$", "rhs", ")", ";", "$", "rule", "->", "AddFlag", "(", "new", "CommandFlag", "(", "FlagType", "::", "Qsa", "(", ")", ")", ")", ";", "$", "rule", "->", "AddFlag", "(", "new", "CommandFlag", "(", "FlagType", "::", "L", "(", ")", ")", ")", ";", "return", "$", "rule", ";", "}" ]
Returns the page rule @param Page $page @param array $params @return RewriteRule
[ "Returns", "the", "page", "rule" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Routing/Rewriter.php#L145-L167
train
agentmedia/phine-core
src/Core/Logic/Routing/Rewriter.php
Rewriter.PageStartComment
function PageStartComment(Page $page) { $text = str_replace('{0}', $page->GetID(), self::START_PAGE_COMMENT); return new CommentLine($text); }
php
function PageStartComment(Page $page) { $text = str_replace('{0}', $page->GetID(), self::START_PAGE_COMMENT); return new CommentLine($text); }
[ "function", "PageStartComment", "(", "Page", "$", "page", ")", "{", "$", "text", "=", "str_replace", "(", "'{0}'", ",", "$", "page", "->", "GetID", "(", ")", ",", "self", "::", "START_PAGE_COMMENT", ")", ";", "return", "new", "CommentLine", "(", "$", "text", ")", ";", "}" ]
The page start comment @param Page $page @return CommentLine
[ "The", "page", "start", "comment" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Routing/Rewriter.php#L173-L177
train
agentmedia/phine-core
src/Core/Logic/Routing/Rewriter.php
Rewriter.PageEndComment
function PageEndComment(Page $page) { $text = str_replace('{0}', $page->GetID(), self::END_PAGE_COMMENT); return new CommentLine($text); }
php
function PageEndComment(Page $page) { $text = str_replace('{0}', $page->GetID(), self::END_PAGE_COMMENT); return new CommentLine($text); }
[ "function", "PageEndComment", "(", "Page", "$", "page", ")", "{", "$", "text", "=", "str_replace", "(", "'{0}'", ",", "$", "page", "->", "GetID", "(", ")", ",", "self", "::", "END_PAGE_COMMENT", ")", ";", "return", "new", "CommentLine", "(", "$", "text", ")", ";", "}" ]
The page end comment @param Page $page @return CommentLine
[ "The", "page", "end", "comment" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Routing/Rewriter.php#L185-L189
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.&
private static function &getProperty($object, string $property) { $value = &\Closure::bind(function & () use ($property) { return $this->$property; }, $object, $object)->__invoke(); return $value; }
php
private static function &getProperty($object, string $property) { $value = &\Closure::bind(function & () use ($property) { return $this->$property; }, $object, $object)->__invoke(); return $value; }
[ "private", "static", "function", "&", "getProperty", "(", "$", "object", ",", "string", "$", "property", ")", "{", "$", "value", "=", "&", "\\", "Closure", "::", "bind", "(", "function", "&", "(", ")", "use", "(", "$", "property", ")", "{", "return", "$", "this", "->", "$", "property", ";", "}", ",", "$", "object", ",", "$", "object", ")", "->", "__invoke", "(", ")", ";", "return", "$", "value", ";", "}" ]
Returns a reference to a non static property of an object. @param object $object The object. @param string $property The name of the property. @return mixed
[ "Returns", "a", "reference", "to", "a", "non", "static", "property", "of", "an", "object", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L63-L70
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.&
private static function &getStaticProperty($object, string $property) { $value = &\Closure::bind(function & () use ($property) { return self::$$property; }, $object, $object)->__invoke(); return $value; }
php
private static function &getStaticProperty($object, string $property) { $value = &\Closure::bind(function & () use ($property) { return self::$$property; }, $object, $object)->__invoke(); return $value; }
[ "private", "static", "function", "&", "getStaticProperty", "(", "$", "object", ",", "string", "$", "property", ")", "{", "$", "value", "=", "&", "\\", "Closure", "::", "bind", "(", "function", "&", "(", ")", "use", "(", "$", "property", ")", "{", "return", "self", "::", "$", "$", "property", ";", "}", ",", "$", "object", ",", "$", "object", ")", "->", "__invoke", "(", ")", ";", "return", "$", "value", ";", "}" ]
Returns a reference to a static property of an object. @param object $object The object. @param string $property The name of the property. @return mixed
[ "Returns", "a", "reference", "to", "a", "static", "property", "of", "an", "object", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L81-L88
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.dump
public function dump($name, &$value, bool $scalarReferences = false): void { $this->seen = []; $this->scalarReferences = $scalarReferences; $this->gid = uniqid((string)mt_rand(), true); $this->writer->start(); $this->recursiveDump($value, $name); $this->writer->stop(); }
php
public function dump($name, &$value, bool $scalarReferences = false): void { $this->seen = []; $this->scalarReferences = $scalarReferences; $this->gid = uniqid((string)mt_rand(), true); $this->writer->start(); $this->recursiveDump($value, $name); $this->writer->stop(); }
[ "public", "function", "dump", "(", "$", "name", ",", "&", "$", "value", ",", "bool", "$", "scalarReferences", "=", "false", ")", ":", "void", "{", "$", "this", "->", "seen", "=", "[", "]", ";", "$", "this", "->", "scalarReferences", "=", "$", "scalarReferences", ";", "$", "this", "->", "gid", "=", "uniqid", "(", "(", "string", ")", "mt_rand", "(", ")", ",", "true", ")", ";", "$", "this", "->", "writer", "->", "start", "(", ")", ";", "$", "this", "->", "recursiveDump", "(", "$", "value", ",", "$", "name", ")", ";", "$", "this", "->", "writer", "->", "stop", "(", ")", ";", "}" ]
Main function for dumping. @param string|int|null $name The name of the variable. @param mixed $value Value to be dumped. @param bool $scalarReferences If true scalar references to values must be traced. @api @since 1.0.0
[ "Main", "function", "for", "dumping", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L125-L136
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.dumpArray
private function dumpArray(array &$value, $name): void { list($id, $ref) = $this->isReference($value); if ($ref===null) { $this->writer->writeArrayOpen($id, $name); foreach ($value as $key => &$item) { $this->recursiveDump($item, $key); } $this->writer->writeArrayClose($id, $name); } else { $this->writer->writeArrayReference($ref, $name); } }
php
private function dumpArray(array &$value, $name): void { list($id, $ref) = $this->isReference($value); if ($ref===null) { $this->writer->writeArrayOpen($id, $name); foreach ($value as $key => &$item) { $this->recursiveDump($item, $key); } $this->writer->writeArrayClose($id, $name); } else { $this->writer->writeArrayReference($ref, $name); } }
[ "private", "function", "dumpArray", "(", "array", "&", "$", "value", ",", "$", "name", ")", ":", "void", "{", "list", "(", "$", "id", ",", "$", "ref", ")", "=", "$", "this", "->", "isReference", "(", "$", "value", ")", ";", "if", "(", "$", "ref", "===", "null", ")", "{", "$", "this", "->", "writer", "->", "writeArrayOpen", "(", "$", "id", ",", "$", "name", ")", ";", "foreach", "(", "$", "value", "as", "$", "key", "=>", "&", "$", "item", ")", "{", "$", "this", "->", "recursiveDump", "(", "$", "item", ",", "$", "key", ")", ";", "}", "$", "this", "->", "writer", "->", "writeArrayClose", "(", "$", "id", ",", "$", "name", ")", ";", "}", "else", "{", "$", "this", "->", "writer", "->", "writeArrayReference", "(", "$", "ref", ",", "$", "name", ")", ";", "}", "}" ]
Dumps an array. @param array $value The array. @param string|int|null $name Variable name.
[ "Dumps", "an", "array", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L145-L164
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.dumpBool
private function dumpBool(bool &$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeBool($id, $ref, $value, $name); }
php
private function dumpBool(bool &$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeBool($id, $ref, $value, $name); }
[ "private", "function", "dumpBool", "(", "bool", "&", "$", "value", ",", "$", "name", ")", ":", "void", "{", "if", "(", "$", "this", "->", "scalarReferences", ")", "{", "list", "(", "$", "id", ",", "$", "ref", ")", "=", "$", "this", "->", "isReference", "(", "$", "value", ")", ";", "}", "else", "{", "$", "id", "=", "null", ";", "$", "ref", "=", "null", ";", "}", "$", "this", "->", "writer", "->", "writeBool", "(", "$", "id", ",", "$", "ref", ",", "$", "value", ",", "$", "name", ")", ";", "}" ]
Dumps a boolean. @param bool $value The boolean. @param string|int|null $name The name of the variable.
[ "Dumps", "a", "boolean", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L173-L186
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.dumpFloat
private function dumpFloat(float &$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeFloat($id, $ref, $value, $name); }
php
private function dumpFloat(float &$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeFloat($id, $ref, $value, $name); }
[ "private", "function", "dumpFloat", "(", "float", "&", "$", "value", ",", "$", "name", ")", ":", "void", "{", "if", "(", "$", "this", "->", "scalarReferences", ")", "{", "list", "(", "$", "id", ",", "$", "ref", ")", "=", "$", "this", "->", "isReference", "(", "$", "value", ")", ";", "}", "else", "{", "$", "id", "=", "null", ";", "$", "ref", "=", "null", ";", "}", "$", "this", "->", "writer", "->", "writeFloat", "(", "$", "id", ",", "$", "ref", ",", "$", "value", ",", "$", "name", ")", ";", "}" ]
Dumps a float. @param float $value The float. @param string|int|null $name The name of the variable.
[ "Dumps", "a", "float", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L195-L208
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.dumpInt
private function dumpInt(int &$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeInt($id, $ref, $value, $name); }
php
private function dumpInt(int &$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeInt($id, $ref, $value, $name); }
[ "private", "function", "dumpInt", "(", "int", "&", "$", "value", ",", "$", "name", ")", ":", "void", "{", "if", "(", "$", "this", "->", "scalarReferences", ")", "{", "list", "(", "$", "id", ",", "$", "ref", ")", "=", "$", "this", "->", "isReference", "(", "$", "value", ")", ";", "}", "else", "{", "$", "id", "=", "null", ";", "$", "ref", "=", "null", ";", "}", "$", "this", "->", "writer", "->", "writeInt", "(", "$", "id", ",", "$", "ref", ",", "$", "value", ",", "$", "name", ")", ";", "}" ]
Dumps an integer. @param int $value The integer. @param string|int|null $name The name of the variable.
[ "Dumps", "an", "integer", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L217-L230
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.dumpNull
private function dumpNull(&$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeNull($id, $ref, $name); }
php
private function dumpNull(&$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeNull($id, $ref, $name); }
[ "private", "function", "dumpNull", "(", "&", "$", "value", ",", "$", "name", ")", ":", "void", "{", "if", "(", "$", "this", "->", "scalarReferences", ")", "{", "list", "(", "$", "id", ",", "$", "ref", ")", "=", "$", "this", "->", "isReference", "(", "$", "value", ")", ";", "}", "else", "{", "$", "id", "=", "null", ";", "$", "ref", "=", "null", ";", "}", "$", "this", "->", "writer", "->", "writeNull", "(", "$", "id", ",", "$", "ref", ",", "$", "name", ")", ";", "}" ]
Dumps null. @param null $value The null. @param string|int|null $name The name of the variable.
[ "Dumps", "null", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L239-L252
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.dumpObject
private function dumpObject($value, $name): void { list($id, $ref) = $this->isReference($value); if ($ref===null) { $this->writer->writeObjectOpen($id, $name, get_class($value)); // Dump all fields of the object, unless the object is me. if ($this!==$value) { $reflect = new \ReflectionClass($value); $properties = $reflect->getProperties(); if (strpos(get_class($value), '\\')!==false) { foreach ($properties as $property) { $propertyName = $property->getName(); if ($property->isStatic()) { $propertyValue = &self::getStaticProperty($value, $propertyName); } else { $propertyValue = &self::getProperty($value, $propertyName); } $this->recursiveDump($propertyValue, $propertyName); } } elseif (get_class($value)=='stdClass') { foreach ($value as $propertyName => $propertyValue) { $this->recursiveDump($propertyValue, $propertyName); } } } $this->writer->writeObjectClose($id, $name, get_class($value)); } else { $this->writer->writeObjectReference($ref, $name, get_class($value)); } }
php
private function dumpObject($value, $name): void { list($id, $ref) = $this->isReference($value); if ($ref===null) { $this->writer->writeObjectOpen($id, $name, get_class($value)); // Dump all fields of the object, unless the object is me. if ($this!==$value) { $reflect = new \ReflectionClass($value); $properties = $reflect->getProperties(); if (strpos(get_class($value), '\\')!==false) { foreach ($properties as $property) { $propertyName = $property->getName(); if ($property->isStatic()) { $propertyValue = &self::getStaticProperty($value, $propertyName); } else { $propertyValue = &self::getProperty($value, $propertyName); } $this->recursiveDump($propertyValue, $propertyName); } } elseif (get_class($value)=='stdClass') { foreach ($value as $propertyName => $propertyValue) { $this->recursiveDump($propertyValue, $propertyName); } } } $this->writer->writeObjectClose($id, $name, get_class($value)); } else { $this->writer->writeObjectReference($ref, $name, get_class($value)); } }
[ "private", "function", "dumpObject", "(", "$", "value", ",", "$", "name", ")", ":", "void", "{", "list", "(", "$", "id", ",", "$", "ref", ")", "=", "$", "this", "->", "isReference", "(", "$", "value", ")", ";", "if", "(", "$", "ref", "===", "null", ")", "{", "$", "this", "->", "writer", "->", "writeObjectOpen", "(", "$", "id", ",", "$", "name", ",", "get_class", "(", "$", "value", ")", ")", ";", "// Dump all fields of the object, unless the object is me.", "if", "(", "$", "this", "!==", "$", "value", ")", "{", "$", "reflect", "=", "new", "\\", "ReflectionClass", "(", "$", "value", ")", ";", "$", "properties", "=", "$", "reflect", "->", "getProperties", "(", ")", ";", "if", "(", "strpos", "(", "get_class", "(", "$", "value", ")", ",", "'\\\\'", ")", "!==", "false", ")", "{", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "propertyName", "=", "$", "property", "->", "getName", "(", ")", ";", "if", "(", "$", "property", "->", "isStatic", "(", ")", ")", "{", "$", "propertyValue", "=", "&", "self", "::", "getStaticProperty", "(", "$", "value", ",", "$", "propertyName", ")", ";", "}", "else", "{", "$", "propertyValue", "=", "&", "self", "::", "getProperty", "(", "$", "value", ",", "$", "propertyName", ")", ";", "}", "$", "this", "->", "recursiveDump", "(", "$", "propertyValue", ",", "$", "propertyName", ")", ";", "}", "}", "elseif", "(", "get_class", "(", "$", "value", ")", "==", "'stdClass'", ")", "{", "foreach", "(", "$", "value", "as", "$", "propertyName", "=>", "$", "propertyValue", ")", "{", "$", "this", "->", "recursiveDump", "(", "$", "propertyValue", ",", "$", "propertyName", ")", ";", "}", "}", "}", "$", "this", "->", "writer", "->", "writeObjectClose", "(", "$", "id", ",", "$", "name", ",", "get_class", "(", "$", "value", ")", ")", ";", "}", "else", "{", "$", "this", "->", "writer", "->", "writeObjectReference", "(", "$", "ref", ",", "$", "name", ",", "get_class", "(", "$", "value", ")", ")", ";", "}", "}" ]
Dumps an object. @param object $value The object. @param string|int|null $name The name of the variable.
[ "Dumps", "an", "object", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L261-L307
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.dumpResource
private function dumpResource($value, $name): void { list($id, $ref) = $this->isReference($value); $this->writer->writeResource($id, $ref, $name, get_resource_type($value)); }
php
private function dumpResource($value, $name): void { list($id, $ref) = $this->isReference($value); $this->writer->writeResource($id, $ref, $name, get_resource_type($value)); }
[ "private", "function", "dumpResource", "(", "$", "value", ",", "$", "name", ")", ":", "void", "{", "list", "(", "$", "id", ",", "$", "ref", ")", "=", "$", "this", "->", "isReference", "(", "$", "value", ")", ";", "$", "this", "->", "writer", "->", "writeResource", "(", "$", "id", ",", "$", "ref", ",", "$", "name", ",", "get_resource_type", "(", "$", "value", ")", ")", ";", "}" ]
Dumps a resource. @param resource $value The resource. @param string $name The name of the variable.
[ "Dumps", "a", "resource", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L316-L321
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.dumpString
private function dumpString(string &$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeString($id, $ref, $value, $name); }
php
private function dumpString(string &$value, $name): void { if ($this->scalarReferences) { list($id, $ref) = $this->isReference($value); } else { $id = null; $ref = null; } $this->writer->writeString($id, $ref, $value, $name); }
[ "private", "function", "dumpString", "(", "string", "&", "$", "value", ",", "$", "name", ")", ":", "void", "{", "if", "(", "$", "this", "->", "scalarReferences", ")", "{", "list", "(", "$", "id", ",", "$", "ref", ")", "=", "$", "this", "->", "isReference", "(", "$", "value", ")", ";", "}", "else", "{", "$", "id", "=", "null", ";", "$", "ref", "=", "null", ";", "}", "$", "this", "->", "writer", "->", "writeString", "(", "$", "id", ",", "$", "ref", ",", "$", "value", ",", "$", "name", ")", ";", "}" ]
Dumps a string. @param string $value The string. @param string|int|null $name The name of the variable.
[ "Dumps", "a", "string", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L330-L343
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.isReference
private function isReference(&$value): array { switch (true) { case is_bool($value): case is_null($value): case is_int($value): case is_string($value): case is_double($value): case is_resource($value): $ref = $this->testSeen($value); break; case is_object($value): $ref = $this->testSeenObject($value); break; case is_array($value): $ref = $this->testSeenArray($value); break; default: throw new FallenException('type', gettype($value)); } $id = ($ref===null) ? sizeof($this->seen) - 1 : null; return [$id, $ref]; }
php
private function isReference(&$value): array { switch (true) { case is_bool($value): case is_null($value): case is_int($value): case is_string($value): case is_double($value): case is_resource($value): $ref = $this->testSeen($value); break; case is_object($value): $ref = $this->testSeenObject($value); break; case is_array($value): $ref = $this->testSeenArray($value); break; default: throw new FallenException('type', gettype($value)); } $id = ($ref===null) ? sizeof($this->seen) - 1 : null; return [$id, $ref]; }
[ "private", "function", "isReference", "(", "&", "$", "value", ")", ":", "array", "{", "switch", "(", "true", ")", "{", "case", "is_bool", "(", "$", "value", ")", ":", "case", "is_null", "(", "$", "value", ")", ":", "case", "is_int", "(", "$", "value", ")", ":", "case", "is_string", "(", "$", "value", ")", ":", "case", "is_double", "(", "$", "value", ")", ":", "case", "is_resource", "(", "$", "value", ")", ":", "$", "ref", "=", "$", "this", "->", "testSeen", "(", "$", "value", ")", ";", "break", ";", "case", "is_object", "(", "$", "value", ")", ":", "$", "ref", "=", "$", "this", "->", "testSeenObject", "(", "$", "value", ")", ";", "break", ";", "case", "is_array", "(", "$", "value", ")", ":", "$", "ref", "=", "$", "this", "->", "testSeenArray", "(", "$", "value", ")", ";", "break", ";", "default", ":", "throw", "new", "FallenException", "(", "'type'", ",", "gettype", "(", "$", "value", ")", ")", ";", "}", "$", "id", "=", "(", "$", "ref", "===", "null", ")", "?", "sizeof", "(", "$", "this", "->", "seen", ")", "-", "1", ":", "null", ";", "return", "[", "$", "id", ",", "$", "ref", "]", ";", "}" ]
If a value has been dumped before returns the ID of the variable. Otherwise returns null. @param mixed $value The variable. @return array<int|null>
[ "If", "a", "value", "has", "been", "dumped", "before", "returns", "the", "ID", "of", "the", "variable", ".", "Otherwise", "returns", "null", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L353-L381
train
SetBased/php-abc-var-dumper
src/VarDumper.php
VarDumper.recursiveDump
private function recursiveDump(&$value, $name): void { switch (true) { case is_null($value): $this->dumpNull($value, $name); break; case is_bool($value): $this->dumpBool($value, $name); break; case is_float($value): $this->dumpFloat($value, $name); break; case is_int($value): $this->dumpInt($value, $name); break; case is_string($value): if (is_string($name) && stripos($name, 'password')!==false) { // Do not dump the value of a variable/key with a name tha contains 'password'. $tmp = str_repeat('*', 12); $this->dumpString($tmp, $name); } else { $this->dumpString($value, $name); } break; case is_object($value): $this->dumpObject($value, $name); break; case is_array($value): $this->dumpArray($value, $name); break; case is_resource($value): $this->dumpResource($value, $name); break; default: throw new FallenException('type', gettype($value)); } }
php
private function recursiveDump(&$value, $name): void { switch (true) { case is_null($value): $this->dumpNull($value, $name); break; case is_bool($value): $this->dumpBool($value, $name); break; case is_float($value): $this->dumpFloat($value, $name); break; case is_int($value): $this->dumpInt($value, $name); break; case is_string($value): if (is_string($name) && stripos($name, 'password')!==false) { // Do not dump the value of a variable/key with a name tha contains 'password'. $tmp = str_repeat('*', 12); $this->dumpString($tmp, $name); } else { $this->dumpString($value, $name); } break; case is_object($value): $this->dumpObject($value, $name); break; case is_array($value): $this->dumpArray($value, $name); break; case is_resource($value): $this->dumpResource($value, $name); break; default: throw new FallenException('type', gettype($value)); } }
[ "private", "function", "recursiveDump", "(", "&", "$", "value", ",", "$", "name", ")", ":", "void", "{", "switch", "(", "true", ")", "{", "case", "is_null", "(", "$", "value", ")", ":", "$", "this", "->", "dumpNull", "(", "$", "value", ",", "$", "name", ")", ";", "break", ";", "case", "is_bool", "(", "$", "value", ")", ":", "$", "this", "->", "dumpBool", "(", "$", "value", ",", "$", "name", ")", ";", "break", ";", "case", "is_float", "(", "$", "value", ")", ":", "$", "this", "->", "dumpFloat", "(", "$", "value", ",", "$", "name", ")", ";", "break", ";", "case", "is_int", "(", "$", "value", ")", ":", "$", "this", "->", "dumpInt", "(", "$", "value", ",", "$", "name", ")", ";", "break", ";", "case", "is_string", "(", "$", "value", ")", ":", "if", "(", "is_string", "(", "$", "name", ")", "&&", "stripos", "(", "$", "name", ",", "'password'", ")", "!==", "false", ")", "{", "// Do not dump the value of a variable/key with a name tha contains 'password'.", "$", "tmp", "=", "str_repeat", "(", "'*'", ",", "12", ")", ";", "$", "this", "->", "dumpString", "(", "$", "tmp", ",", "$", "name", ")", ";", "}", "else", "{", "$", "this", "->", "dumpString", "(", "$", "value", ",", "$", "name", ")", ";", "}", "break", ";", "case", "is_object", "(", "$", "value", ")", ":", "$", "this", "->", "dumpObject", "(", "$", "value", ",", "$", "name", ")", ";", "break", ";", "case", "is_array", "(", "$", "value", ")", ":", "$", "this", "->", "dumpArray", "(", "$", "value", ",", "$", "name", ")", ";", "break", ";", "case", "is_resource", "(", "$", "value", ")", ":", "$", "this", "->", "dumpResource", "(", "$", "value", ",", "$", "name", ")", ";", "break", ";", "default", ":", "throw", "new", "FallenException", "(", "'type'", ",", "gettype", "(", "$", "value", ")", ")", ";", "}", "}" ]
Dumps recursively a variable. @param mixed $value The value. @param string|int|null $name Variable The name of the variable.
[ "Dumps", "recursively", "a", "variable", "." ]
cb03a4f1e76d65378c818120f97cbd734768a842
https://github.com/SetBased/php-abc-var-dumper/blob/cb03a4f1e76d65378c818120f97cbd734768a842/src/VarDumper.php#L390-L438
train
phospr/DoubleEntryBundle
Model/Account.php
Account.generateSlugSegmentationAndPath
public function generateSlugSegmentationAndPath() { // Set slug for this Account. The reason we do this here is that // the slug listener hasn't been called yet $this->setSlug(\Gedmo\Sluggable\Util\Urlizer::urlize($this->name)); if ($this->getParent()) { $account = $this; $pathSegments = array($account->getSlug()); $nameSegments = array($account->getName()); while ($account->getParent()) { $account = $account->getParent(); // Don't include root if ($account->getParent()) { $pathSegments[] = $account->getSlug(); $nameSegments[] = $account->getName(); } } $this->setPath(implode('/', array_reverse($pathSegments))); $this->setSegmentation(implode(':', array_reverse($nameSegments))); } else { $this->setPath('/'); $this->setSegmentation(':'); } }
php
public function generateSlugSegmentationAndPath() { // Set slug for this Account. The reason we do this here is that // the slug listener hasn't been called yet $this->setSlug(\Gedmo\Sluggable\Util\Urlizer::urlize($this->name)); if ($this->getParent()) { $account = $this; $pathSegments = array($account->getSlug()); $nameSegments = array($account->getName()); while ($account->getParent()) { $account = $account->getParent(); // Don't include root if ($account->getParent()) { $pathSegments[] = $account->getSlug(); $nameSegments[] = $account->getName(); } } $this->setPath(implode('/', array_reverse($pathSegments))); $this->setSegmentation(implode(':', array_reverse($nameSegments))); } else { $this->setPath('/'); $this->setSegmentation(':'); } }
[ "public", "function", "generateSlugSegmentationAndPath", "(", ")", "{", "// Set slug for this Account. The reason we do this here is that", "// the slug listener hasn't been called yet", "$", "this", "->", "setSlug", "(", "\\", "Gedmo", "\\", "Sluggable", "\\", "Util", "\\", "Urlizer", "::", "urlize", "(", "$", "this", "->", "name", ")", ")", ";", "if", "(", "$", "this", "->", "getParent", "(", ")", ")", "{", "$", "account", "=", "$", "this", ";", "$", "pathSegments", "=", "array", "(", "$", "account", "->", "getSlug", "(", ")", ")", ";", "$", "nameSegments", "=", "array", "(", "$", "account", "->", "getName", "(", ")", ")", ";", "while", "(", "$", "account", "->", "getParent", "(", ")", ")", "{", "$", "account", "=", "$", "account", "->", "getParent", "(", ")", ";", "// Don't include root", "if", "(", "$", "account", "->", "getParent", "(", ")", ")", "{", "$", "pathSegments", "[", "]", "=", "$", "account", "->", "getSlug", "(", ")", ";", "$", "nameSegments", "[", "]", "=", "$", "account", "->", "getName", "(", ")", ";", "}", "}", "$", "this", "->", "setPath", "(", "implode", "(", "'/'", ",", "array_reverse", "(", "$", "pathSegments", ")", ")", ")", ";", "$", "this", "->", "setSegmentation", "(", "implode", "(", "':'", ",", "array_reverse", "(", "$", "nameSegments", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "setPath", "(", "'/'", ")", ";", "$", "this", "->", "setSegmentation", "(", "':'", ")", ";", "}", "}" ]
Generate slug, segmentation and path @author Tom Haskins-Vaughan <[email protected]> @since 0.8.0 @ORM\PrePersist @ORM\PreUpdate
[ "Generate", "slug", "segmentation", "and", "path" ]
d9c421f30922b461483731983c59beb26047fb7f
https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/Account.php#L574-L602
train
phospr/DoubleEntryBundle
Model/Account.php
Account.getPostedPostings
public function getPostedPostings() { $criteria = Criteria::create() ->where(Criteria::expr()->neq('postedAt', null)) ->orderBy(array('postedAt' => Criteria::ASC)) ; return $this->getPostings()->matching($criteria); }
php
public function getPostedPostings() { $criteria = Criteria::create() ->where(Criteria::expr()->neq('postedAt', null)) ->orderBy(array('postedAt' => Criteria::ASC)) ; return $this->getPostings()->matching($criteria); }
[ "public", "function", "getPostedPostings", "(", ")", "{", "$", "criteria", "=", "Criteria", "::", "create", "(", ")", "->", "where", "(", "Criteria", "::", "expr", "(", ")", "->", "neq", "(", "'postedAt'", ",", "null", ")", ")", "->", "orderBy", "(", "array", "(", "'postedAt'", "=>", "Criteria", "::", "ASC", ")", ")", ";", "return", "$", "this", "->", "getPostings", "(", ")", "->", "matching", "(", "$", "criteria", ")", ";", "}" ]
Get posted Postings @author Tom Haskins-Vaughan <[email protected]> @since 0.8.0 @return ArrayCollection|Posting
[ "Get", "posted", "Postings" ]
d9c421f30922b461483731983c59beb26047fb7f
https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/Account.php#L672-L680
train
phospr/DoubleEntryBundle
Model/Account.php
Account.getUnpostedPostings
public function getUnpostedPostings() { $criteria = Criteria::create() ->where(Criteria::expr()->eq('postedAt', null)) ; return $this->getPostings()->matching($criteria); }
php
public function getUnpostedPostings() { $criteria = Criteria::create() ->where(Criteria::expr()->eq('postedAt', null)) ; return $this->getPostings()->matching($criteria); }
[ "public", "function", "getUnpostedPostings", "(", ")", "{", "$", "criteria", "=", "Criteria", "::", "create", "(", ")", "->", "where", "(", "Criteria", "::", "expr", "(", ")", "->", "eq", "(", "'postedAt'", ",", "null", ")", ")", ";", "return", "$", "this", "->", "getPostings", "(", ")", "->", "matching", "(", "$", "criteria", ")", ";", "}" ]
Get unposted Postings @author Tom Haskins-Vaughan <[email protected]> @since 0.8.0 @return ArrayCollection|Posting
[ "Get", "unposted", "Postings" ]
d9c421f30922b461483731983c59beb26047fb7f
https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/Account.php#L690-L697
train
phospr/DoubleEntryBundle
Model/Account.php
Account.getChildForName
public function getChildForName($name) { $criteria = Criteria::create() ->where(Criteria::expr()->eq('name', $name)) ; return $this->getChildren()->matching($criteria)->first(); }
php
public function getChildForName($name) { $criteria = Criteria::create() ->where(Criteria::expr()->eq('name', $name)) ; return $this->getChildren()->matching($criteria)->first(); }
[ "public", "function", "getChildForName", "(", "$", "name", ")", "{", "$", "criteria", "=", "Criteria", "::", "create", "(", ")", "->", "where", "(", "Criteria", "::", "expr", "(", ")", "->", "eq", "(", "'name'", ",", "$", "name", ")", ")", ";", "return", "$", "this", "->", "getChildren", "(", ")", "->", "matching", "(", "$", "criteria", ")", "->", "first", "(", ")", ";", "}" ]
Get a child account by name @author Tom Haskins-Vaughan <[email protected]> @since 0.8.0 @param string $name @return Account
[ "Get", "a", "child", "account", "by", "name" ]
d9c421f30922b461483731983c59beb26047fb7f
https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/Account.php#L709-L716
train
RudyMas/Emvc_Router
src/Router/Router.php
Router.respondOnOptionsRequest
private function respondOnOptionsRequest(int $httpResponseCode): void { http_response_code($httpResponseCode); header('Content-Type: application/json'); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: *'); exit; }
php
private function respondOnOptionsRequest(int $httpResponseCode): void { http_response_code($httpResponseCode); header('Content-Type: application/json'); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: *'); exit; }
[ "private", "function", "respondOnOptionsRequest", "(", "int", "$", "httpResponseCode", ")", ":", "void", "{", "http_response_code", "(", "$", "httpResponseCode", ")", ";", "header", "(", "'Content-Type: application/json'", ")", ";", "header", "(", "'Access-Control-Allow-Origin: *'", ")", ";", "header", "(", "'Access-Control-Allow-Headers: *'", ")", ";", "exit", ";", "}" ]
Send confirmation for an OPTIONS request @param int $httpResponseCode
[ "Send", "confirmation", "for", "an", "OPTIONS", "request" ]
80eada990a5f9471d7516e988d464ba2bfa9ebd3
https://github.com/RudyMas/Emvc_Router/blob/80eada990a5f9471d7516e988d464ba2bfa9ebd3/src/Router/Router.php#L344-L351
train
RudyMas/Emvc_Router
src/Router/Router.php
Router.checkFunctions
private function checkFunctions() { if (!function_exists('apache_request_headers')) { function apache_request_headers() { $arh = array(); $rx_http = '/\AHTTP_/'; foreach ($_SERVER as $key => $val) { if (preg_match($rx_http, $key)) { $arh_key = preg_replace($rx_http, '', $key); $rx_matches = explode('_', $arh_key); if (count($rx_matches) > 0 and strlen($arh_key) > 2) { foreach ($rx_matches as $ak_key => $ak_val) { $rx_matches[$ak_key] = ucfirst($ak_val); } $arh_key = implode('-', $rx_matches); } $arh[$arh_key] = $val; } } return ($arh); } } }
php
private function checkFunctions() { if (!function_exists('apache_request_headers')) { function apache_request_headers() { $arh = array(); $rx_http = '/\AHTTP_/'; foreach ($_SERVER as $key => $val) { if (preg_match($rx_http, $key)) { $arh_key = preg_replace($rx_http, '', $key); $rx_matches = explode('_', $arh_key); if (count($rx_matches) > 0 and strlen($arh_key) > 2) { foreach ($rx_matches as $ak_key => $ak_val) { $rx_matches[$ak_key] = ucfirst($ak_val); } $arh_key = implode('-', $rx_matches); } $arh[$arh_key] = $val; } } return ($arh); } } }
[ "private", "function", "checkFunctions", "(", ")", "{", "if", "(", "!", "function_exists", "(", "'apache_request_headers'", ")", ")", "{", "function", "apache_request_headers", "(", ")", "{", "$", "arh", "=", "array", "(", ")", ";", "$", "rx_http", "=", "'/\\AHTTP_/'", ";", "foreach", "(", "$", "_SERVER", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "preg_match", "(", "$", "rx_http", ",", "$", "key", ")", ")", "{", "$", "arh_key", "=", "preg_replace", "(", "$", "rx_http", ",", "''", ",", "$", "key", ")", ";", "$", "rx_matches", "=", "explode", "(", "'_'", ",", "$", "arh_key", ")", ";", "if", "(", "count", "(", "$", "rx_matches", ")", ">", "0", "and", "strlen", "(", "$", "arh_key", ")", ">", "2", ")", "{", "foreach", "(", "$", "rx_matches", "as", "$", "ak_key", "=>", "$", "ak_val", ")", "{", "$", "rx_matches", "[", "$", "ak_key", "]", "=", "ucfirst", "(", "$", "ak_val", ")", ";", "}", "$", "arh_key", "=", "implode", "(", "'-'", ",", "$", "rx_matches", ")", ";", "}", "$", "arh", "[", "$", "arh_key", "]", "=", "$", "val", ";", "}", "}", "return", "(", "$", "arh", ")", ";", "}", "}", "}" ]
Checks if a certain function exists on the server, or not. I needed to add this, because else the router wouldn't work on a NGINX server!
[ "Checks", "if", "a", "certain", "function", "exists", "on", "the", "server", "or", "not", ".", "I", "needed", "to", "add", "this", "because", "else", "the", "router", "wouldn", "t", "work", "on", "a", "NGINX", "server!" ]
80eada990a5f9471d7516e988d464ba2bfa9ebd3
https://github.com/RudyMas/Emvc_Router/blob/80eada990a5f9471d7516e988d464ba2bfa9ebd3/src/Router/Router.php#L357-L380
train
mageware/magento2-common
Model/Feed.php
Feed.getFeedXml
protected function getFeedXml() { $client = $this->curlFactory->create(); $client->setConfig($this->getCurlConfig()); $client->write(\Zend_Http_Client::GET, self::ENDPOINT, '1.0'); $response = $client->read(); $client->close(); if (false !== $response) { $data = preg_split('/^\r?$/m', $response, 2); try { $xml = new \SimpleXMLElement(trim($data[1])); } catch (\Exception $e) { return false; } return $xml; } return false; }
php
protected function getFeedXml() { $client = $this->curlFactory->create(); $client->setConfig($this->getCurlConfig()); $client->write(\Zend_Http_Client::GET, self::ENDPOINT, '1.0'); $response = $client->read(); $client->close(); if (false !== $response) { $data = preg_split('/^\r?$/m', $response, 2); try { $xml = new \SimpleXMLElement(trim($data[1])); } catch (\Exception $e) { return false; } return $xml; } return false; }
[ "protected", "function", "getFeedXml", "(", ")", "{", "$", "client", "=", "$", "this", "->", "curlFactory", "->", "create", "(", ")", ";", "$", "client", "->", "setConfig", "(", "$", "this", "->", "getCurlConfig", "(", ")", ")", ";", "$", "client", "->", "write", "(", "\\", "Zend_Http_Client", "::", "GET", ",", "self", "::", "ENDPOINT", ",", "'1.0'", ")", ";", "$", "response", "=", "$", "client", "->", "read", "(", ")", ";", "$", "client", "->", "close", "(", ")", ";", "if", "(", "false", "!==", "$", "response", ")", "{", "$", "data", "=", "preg_split", "(", "'/^\\r?$/m'", ",", "$", "response", ",", "2", ")", ";", "try", "{", "$", "xml", "=", "new", "\\", "SimpleXMLElement", "(", "trim", "(", "$", "data", "[", "1", "]", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "$", "xml", ";", "}", "return", "false", ";", "}" ]
Retrieve feed data as XML element @return \SimpleXMLElement|bool
[ "Retrieve", "feed", "data", "as", "XML", "element" ]
3cf0dff5600f614d9081a4d585e257bbec27b1e6
https://github.com/mageware/magento2-common/blob/3cf0dff5600f614d9081a4d585e257bbec27b1e6/Model/Feed.php#L83-L106
train
mageware/magento2-common
Model/Feed.php
Feed.getCurlConfig
protected function getCurlConfig() { $useragent = $this->productMetadata->getName() . '/' . $this->productMetadata->getVersion() . ' (' . $this->productMetadata->getEdition() . ')'; return [ 'useragent' => $useragent, 'timeout' => 2 ]; }
php
protected function getCurlConfig() { $useragent = $this->productMetadata->getName() . '/' . $this->productMetadata->getVersion() . ' (' . $this->productMetadata->getEdition() . ')'; return [ 'useragent' => $useragent, 'timeout' => 2 ]; }
[ "protected", "function", "getCurlConfig", "(", ")", "{", "$", "useragent", "=", "$", "this", "->", "productMetadata", "->", "getName", "(", ")", ".", "'/'", ".", "$", "this", "->", "productMetadata", "->", "getVersion", "(", ")", ".", "' ('", ".", "$", "this", "->", "productMetadata", "->", "getEdition", "(", ")", ".", "')'", ";", "return", "[", "'useragent'", "=>", "$", "useragent", ",", "'timeout'", "=>", "2", "]", ";", "}" ]
Retrieve config for curl @return array
[ "Retrieve", "config", "for", "curl" ]
3cf0dff5600f614d9081a4d585e257bbec27b1e6
https://github.com/mageware/magento2-common/blob/3cf0dff5600f614d9081a4d585e257bbec27b1e6/Model/Feed.php#L113-L123
train
anime-db/catalog-bundle
src/Service/Item/ListControls.php
ListControls.getLimit
public function getLimit(array $query = []) { if (isset($query['limit']) && is_numeric($query['limit']) && in_array($query['limit'], self::$limits)) { return (int) $query['limit']; } return self::DEFAULT_LIMIT; }
php
public function getLimit(array $query = []) { if (isset($query['limit']) && is_numeric($query['limit']) && in_array($query['limit'], self::$limits)) { return (int) $query['limit']; } return self::DEFAULT_LIMIT; }
[ "public", "function", "getLimit", "(", "array", "$", "query", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "query", "[", "'limit'", "]", ")", "&&", "is_numeric", "(", "$", "query", "[", "'limit'", "]", ")", "&&", "in_array", "(", "$", "query", "[", "'limit'", "]", ",", "self", "::", "$", "limits", ")", ")", "{", "return", "(", "int", ")", "$", "query", "[", "'limit'", "]", ";", "}", "return", "self", "::", "DEFAULT_LIMIT", ";", "}" ]
Get limit list items. @param array $query @return int
[ "Get", "limit", "list", "items", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Service/Item/ListControls.php#L95-L102
train
anime-db/catalog-bundle
src/Service/Item/ListControls.php
ListControls.getLimits
public function getLimits(array $query = []) { $limits = []; $current_limit = $this->getLimit($query); foreach (self::$limits as $limit) { $limits[] = [ 'link' => '?'.http_build_query(array_merge($query, ['limit' => $limit])), 'name' => $limit ? $limit : self::LIMIT_ALL_NAME, 'count' => $limit, 'current' => $current_limit == $limit, ]; } return $limits; }
php
public function getLimits(array $query = []) { $limits = []; $current_limit = $this->getLimit($query); foreach (self::$limits as $limit) { $limits[] = [ 'link' => '?'.http_build_query(array_merge($query, ['limit' => $limit])), 'name' => $limit ? $limit : self::LIMIT_ALL_NAME, 'count' => $limit, 'current' => $current_limit == $limit, ]; } return $limits; }
[ "public", "function", "getLimits", "(", "array", "$", "query", "=", "[", "]", ")", "{", "$", "limits", "=", "[", "]", ";", "$", "current_limit", "=", "$", "this", "->", "getLimit", "(", "$", "query", ")", ";", "foreach", "(", "self", "::", "$", "limits", "as", "$", "limit", ")", "{", "$", "limits", "[", "]", "=", "[", "'link'", "=>", "'?'", ".", "http_build_query", "(", "array_merge", "(", "$", "query", ",", "[", "'limit'", "=>", "$", "limit", "]", ")", ")", ",", "'name'", "=>", "$", "limit", "?", "$", "limit", ":", "self", "::", "LIMIT_ALL_NAME", ",", "'count'", "=>", "$", "limit", ",", "'current'", "=>", "$", "current_limit", "==", "$", "limit", ",", "]", ";", "}", "return", "$", "limits", ";", "}" ]
Get list limits. @param array $query @return array
[ "Get", "list", "limits", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Service/Item/ListControls.php#L111-L126
train
SagittariusX/Beluga.IO
src/Beluga/IO/MimeTypeTool.php
MimeTypeTool.GetByExtension
public static function GetByExtension( string $extension ) : string { $normalizedExtension = \strtolower( \ltrim( $extension, '.' ) ); if ( isset( static::$mimeTypes[ $normalizedExtension ] ) ) { return static::$mimeTypes[ $normalizedExtension ]; } return 'application/octet-stream'; }
php
public static function GetByExtension( string $extension ) : string { $normalizedExtension = \strtolower( \ltrim( $extension, '.' ) ); if ( isset( static::$mimeTypes[ $normalizedExtension ] ) ) { return static::$mimeTypes[ $normalizedExtension ]; } return 'application/octet-stream'; }
[ "public", "static", "function", "GetByExtension", "(", "string", "$", "extension", ")", ":", "string", "{", "$", "normalizedExtension", "=", "\\", "strtolower", "(", "\\", "ltrim", "(", "$", "extension", ",", "'.'", ")", ")", ";", "if", "(", "isset", "(", "static", "::", "$", "mimeTypes", "[", "$", "normalizedExtension", "]", ")", ")", "{", "return", "static", "::", "$", "mimeTypes", "[", "$", "normalizedExtension", "]", ";", "}", "return", "'application/octet-stream'", ";", "}" ]
Returns the MIME type, associated with the defined file name extension. @param string $extension The file name extension (with or without the leading dot) @return string Returns the MIME type
[ "Returns", "the", "MIME", "type", "associated", "with", "the", "defined", "file", "name", "extension", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/MimeTypeTool.php#L210-L222
train
SagittariusX/Beluga.IO
src/Beluga/IO/MimeTypeTool.php
MimeTypeTool.HasGifHeader
public static function HasGifHeader( string $file, string $firstBytes = null ) : bool { if ( empty( $firstBytes ) ) { $firstBytes = File::ReadFirstBytes( $file, 6 ); } return (bool) \preg_match( '~^GIF\d~', $firstBytes ); }
php
public static function HasGifHeader( string $file, string $firstBytes = null ) : bool { if ( empty( $firstBytes ) ) { $firstBytes = File::ReadFirstBytes( $file, 6 ); } return (bool) \preg_match( '~^GIF\d~', $firstBytes ); }
[ "public", "static", "function", "HasGifHeader", "(", "string", "$", "file", ",", "string", "$", "firstBytes", "=", "null", ")", ":", "bool", "{", "if", "(", "empty", "(", "$", "firstBytes", ")", ")", "{", "$", "firstBytes", "=", "File", "::", "ReadFirstBytes", "(", "$", "file", ",", "6", ")", ";", "}", "return", "(", "bool", ")", "\\", "preg_match", "(", "'~^GIF\\d~'", ",", "$", "firstBytes", ")", ";", "}" ]
Returns if the defined file uses a valid GIF image file header. @param string $file @param string $firstBytes If defined it is used to get image info from. @return boolean
[ "Returns", "if", "the", "defined", "file", "uses", "a", "valid", "GIF", "image", "file", "header", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/MimeTypeTool.php#L283-L293
train
SagittariusX/Beluga.IO
src/Beluga/IO/MimeTypeTool.php
MimeTypeTool.HasJpegHeader
public static function HasJpegHeader( string $file, string $firstBytes = null ) : bool { if ( empty( $firstBytes ) ) { $firstBytes = File::ReadFirstBytes( $file, 4 ); } return ( ( 'ff' == \dechex( \ord( $firstBytes [ 0 ] ) ) ) && ( 'd8' == \dechex( \ord( $firstBytes [ 1 ] ) ) ) && ( 'ff' == \dechex( \ord( $firstBytes [ 2 ] ) ) ) ); }
php
public static function HasJpegHeader( string $file, string $firstBytes = null ) : bool { if ( empty( $firstBytes ) ) { $firstBytes = File::ReadFirstBytes( $file, 4 ); } return ( ( 'ff' == \dechex( \ord( $firstBytes [ 0 ] ) ) ) && ( 'd8' == \dechex( \ord( $firstBytes [ 1 ] ) ) ) && ( 'ff' == \dechex( \ord( $firstBytes [ 2 ] ) ) ) ); }
[ "public", "static", "function", "HasJpegHeader", "(", "string", "$", "file", ",", "string", "$", "firstBytes", "=", "null", ")", ":", "bool", "{", "if", "(", "empty", "(", "$", "firstBytes", ")", ")", "{", "$", "firstBytes", "=", "File", "::", "ReadFirstBytes", "(", "$", "file", ",", "4", ")", ";", "}", "return", "(", "(", "'ff'", "==", "\\", "dechex", "(", "\\", "ord", "(", "$", "firstBytes", "[", "0", "]", ")", ")", ")", "&&", "(", "'d8'", "==", "\\", "dechex", "(", "\\", "ord", "(", "$", "firstBytes", "[", "1", "]", ")", ")", ")", "&&", "(", "'ff'", "==", "\\", "dechex", "(", "\\", "ord", "(", "$", "firstBytes", "[", "2", "]", ")", ")", ")", ")", ";", "}" ]
Returns if the defined file uses a valid JPEG image file header. @param string $file @param string $firstBytes If defined it is used to get image info from. @return boolean
[ "Returns", "if", "the", "defined", "file", "uses", "a", "valid", "JPEG", "image", "file", "header", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/MimeTypeTool.php#L302-L316
train
SagittariusX/Beluga.IO
src/Beluga/IO/MimeTypeTool.php
MimeTypeTool.GetWebImageMimeTypeByHeaderCode
public static function GetWebImageMimeTypeByHeaderCode( string $file ) { $f8b = File::ReadFirstBytes( $file, 8 ); $ext = \strtolower( File::GetExtensionName( $file ) ); switch ( $ext ) { case 'gif': if ( static::HasGifHeader( $file, $f8b ) ) { return 'image/gif'; } return false; case 'jpg': case 'jpeg': if ( static::HasJpegHeader( $file, $f8b ) ) { return 'image/jpeg'; } return false; case 'png': if ( static::HasPngHeader( $file, $f8b ) ) { return 'image/png'; } return false; default: return false; } }
php
public static function GetWebImageMimeTypeByHeaderCode( string $file ) { $f8b = File::ReadFirstBytes( $file, 8 ); $ext = \strtolower( File::GetExtensionName( $file ) ); switch ( $ext ) { case 'gif': if ( static::HasGifHeader( $file, $f8b ) ) { return 'image/gif'; } return false; case 'jpg': case 'jpeg': if ( static::HasJpegHeader( $file, $f8b ) ) { return 'image/jpeg'; } return false; case 'png': if ( static::HasPngHeader( $file, $f8b ) ) { return 'image/png'; } return false; default: return false; } }
[ "public", "static", "function", "GetWebImageMimeTypeByHeaderCode", "(", "string", "$", "file", ")", "{", "$", "f8b", "=", "File", "::", "ReadFirstBytes", "(", "$", "file", ",", "8", ")", ";", "$", "ext", "=", "\\", "strtolower", "(", "File", "::", "GetExtensionName", "(", "$", "file", ")", ")", ";", "switch", "(", "$", "ext", ")", "{", "case", "'gif'", ":", "if", "(", "static", "::", "HasGifHeader", "(", "$", "file", ",", "$", "f8b", ")", ")", "{", "return", "'image/gif'", ";", "}", "return", "false", ";", "case", "'jpg'", ":", "case", "'jpeg'", ":", "if", "(", "static", "::", "HasJpegHeader", "(", "$", "file", ",", "$", "f8b", ")", ")", "{", "return", "'image/jpeg'", ";", "}", "return", "false", ";", "case", "'png'", ":", "if", "(", "static", "::", "HasPngHeader", "(", "$", "file", ",", "$", "f8b", ")", ")", "{", "return", "'image/png'", ";", "}", "return", "false", ";", "default", ":", "return", "false", ";", "}", "}" ]
Returns the web image MIME type, depending to file name extension and used image file header. If its not a web image FALSE is returned. Valid web image ar images of type GIF, PNG and JPEG. @param string $file @return string|FALSE
[ "Returns", "the", "web", "image", "MIME", "type", "depending", "to", "file", "name", "extension", "and", "used", "image", "file", "header", "." ]
c8af09a1b3cc8a955e43c89b70779d11b30ae29e
https://github.com/SagittariusX/Beluga.IO/blob/c8af09a1b3cc8a955e43c89b70779d11b30ae29e/src/Beluga/IO/MimeTypeTool.php#L351-L379
train
CeusMedia/Router
src/Registry.php
Registry.add
public function add( Route $route ){ $routeId = $route->getId(); if( array_key_exists( $routeId, $this->routes ) ){ throw new \DomainException( sprintf( 'A route for pattern and method is already registered: %2$s %1$s', $route->getPattern(), $route->getMethod() ) ); } $this->routes[$routeId] = $route; return $routeId; }
php
public function add( Route $route ){ $routeId = $route->getId(); if( array_key_exists( $routeId, $this->routes ) ){ throw new \DomainException( sprintf( 'A route for pattern and method is already registered: %2$s %1$s', $route->getPattern(), $route->getMethod() ) ); } $this->routes[$routeId] = $route; return $routeId; }
[ "public", "function", "add", "(", "Route", "$", "route", ")", "{", "$", "routeId", "=", "$", "route", "->", "getId", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "routeId", ",", "$", "this", "->", "routes", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "sprintf", "(", "'A route for pattern and method is already registered: %2$s %1$s'", ",", "$", "route", "->", "getPattern", "(", ")", ",", "$", "route", "->", "getMethod", "(", ")", ")", ")", ";", "}", "$", "this", "->", "routes", "[", "$", "routeId", "]", "=", "$", "route", ";", "return", "$", "routeId", ";", "}" ]
Adds route to route registry by route object. @access public @param Route $route Route object @return string ID of added route @throws DomainException if route is already registered by route ID
[ "Adds", "route", "to", "route", "registry", "by", "route", "object", "." ]
d4c68e8c2895abf5c13835e1671635507e2fb21d
https://github.com/CeusMedia/Router/blob/d4c68e8c2895abf5c13835e1671635507e2fb21d/src/Registry.php#L51-L62
train
CeusMedia/Router
src/Registry.php
Registry.loadFromJsonFile
public function loadFromJsonFile( $filePath, $folderPath = NULL ){ if( !file_exists( $filePath ) && $folderPath ){ $this->assembleJsonFileFromFolder( $filePath, $folderPath ); } $data = \FS_File_JSON_Reader::load( $filePath ); foreach( $data as $item ){ if( !isset( $item->controller ) ) throw new \OutOfRangeException( 'Route set is missing controller' ); if( !isset( $item->action ) ) throw new \OutOfRangeException( 'Route set is missing action' ); if( !isset( $item->pattern ) ) throw new \OutOfRangeException( 'Route set is missing pattern' ); if( !isset( $item->method ) ) throw new \OutOfRangeException( 'Route set is missing method' ); $route = new Route( $item->controller, $item->action, $item->pattern, $item->method, isset( $item->roles ) ? preg_split( "/, */", trim( $item->roles ) ) : array() ); $this->add( $route ); } }
php
public function loadFromJsonFile( $filePath, $folderPath = NULL ){ if( !file_exists( $filePath ) && $folderPath ){ $this->assembleJsonFileFromFolder( $filePath, $folderPath ); } $data = \FS_File_JSON_Reader::load( $filePath ); foreach( $data as $item ){ if( !isset( $item->controller ) ) throw new \OutOfRangeException( 'Route set is missing controller' ); if( !isset( $item->action ) ) throw new \OutOfRangeException( 'Route set is missing action' ); if( !isset( $item->pattern ) ) throw new \OutOfRangeException( 'Route set is missing pattern' ); if( !isset( $item->method ) ) throw new \OutOfRangeException( 'Route set is missing method' ); $route = new Route( $item->controller, $item->action, $item->pattern, $item->method, isset( $item->roles ) ? preg_split( "/, */", trim( $item->roles ) ) : array() ); $this->add( $route ); } }
[ "public", "function", "loadFromJsonFile", "(", "$", "filePath", ",", "$", "folderPath", "=", "NULL", ")", "{", "if", "(", "!", "file_exists", "(", "$", "filePath", ")", "&&", "$", "folderPath", ")", "{", "$", "this", "->", "assembleJsonFileFromFolder", "(", "$", "filePath", ",", "$", "folderPath", ")", ";", "}", "$", "data", "=", "\\", "FS_File_JSON_Reader", "::", "load", "(", "$", "filePath", ")", ";", "foreach", "(", "$", "data", "as", "$", "item", ")", "{", "if", "(", "!", "isset", "(", "$", "item", "->", "controller", ")", ")", "throw", "new", "\\", "OutOfRangeException", "(", "'Route set is missing controller'", ")", ";", "if", "(", "!", "isset", "(", "$", "item", "->", "action", ")", ")", "throw", "new", "\\", "OutOfRangeException", "(", "'Route set is missing action'", ")", ";", "if", "(", "!", "isset", "(", "$", "item", "->", "pattern", ")", ")", "throw", "new", "\\", "OutOfRangeException", "(", "'Route set is missing pattern'", ")", ";", "if", "(", "!", "isset", "(", "$", "item", "->", "method", ")", ")", "throw", "new", "\\", "OutOfRangeException", "(", "'Route set is missing method'", ")", ";", "$", "route", "=", "new", "Route", "(", "$", "item", "->", "controller", ",", "$", "item", "->", "action", ",", "$", "item", "->", "pattern", ",", "$", "item", "->", "method", ",", "isset", "(", "$", "item", "->", "roles", ")", "?", "preg_split", "(", "\"/, */\"", ",", "trim", "(", "$", "item", "->", "roles", ")", ")", ":", "array", "(", ")", ")", ";", "$", "this", "->", "add", "(", "$", "route", ")", ";", "}", "}" ]
Adds a list of routes defined in a JSON file. @access public @param string $filePath Relative or absolute file path of JSON file to load @param string $folderPath Relative or absolute path to folder containing JSON files to assemble @return void @throws OutOfRangeException if route set has no controller @throws OutOfRangeException if route set has no action @throws OutOfRangeException if route set has no pattern @throws OutOfRangeException if route set has no method
[ "Adds", "a", "list", "of", "routes", "defined", "in", "a", "JSON", "file", "." ]
d4c68e8c2895abf5c13835e1671635507e2fb21d
https://github.com/CeusMedia/Router/blob/d4c68e8c2895abf5c13835e1671635507e2fb21d/src/Registry.php#L114-L138
train
CeusMedia/Router
src/Registry.php
Registry.remove
public function remove( $routeId, $strict = TRUE ){ if( array_key_exists( $routeId, $this->routes ) ){ unset( $this->routes[$routeId] ); return TRUE; } if( $strict ) throw new \DomainException( 'No route found for this route ID' ); return FALSE; }
php
public function remove( $routeId, $strict = TRUE ){ if( array_key_exists( $routeId, $this->routes ) ){ unset( $this->routes[$routeId] ); return TRUE; } if( $strict ) throw new \DomainException( 'No route found for this route ID' ); return FALSE; }
[ "public", "function", "remove", "(", "$", "routeId", ",", "$", "strict", "=", "TRUE", ")", "{", "if", "(", "array_key_exists", "(", "$", "routeId", ",", "$", "this", "->", "routes", ")", ")", "{", "unset", "(", "$", "this", "->", "routes", "[", "$", "routeId", "]", ")", ";", "return", "TRUE", ";", "}", "if", "(", "$", "strict", ")", "throw", "new", "\\", "DomainException", "(", "'No route found for this route ID'", ")", ";", "return", "FALSE", ";", "}" ]
Removes a route from route registry by its ID. @access public @param string $routeId ID of route @param boolean $strict Throw exception if route ID is invalid @return boolean TRUE is route existed and has been removed @throws DomainException if route ID has not been found in registry (strict mode only)
[ "Removes", "a", "route", "from", "route", "registry", "by", "its", "ID", "." ]
d4c68e8c2895abf5c13835e1671635507e2fb21d
https://github.com/CeusMedia/Router/blob/d4c68e8c2895abf5c13835e1671635507e2fb21d/src/Registry.php#L148-L156
train
phpffcms/ffcms-core
src/Arch/Widget.php
Widget.widget
public static function widget(?array $params = null): ?string { self::$class = get_called_class(); self::$view = App::$View; self::$request = App::$Request; self::$response = App::$Response; // check if class exist if (!class_exists(self::$class)) { return 'Error: Widget is not founded: ' . self::$class; } /** @var iWidget $object */ $object = new self::$class; if (Any::isArray($params) && count($params) > 0) { foreach ($params as $property => $value) { if (property_exists($object, $property)) { $object->{$property} = $value; } } } // initialize widget $object->init(); return $object->display(); }
php
public static function widget(?array $params = null): ?string { self::$class = get_called_class(); self::$view = App::$View; self::$request = App::$Request; self::$response = App::$Response; // check if class exist if (!class_exists(self::$class)) { return 'Error: Widget is not founded: ' . self::$class; } /** @var iWidget $object */ $object = new self::$class; if (Any::isArray($params) && count($params) > 0) { foreach ($params as $property => $value) { if (property_exists($object, $property)) { $object->{$property} = $value; } } } // initialize widget $object->init(); return $object->display(); }
[ "public", "static", "function", "widget", "(", "?", "array", "$", "params", "=", "null", ")", ":", "?", "string", "{", "self", "::", "$", "class", "=", "get_called_class", "(", ")", ";", "self", "::", "$", "view", "=", "App", "::", "$", "View", ";", "self", "::", "$", "request", "=", "App", "::", "$", "Request", ";", "self", "::", "$", "response", "=", "App", "::", "$", "Response", ";", "// check if class exist", "if", "(", "!", "class_exists", "(", "self", "::", "$", "class", ")", ")", "{", "return", "'Error: Widget is not founded: '", ".", "self", "::", "$", "class", ";", "}", "/** @var iWidget $object */", "$", "object", "=", "new", "self", "::", "$", "class", ";", "if", "(", "Any", "::", "isArray", "(", "$", "params", ")", "&&", "count", "(", "$", "params", ")", ">", "0", ")", "{", "foreach", "(", "$", "params", "as", "$", "property", "=>", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "object", ",", "$", "property", ")", ")", "{", "$", "object", "->", "{", "$", "property", "}", "=", "$", "value", ";", "}", "}", "}", "// initialize widget", "$", "object", "->", "init", "(", ")", ";", "return", "$", "object", "->", "display", "(", ")", ";", "}" ]
Build and display widget @param array|null $params @return null|string
[ "Build", "and", "display", "widget" ]
44a309553ef9f115ccfcfd71f2ac6e381c612082
https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Arch/Widget.php#L29-L54
train
agentmedia/phine-core
src/Core/Modules/Backend/ContainerList.php
ContainerList.CanCreate
protected function CanCreate() { return self::Guard()->Allow(BackendAction::Create(), new Container()) && self::Guard()->Allow(BackendAction::UseIt(), new ContainerForm()); }
php
protected function CanCreate() { return self::Guard()->Allow(BackendAction::Create(), new Container()) && self::Guard()->Allow(BackendAction::UseIt(), new ContainerForm()); }
[ "protected", "function", "CanCreate", "(", ")", "{", "return", "self", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "Create", "(", ")", ",", "new", "Container", "(", ")", ")", "&&", "self", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "UseIt", "(", ")", ",", "new", "ContainerForm", "(", ")", ")", ";", "}" ]
True if a new container can be created @return bool
[ "True", "if", "a", "new", "container", "can", "be", "created" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/ContainerList.php#L109-L113
train
agentmedia/phine-core
src/Core/Modules/Backend/ContainerList.php
ContainerList.CanEdit
protected function CanEdit(Container $container) { return self::Guard()->Allow(BackendAction::Edit(), $container) && self::Guard()->Allow(BackendAction::UseIt(), new ContainerForm()); }
php
protected function CanEdit(Container $container) { return self::Guard()->Allow(BackendAction::Edit(), $container) && self::Guard()->Allow(BackendAction::UseIt(), new ContainerForm()); }
[ "protected", "function", "CanEdit", "(", "Container", "$", "container", ")", "{", "return", "self", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "Edit", "(", ")", ",", "$", "container", ")", "&&", "self", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "UseIt", "(", ")", ",", "new", "ContainerForm", "(", ")", ")", ";", "}" ]
True if the container can be edited @param Container $container @return boolean
[ "True", "if", "the", "container", "can", "be", "edited" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/ContainerList.php#L119-L123
train
brightnucleus/options-store
src/Option/OptionTrait.php
OptionTrait.setValue
public function setValue($value, $persist = true) { if ($this->isEmpty($value) && ! $this->flags & Value::CAN_BE_EMPTY) { throw FailedToValidate::fromValue($value, $this); } if (! $this->isEmpty($value)) { $value = $this->validate($value); } if (null === $value) { throw FailedToValidate::fromValue($value, $this); } $this->value = $value; if (! $persist ) { return $this; } $repository = IdentityMap::getInstance()->getRepository($this->key); $repository->save($this); return $this; }
php
public function setValue($value, $persist = true) { if ($this->isEmpty($value) && ! $this->flags & Value::CAN_BE_EMPTY) { throw FailedToValidate::fromValue($value, $this); } if (! $this->isEmpty($value)) { $value = $this->validate($value); } if (null === $value) { throw FailedToValidate::fromValue($value, $this); } $this->value = $value; if (! $persist ) { return $this; } $repository = IdentityMap::getInstance()->getRepository($this->key); $repository->save($this); return $this; }
[ "public", "function", "setValue", "(", "$", "value", ",", "$", "persist", "=", "true", ")", "{", "if", "(", "$", "this", "->", "isEmpty", "(", "$", "value", ")", "&&", "!", "$", "this", "->", "flags", "&", "Value", "::", "CAN_BE_EMPTY", ")", "{", "throw", "FailedToValidate", "::", "fromValue", "(", "$", "value", ",", "$", "this", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isEmpty", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "validate", "(", "$", "value", ")", ";", "}", "if", "(", "null", "===", "$", "value", ")", "{", "throw", "FailedToValidate", "::", "fromValue", "(", "$", "value", ",", "$", "this", ")", ";", "}", "$", "this", "->", "value", "=", "$", "value", ";", "if", "(", "!", "$", "persist", ")", "{", "return", "$", "this", ";", "}", "$", "repository", "=", "IdentityMap", "::", "getInstance", "(", ")", "->", "getRepository", "(", "$", "this", "->", "key", ")", ";", "$", "repository", "->", "save", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Set the raw value. @since 0.1.0 @param mixed $value New raw value. @param bool $persist Optional. Whether to immediately persist the value. @return Option Modified Option object. Can differ from the original one.
[ "Set", "the", "raw", "value", "." ]
9a9ef2a160bbacd69fe3e9db0be8ed89e6905ef1
https://github.com/brightnucleus/options-store/blob/9a9ef2a160bbacd69fe3e9db0be8ed89e6905ef1/src/Option/OptionTrait.php#L83-L107
train
jdmaymeow/cake-utility
src/Random/Dice.php
Dice.roll
public function roll($config = '1x6') { // parse config and set variables $config = $this->parseConfig($config); $diceType = $config[2]; $count = $config[1]; // initialize rolls and value variables $rolls = []; $value = 0; // roll dice for ($i = 1; $i <= $count; $i++) { $roll = $this->random->getRand(1, $diceType); $rolls[$i] = $roll; $value += $roll; } // set data and retun them $this->data['rolls'] = $rolls; $this->data['value'] = $value; return $this->data; }
php
public function roll($config = '1x6') { // parse config and set variables $config = $this->parseConfig($config); $diceType = $config[2]; $count = $config[1]; // initialize rolls and value variables $rolls = []; $value = 0; // roll dice for ($i = 1; $i <= $count; $i++) { $roll = $this->random->getRand(1, $diceType); $rolls[$i] = $roll; $value += $roll; } // set data and retun them $this->data['rolls'] = $rolls; $this->data['value'] = $value; return $this->data; }
[ "public", "function", "roll", "(", "$", "config", "=", "'1x6'", ")", "{", "// parse config and set variables", "$", "config", "=", "$", "this", "->", "parseConfig", "(", "$", "config", ")", ";", "$", "diceType", "=", "$", "config", "[", "2", "]", ";", "$", "count", "=", "$", "config", "[", "1", "]", ";", "// initialize rolls and value variables", "$", "rolls", "=", "[", "]", ";", "$", "value", "=", "0", ";", "// roll dice", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "count", ";", "$", "i", "++", ")", "{", "$", "roll", "=", "$", "this", "->", "random", "->", "getRand", "(", "1", ",", "$", "diceType", ")", ";", "$", "rolls", "[", "$", "i", "]", "=", "$", "roll", ";", "$", "value", "+=", "$", "roll", ";", "}", "// set data and retun them", "$", "this", "->", "data", "[", "'rolls'", "]", "=", "$", "rolls", ";", "$", "this", "->", "data", "[", "'value'", "]", "=", "$", "value", ";", "return", "$", "this", "->", "data", ";", "}" ]
Roll Dice and return array with all rolls and sum fo your rolls. @param null $config Config @return array
[ "Roll", "Dice", "and", "return", "array", "with", "all", "rolls", "and", "sum", "fo", "your", "rolls", "." ]
9da54f12a0f41fb1d590924db0c1130978b6e94e
https://github.com/jdmaymeow/cake-utility/blob/9da54f12a0f41fb1d590924db0c1130978b6e94e/src/Random/Dice.php#L36-L55
train
SlabPHP/configuration-manager
src/Manager.php
Manager.buildFileList
private function buildFileList($directories = [], $fileList = []) { $output = []; foreach ($directories as $directory) { foreach ($fileList as $file) { $fileName = $directory . DIRECTORY_SEPARATOR . $file; if (is_file($fileName) && is_readable($fileName)) { $output[] = $fileName; } } } return $output; }
php
private function buildFileList($directories = [], $fileList = []) { $output = []; foreach ($directories as $directory) { foreach ($fileList as $file) { $fileName = $directory . DIRECTORY_SEPARATOR . $file; if (is_file($fileName) && is_readable($fileName)) { $output[] = $fileName; } } } return $output; }
[ "private", "function", "buildFileList", "(", "$", "directories", "=", "[", "]", ",", "$", "fileList", "=", "[", "]", ")", "{", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "directories", "as", "$", "directory", ")", "{", "foreach", "(", "$", "fileList", "as", "$", "file", ")", "{", "$", "fileName", "=", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", ";", "if", "(", "is_file", "(", "$", "fileName", ")", "&&", "is_readable", "(", "$", "fileName", ")", ")", "{", "$", "output", "[", "]", "=", "$", "fileName", ";", "}", "}", "}", "return", "$", "output", ";", "}" ]
Build file list @param array $directories @param array $fileList @return array
[ "Build", "file", "list" ]
3f36b528b8d7b0ffbb43ec933e82efd7312a3397
https://github.com/SlabPHP/configuration-manager/blob/3f36b528b8d7b0ffbb43ec933e82efd7312a3397/src/Manager.php#L114-L128
train
SlabPHP/configuration-manager
src/Manager.php
Manager.parseConfigurationFiles
private function parseConfigurationFiles($fileList) { foreach ($fileList as $file) { if (!is_file($file) || !is_readable($file)) { if ($this->configuration->getLog()) { $this->configuration->getLog()->error("Failed to load configuration file " . $file); } continue; } global $config; $config = array(); include_once($file); foreach ($config as $name => $value) { $this->mergeConfigurationOption($this->_config, $name, $value); } unset($config); if (!empty($GLOBALS['config'])) { unset($GLOBALS['config']); } } //Do a little global cleanup unset($config); if (!empty($GLOBALS['config'])) { unset($GLOBALS['config']); } }
php
private function parseConfigurationFiles($fileList) { foreach ($fileList as $file) { if (!is_file($file) || !is_readable($file)) { if ($this->configuration->getLog()) { $this->configuration->getLog()->error("Failed to load configuration file " . $file); } continue; } global $config; $config = array(); include_once($file); foreach ($config as $name => $value) { $this->mergeConfigurationOption($this->_config, $name, $value); } unset($config); if (!empty($GLOBALS['config'])) { unset($GLOBALS['config']); } } //Do a little global cleanup unset($config); if (!empty($GLOBALS['config'])) { unset($GLOBALS['config']); } }
[ "private", "function", "parseConfigurationFiles", "(", "$", "fileList", ")", "{", "foreach", "(", "$", "fileList", "as", "$", "file", ")", "{", "if", "(", "!", "is_file", "(", "$", "file", ")", "||", "!", "is_readable", "(", "$", "file", ")", ")", "{", "if", "(", "$", "this", "->", "configuration", "->", "getLog", "(", ")", ")", "{", "$", "this", "->", "configuration", "->", "getLog", "(", ")", "->", "error", "(", "\"Failed to load configuration file \"", ".", "$", "file", ")", ";", "}", "continue", ";", "}", "global", "$", "config", ";", "$", "config", "=", "array", "(", ")", ";", "include_once", "(", "$", "file", ")", ";", "foreach", "(", "$", "config", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "mergeConfigurationOption", "(", "$", "this", "->", "_config", ",", "$", "name", ",", "$", "value", ")", ";", "}", "unset", "(", "$", "config", ")", ";", "if", "(", "!", "empty", "(", "$", "GLOBALS", "[", "'config'", "]", ")", ")", "{", "unset", "(", "$", "GLOBALS", "[", "'config'", "]", ")", ";", "}", "}", "//Do a little global cleanup", "unset", "(", "$", "config", ")", ";", "if", "(", "!", "empty", "(", "$", "GLOBALS", "[", "'config'", "]", ")", ")", "{", "unset", "(", "$", "GLOBALS", "[", "'config'", "]", ")", ";", "}", "}" ]
Go through each configuration directory and get the data @param string[] $fileList
[ "Go", "through", "each", "configuration", "directory", "and", "get", "the", "data" ]
3f36b528b8d7b0ffbb43ec933e82efd7312a3397
https://github.com/SlabPHP/configuration-manager/blob/3f36b528b8d7b0ffbb43ec933e82efd7312a3397/src/Manager.php#L136-L167
train
SlabPHP/configuration-manager
src/Manager.php
Manager.mergeConfigurationOption
private function mergeConfigurationOption(&$currentNode, $name, $value) { if (empty($currentNode) || empty($name)) { return; } //We're going to be building our own objects here if (is_object($value)) { $value = (array)$value; } if (is_array($value)) { if ($this->isAssociative($value)) { //An associative array can contain non-leaves, recursively merge them in $childNode = null; if (!empty($currentNode->$name)) { $childNode = $currentNode->$name; } else { $childNode = new Parameter($currentNode, $name); $currentNode->$name = $childNode; } foreach ($value as $subName => $subValue) { $this->mergeConfigurationOption($childNode, $subName, $subValue); } } else { //Simply an array of values, just add them to the node and assume they're leaves if (empty($currentNode->$name)) { $currentNode->$name = array(); } if (!is_array($currentNode->$name)) { $currentNode->$name = array(); } foreach ($value as $subValue) { $currentNode->{$name}[] = $subValue; } } } else { //Yay, a scalar value $currentNode->$name = $value; } }
php
private function mergeConfigurationOption(&$currentNode, $name, $value) { if (empty($currentNode) || empty($name)) { return; } //We're going to be building our own objects here if (is_object($value)) { $value = (array)$value; } if (is_array($value)) { if ($this->isAssociative($value)) { //An associative array can contain non-leaves, recursively merge them in $childNode = null; if (!empty($currentNode->$name)) { $childNode = $currentNode->$name; } else { $childNode = new Parameter($currentNode, $name); $currentNode->$name = $childNode; } foreach ($value as $subName => $subValue) { $this->mergeConfigurationOption($childNode, $subName, $subValue); } } else { //Simply an array of values, just add them to the node and assume they're leaves if (empty($currentNode->$name)) { $currentNode->$name = array(); } if (!is_array($currentNode->$name)) { $currentNode->$name = array(); } foreach ($value as $subValue) { $currentNode->{$name}[] = $subValue; } } } else { //Yay, a scalar value $currentNode->$name = $value; } }
[ "private", "function", "mergeConfigurationOption", "(", "&", "$", "currentNode", ",", "$", "name", ",", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "currentNode", ")", "||", "empty", "(", "$", "name", ")", ")", "{", "return", ";", "}", "//We're going to be building our own objects here", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "(", "array", ")", "$", "value", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "$", "this", "->", "isAssociative", "(", "$", "value", ")", ")", "{", "//An associative array can contain non-leaves, recursively merge them in", "$", "childNode", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "currentNode", "->", "$", "name", ")", ")", "{", "$", "childNode", "=", "$", "currentNode", "->", "$", "name", ";", "}", "else", "{", "$", "childNode", "=", "new", "Parameter", "(", "$", "currentNode", ",", "$", "name", ")", ";", "$", "currentNode", "->", "$", "name", "=", "$", "childNode", ";", "}", "foreach", "(", "$", "value", "as", "$", "subName", "=>", "$", "subValue", ")", "{", "$", "this", "->", "mergeConfigurationOption", "(", "$", "childNode", ",", "$", "subName", ",", "$", "subValue", ")", ";", "}", "}", "else", "{", "//Simply an array of values, just add them to the node and assume they're leaves", "if", "(", "empty", "(", "$", "currentNode", "->", "$", "name", ")", ")", "{", "$", "currentNode", "->", "$", "name", "=", "array", "(", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "currentNode", "->", "$", "name", ")", ")", "{", "$", "currentNode", "->", "$", "name", "=", "array", "(", ")", ";", "}", "foreach", "(", "$", "value", "as", "$", "subValue", ")", "{", "$", "currentNode", "->", "{", "$", "name", "}", "[", "]", "=", "$", "subValue", ";", "}", "}", "}", "else", "{", "//Yay, a scalar value", "$", "currentNode", "->", "$", "name", "=", "$", "value", ";", "}", "}" ]
Merge a configuration option in @param mixed $currentNode @param string $name @param mixed $value
[ "Merge", "a", "configuration", "option", "in" ]
3f36b528b8d7b0ffbb43ec933e82efd7312a3397
https://github.com/SlabPHP/configuration-manager/blob/3f36b528b8d7b0ffbb43ec933e82efd7312a3397/src/Manager.php#L222-L268
train
native5/native5-sdk-client-php
src/Native5/Control/DefaultController.php
DefaultController.execute
public function execute($request) { ob_start(); $logger = $GLOBALS['logger']; $this->_request = $request; $this->_response = new HttpResponse(); try { WebSessionManager::updateActiveSession(); foreach ($this->_preProcessors as $preProcessor) { $preProcessor->process($this->_request); } $functionToCall = $this->command->getFunction(); if (empty($functionToCall) === true) { $functionToCall = 'default'; } if (!is_callable(array(&$this,'_'.$functionToCall))) { $functionToCall = 'error'; } call_user_func(array(&$this,'_'.$functionToCall), $this->_request); foreach ($this->_postProcessors as $postProcessor) { $postProcessor->process($this->_response); } ob_end_clean(); if (empty($this->_response)) { $this->_response = new HttpResponse(); } if($this->_response->getEncoding() == null) { $responseMode = $this->_request->getParam('mode'); if ($responseMode === 'ui') { $this->_response->setEncoding('html'); } else if ($responseMode === 'data') { $this->_response->setEncoding('json'); } } $this->_response->send(); } catch (ServiceException $se) { $this->_response = new HttpResponse(); $response->addHeader('HTTP/1.1 400 Bad Request'); $this->_response->send(); } catch(BadResponseException $bre) { $renderer = new TwigRenderer('500.html'); if($renderer->exists()) { $this->_response = new HttpResponse('none', $renderer); } else $this->_response = new HttpResponse(); $response->addHeader('HTTP/1.1 500 Internal Server Error'); $this->_response->send(); }//end try }
php
public function execute($request) { ob_start(); $logger = $GLOBALS['logger']; $this->_request = $request; $this->_response = new HttpResponse(); try { WebSessionManager::updateActiveSession(); foreach ($this->_preProcessors as $preProcessor) { $preProcessor->process($this->_request); } $functionToCall = $this->command->getFunction(); if (empty($functionToCall) === true) { $functionToCall = 'default'; } if (!is_callable(array(&$this,'_'.$functionToCall))) { $functionToCall = 'error'; } call_user_func(array(&$this,'_'.$functionToCall), $this->_request); foreach ($this->_postProcessors as $postProcessor) { $postProcessor->process($this->_response); } ob_end_clean(); if (empty($this->_response)) { $this->_response = new HttpResponse(); } if($this->_response->getEncoding() == null) { $responseMode = $this->_request->getParam('mode'); if ($responseMode === 'ui') { $this->_response->setEncoding('html'); } else if ($responseMode === 'data') { $this->_response->setEncoding('json'); } } $this->_response->send(); } catch (ServiceException $se) { $this->_response = new HttpResponse(); $response->addHeader('HTTP/1.1 400 Bad Request'); $this->_response->send(); } catch(BadResponseException $bre) { $renderer = new TwigRenderer('500.html'); if($renderer->exists()) { $this->_response = new HttpResponse('none', $renderer); } else $this->_response = new HttpResponse(); $response->addHeader('HTTP/1.1 500 Internal Server Error'); $this->_response->send(); }//end try }
[ "public", "function", "execute", "(", "$", "request", ")", "{", "ob_start", "(", ")", ";", "$", "logger", "=", "$", "GLOBALS", "[", "'logger'", "]", ";", "$", "this", "->", "_request", "=", "$", "request", ";", "$", "this", "->", "_response", "=", "new", "HttpResponse", "(", ")", ";", "try", "{", "WebSessionManager", "::", "updateActiveSession", "(", ")", ";", "foreach", "(", "$", "this", "->", "_preProcessors", "as", "$", "preProcessor", ")", "{", "$", "preProcessor", "->", "process", "(", "$", "this", "->", "_request", ")", ";", "}", "$", "functionToCall", "=", "$", "this", "->", "command", "->", "getFunction", "(", ")", ";", "if", "(", "empty", "(", "$", "functionToCall", ")", "===", "true", ")", "{", "$", "functionToCall", "=", "'default'", ";", "}", "if", "(", "!", "is_callable", "(", "array", "(", "&", "$", "this", ",", "'_'", ".", "$", "functionToCall", ")", ")", ")", "{", "$", "functionToCall", "=", "'error'", ";", "}", "call_user_func", "(", "array", "(", "&", "$", "this", ",", "'_'", ".", "$", "functionToCall", ")", ",", "$", "this", "->", "_request", ")", ";", "foreach", "(", "$", "this", "->", "_postProcessors", "as", "$", "postProcessor", ")", "{", "$", "postProcessor", "->", "process", "(", "$", "this", "->", "_response", ")", ";", "}", "ob_end_clean", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "_response", ")", ")", "{", "$", "this", "->", "_response", "=", "new", "HttpResponse", "(", ")", ";", "}", "if", "(", "$", "this", "->", "_response", "->", "getEncoding", "(", ")", "==", "null", ")", "{", "$", "responseMode", "=", "$", "this", "->", "_request", "->", "getParam", "(", "'mode'", ")", ";", "if", "(", "$", "responseMode", "===", "'ui'", ")", "{", "$", "this", "->", "_response", "->", "setEncoding", "(", "'html'", ")", ";", "}", "else", "if", "(", "$", "responseMode", "===", "'data'", ")", "{", "$", "this", "->", "_response", "->", "setEncoding", "(", "'json'", ")", ";", "}", "}", "$", "this", "->", "_response", "->", "send", "(", ")", ";", "}", "catch", "(", "ServiceException", "$", "se", ")", "{", "$", "this", "->", "_response", "=", "new", "HttpResponse", "(", ")", ";", "$", "response", "->", "addHeader", "(", "'HTTP/1.1 400 Bad Request'", ")", ";", "$", "this", "->", "_response", "->", "send", "(", ")", ";", "}", "catch", "(", "BadResponseException", "$", "bre", ")", "{", "$", "renderer", "=", "new", "TwigRenderer", "(", "'500.html'", ")", ";", "if", "(", "$", "renderer", "->", "exists", "(", ")", ")", "{", "$", "this", "->", "_response", "=", "new", "HttpResponse", "(", "'none'", ",", "$", "renderer", ")", ";", "}", "else", "$", "this", "->", "_response", "=", "new", "HttpResponse", "(", ")", ";", "$", "response", "->", "addHeader", "(", "'HTTP/1.1 500 Internal Server Error'", ")", ";", "$", "this", "->", "_response", "->", "send", "(", ")", ";", "}", "//end try", "}" ]
Handles Request Execution. @param mixed $request HttpRequest @see Native5/Route/HttpRequest @access public @return void
[ "Handles", "Request", "Execution", "." ]
e1f598cf27654d81bb5facace1990b737242a2f9
https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Control/DefaultController.php#L104-L158
train
SlabPHP/controllers
src/Sequenced.php
Sequenced.buildFailedOutputObject
protected function buildFailedOutputObject() { $error = '<!DOCTYPE html><html><head><title>An Error Occurred</title></head><body>'; $error.= '<h1>Error ' . $this->statusCode . '</h1>'; $error.= '<p>Sorry about that, please try again later!</p></body></html>'; $output = new \Slab\Controllers\Response( static::ERROR_DISPLAY_RESOLVER, $error, $this->statusCode, ['Content-type' => 'text/html'] ); return $output; }
php
protected function buildFailedOutputObject() { $error = '<!DOCTYPE html><html><head><title>An Error Occurred</title></head><body>'; $error.= '<h1>Error ' . $this->statusCode . '</h1>'; $error.= '<p>Sorry about that, please try again later!</p></body></html>'; $output = new \Slab\Controllers\Response( static::ERROR_DISPLAY_RESOLVER, $error, $this->statusCode, ['Content-type' => 'text/html'] ); return $output; }
[ "protected", "function", "buildFailedOutputObject", "(", ")", "{", "$", "error", "=", "'<!DOCTYPE html><html><head><title>An Error Occurred</title></head><body>'", ";", "$", "error", ".=", "'<h1>Error '", ".", "$", "this", "->", "statusCode", ".", "'</h1>'", ";", "$", "error", ".=", "'<p>Sorry about that, please try again later!</p></body></html>'", ";", "$", "output", "=", "new", "\\", "Slab", "\\", "Controllers", "\\", "Response", "(", "static", "::", "ERROR_DISPLAY_RESOLVER", ",", "$", "error", ",", "$", "this", "->", "statusCode", ",", "[", "'Content-type'", "=>", "'text/html'", "]", ")", ";", "return", "$", "output", ";", "}" ]
When a call queue fails, this method will be used @return \Slab\Components\Output\ControllerResponseInterface
[ "When", "a", "call", "queue", "fails", "this", "method", "will", "be", "used" ]
a1c4fded0265100a85904dd664b972a7f8687652
https://github.com/SlabPHP/controllers/blob/a1c4fded0265100a85904dd664b972a7f8687652/src/Sequenced.php#L97-L111
train
rollerworks/search-core
LazyFieldSetRegistry.php
LazyFieldSetRegistry.create
public static function create(array $configurators = []): self { $names = array_keys($configurators); return new self(new ClosureContainer($configurators), array_combine($names, $names)); }
php
public static function create(array $configurators = []): self { $names = array_keys($configurators); return new self(new ClosureContainer($configurators), array_combine($names, $names)); }
[ "public", "static", "function", "create", "(", "array", "$", "configurators", "=", "[", "]", ")", ":", "self", "{", "$", "names", "=", "array_keys", "(", "$", "configurators", ")", ";", "return", "new", "self", "(", "new", "ClosureContainer", "(", "$", "configurators", ")", ",", "array_combine", "(", "$", "names", ",", "$", "names", ")", ")", ";", "}" ]
Creates a new LazyFieldSetRegistry with easy factories for loading. @param \Closure[] $configurators an array of lazy loading configurators. The Closure when called is expected to return a FieldSetConfiguratorInterface object @return LazyFieldSetRegistry
[ "Creates", "a", "new", "LazyFieldSetRegistry", "with", "easy", "factories", "for", "loading", "." ]
6b5671b8c4d6298906ded768261b0a59845140fb
https://github.com/rollerworks/search-core/blob/6b5671b8c4d6298906ded768261b0a59845140fb/LazyFieldSetRegistry.php#L66-L71
train
rollerworks/search-core
LazyFieldSetRegistry.php
LazyFieldSetRegistry.getConfigurator
public function getConfigurator(string $name): FieldSetConfigurator { if (!isset($this->configurators[$name])) { if (isset($this->serviceIds[$name])) { $configurator = $this->container->get($this->serviceIds[$name]); } elseif (class_exists($name)) { // Support fully-qualified class names. $configurator = new $name(); } else { throw new InvalidArgumentException(sprintf('Could not load FieldSet configurator "%s".', $name)); } if (!$configurator instanceof FieldSetConfigurator) { throw new InvalidArgumentException(sprintf('Configurator class "%s" is expected to be an instance of '.FieldSetConfigurator::class, $name)); } $this->configurators[$name] = $configurator; } return $this->configurators[$name]; }
php
public function getConfigurator(string $name): FieldSetConfigurator { if (!isset($this->configurators[$name])) { if (isset($this->serviceIds[$name])) { $configurator = $this->container->get($this->serviceIds[$name]); } elseif (class_exists($name)) { // Support fully-qualified class names. $configurator = new $name(); } else { throw new InvalidArgumentException(sprintf('Could not load FieldSet configurator "%s".', $name)); } if (!$configurator instanceof FieldSetConfigurator) { throw new InvalidArgumentException(sprintf('Configurator class "%s" is expected to be an instance of '.FieldSetConfigurator::class, $name)); } $this->configurators[$name] = $configurator; } return $this->configurators[$name]; }
[ "public", "function", "getConfigurator", "(", "string", "$", "name", ")", ":", "FieldSetConfigurator", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "configurators", "[", "$", "name", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "serviceIds", "[", "$", "name", "]", ")", ")", "{", "$", "configurator", "=", "$", "this", "->", "container", "->", "get", "(", "$", "this", "->", "serviceIds", "[", "$", "name", "]", ")", ";", "}", "elseif", "(", "class_exists", "(", "$", "name", ")", ")", "{", "// Support fully-qualified class names.", "$", "configurator", "=", "new", "$", "name", "(", ")", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Could not load FieldSet configurator \"%s\".'", ",", "$", "name", ")", ")", ";", "}", "if", "(", "!", "$", "configurator", "instanceof", "FieldSetConfigurator", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Configurator class \"%s\" is expected to be an instance of '", ".", "FieldSetConfigurator", "::", "class", ",", "$", "name", ")", ")", ";", "}", "$", "this", "->", "configurators", "[", "$", "name", "]", "=", "$", "configurator", ";", "}", "return", "$", "this", "->", "configurators", "[", "$", "name", "]", ";", "}" ]
Returns a FieldSetConfigurator by name. @param string $name The name of the FieldSet configurator @throws InvalidArgumentException if the configurator can not be retrieved @return FieldSetConfigurator
[ "Returns", "a", "FieldSetConfigurator", "by", "name", "." ]
6b5671b8c4d6298906ded768261b0a59845140fb
https://github.com/rollerworks/search-core/blob/6b5671b8c4d6298906ded768261b0a59845140fb/LazyFieldSetRegistry.php#L82-L102
train
rollerworks/search-core
LazyFieldSetRegistry.php
LazyFieldSetRegistry.hasConfigurator
public function hasConfigurator(string $name): bool { if (isset($this->configurators[$name])) { return true; } if (isset($this->serviceIds[$name])) { return true; } return class_exists($name) && \in_array(FieldSetConfigurator::class, class_implements($name), true); }
php
public function hasConfigurator(string $name): bool { if (isset($this->configurators[$name])) { return true; } if (isset($this->serviceIds[$name])) { return true; } return class_exists($name) && \in_array(FieldSetConfigurator::class, class_implements($name), true); }
[ "public", "function", "hasConfigurator", "(", "string", "$", "name", ")", ":", "bool", "{", "if", "(", "isset", "(", "$", "this", "->", "configurators", "[", "$", "name", "]", ")", ")", "{", "return", "true", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "serviceIds", "[", "$", "name", "]", ")", ")", "{", "return", "true", ";", "}", "return", "class_exists", "(", "$", "name", ")", "&&", "\\", "in_array", "(", "FieldSetConfigurator", "::", "class", ",", "class_implements", "(", "$", "name", ")", ",", "true", ")", ";", "}" ]
Returns whether the given FieldSetConfigurator is supported. @param string $name The name of the FieldSet configurator @return bool
[ "Returns", "whether", "the", "given", "FieldSetConfigurator", "is", "supported", "." ]
6b5671b8c4d6298906ded768261b0a59845140fb
https://github.com/rollerworks/search-core/blob/6b5671b8c4d6298906ded768261b0a59845140fb/LazyFieldSetRegistry.php#L111-L122
train
DoSomething/mb-toolbox
src/MB_Configuration.php
MB_Configuration.getProperty
public function getProperty($key, $notifyWarnings = true) { if (!(isset($this->configSettings[$key])) && $notifyWarnings) { echo 'MB_Configuration->getProperty() - Warning: "' . $key . '" not defined.', PHP_EOL; $callers = debug_backtrace(); echo '- Called from: ' . $callers[1]['function'], PHP_EOL; return false; } elseif (!(isset($this->configSettings[$key]))) { return false; } return $this->configSettings[$key]; }
php
public function getProperty($key, $notifyWarnings = true) { if (!(isset($this->configSettings[$key])) && $notifyWarnings) { echo 'MB_Configuration->getProperty() - Warning: "' . $key . '" not defined.', PHP_EOL; $callers = debug_backtrace(); echo '- Called from: ' . $callers[1]['function'], PHP_EOL; return false; } elseif (!(isset($this->configSettings[$key]))) { return false; } return $this->configSettings[$key]; }
[ "public", "function", "getProperty", "(", "$", "key", ",", "$", "notifyWarnings", "=", "true", ")", "{", "if", "(", "!", "(", "isset", "(", "$", "this", "->", "configSettings", "[", "$", "key", "]", ")", ")", "&&", "$", "notifyWarnings", ")", "{", "echo", "'MB_Configuration->getProperty() - Warning: \"'", ".", "$", "key", ".", "'\" not defined.'", ",", "PHP_EOL", ";", "$", "callers", "=", "debug_backtrace", "(", ")", ";", "echo", "'- Called from: '", ".", "$", "callers", "[", "1", "]", "[", "'function'", "]", ",", "PHP_EOL", ";", "return", "false", ";", "}", "elseif", "(", "!", "(", "isset", "(", "$", "this", "->", "configSettings", "[", "$", "key", "]", ")", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "configSettings", "[", "$", "key", "]", ";", "}" ]
Get property in MB_Configuration instance. @param string $key The name of property to get. @param boolean $notifyWarnings Flag to enable / disable warning and traceback if property not found.
[ "Get", "property", "in", "MB_Configuration", "instance", "." ]
ceec5fc594bae137d1ab1f447344800343b62ac6
https://github.com/DoSomething/mb-toolbox/blob/ceec5fc594bae137d1ab1f447344800343b62ac6/src/MB_Configuration.php#L99-L110
train
DoSomething/mb-toolbox
src/MB_Configuration.php
MB_Configuration.exchangeSettings
public function exchangeSettings($targetExchange) { $settings = null; if (isset($this->configSettings['configFile']->rabbit->exchanges)) { foreach ($this->configSettings['configFile']->rabbit->exchanges as $exchange => $exchangeSettings) { if ($exchange == $targetExchange) { $settings = $exchangeSettings; } } } else { echo 'Error - No exchange settings found.', PHP_EOL; } // Trap exchange not found if ($settings == null) { echo 'MB_Configuration->exchangeSettings(): Error - ' . $targetExchange . ' not found in config settings.'; exit; } return $settings; }
php
public function exchangeSettings($targetExchange) { $settings = null; if (isset($this->configSettings['configFile']->rabbit->exchanges)) { foreach ($this->configSettings['configFile']->rabbit->exchanges as $exchange => $exchangeSettings) { if ($exchange == $targetExchange) { $settings = $exchangeSettings; } } } else { echo 'Error - No exchange settings found.', PHP_EOL; } // Trap exchange not found if ($settings == null) { echo 'MB_Configuration->exchangeSettings(): Error - ' . $targetExchange . ' not found in config settings.'; exit; } return $settings; }
[ "public", "function", "exchangeSettings", "(", "$", "targetExchange", ")", "{", "$", "settings", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "configSettings", "[", "'configFile'", "]", "->", "rabbit", "->", "exchanges", ")", ")", "{", "foreach", "(", "$", "this", "->", "configSettings", "[", "'configFile'", "]", "->", "rabbit", "->", "exchanges", "as", "$", "exchange", "=>", "$", "exchangeSettings", ")", "{", "if", "(", "$", "exchange", "==", "$", "targetExchange", ")", "{", "$", "settings", "=", "$", "exchangeSettings", ";", "}", "}", "}", "else", "{", "echo", "'Error - No exchange settings found.'", ",", "PHP_EOL", ";", "}", "// Trap exchange not found", "if", "(", "$", "settings", "==", "null", ")", "{", "echo", "'MB_Configuration->exchangeSettings(): Error - '", ".", "$", "targetExchange", ".", "' not found in config settings.'", ";", "exit", ";", "}", "return", "$", "settings", ";", "}" ]
Gather all setting for a specific exchange @param string $targetExchange The name of the exchange to gather setting for. @return array $settings The exchange settings in the format needed for a RabbitMQ connection.
[ "Gather", "all", "setting", "for", "a", "specific", "exchange" ]
ceec5fc594bae137d1ab1f447344800343b62ac6
https://github.com/DoSomething/mb-toolbox/blob/ceec5fc594bae137d1ab1f447344800343b62ac6/src/MB_Configuration.php#L204-L225
train
DoSomething/mb-toolbox
src/MB_Configuration.php
MB_Configuration._gatherSettings
private static function _gatherSettings($source) { if (strpos('http://', $source) !== false) { echo 'cURL sources are not currently supported.', PHP_EOL; } elseif (file_exists($source)) { $settings = json_decode(implode(file($source))); return $settings; } else { echo 'Source: ' . $source . ' not found.', PHP_EOL; } }
php
private static function _gatherSettings($source) { if (strpos('http://', $source) !== false) { echo 'cURL sources are not currently supported.', PHP_EOL; } elseif (file_exists($source)) { $settings = json_decode(implode(file($source))); return $settings; } else { echo 'Source: ' . $source . ' not found.', PHP_EOL; } }
[ "private", "static", "function", "_gatherSettings", "(", "$", "source", ")", "{", "if", "(", "strpos", "(", "'http://'", ",", "$", "source", ")", "!==", "false", ")", "{", "echo", "'cURL sources are not currently supported.'", ",", "PHP_EOL", ";", "}", "elseif", "(", "file_exists", "(", "$", "source", ")", ")", "{", "$", "settings", "=", "json_decode", "(", "implode", "(", "file", "(", "$", "source", ")", ")", ")", ";", "return", "$", "settings", ";", "}", "else", "{", "echo", "'Source: '", ".", "$", "source", ".", "' not found.'", ",", "PHP_EOL", ";", "}", "}" ]
Gather all Message Broker configuration settings from the defined source. @param string $source Source can be the path to a file or a URL to an endpoint.
[ "Gather", "all", "Message", "Broker", "configuration", "settings", "from", "the", "defined", "source", "." ]
ceec5fc594bae137d1ab1f447344800343b62ac6
https://github.com/DoSomething/mb-toolbox/blob/ceec5fc594bae137d1ab1f447344800343b62ac6/src/MB_Configuration.php#L264-L275
train
linpax/microphp-framework
src/file/Filesystem.php
Filesystem.setDriver
public function setDriver(array $params = []) { $driverName = !empty($params['driver']) ? $params['driver'] : 'local'; $this->driver = new $driverName($params); }
php
public function setDriver(array $params = []) { $driverName = !empty($params['driver']) ? $params['driver'] : 'local'; $this->driver = new $driverName($params); }
[ "public", "function", "setDriver", "(", "array", "$", "params", "=", "[", "]", ")", "{", "$", "driverName", "=", "!", "empty", "(", "$", "params", "[", "'driver'", "]", ")", "?", "$", "params", "[", "'driver'", "]", ":", "'local'", ";", "$", "this", "->", "driver", "=", "new", "$", "driverName", "(", "$", "params", ")", ";", "}" ]
Set driver usage driver params @access public @param array $params Driver params @return void
[ "Set", "driver", "usage", "driver", "params" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/file/Filesystem.php#L52-L57
train
sokil/NotificationBundle
src/DependencyInjection/CompilerPass/MessageBuilderPass.php
MessageBuilderPass.getMessageBuilderCollectionServiceidList
private function getMessageBuilderCollectionServiceidList(ContainerBuilder $container) { $builderCollectionServiceIdList = []; $messageBuilderCollectionListDefinition = $container->findTaggedServiceIds('notification.message_builder_collection'); foreach ($messageBuilderCollectionListDefinition as $builderCollectionServiceId => $builderCollectionDefinitionTags) { foreach ($builderCollectionDefinitionTags as $builderCollectionDefinitionTag) { $collectionName = empty($builderCollectionDefinitionTag['collectionName']) ? 'default' : $builderCollectionDefinitionTag['collectionName']; $builderCollectionServiceIdList[$collectionName] = $builderCollectionServiceId; } } return $builderCollectionServiceIdList; }
php
private function getMessageBuilderCollectionServiceidList(ContainerBuilder $container) { $builderCollectionServiceIdList = []; $messageBuilderCollectionListDefinition = $container->findTaggedServiceIds('notification.message_builder_collection'); foreach ($messageBuilderCollectionListDefinition as $builderCollectionServiceId => $builderCollectionDefinitionTags) { foreach ($builderCollectionDefinitionTags as $builderCollectionDefinitionTag) { $collectionName = empty($builderCollectionDefinitionTag['collectionName']) ? 'default' : $builderCollectionDefinitionTag['collectionName']; $builderCollectionServiceIdList[$collectionName] = $builderCollectionServiceId; } } return $builderCollectionServiceIdList; }
[ "private", "function", "getMessageBuilderCollectionServiceidList", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "builderCollectionServiceIdList", "=", "[", "]", ";", "$", "messageBuilderCollectionListDefinition", "=", "$", "container", "->", "findTaggedServiceIds", "(", "'notification.message_builder_collection'", ")", ";", "foreach", "(", "$", "messageBuilderCollectionListDefinition", "as", "$", "builderCollectionServiceId", "=>", "$", "builderCollectionDefinitionTags", ")", "{", "foreach", "(", "$", "builderCollectionDefinitionTags", "as", "$", "builderCollectionDefinitionTag", ")", "{", "$", "collectionName", "=", "empty", "(", "$", "builderCollectionDefinitionTag", "[", "'collectionName'", "]", ")", "?", "'default'", ":", "$", "builderCollectionDefinitionTag", "[", "'collectionName'", "]", ";", "$", "builderCollectionServiceIdList", "[", "$", "collectionName", "]", "=", "$", "builderCollectionServiceId", ";", "}", "}", "return", "$", "builderCollectionServiceIdList", ";", "}" ]
Get service ids of collections
[ "Get", "service", "ids", "of", "collections" ]
bf8d793b6b5a13827b2db4f0b3c588cf6a03c66b
https://github.com/sokil/NotificationBundle/blob/bf8d793b6b5a13827b2db4f0b3c588cf6a03c66b/src/DependencyInjection/CompilerPass/MessageBuilderPass.php#L81-L97
train
FuzeWorks/Core
src/FuzeWorks/ConfigORM/ConfigORM.php
ConfigORM.commit
public function commit() { // Write the changes if (is_writable($this->file)) { $config = var_export($this->cfg, true); file_put_contents($this->file, "<?php return $config ;"); return true; } throw new ConfigException("Could not write config file. $file is not writable", 1); }
php
public function commit() { // Write the changes if (is_writable($this->file)) { $config = var_export($this->cfg, true); file_put_contents($this->file, "<?php return $config ;"); return true; } throw new ConfigException("Could not write config file. $file is not writable", 1); }
[ "public", "function", "commit", "(", ")", "{", "// Write the changes", "if", "(", "is_writable", "(", "$", "this", "->", "file", ")", ")", "{", "$", "config", "=", "var_export", "(", "$", "this", "->", "cfg", ",", "true", ")", ";", "file_put_contents", "(", "$", "this", "->", "file", ",", "\"<?php return $config ;\"", ")", ";", "return", "true", ";", "}", "throw", "new", "ConfigException", "(", "\"Could not write config file. $file is not writable\"", ",", "1", ")", ";", "}" ]
Updates the config file and writes it. @throws ConfigException on fatal error
[ "Updates", "the", "config", "file", "and", "writes", "it", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/ConfigORM/ConfigORM.php#L84-L94
train
Lustmored/oauth2-lockme
src/Provider/Lockme.php
Lockme.executeRequest
public function executeRequest($method, $url, $token, $body = null) { $options = []; if ($body) { $options['body'] = json_encode($body); $options['headers']['Content-Type'] = 'application/json'; } $request = $this->getAuthenticatedRequest($method, $this->apiDomain.'/'.$this->version.$url, $token, $options); return $this->getParsedResponse($request); }
php
public function executeRequest($method, $url, $token, $body = null) { $options = []; if ($body) { $options['body'] = json_encode($body); $options['headers']['Content-Type'] = 'application/json'; } $request = $this->getAuthenticatedRequest($method, $this->apiDomain.'/'.$this->version.$url, $token, $options); return $this->getParsedResponse($request); }
[ "public", "function", "executeRequest", "(", "$", "method", ",", "$", "url", ",", "$", "token", ",", "$", "body", "=", "null", ")", "{", "$", "options", "=", "[", "]", ";", "if", "(", "$", "body", ")", "{", "$", "options", "[", "'body'", "]", "=", "json_encode", "(", "$", "body", ")", ";", "$", "options", "[", "'headers'", "]", "[", "'Content-Type'", "]", "=", "'application/json'", ";", "}", "$", "request", "=", "$", "this", "->", "getAuthenticatedRequest", "(", "$", "method", ",", "$", "this", "->", "apiDomain", ".", "'/'", ".", "$", "this", "->", "version", ".", "$", "url", ",", "$", "token", ",", "$", "options", ")", ";", "return", "$", "this", "->", "getParsedResponse", "(", "$", "request", ")", ";", "}" ]
Generate request, execute it and return parsed response @param string $method @param string $url @param AccessToken|string|null $token @param mixed $body @return mixed
[ "Generate", "request", "execute", "it", "and", "return", "parsed", "response" ]
906c40be9d896d28d20b1bbdf32f91c858e3c280
https://github.com/Lustmored/oauth2-lockme/blob/906c40be9d896d28d20b1bbdf32f91c858e3c280/src/Provider/Lockme.php#L77-L88
train
miguelibero/meinhof
src/Meinhof/Meinhof.php
Meinhof.reload
public function reload() { $this->container = $this->buildContainer($this->dir); // load input and output $this->container->set('input', $this->input); $this->container->set('output', $this->output); // freeze the container $this->container->compile(); }
php
public function reload() { $this->container = $this->buildContainer($this->dir); // load input and output $this->container->set('input', $this->input); $this->container->set('output', $this->output); // freeze the container $this->container->compile(); }
[ "public", "function", "reload", "(", ")", "{", "$", "this", "->", "container", "=", "$", "this", "->", "buildContainer", "(", "$", "this", "->", "dir", ")", ";", "// load input and output", "$", "this", "->", "container", "->", "set", "(", "'input'", ",", "$", "this", "->", "input", ")", ";", "$", "this", "->", "container", "->", "set", "(", "'output'", ",", "$", "this", "->", "output", ")", ";", "// freeze the container", "$", "this", "->", "container", "->", "compile", "(", ")", ";", "}" ]
Reload the dependency container
[ "Reload", "the", "dependency", "container" ]
3a090f08485dc0da3e27463cf349dba374201072
https://github.com/miguelibero/meinhof/blob/3a090f08485dc0da3e27463cf349dba374201072/src/Meinhof/Meinhof.php#L60-L70
train
miguelibero/meinhof
src/Meinhof/Meinhof.php
Meinhof.buildContainer
public function buildContainer($dir) { // load the container $container = new ContainerBuilder(); // setup basic container compiler passes $container->addCompilerPass(new EventListenerPass()); $container->addCompilerPass(new TemplatingEnginePass()); $configDir = $dir.'/config'; // set the key as a parameter $container->setParameter('base_dir', $dir); $container->setParameter('config_dir', $configDir); // load base services $configdirs = array(__DIR__.'/Resources/config', $dir, $configDir); $loader = new XmlFileLoader($container, new FileLocator($configdirs)); $loader->load('services.xml'); // register extensions foreach ($container->findTaggedServiceIds('extension') as $id => $attributes) { $extension = $container->get($id); if (!$extension instanceof BaseExtensionInterface) { throw new \RuntimeException("Invalid extension with id '${id}'."); } $container->registerExtension($extension); } // preload the extensions foreach ($container->getExtensions() as $extension) { if ($extension instanceof ExtensionInterface) { $extension->preload($container); } } return $container; }
php
public function buildContainer($dir) { // load the container $container = new ContainerBuilder(); // setup basic container compiler passes $container->addCompilerPass(new EventListenerPass()); $container->addCompilerPass(new TemplatingEnginePass()); $configDir = $dir.'/config'; // set the key as a parameter $container->setParameter('base_dir', $dir); $container->setParameter('config_dir', $configDir); // load base services $configdirs = array(__DIR__.'/Resources/config', $dir, $configDir); $loader = new XmlFileLoader($container, new FileLocator($configdirs)); $loader->load('services.xml'); // register extensions foreach ($container->findTaggedServiceIds('extension') as $id => $attributes) { $extension = $container->get($id); if (!$extension instanceof BaseExtensionInterface) { throw new \RuntimeException("Invalid extension with id '${id}'."); } $container->registerExtension($extension); } // preload the extensions foreach ($container->getExtensions() as $extension) { if ($extension instanceof ExtensionInterface) { $extension->preload($container); } } return $container; }
[ "public", "function", "buildContainer", "(", "$", "dir", ")", "{", "// load the container", "$", "container", "=", "new", "ContainerBuilder", "(", ")", ";", "// setup basic container compiler passes", "$", "container", "->", "addCompilerPass", "(", "new", "EventListenerPass", "(", ")", ")", ";", "$", "container", "->", "addCompilerPass", "(", "new", "TemplatingEnginePass", "(", ")", ")", ";", "$", "configDir", "=", "$", "dir", ".", "'/config'", ";", "// set the key as a parameter", "$", "container", "->", "setParameter", "(", "'base_dir'", ",", "$", "dir", ")", ";", "$", "container", "->", "setParameter", "(", "'config_dir'", ",", "$", "configDir", ")", ";", "// load base services", "$", "configdirs", "=", "array", "(", "__DIR__", ".", "'/Resources/config'", ",", "$", "dir", ",", "$", "configDir", ")", ";", "$", "loader", "=", "new", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "$", "configdirs", ")", ")", ";", "$", "loader", "->", "load", "(", "'services.xml'", ")", ";", "// register extensions", "foreach", "(", "$", "container", "->", "findTaggedServiceIds", "(", "'extension'", ")", "as", "$", "id", "=>", "$", "attributes", ")", "{", "$", "extension", "=", "$", "container", "->", "get", "(", "$", "id", ")", ";", "if", "(", "!", "$", "extension", "instanceof", "BaseExtensionInterface", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Invalid extension with id '${id}'.\"", ")", ";", "}", "$", "container", "->", "registerExtension", "(", "$", "extension", ")", ";", "}", "// preload the extensions", "foreach", "(", "$", "container", "->", "getExtensions", "(", ")", "as", "$", "extension", ")", "{", "if", "(", "$", "extension", "instanceof", "ExtensionInterface", ")", "{", "$", "extension", "->", "preload", "(", "$", "container", ")", ";", "}", "}", "return", "$", "container", ";", "}" ]
Builds the dependency injection container @param string $dir the path to the base of the site configuration @return ContainerInterface the new container @throws \RuntimeException when a service tagged as an extension does not implement ExtensionInterface
[ "Builds", "the", "dependency", "injection", "container" ]
3a090f08485dc0da3e27463cf349dba374201072
https://github.com/miguelibero/meinhof/blob/3a090f08485dc0da3e27463cf349dba374201072/src/Meinhof/Meinhof.php#L103-L139
train
miguelibero/meinhof
src/Meinhof/Meinhof.php
Meinhof.dispatchEvent
protected function dispatchEvent($event) { if (!$this->container) { throw new \RuntimeException("The container has not been set up."); } $dir = $this->container->getParameter('base_dir'); if (!is_dir($dir) || !is_readable($dir)) { throw new \RuntimeException("'${dir}' is not a valid readable directory."); } $dispatcher = $this->container->get('event_dispatcher'); $dispatcher->dispatch($event); }
php
protected function dispatchEvent($event) { if (!$this->container) { throw new \RuntimeException("The container has not been set up."); } $dir = $this->container->getParameter('base_dir'); if (!is_dir($dir) || !is_readable($dir)) { throw new \RuntimeException("'${dir}' is not a valid readable directory."); } $dispatcher = $this->container->get('event_dispatcher'); $dispatcher->dispatch($event); }
[ "protected", "function", "dispatchEvent", "(", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "container", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"The container has not been set up.\"", ")", ";", "}", "$", "dir", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'base_dir'", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", "||", "!", "is_readable", "(", "$", "dir", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"'${dir}' is not a valid readable directory.\"", ")", ";", "}", "$", "dispatcher", "=", "$", "this", "->", "container", "->", "get", "(", "'event_dispatcher'", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "$", "event", ")", ";", "}" ]
Dispatches an event @throws \RuntimeException when the container is not present @throws \RuntimeException when the site directory is not readable
[ "Dispatches", "an", "event" ]
3a090f08485dc0da3e27463cf349dba374201072
https://github.com/miguelibero/meinhof/blob/3a090f08485dc0da3e27463cf349dba374201072/src/Meinhof/Meinhof.php#L147-L158
train
quantaphp/container-factories
src/AutowiredInstance.php
AutowiredInstance.parameters
private function parameters(): array { try { $reflection = new \ReflectionClass($this->class); } catch (\ReflectionException $e) { return []; } $constructor = $reflection->getConstructor(); return is_null($constructor) ? [] : $constructor->getParameters(); }
php
private function parameters(): array { try { $reflection = new \ReflectionClass($this->class); } catch (\ReflectionException $e) { return []; } $constructor = $reflection->getConstructor(); return is_null($constructor) ? [] : $constructor->getParameters(); }
[ "private", "function", "parameters", "(", ")", ":", "array", "{", "try", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "this", "->", "class", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", "{", "return", "[", "]", ";", "}", "$", "constructor", "=", "$", "reflection", "->", "getConstructor", "(", ")", ";", "return", "is_null", "(", "$", "constructor", ")", "?", "[", "]", ":", "$", "constructor", "->", "getParameters", "(", ")", ";", "}" ]
Return the non variadic class constructor parameter reflections. When the string is not a class name the method does not fail and returns an empty array. This way the script keeps going until the factory tries to instantiate a non class and fail like it would by manually doing so. @return \ReflectionParameter[]
[ "Return", "the", "non", "variadic", "class", "constructor", "parameter", "reflections", "." ]
5e753d66a18d0ce4418cbf33fe6d6b74948f303d
https://github.com/quantaphp/container-factories/blob/5e753d66a18d0ce4418cbf33fe6d6b74948f303d/src/AutowiredInstance.php#L82-L95
train
enikeishik/ufoframework
src/Ufo/Core/Debug.php
Debug.trace
public function trace(string $operation): int { $this->buffTrace[] = [ 'operation' => $operation, 'time' => microtime(true), 'result' => '', 'stack' => 9 == self::C_DEBUG_LEVEL ? debug_backtrace(): null, ]; return count($this->buffTrace) - 1; }
php
public function trace(string $operation): int { $this->buffTrace[] = [ 'operation' => $operation, 'time' => microtime(true), 'result' => '', 'stack' => 9 == self::C_DEBUG_LEVEL ? debug_backtrace(): null, ]; return count($this->buffTrace) - 1; }
[ "public", "function", "trace", "(", "string", "$", "operation", ")", ":", "int", "{", "$", "this", "->", "buffTrace", "[", "]", "=", "[", "'operation'", "=>", "$", "operation", ",", "'time'", "=>", "microtime", "(", "true", ")", ",", "'result'", "=>", "''", ",", "'stack'", "=>", "9", "==", "self", "::", "C_DEBUG_LEVEL", "?", "debug_backtrace", "(", ")", ":", "null", ",", "]", ";", "return", "count", "(", "$", "this", "->", "buffTrace", ")", "-", "1", ";", "}" ]
Create new trace item. @param string $operation @return int
[ "Create", "new", "trace", "item", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Debug.php#L58-L67
train
enikeishik/ufoframework
src/Ufo/Core/Debug.php
Debug.traceClose
public function traceClose(int $idx = null, int $errCode = null, string $errMessage = null): void { if (null === $idx) { $idx = count($this->buffTrace) - 1; } if (!array_key_exists($idx, $this->buffTrace)) { throw new DebugIndexNotExistsException(); } $this->buffTrace[$idx]['time'] = microtime(true) - $this->buffTrace[$idx]['time']; $this->buffTrace[$idx]['result'] = (null === $errCode ? 'OK' : '(' . $errCode . ') ' . $errMessage); }
php
public function traceClose(int $idx = null, int $errCode = null, string $errMessage = null): void { if (null === $idx) { $idx = count($this->buffTrace) - 1; } if (!array_key_exists($idx, $this->buffTrace)) { throw new DebugIndexNotExistsException(); } $this->buffTrace[$idx]['time'] = microtime(true) - $this->buffTrace[$idx]['time']; $this->buffTrace[$idx]['result'] = (null === $errCode ? 'OK' : '(' . $errCode . ') ' . $errMessage); }
[ "public", "function", "traceClose", "(", "int", "$", "idx", "=", "null", ",", "int", "$", "errCode", "=", "null", ",", "string", "$", "errMessage", "=", "null", ")", ":", "void", "{", "if", "(", "null", "===", "$", "idx", ")", "{", "$", "idx", "=", "count", "(", "$", "this", "->", "buffTrace", ")", "-", "1", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "idx", ",", "$", "this", "->", "buffTrace", ")", ")", "{", "throw", "new", "DebugIndexNotExistsException", "(", ")", ";", "}", "$", "this", "->", "buffTrace", "[", "$", "idx", "]", "[", "'time'", "]", "=", "microtime", "(", "true", ")", "-", "$", "this", "->", "buffTrace", "[", "$", "idx", "]", "[", "'time'", "]", ";", "$", "this", "->", "buffTrace", "[", "$", "idx", "]", "[", "'result'", "]", "=", "(", "null", "===", "$", "errCode", "?", "'OK'", ":", "'('", ".", "$", "errCode", ".", "') '", ".", "$", "errMessage", ")", ";", "}" ]
Close trace item by its index. @param int $idx = null @param int $errCode = null @param string $errMessage = null @return void
[ "Close", "trace", "item", "by", "its", "index", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Debug.php#L76-L88
train
enikeishik/ufoframework
src/Ufo/Core/Debug.php
Debug.traceEnd
public function traceEnd(): void { $now = microtime(true); foreach ($this->buffTrace as &$traceItem) { if ('' === $traceItem['result']) { $traceItem['time'] = $now - $traceItem['time']; $traceItem['result'] = 'Trace end'; } } unset($traceItem); }
php
public function traceEnd(): void { $now = microtime(true); foreach ($this->buffTrace as &$traceItem) { if ('' === $traceItem['result']) { $traceItem['time'] = $now - $traceItem['time']; $traceItem['result'] = 'Trace end'; } } unset($traceItem); }
[ "public", "function", "traceEnd", "(", ")", ":", "void", "{", "$", "now", "=", "microtime", "(", "true", ")", ";", "foreach", "(", "$", "this", "->", "buffTrace", "as", "&", "$", "traceItem", ")", "{", "if", "(", "''", "===", "$", "traceItem", "[", "'result'", "]", ")", "{", "$", "traceItem", "[", "'time'", "]", "=", "$", "now", "-", "$", "traceItem", "[", "'time'", "]", ";", "$", "traceItem", "[", "'result'", "]", "=", "'Trace end'", ";", "}", "}", "unset", "(", "$", "traceItem", ")", ";", "}" ]
Set time to now-time for each unclosed trace items. @return void
[ "Set", "time", "to", "now", "-", "time", "for", "each", "unclosed", "trace", "items", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Debug.php#L94-L104
train
enikeishik/ufoframework
src/Ufo/Core/Debug.php
Debug.vd
public static function vd($var, bool $dump = true, bool $stop = true, int $obLevel = 0): void { if ($stop) { while (ob_get_level() > $obLevel) { ob_end_clean(); } } ob_start(); if (empty($_SERVER['DOCUMENT_ROOT'])) { $dump ? var_dump($var) : print_r($var); echo PHP_EOL . str_replace("=>\n", ' =>', ob_get_clean()); } else { echo '<pre>'; $dump ? var_dump($var) : print_r($var); echo htmlspecialchars(str_replace("=>\n", ' =>', ob_get_clean())); echo '</pre>'; } if ($stop) { throw new DebugStopExecutionException(); } }
php
public static function vd($var, bool $dump = true, bool $stop = true, int $obLevel = 0): void { if ($stop) { while (ob_get_level() > $obLevel) { ob_end_clean(); } } ob_start(); if (empty($_SERVER['DOCUMENT_ROOT'])) { $dump ? var_dump($var) : print_r($var); echo PHP_EOL . str_replace("=>\n", ' =>', ob_get_clean()); } else { echo '<pre>'; $dump ? var_dump($var) : print_r($var); echo htmlspecialchars(str_replace("=>\n", ' =>', ob_get_clean())); echo '</pre>'; } if ($stop) { throw new DebugStopExecutionException(); } }
[ "public", "static", "function", "vd", "(", "$", "var", ",", "bool", "$", "dump", "=", "true", ",", "bool", "$", "stop", "=", "true", ",", "int", "$", "obLevel", "=", "0", ")", ":", "void", "{", "if", "(", "$", "stop", ")", "{", "while", "(", "ob_get_level", "(", ")", ">", "$", "obLevel", ")", "{", "ob_end_clean", "(", ")", ";", "}", "}", "ob_start", "(", ")", ";", "if", "(", "empty", "(", "$", "_SERVER", "[", "'DOCUMENT_ROOT'", "]", ")", ")", "{", "$", "dump", "?", "var_dump", "(", "$", "var", ")", ":", "print_r", "(", "$", "var", ")", ";", "echo", "PHP_EOL", ".", "str_replace", "(", "\"=>\\n\"", ",", "' =>'", ",", "ob_get_clean", "(", ")", ")", ";", "}", "else", "{", "echo", "'<pre>'", ";", "$", "dump", "?", "var_dump", "(", "$", "var", ")", ":", "print_r", "(", "$", "var", ")", ";", "echo", "htmlspecialchars", "(", "str_replace", "(", "\"=>\\n\"", ",", "' =>'", ",", "ob_get_clean", "(", ")", ")", ")", ";", "echo", "'</pre>'", ";", "}", "if", "(", "$", "stop", ")", "{", "throw", "new", "DebugStopExecutionException", "(", ")", ";", "}", "}" ]
Show variable debug info. @param mixed $var @param bool $dump = true @param bool $stop = true @return void
[ "Show", "variable", "debug", "info", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Debug.php#L150-L172
train
Dhii/exception-helper-base
src/CreateOutOfRangeExceptionCapableTrait.php
CreateOutOfRangeExceptionCapableTrait._createOutOfRangeException
protected function _createOutOfRangeException( $message = null, $code = null, RootException $previous = null, $argument = null ) { return new OutOfRangeException($message, $code, $previous, $argument); }
php
protected function _createOutOfRangeException( $message = null, $code = null, RootException $previous = null, $argument = null ) { return new OutOfRangeException($message, $code, $previous, $argument); }
[ "protected", "function", "_createOutOfRangeException", "(", "$", "message", "=", "null", ",", "$", "code", "=", "null", ",", "RootException", "$", "previous", "=", "null", ",", "$", "argument", "=", "null", ")", "{", "return", "new", "OutOfRangeException", "(", "$", "message", ",", "$", "code", ",", "$", "previous", ",", "$", "argument", ")", ";", "}" ]
Creates a new Dhii Out Of Range exception. @since [*next-version*] @param string|Stringable|int|float|bool|null $message The message, if any. @param int|float|string|Stringable|null $code The numeric error code, if any. @param RootException|null $previous The inner exception, if any. @param mixed|null $argument The value that is out of range, if any. @return OutOfRangeException The new exception.
[ "Creates", "a", "new", "Dhii", "Out", "Of", "Range", "exception", "." ]
e97bfa6c0f79ea079e36b2f1d8f84d7566a3ccf5
https://github.com/Dhii/exception-helper-base/blob/e97bfa6c0f79ea079e36b2f1d8f84d7566a3ccf5/src/CreateOutOfRangeExceptionCapableTrait.php#L27-L34
train
Wedeto/HTTP
src/Response/StringResponse.php
StringResponse.setOutput
public function setOutput($output, string $mime = "text/html") { if ( !is_string($output) && !is_callable($output) && !(is_object($output) && method_exists($output, '__toString')) ) { throw new \InvalidArgumentException( "Output must be text, string-castable object or valid callback" ); } $this->addMimeType($mime); $this->output[$mime] = $output; return $this; }
php
public function setOutput($output, string $mime = "text/html") { if ( !is_string($output) && !is_callable($output) && !(is_object($output) && method_exists($output, '__toString')) ) { throw new \InvalidArgumentException( "Output must be text, string-castable object or valid callback" ); } $this->addMimeType($mime); $this->output[$mime] = $output; return $this; }
[ "public", "function", "setOutput", "(", "$", "output", ",", "string", "$", "mime", "=", "\"text/html\"", ")", "{", "if", "(", "!", "is_string", "(", "$", "output", ")", "&&", "!", "is_callable", "(", "$", "output", ")", "&&", "!", "(", "is_object", "(", "$", "output", ")", "&&", "method_exists", "(", "$", "output", ",", "'__toString'", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Output must be text, string-castable object or valid callback\"", ")", ";", "}", "$", "this", "->", "addMimeType", "(", "$", "mime", ")", ";", "$", "this", "->", "output", "[", "$", "mime", "]", "=", "$", "output", ";", "return", "$", "this", ";", "}" ]
Set or replace the output for a content type @param mixed $str The text to add. This can be a string, a callback function returning a string or an object with a __toString method. @param string $mime The mime-type for the content @return StringResponse Provides fluent interface
[ "Set", "or", "replace", "the", "output", "for", "a", "content", "type" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Response/StringResponse.php#L55-L69
train
Wedeto/HTTP
src/Response/StringResponse.php
StringResponse.append
public function append(string $str, string $mime = "text/html") { // To append, we need to make sure we have a string first if (empty($this->output[$mime]) || !is_string($this->output[$mime])) $this->output[$mime] = $this->getOutput($mime); $this->output[$mime] .= $str; return $this; }
php
public function append(string $str, string $mime = "text/html") { // To append, we need to make sure we have a string first if (empty($this->output[$mime]) || !is_string($this->output[$mime])) $this->output[$mime] = $this->getOutput($mime); $this->output[$mime] .= $str; return $this; }
[ "public", "function", "append", "(", "string", "$", "str", ",", "string", "$", "mime", "=", "\"text/html\"", ")", "{", "// To append, we need to make sure we have a string first", "if", "(", "empty", "(", "$", "this", "->", "output", "[", "$", "mime", "]", ")", "||", "!", "is_string", "(", "$", "this", "->", "output", "[", "$", "mime", "]", ")", ")", "$", "this", "->", "output", "[", "$", "mime", "]", "=", "$", "this", "->", "getOutput", "(", "$", "mime", ")", ";", "$", "this", "->", "output", "[", "$", "mime", "]", ".=", "$", "str", ";", "return", "$", "this", ";", "}" ]
Append a string to the current output @param string $str The string to add @return StringResponse Provides fluent interface
[ "Append", "a", "string", "to", "the", "current", "output" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Response/StringResponse.php#L76-L84
train
Wedeto/HTTP
src/Response/StringResponse.php
StringResponse.output
public function output(string $mime) { $output = $this->getOutput($mime); if (empty($output)) $output = "Unknown mime type requested"; echo $output; return $this; }
php
public function output(string $mime) { $output = $this->getOutput($mime); if (empty($output)) $output = "Unknown mime type requested"; echo $output; return $this; }
[ "public", "function", "output", "(", "string", "$", "mime", ")", "{", "$", "output", "=", "$", "this", "->", "getOutput", "(", "$", "mime", ")", ";", "if", "(", "empty", "(", "$", "output", ")", ")", "$", "output", "=", "\"Unknown mime type requested\"", ";", "echo", "$", "output", ";", "return", "$", "this", ";", "}" ]
Write the string to the script output @return StringResponse Provides fluent interface
[ "Write", "the", "string", "to", "the", "script", "output" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Response/StringResponse.php#L108-L116
train
mrcrmn/collection
src/Collection.php
Collection.set
public function set($key, $value = null) { if (isset($value)) { return $this->array[$key] = $value; } return $this->array[] = $key; }
php
public function set($key, $value = null) { if (isset($value)) { return $this->array[$key] = $value; } return $this->array[] = $key; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "array", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", "->", "array", "[", "]", "=", "$", "key", ";", "}" ]
Adds an element to the array. With key or without. @param int|string $key @param mixed $value @return void
[ "Adds", "an", "element", "to", "the", "array", ".", "With", "key", "or", "without", "." ]
a48c5ed15f14ff4b52d2a824c4df7456a88f7678
https://github.com/mrcrmn/collection/blob/a48c5ed15f14ff4b52d2a824c4df7456a88f7678/src/Collection.php#L123-L130
train
mrcrmn/collection
src/Collection.php
Collection.each
public function each($callback) { array_walk($this->array, function($value, $key) use ($callback) { $callback($key, $value); }); return $this; }
php
public function each($callback) { array_walk($this->array, function($value, $key) use ($callback) { $callback($key, $value); }); return $this; }
[ "public", "function", "each", "(", "$", "callback", ")", "{", "array_walk", "(", "$", "this", "->", "array", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "callback", ")", "{", "$", "callback", "(", "$", "key", ",", "$", "value", ")", ";", "}", ")", ";", "return", "$", "this", ";", "}" ]
Runs the given callback on each element of the array. @param Callable $callback @return $this
[ "Runs", "the", "given", "callback", "on", "each", "element", "of", "the", "array", "." ]
a48c5ed15f14ff4b52d2a824c4df7456a88f7678
https://github.com/mrcrmn/collection/blob/a48c5ed15f14ff4b52d2a824c4df7456a88f7678/src/Collection.php#L213-L220
train
mrcrmn/collection
src/Collection.php
Collection.filter
public function filter($callback = null) { if (is_null($callback)) { return new static(array_filter($this->array)); } return new static(array_filter($this->array, $callback)); }
php
public function filter($callback = null) { if (is_null($callback)) { return new static(array_filter($this->array)); } return new static(array_filter($this->array, $callback)); }
[ "public", "function", "filter", "(", "$", "callback", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "callback", ")", ")", "{", "return", "new", "static", "(", "array_filter", "(", "$", "this", "->", "array", ")", ")", ";", "}", "return", "new", "static", "(", "array_filter", "(", "$", "this", "->", "array", ",", "$", "callback", ")", ")", ";", "}" ]
Filters the array by a given callback. @param Callable $callback @return self
[ "Filters", "the", "array", "by", "a", "given", "callback", "." ]
a48c5ed15f14ff4b52d2a824c4df7456a88f7678
https://github.com/mrcrmn/collection/blob/a48c5ed15f14ff4b52d2a824c4df7456a88f7678/src/Collection.php#L249-L255
train
mrcrmn/collection
src/Collection.php
Collection.chunk
public function chunk($size) { $chunked = array_chunk($this->array, $size); return new static(array_map(function ($item) { return new static($item); }, $chunked)); }
php
public function chunk($size) { $chunked = array_chunk($this->array, $size); return new static(array_map(function ($item) { return new static($item); }, $chunked)); }
[ "public", "function", "chunk", "(", "$", "size", ")", "{", "$", "chunked", "=", "array_chunk", "(", "$", "this", "->", "array", ",", "$", "size", ")", ";", "return", "new", "static", "(", "array_map", "(", "function", "(", "$", "item", ")", "{", "return", "new", "static", "(", "$", "item", ")", ";", "}", ",", "$", "chunked", ")", ")", ";", "}" ]
Splits the array into chunks of the given size. @param string $size @return self
[ "Splits", "the", "array", "into", "chunks", "of", "the", "given", "size", "." ]
a48c5ed15f14ff4b52d2a824c4df7456a88f7678
https://github.com/mrcrmn/collection/blob/a48c5ed15f14ff4b52d2a824c4df7456a88f7678/src/Collection.php#L263-L270
train
pryley/castor-framework
src/Forms/Form.php
Form.normalize
public function normalize( array $args = [] ) { $defaults = [ 'action' => '', 'attributes' => '', 'id' => '', 'class' => '', 'enctype' => 'multipart/form-data', 'method' => 'post', 'nonce' => '', 'submit' => __( 'Submit', 'site-reviews' ), ]; $this->args = array_merge( $defaults, $args ); $attributes = $this->normalize->form( $this->args, 'implode' ); $this->args['attributes'] = $attributes; return $this; }
php
public function normalize( array $args = [] ) { $defaults = [ 'action' => '', 'attributes' => '', 'id' => '', 'class' => '', 'enctype' => 'multipart/form-data', 'method' => 'post', 'nonce' => '', 'submit' => __( 'Submit', 'site-reviews' ), ]; $this->args = array_merge( $defaults, $args ); $attributes = $this->normalize->form( $this->args, 'implode' ); $this->args['attributes'] = $attributes; return $this; }
[ "public", "function", "normalize", "(", "array", "$", "args", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'action'", "=>", "''", ",", "'attributes'", "=>", "''", ",", "'id'", "=>", "''", ",", "'class'", "=>", "''", ",", "'enctype'", "=>", "'multipart/form-data'", ",", "'method'", "=>", "'post'", ",", "'nonce'", "=>", "''", ",", "'submit'", "=>", "__", "(", "'Submit'", ",", "'site-reviews'", ")", ",", "]", ";", "$", "this", "->", "args", "=", "array_merge", "(", "$", "defaults", ",", "$", "args", ")", ";", "$", "attributes", "=", "$", "this", "->", "normalize", "->", "form", "(", "$", "this", "->", "args", ",", "'implode'", ")", ";", "$", "this", "->", "args", "[", "'attributes'", "]", "=", "$", "attributes", ";", "return", "$", "this", ";", "}" ]
Normalize the form arguments @return Form
[ "Normalize", "the", "form", "arguments" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Form.php#L106-L126
train
pryley/castor-framework
src/Forms/Form.php
Form.generateFields
protected function generateFields() { $hiddenFields = ''; $fields = array_reduce( $this->fields, function( $carry, $formField ) use ( &$hiddenFields ) { $stringLegend = '<legend class="screen-reader-text"><span>%s</span></legend>'; $stringFieldset = '<fieldset%s>%s%s</fieldset>'; $stringRendered = '<tr class="glsr-field %s"><th scope="row">%s</th><td>%s</td></tr>'; $outsideRendered = '</tbody></table>%s<table class="form-table"><tbody>'; // set field value only when rendering because we need to check the default setting // against the database $field = $formField->setValue()->getField(); $multi = $field->multi === true; $label = $field->generateLabel(); $rendered = $field->render(); // render hidden inputs outside the table if( $field->args['type'] === 'hidden' ) { $hiddenFields .= $rendered; return $carry; } $hiddenClass = $this->isFieldHidden( $formField ) ? 'hidden' : ''; if( $multi ) { if( $depends = $formField->getDataDepends() ) { $depends = sprintf( ' data-depends=\'%s\'', json_encode( $depends )); } $legend = $label ? sprintf( $stringLegend, $label ) : ''; $rendered = sprintf( $stringFieldset, $depends, $legend, $rendered ); } $renderedField = $field->outside ? sprintf( $outsideRendered, $rendered ) : sprintf( $stringRendered, $hiddenClass, $label, $rendered ); return $carry . $renderedField; }); return sprintf( '<table class="form-table"><tbody>%s</tbody></table>%s', $fields, $hiddenFields ); }
php
protected function generateFields() { $hiddenFields = ''; $fields = array_reduce( $this->fields, function( $carry, $formField ) use ( &$hiddenFields ) { $stringLegend = '<legend class="screen-reader-text"><span>%s</span></legend>'; $stringFieldset = '<fieldset%s>%s%s</fieldset>'; $stringRendered = '<tr class="glsr-field %s"><th scope="row">%s</th><td>%s</td></tr>'; $outsideRendered = '</tbody></table>%s<table class="form-table"><tbody>'; // set field value only when rendering because we need to check the default setting // against the database $field = $formField->setValue()->getField(); $multi = $field->multi === true; $label = $field->generateLabel(); $rendered = $field->render(); // render hidden inputs outside the table if( $field->args['type'] === 'hidden' ) { $hiddenFields .= $rendered; return $carry; } $hiddenClass = $this->isFieldHidden( $formField ) ? 'hidden' : ''; if( $multi ) { if( $depends = $formField->getDataDepends() ) { $depends = sprintf( ' data-depends=\'%s\'', json_encode( $depends )); } $legend = $label ? sprintf( $stringLegend, $label ) : ''; $rendered = sprintf( $stringFieldset, $depends, $legend, $rendered ); } $renderedField = $field->outside ? sprintf( $outsideRendered, $rendered ) : sprintf( $stringRendered, $hiddenClass, $label, $rendered ); return $carry . $renderedField; }); return sprintf( '<table class="form-table"><tbody>%s</tbody></table>%s', $fields, $hiddenFields ); }
[ "protected", "function", "generateFields", "(", ")", "{", "$", "hiddenFields", "=", "''", ";", "$", "fields", "=", "array_reduce", "(", "$", "this", "->", "fields", ",", "function", "(", "$", "carry", ",", "$", "formField", ")", "use", "(", "&", "$", "hiddenFields", ")", "{", "$", "stringLegend", "=", "'<legend class=\"screen-reader-text\"><span>%s</span></legend>'", ";", "$", "stringFieldset", "=", "'<fieldset%s>%s%s</fieldset>'", ";", "$", "stringRendered", "=", "'<tr class=\"glsr-field %s\"><th scope=\"row\">%s</th><td>%s</td></tr>'", ";", "$", "outsideRendered", "=", "'</tbody></table>%s<table class=\"form-table\"><tbody>'", ";", "// set field value only when rendering because we need to check the default setting", "// against the database", "$", "field", "=", "$", "formField", "->", "setValue", "(", ")", "->", "getField", "(", ")", ";", "$", "multi", "=", "$", "field", "->", "multi", "===", "true", ";", "$", "label", "=", "$", "field", "->", "generateLabel", "(", ")", ";", "$", "rendered", "=", "$", "field", "->", "render", "(", ")", ";", "// render hidden inputs outside the table", "if", "(", "$", "field", "->", "args", "[", "'type'", "]", "===", "'hidden'", ")", "{", "$", "hiddenFields", ".=", "$", "rendered", ";", "return", "$", "carry", ";", "}", "$", "hiddenClass", "=", "$", "this", "->", "isFieldHidden", "(", "$", "formField", ")", "?", "'hidden'", ":", "''", ";", "if", "(", "$", "multi", ")", "{", "if", "(", "$", "depends", "=", "$", "formField", "->", "getDataDepends", "(", ")", ")", "{", "$", "depends", "=", "sprintf", "(", "' data-depends=\\'%s\\''", ",", "json_encode", "(", "$", "depends", ")", ")", ";", "}", "$", "legend", "=", "$", "label", "?", "sprintf", "(", "$", "stringLegend", ",", "$", "label", ")", ":", "''", ";", "$", "rendered", "=", "sprintf", "(", "$", "stringFieldset", ",", "$", "depends", ",", "$", "legend", ",", "$", "rendered", ")", ";", "}", "$", "renderedField", "=", "$", "field", "->", "outside", "?", "sprintf", "(", "$", "outsideRendered", ",", "$", "rendered", ")", ":", "sprintf", "(", "$", "stringRendered", ",", "$", "hiddenClass", ",", "$", "label", ",", "$", "rendered", ")", ";", "return", "$", "carry", ".", "$", "renderedField", ";", "}", ")", ";", "return", "sprintf", "(", "'<table class=\"form-table\"><tbody>%s</tbody></table>%s'", ",", "$", "fields", ",", "$", "hiddenFields", ")", ";", "}" ]
Generate the form fields @return string
[ "Generate", "the", "form", "fields" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Form.php#L168-L212
train
pryley/castor-framework
src/Forms/Form.php
Form.generateSubmitButton
protected function generateSubmitButton() { $args = $this->args['submit']; is_array( $args ) ?: $args = ['text' => $args ]; $args = shortcode_atts([ 'text' => __( 'Save Changes', 'site-reviews' ), 'type' => 'primary', 'name' => 'submit', 'wrap' => true, 'other_attributes' => null, ], $args ); if( is_admin() ) { ob_start(); submit_button( $args['text'], $args['type'], $args['name'], $args['wrap'], $args['other_attributes'] ); return ob_get_clean(); } }
php
protected function generateSubmitButton() { $args = $this->args['submit']; is_array( $args ) ?: $args = ['text' => $args ]; $args = shortcode_atts([ 'text' => __( 'Save Changes', 'site-reviews' ), 'type' => 'primary', 'name' => 'submit', 'wrap' => true, 'other_attributes' => null, ], $args ); if( is_admin() ) { ob_start(); submit_button( $args['text'], $args['type'], $args['name'], $args['wrap'], $args['other_attributes'] ); return ob_get_clean(); } }
[ "protected", "function", "generateSubmitButton", "(", ")", "{", "$", "args", "=", "$", "this", "->", "args", "[", "'submit'", "]", ";", "is_array", "(", "$", "args", ")", "?", ":", "$", "args", "=", "[", "'text'", "=>", "$", "args", "]", ";", "$", "args", "=", "shortcode_atts", "(", "[", "'text'", "=>", "__", "(", "'Save Changes'", ",", "'site-reviews'", ")", ",", "'type'", "=>", "'primary'", ",", "'name'", "=>", "'submit'", ",", "'wrap'", "=>", "true", ",", "'other_attributes'", "=>", "null", ",", "]", ",", "$", "args", ")", ";", "if", "(", "is_admin", "(", ")", ")", "{", "ob_start", "(", ")", ";", "submit_button", "(", "$", "args", "[", "'text'", "]", ",", "$", "args", "[", "'type'", "]", ",", "$", "args", "[", "'name'", "]", ",", "$", "args", "[", "'wrap'", "]", ",", "$", "args", "[", "'other_attributes'", "]", ")", ";", "return", "ob_get_clean", "(", ")", ";", "}", "}" ]
Generate the form submit button @return null|string
[ "Generate", "the", "form", "submit", "button" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Form.php#L219-L238
train
Talesoft/tale-framework
src/Tale/Enum.php
Enum.getName
public static function getName( $value ) { $constants = array_flip( static::getValues() ); if( !isset( $constants[ $value ] ) ) throw new InvalidArgumentException( "Invalid argument passed to Enum::getName: $value is not a valid value in this enum" ); return $constants[ $value ]; }
php
public static function getName( $value ) { $constants = array_flip( static::getValues() ); if( !isset( $constants[ $value ] ) ) throw new InvalidArgumentException( "Invalid argument passed to Enum::getName: $value is not a valid value in this enum" ); return $constants[ $value ]; }
[ "public", "static", "function", "getName", "(", "$", "value", ")", "{", "$", "constants", "=", "array_flip", "(", "static", "::", "getValues", "(", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "constants", "[", "$", "value", "]", ")", ")", "throw", "new", "InvalidArgumentException", "(", "\"Invalid argument passed to Enum::getName: $value is not a valid value in this enum\"", ")", ";", "return", "$", "constants", "[", "$", "value", "]", ";", "}" ]
Returns the name for a specific enum value. Notice that it find's the first constant having that value, all constants with the same value after that will be ignored @param mixed $value The value for the constant name to find @return string The name of the constant with the given value
[ "Returns", "the", "name", "for", "a", "specific", "enum", "value", ".", "Notice", "that", "it", "find", "s", "the", "first", "constant", "having", "that", "value", "all", "constants", "with", "the", "same", "value", "after", "that", "will", "be", "ignored" ]
739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49
https://github.com/Talesoft/tale-framework/blob/739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49/src/Tale/Enum.php#L58-L66
train
mpf-soft/admin-widgets
datatable/columns/Basic.php
Basic.getFilter
public function getFilter() { if (false === $this->filter) { return ''; } if (is_array($this->filter)) { return Form::get()->select($this->dataProvider->filtersKey . '[' . $this->name . ']', $this->filter, null, array(), ''); } if (is_string($this->filter) && (strlen($this->filter) > 10)){ return $this->filter; } return Form::get()->input($this->dataProvider->filtersKey . '[' . $this->name . ']'); }
php
public function getFilter() { if (false === $this->filter) { return ''; } if (is_array($this->filter)) { return Form::get()->select($this->dataProvider->filtersKey . '[' . $this->name . ']', $this->filter, null, array(), ''); } if (is_string($this->filter) && (strlen($this->filter) > 10)){ return $this->filter; } return Form::get()->input($this->dataProvider->filtersKey . '[' . $this->name . ']'); }
[ "public", "function", "getFilter", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "filter", ")", "{", "return", "''", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "filter", ")", ")", "{", "return", "Form", "::", "get", "(", ")", "->", "select", "(", "$", "this", "->", "dataProvider", "->", "filtersKey", ".", "'['", ".", "$", "this", "->", "name", ".", "']'", ",", "$", "this", "->", "filter", ",", "null", ",", "array", "(", ")", ",", "''", ")", ";", "}", "if", "(", "is_string", "(", "$", "this", "->", "filter", ")", "&&", "(", "strlen", "(", "$", "this", "->", "filter", ")", ">", "10", ")", ")", "{", "return", "$", "this", "->", "filter", ";", "}", "return", "Form", "::", "get", "(", ")", "->", "input", "(", "$", "this", "->", "dataProvider", "->", "filtersKey", ".", "'['", ".", "$", "this", "->", "name", ".", "']'", ")", ";", "}" ]
Get HTML table filter for selected column; @return string
[ "Get", "HTML", "table", "filter", "for", "selected", "column", ";" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/datatable/columns/Basic.php#L181-L195
train
mpf-soft/admin-widgets
datatable/columns/Basic.php
Basic.getHeaderHtmlOptions
public function getHeaderHtmlOptions() { $r = ''; if ($this->htmlClass) { $this->headerHtmlOptions['class'] = (isset($this->headerHtmlOptions['class']) ? $this->headerHtmlOptions['class'] . ' ' : '') . $this->htmlClass; } foreach ($this->headerHtmlOptions as $k => $v) $r .= "$k = '$v' "; return $r; }
php
public function getHeaderHtmlOptions() { $r = ''; if ($this->htmlClass) { $this->headerHtmlOptions['class'] = (isset($this->headerHtmlOptions['class']) ? $this->headerHtmlOptions['class'] . ' ' : '') . $this->htmlClass; } foreach ($this->headerHtmlOptions as $k => $v) $r .= "$k = '$v' "; return $r; }
[ "public", "function", "getHeaderHtmlOptions", "(", ")", "{", "$", "r", "=", "''", ";", "if", "(", "$", "this", "->", "htmlClass", ")", "{", "$", "this", "->", "headerHtmlOptions", "[", "'class'", "]", "=", "(", "isset", "(", "$", "this", "->", "headerHtmlOptions", "[", "'class'", "]", ")", "?", "$", "this", "->", "headerHtmlOptions", "[", "'class'", "]", ".", "' '", ":", "''", ")", ".", "$", "this", "->", "htmlClass", ";", "}", "foreach", "(", "$", "this", "->", "headerHtmlOptions", "as", "$", "k", "=>", "$", "v", ")", "$", "r", ".=", "\"$k = '$v' \"", ";", "return", "$", "r", ";", "}" ]
Return html options for header; @return string
[ "Return", "html", "options", "for", "header", ";" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/datatable/columns/Basic.php#L201-L210
train
mpf-soft/admin-widgets
datatable/columns/Basic.php
Basic.getFilterHtmlOptions
public function getFilterHtmlOptions() { $r = ''; if ($this->htmlClass) { $this->filterHtmlOptions['class'] = (isset($this->filterHtmlOptions['class']) ? $this->filterHtmlOptions['class'] . ' ' : '') . $this->htmlClass; } foreach ($this->filterHtmlOptions as $k => $v) $r .= "$k = '$v' "; return $r; }
php
public function getFilterHtmlOptions() { $r = ''; if ($this->htmlClass) { $this->filterHtmlOptions['class'] = (isset($this->filterHtmlOptions['class']) ? $this->filterHtmlOptions['class'] . ' ' : '') . $this->htmlClass; } foreach ($this->filterHtmlOptions as $k => $v) $r .= "$k = '$v' "; return $r; }
[ "public", "function", "getFilterHtmlOptions", "(", ")", "{", "$", "r", "=", "''", ";", "if", "(", "$", "this", "->", "htmlClass", ")", "{", "$", "this", "->", "filterHtmlOptions", "[", "'class'", "]", "=", "(", "isset", "(", "$", "this", "->", "filterHtmlOptions", "[", "'class'", "]", ")", "?", "$", "this", "->", "filterHtmlOptions", "[", "'class'", "]", ".", "' '", ":", "''", ")", ".", "$", "this", "->", "htmlClass", ";", "}", "foreach", "(", "$", "this", "->", "filterHtmlOptions", "as", "$", "k", "=>", "$", "v", ")", "$", "r", ".=", "\"$k = '$v' \"", ";", "return", "$", "r", ";", "}" ]
Return html options for filter; @return string
[ "Return", "html", "options", "for", "filter", ";" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/datatable/columns/Basic.php#L216-L225
train
mpf-soft/admin-widgets
datatable/columns/Basic.php
Basic.getHtmlOptions
public function getHtmlOptions() { $r = ''; if ($this->htmlClass) { $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . $this->htmlClass; } foreach ($this->htmlOptions as $k => $v) $r .= "$k = '$v' "; return $r; }
php
public function getHtmlOptions() { $r = ''; if ($this->htmlClass) { $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . $this->htmlClass; } foreach ($this->htmlOptions as $k => $v) $r .= "$k = '$v' "; return $r; }
[ "public", "function", "getHtmlOptions", "(", ")", "{", "$", "r", "=", "''", ";", "if", "(", "$", "this", "->", "htmlClass", ")", "{", "$", "this", "->", "htmlOptions", "[", "'class'", "]", "=", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'class'", "]", ")", "?", "$", "this", "->", "htmlOptions", "[", "'class'", "]", ".", "' '", ":", "''", ")", ".", "$", "this", "->", "htmlClass", ";", "}", "foreach", "(", "$", "this", "->", "htmlOptions", "as", "$", "k", "=>", "$", "v", ")", "$", "r", ".=", "\"$k = '$v' \"", ";", "return", "$", "r", ";", "}" ]
Return html options for cell; @return string
[ "Return", "html", "options", "for", "cell", ";" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/datatable/columns/Basic.php#L231-L240
train
mpf-soft/admin-widgets
datatable/columns/Basic.php
Basic.getHeaderCode
public function getHeaderCode(\mpf\widgets\datatable\Table $table) { $label = $this->getLabel(); if (!$this->order) { return $label; } $order = $this->dataProvider->getOrder(); $prefix = ''; $this->iconArrowUp = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), ($this->iconSize . 'x' . $this->iconSize)), $this->iconArrowUp); $this->iconArrowDown = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), ($this->iconSize . 'x' . $this->iconSize)), $this->iconArrowDown); if ('%MPF_ASSETS%' == substr($this->iconArrowUp, 0, 12)) { $this->iconArrowUp = AssetsPublisher::get()->mpfAssetFile(substr($this->iconArrowUp, 12)); } if ('%MPF_ASSETS%' == substr($this->iconArrowDown, 0, 12)) { $this->iconArrowDown = AssetsPublisher::get()->mpfAssetFile(substr($this->iconArrowDown, 12)); } if ($order[0] == (is_string($this->order) ? $this->order : '`' . $this->name . '`')) { $prefix = ('ASC' == $order[1]) ? Html::get()->image($this->iconArrowUp, 'Order Descendent', ['class' => 'order-by-img']) : Html::get()->image($this->iconArrowDown, 'Order Ascendent', ['class' => 'order-by-img']); } return $this->dataProvider->getColumnOrderLink(is_string($this->order) ? $this->order : '`' . $this->name . '`', $prefix . $label); }
php
public function getHeaderCode(\mpf\widgets\datatable\Table $table) { $label = $this->getLabel(); if (!$this->order) { return $label; } $order = $this->dataProvider->getOrder(); $prefix = ''; $this->iconArrowUp = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), ($this->iconSize . 'x' . $this->iconSize)), $this->iconArrowUp); $this->iconArrowDown = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), ($this->iconSize . 'x' . $this->iconSize)), $this->iconArrowDown); if ('%MPF_ASSETS%' == substr($this->iconArrowUp, 0, 12)) { $this->iconArrowUp = AssetsPublisher::get()->mpfAssetFile(substr($this->iconArrowUp, 12)); } if ('%MPF_ASSETS%' == substr($this->iconArrowDown, 0, 12)) { $this->iconArrowDown = AssetsPublisher::get()->mpfAssetFile(substr($this->iconArrowDown, 12)); } if ($order[0] == (is_string($this->order) ? $this->order : '`' . $this->name . '`')) { $prefix = ('ASC' == $order[1]) ? Html::get()->image($this->iconArrowUp, 'Order Descendent', ['class' => 'order-by-img']) : Html::get()->image($this->iconArrowDown, 'Order Ascendent', ['class' => 'order-by-img']); } return $this->dataProvider->getColumnOrderLink(is_string($this->order) ? $this->order : '`' . $this->name . '`', $prefix . $label); }
[ "public", "function", "getHeaderCode", "(", "\\", "mpf", "\\", "widgets", "\\", "datatable", "\\", "Table", "$", "table", ")", "{", "$", "label", "=", "$", "this", "->", "getLabel", "(", ")", ";", "if", "(", "!", "$", "this", "->", "order", ")", "{", "return", "$", "label", ";", "}", "$", "order", "=", "$", "this", "->", "dataProvider", "->", "getOrder", "(", ")", ";", "$", "prefix", "=", "''", ";", "$", "this", "->", "iconArrowUp", "=", "str_replace", "(", "array", "(", "'%DATATABLE_ASSETS%'", ",", "'%SIZE%'", ")", ",", "array", "(", "$", "table", "->", "getAssetsURL", "(", ")", ",", "(", "$", "this", "->", "iconSize", ".", "'x'", ".", "$", "this", "->", "iconSize", ")", ")", ",", "$", "this", "->", "iconArrowUp", ")", ";", "$", "this", "->", "iconArrowDown", "=", "str_replace", "(", "array", "(", "'%DATATABLE_ASSETS%'", ",", "'%SIZE%'", ")", ",", "array", "(", "$", "table", "->", "getAssetsURL", "(", ")", ",", "(", "$", "this", "->", "iconSize", ".", "'x'", ".", "$", "this", "->", "iconSize", ")", ")", ",", "$", "this", "->", "iconArrowDown", ")", ";", "if", "(", "'%MPF_ASSETS%'", "==", "substr", "(", "$", "this", "->", "iconArrowUp", ",", "0", ",", "12", ")", ")", "{", "$", "this", "->", "iconArrowUp", "=", "AssetsPublisher", "::", "get", "(", ")", "->", "mpfAssetFile", "(", "substr", "(", "$", "this", "->", "iconArrowUp", ",", "12", ")", ")", ";", "}", "if", "(", "'%MPF_ASSETS%'", "==", "substr", "(", "$", "this", "->", "iconArrowDown", ",", "0", ",", "12", ")", ")", "{", "$", "this", "->", "iconArrowDown", "=", "AssetsPublisher", "::", "get", "(", ")", "->", "mpfAssetFile", "(", "substr", "(", "$", "this", "->", "iconArrowDown", ",", "12", ")", ")", ";", "}", "if", "(", "$", "order", "[", "0", "]", "==", "(", "is_string", "(", "$", "this", "->", "order", ")", "?", "$", "this", "->", "order", ":", "'`'", ".", "$", "this", "->", "name", ".", "'`'", ")", ")", "{", "$", "prefix", "=", "(", "'ASC'", "==", "$", "order", "[", "1", "]", ")", "?", "Html", "::", "get", "(", ")", "->", "image", "(", "$", "this", "->", "iconArrowUp", ",", "'Order Descendent'", ",", "[", "'class'", "=>", "'order-by-img'", "]", ")", ":", "Html", "::", "get", "(", ")", "->", "image", "(", "$", "this", "->", "iconArrowDown", ",", "'Order Ascendent'", ",", "[", "'class'", "=>", "'order-by-img'", "]", ")", ";", "}", "return", "$", "this", "->", "dataProvider", "->", "getColumnOrderLink", "(", "is_string", "(", "$", "this", "->", "order", ")", "?", "$", "this", "->", "order", ":", "'`'", ".", "$", "this", "->", "name", ".", "'`'", ",", "$", "prefix", ".", "$", "label", ")", ";", "}" ]
Get HTML code for header @param Table $table @return string
[ "Get", "HTML", "code", "for", "header" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/datatable/columns/Basic.php#L247-L268
train
Subscribo/klarna-invoice-sdk-wrapped
src/CurlTransport.php
CurlTransport.send
public function send($request) { $this->handle->init(); $this->handle->setOption(CURLOPT_URL, $request->getURL()); $this->handle->setOption(CURLOPT_HTTPHEADER, $request->getHeaders()); $this->handle->setOption(CURLOPT_RETURNTRANSFER, true); $this->handle->setOption(CURLOPT_CONNECTTIMEOUT, $this->getTimeout()); $this->handle->setOption(CURLOPT_TIMEOUT, $this->getTimeout()); $this->handle->setOption(CURLOPT_SSL_VERIFYHOST, 2); $this->handle->setOption(CURLOPT_SSL_VERIFYPEER, true); $data = $this->handle->execute(); $info = $this->handle->getInfo(); $error = $this->handle->getError(); $this->handle->close(); /* * A failure occurred if: * payload is false (e.g. HTTP timeout?). * info is false, then it has no HTTP status code. */ if (strlen($error) > 0) { throw new KlarnaException( "Connection failed with error: {$error}" ); } return $request->createResponse(intval($info['http_code']), $data); }
php
public function send($request) { $this->handle->init(); $this->handle->setOption(CURLOPT_URL, $request->getURL()); $this->handle->setOption(CURLOPT_HTTPHEADER, $request->getHeaders()); $this->handle->setOption(CURLOPT_RETURNTRANSFER, true); $this->handle->setOption(CURLOPT_CONNECTTIMEOUT, $this->getTimeout()); $this->handle->setOption(CURLOPT_TIMEOUT, $this->getTimeout()); $this->handle->setOption(CURLOPT_SSL_VERIFYHOST, 2); $this->handle->setOption(CURLOPT_SSL_VERIFYPEER, true); $data = $this->handle->execute(); $info = $this->handle->getInfo(); $error = $this->handle->getError(); $this->handle->close(); /* * A failure occurred if: * payload is false (e.g. HTTP timeout?). * info is false, then it has no HTTP status code. */ if (strlen($error) > 0) { throw new KlarnaException( "Connection failed with error: {$error}" ); } return $request->createResponse(intval($info['http_code']), $data); }
[ "public", "function", "send", "(", "$", "request", ")", "{", "$", "this", "->", "handle", "->", "init", "(", ")", ";", "$", "this", "->", "handle", "->", "setOption", "(", "CURLOPT_URL", ",", "$", "request", "->", "getURL", "(", ")", ")", ";", "$", "this", "->", "handle", "->", "setOption", "(", "CURLOPT_HTTPHEADER", ",", "$", "request", "->", "getHeaders", "(", ")", ")", ";", "$", "this", "->", "handle", "->", "setOption", "(", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "this", "->", "handle", "->", "setOption", "(", "CURLOPT_CONNECTTIMEOUT", ",", "$", "this", "->", "getTimeout", "(", ")", ")", ";", "$", "this", "->", "handle", "->", "setOption", "(", "CURLOPT_TIMEOUT", ",", "$", "this", "->", "getTimeout", "(", ")", ")", ";", "$", "this", "->", "handle", "->", "setOption", "(", "CURLOPT_SSL_VERIFYHOST", ",", "2", ")", ";", "$", "this", "->", "handle", "->", "setOption", "(", "CURLOPT_SSL_VERIFYPEER", ",", "true", ")", ";", "$", "data", "=", "$", "this", "->", "handle", "->", "execute", "(", ")", ";", "$", "info", "=", "$", "this", "->", "handle", "->", "getInfo", "(", ")", ";", "$", "error", "=", "$", "this", "->", "handle", "->", "getError", "(", ")", ";", "$", "this", "->", "handle", "->", "close", "(", ")", ";", "/*\n * A failure occurred if:\n * payload is false (e.g. HTTP timeout?).\n * info is false, then it has no HTTP status code.\n */", "if", "(", "strlen", "(", "$", "error", ")", ">", "0", ")", "{", "throw", "new", "KlarnaException", "(", "\"Connection failed with error: {$error}\"", ")", ";", "}", "return", "$", "request", "->", "createResponse", "(", "intval", "(", "$", "info", "[", "'http_code'", "]", ")", ",", "$", "data", ")", ";", "}" ]
Send a request object @param object $request The request to send @throws KlarnaException For e.g. a timeout @return object A response to the request sent
[ "Send", "a", "request", "object" ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/CurlTransport.php#L63-L93
train
gregorybesson/PlaygroundStats
src/Service/Stats.php
Stats.getParticipationsByDayByGame
public function getParticipationsByDayByGame($game = null) { $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default'); $emConfig = $em->getConfiguration(); $emConfig->addCustomDatetimeFunction('DATE', '\DoctrineExtensions\Query\Mysql\Date'); if ($game !== null) { $query = $em->createQuery(' SELECT DATE(e.created_at) as date, COUNT(e.id) as qty FROM PlaygroundGame\Entity\Entry e WHERE e.game = :game AND e.active=0 GROUP BY date '); $query->setParameter('game', $game); } else { $query = $em->createQuery(' SELECT DATE(e.created_at) as date, COUNT(e.id) as qty FROM PlaygroundGame\Entity\Entry e WHERE e.active=0 GROUP BY date '); } $result = $query->getResult(); return $result; }
php
public function getParticipationsByDayByGame($game = null) { $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default'); $emConfig = $em->getConfiguration(); $emConfig->addCustomDatetimeFunction('DATE', '\DoctrineExtensions\Query\Mysql\Date'); if ($game !== null) { $query = $em->createQuery(' SELECT DATE(e.created_at) as date, COUNT(e.id) as qty FROM PlaygroundGame\Entity\Entry e WHERE e.game = :game AND e.active=0 GROUP BY date '); $query->setParameter('game', $game); } else { $query = $em->createQuery(' SELECT DATE(e.created_at) as date, COUNT(e.id) as qty FROM PlaygroundGame\Entity\Entry e WHERE e.active=0 GROUP BY date '); } $result = $query->getResult(); return $result; }
[ "public", "function", "getParticipationsByDayByGame", "(", "$", "game", "=", "null", ")", "{", "$", "em", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "'doctrine.entitymanager.orm_default'", ")", ";", "$", "emConfig", "=", "$", "em", "->", "getConfiguration", "(", ")", ";", "$", "emConfig", "->", "addCustomDatetimeFunction", "(", "'DATE'", ",", "'\\DoctrineExtensions\\Query\\Mysql\\Date'", ")", ";", "if", "(", "$", "game", "!==", "null", ")", "{", "$", "query", "=", "$", "em", "->", "createQuery", "(", "'\n SELECT DATE(e.created_at) as date, COUNT(e.id) as qty FROM PlaygroundGame\\Entity\\Entry e\n WHERE e.game = :game\n AND e.active=0\n GROUP BY date\n '", ")", ";", "$", "query", "->", "setParameter", "(", "'game'", ",", "$", "game", ")", ";", "}", "else", "{", "$", "query", "=", "$", "em", "->", "createQuery", "(", "'\n SELECT DATE(e.created_at) as date, COUNT(e.id) as qty FROM PlaygroundGame\\Entity\\Entry e\n WHERE e.active=0\n GROUP BY date\n '", ")", ";", "}", "$", "result", "=", "$", "query", "->", "getResult", "(", ")", ";", "return", "$", "result", ";", "}" ]
Return count of participation for a game @param number|unknown $startDate @param number|unknown $endDate
[ "Return", "count", "of", "participation", "for", "a", "game" ]
166fb340c0b6a19fd5a333eeb8b54350f7cf3360
https://github.com/gregorybesson/PlaygroundStats/blob/166fb340c0b6a19fd5a333eeb8b54350f7cf3360/src/Service/Stats.php#L319-L344
train
jenskooij/cloudcontrol
src/components/LanguageComponent.php
LanguageComponent.checkParameters
protected function checkParameters() { if (isset($this->parameters[self::PARAMETER_DEFAULT_LANGUAGE])) { self::$DEFAULT_LANGUAGE = $this->parameters[self::PARAMETER_DEFAULT_LANGUAGE]; unset($this->parameters[self::PARAMETER_DEFAULT_LANGUAGE]); } if (isset($this->parameters[self::PARAMETER_ACCEPTED_LANGUAGES])) { $this->acceptedLanguages = explode(',', $this->parameters[self::PARAMETER_ACCEPTED_LANGUAGES]); unset($this->parameters[self::PARAMETER_ACCEPTED_LANGUAGES]); } if (isset($this->parameters[self::PARAMETER_LANGUAGE_PARAMETER_NAME])) { $this->languageParameterName = $this->parameters[self::PARAMETER_LANGUAGE_PARAMETER_NAME]; unset($this->parameters[self::PARAMETER_LANGUAGE_PARAMETER_NAME]); } if (isset($this->parameters[self::PARAMETER_FORCE_REDIRECT])) { $this->forceRedirect = (bool)$this->parameters[self::PARAMETER_FORCE_REDIRECT]; unset($this->parameters[self::PARAMETER_FORCE_REDIRECT]); } }
php
protected function checkParameters() { if (isset($this->parameters[self::PARAMETER_DEFAULT_LANGUAGE])) { self::$DEFAULT_LANGUAGE = $this->parameters[self::PARAMETER_DEFAULT_LANGUAGE]; unset($this->parameters[self::PARAMETER_DEFAULT_LANGUAGE]); } if (isset($this->parameters[self::PARAMETER_ACCEPTED_LANGUAGES])) { $this->acceptedLanguages = explode(',', $this->parameters[self::PARAMETER_ACCEPTED_LANGUAGES]); unset($this->parameters[self::PARAMETER_ACCEPTED_LANGUAGES]); } if (isset($this->parameters[self::PARAMETER_LANGUAGE_PARAMETER_NAME])) { $this->languageParameterName = $this->parameters[self::PARAMETER_LANGUAGE_PARAMETER_NAME]; unset($this->parameters[self::PARAMETER_LANGUAGE_PARAMETER_NAME]); } if (isset($this->parameters[self::PARAMETER_FORCE_REDIRECT])) { $this->forceRedirect = (bool)$this->parameters[self::PARAMETER_FORCE_REDIRECT]; unset($this->parameters[self::PARAMETER_FORCE_REDIRECT]); } }
[ "protected", "function", "checkParameters", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_DEFAULT_LANGUAGE", "]", ")", ")", "{", "self", "::", "$", "DEFAULT_LANGUAGE", "=", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_DEFAULT_LANGUAGE", "]", ";", "unset", "(", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_DEFAULT_LANGUAGE", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_ACCEPTED_LANGUAGES", "]", ")", ")", "{", "$", "this", "->", "acceptedLanguages", "=", "explode", "(", "','", ",", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_ACCEPTED_LANGUAGES", "]", ")", ";", "unset", "(", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_ACCEPTED_LANGUAGES", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_LANGUAGE_PARAMETER_NAME", "]", ")", ")", "{", "$", "this", "->", "languageParameterName", "=", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_LANGUAGE_PARAMETER_NAME", "]", ";", "unset", "(", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_LANGUAGE_PARAMETER_NAME", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_FORCE_REDIRECT", "]", ")", ")", "{", "$", "this", "->", "forceRedirect", "=", "(", "bool", ")", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_FORCE_REDIRECT", "]", ";", "unset", "(", "$", "this", "->", "parameters", "[", "self", "::", "PARAMETER_FORCE_REDIRECT", "]", ")", ";", "}", "}" ]
Checks to see if any parameters are given from the configuration in the CMS
[ "Checks", "to", "see", "if", "any", "parameters", "are", "given", "from", "the", "configuration", "in", "the", "CMS" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/components/LanguageComponent.php#L66-L84
train
jenskooij/cloudcontrol
src/components/LanguageComponent.php
LanguageComponent.detectLanguage
protected function detectLanguage($lang, $request) { $lang = $this->setLanguagInSession($lang); $this->sessionValues = $_SESSION[self::SESSION_PARAMETER_LANGUAGE_COMPONENT]; $this->checkForceRedirect($lang, $request); }
php
protected function detectLanguage($lang, $request) { $lang = $this->setLanguagInSession($lang); $this->sessionValues = $_SESSION[self::SESSION_PARAMETER_LANGUAGE_COMPONENT]; $this->checkForceRedirect($lang, $request); }
[ "protected", "function", "detectLanguage", "(", "$", "lang", ",", "$", "request", ")", "{", "$", "lang", "=", "$", "this", "->", "setLanguagInSession", "(", "$", "lang", ")", ";", "$", "this", "->", "sessionValues", "=", "$", "_SESSION", "[", "self", "::", "SESSION_PARAMETER_LANGUAGE_COMPONENT", "]", ";", "$", "this", "->", "checkForceRedirect", "(", "$", "lang", ",", "$", "request", ")", ";", "}" ]
Check if the found language is allowed and if an action is to be taken. @param $lang @param Request $request
[ "Check", "if", "the", "found", "language", "is", "allowed", "and", "if", "an", "action", "is", "to", "be", "taken", "." ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/components/LanguageComponent.php#L102-L109
train
jenskooij/cloudcontrol
src/components/LanguageComponent.php
LanguageComponent.checkLanguageSwitch
protected function checkLanguageSwitch($request) { if (isset($request::$get['langSwitch'])) { $this->forceRedirect = true; $this->detectLanguage($request::$get['langSwitch'], $request); } }
php
protected function checkLanguageSwitch($request) { if (isset($request::$get['langSwitch'])) { $this->forceRedirect = true; $this->detectLanguage($request::$get['langSwitch'], $request); } }
[ "protected", "function", "checkLanguageSwitch", "(", "$", "request", ")", "{", "if", "(", "isset", "(", "$", "request", "::", "$", "get", "[", "'langSwitch'", "]", ")", ")", "{", "$", "this", "->", "forceRedirect", "=", "true", ";", "$", "this", "->", "detectLanguage", "(", "$", "request", "::", "$", "get", "[", "'langSwitch'", "]", ",", "$", "request", ")", ";", "}", "}" ]
Detect if the language is switched manually @param Request $request
[ "Detect", "if", "the", "language", "is", "switched", "manually" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/components/LanguageComponent.php#L116-L122
train
rawphp/RawDispatcher
src/RawPHP/RawDispatcher/Dispatcher.php
Dispatcher.removeListener
public function removeListener( $eventName, IListener $listener ) { if ( !isset( $this->listeners[ $eventName ] ) ) { return $this; } foreach ( $this->listeners[ $eventName ] as $priority => $listeners ) { if ( FALSE !== ( $key = array_search( $listener, $listeners, TRUE ) ) ) { unset( $this->listeners[ $eventName ][ $priority ][ $key ], $this->_sorted[ $eventName ] ); } } return $this; }
php
public function removeListener( $eventName, IListener $listener ) { if ( !isset( $this->listeners[ $eventName ] ) ) { return $this; } foreach ( $this->listeners[ $eventName ] as $priority => $listeners ) { if ( FALSE !== ( $key = array_search( $listener, $listeners, TRUE ) ) ) { unset( $this->listeners[ $eventName ][ $priority ][ $key ], $this->_sorted[ $eventName ] ); } } return $this; }
[ "public", "function", "removeListener", "(", "$", "eventName", ",", "IListener", "$", "listener", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "eventName", "]", ")", ")", "{", "return", "$", "this", ";", "}", "foreach", "(", "$", "this", "->", "listeners", "[", "$", "eventName", "]", "as", "$", "priority", "=>", "$", "listeners", ")", "{", "if", "(", "FALSE", "!==", "(", "$", "key", "=", "array_search", "(", "$", "listener", ",", "$", "listeners", ",", "TRUE", ")", ")", ")", "{", "unset", "(", "$", "this", "->", "listeners", "[", "$", "eventName", "]", "[", "$", "priority", "]", "[", "$", "key", "]", ",", "$", "this", "->", "_sorted", "[", "$", "eventName", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Remove a listener from an event. @param string $eventName @param IListener $listener @return IDispatcher
[ "Remove", "a", "listener", "from", "an", "event", "." ]
b9a62f3ef2266d355e2647d681312770158a6843
https://github.com/rawphp/RawDispatcher/blob/b9a62f3ef2266d355e2647d681312770158a6843/src/RawPHP/RawDispatcher/Dispatcher.php#L102-L118
train
rawphp/RawDispatcher
src/RawPHP/RawDispatcher/Dispatcher.php
Dispatcher.getListeners
public function getListeners( $eventName = NULL ) { if ( NULL !== $eventName ) { if ( !isset( $this->_sorted[ $eventName ] ) ) { $this->sortListeners( $eventName ); } return $this->_sorted[ $eventName ]; } foreach ( array_keys( $this->listeners ) as $eventName ) { if ( !isset( $this->_sorted[ $eventName ] ) ) { $this->sortListeners( $eventName ); } } return array_filter( $this->_sorted ); }
php
public function getListeners( $eventName = NULL ) { if ( NULL !== $eventName ) { if ( !isset( $this->_sorted[ $eventName ] ) ) { $this->sortListeners( $eventName ); } return $this->_sorted[ $eventName ]; } foreach ( array_keys( $this->listeners ) as $eventName ) { if ( !isset( $this->_sorted[ $eventName ] ) ) { $this->sortListeners( $eventName ); } } return array_filter( $this->_sorted ); }
[ "public", "function", "getListeners", "(", "$", "eventName", "=", "NULL", ")", "{", "if", "(", "NULL", "!==", "$", "eventName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_sorted", "[", "$", "eventName", "]", ")", ")", "{", "$", "this", "->", "sortListeners", "(", "$", "eventName", ")", ";", "}", "return", "$", "this", "->", "_sorted", "[", "$", "eventName", "]", ";", "}", "foreach", "(", "array_keys", "(", "$", "this", "->", "listeners", ")", "as", "$", "eventName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_sorted", "[", "$", "eventName", "]", ")", ")", "{", "$", "this", "->", "sortListeners", "(", "$", "eventName", ")", ";", "}", "}", "return", "array_filter", "(", "$", "this", "->", "_sorted", ")", ";", "}" ]
Get all listeners or just for an event. @param string $eventName @return array
[ "Get", "all", "listeners", "or", "just", "for", "an", "event", "." ]
b9a62f3ef2266d355e2647d681312770158a6843
https://github.com/rawphp/RawDispatcher/blob/b9a62f3ef2266d355e2647d681312770158a6843/src/RawPHP/RawDispatcher/Dispatcher.php#L127-L148
train
rawphp/RawDispatcher
src/RawPHP/RawDispatcher/Dispatcher.php
Dispatcher.sortListeners
protected function sortListeners( $eventName ) { $this->_sorted[ $eventName ] = [ ]; if ( isset( $this->listeners[ $eventName ] ) ) { krsort( $this->listeners[ $eventName ] ); $this->_sorted[ $eventName ] = call_user_func_array( 'array_merge', $this->listeners[ $eventName ] ); } }
php
protected function sortListeners( $eventName ) { $this->_sorted[ $eventName ] = [ ]; if ( isset( $this->listeners[ $eventName ] ) ) { krsort( $this->listeners[ $eventName ] ); $this->_sorted[ $eventName ] = call_user_func_array( 'array_merge', $this->listeners[ $eventName ] ); } }
[ "protected", "function", "sortListeners", "(", "$", "eventName", ")", "{", "$", "this", "->", "_sorted", "[", "$", "eventName", "]", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "listeners", "[", "$", "eventName", "]", ")", ")", "{", "krsort", "(", "$", "this", "->", "listeners", "[", "$", "eventName", "]", ")", ";", "$", "this", "->", "_sorted", "[", "$", "eventName", "]", "=", "call_user_func_array", "(", "'array_merge'", ",", "$", "this", "->", "listeners", "[", "$", "eventName", "]", ")", ";", "}", "}" ]
Sorts listeners for an event. @param string $eventName
[ "Sorts", "listeners", "for", "an", "event", "." ]
b9a62f3ef2266d355e2647d681312770158a6843
https://github.com/rawphp/RawDispatcher/blob/b9a62f3ef2266d355e2647d681312770158a6843/src/RawPHP/RawDispatcher/Dispatcher.php#L167-L176
train
MichaelJ2324/PHP-REST-Client
src/Auth/Abstracts/AbstractOAuth2Controller.php
AbstractOAuth2Controller.refresh
public function refresh() { if (isset($this->token['refresh_token'])) { $Endpoint = $this->getActionEndpoint(self::ACTION_OAUTH_REFRESH); if ($Endpoint !== null) { $Endpoint = $this->configureEndpoint($Endpoint, self::ACTION_OAUTH_REFRESH); $response = $Endpoint->execute()->getResponse(); if ($response->getStatus() == '200') { //@codeCoverageIgnoreStart $this->setToken($response->getBody()); return TRUE; } //@codeCoverageIgnoreEnd } } return FALSE; }
php
public function refresh() { if (isset($this->token['refresh_token'])) { $Endpoint = $this->getActionEndpoint(self::ACTION_OAUTH_REFRESH); if ($Endpoint !== null) { $Endpoint = $this->configureEndpoint($Endpoint, self::ACTION_OAUTH_REFRESH); $response = $Endpoint->execute()->getResponse(); if ($response->getStatus() == '200') { //@codeCoverageIgnoreStart $this->setToken($response->getBody()); return TRUE; } //@codeCoverageIgnoreEnd } } return FALSE; }
[ "public", "function", "refresh", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "token", "[", "'refresh_token'", "]", ")", ")", "{", "$", "Endpoint", "=", "$", "this", "->", "getActionEndpoint", "(", "self", "::", "ACTION_OAUTH_REFRESH", ")", ";", "if", "(", "$", "Endpoint", "!==", "null", ")", "{", "$", "Endpoint", "=", "$", "this", "->", "configureEndpoint", "(", "$", "Endpoint", ",", "self", "::", "ACTION_OAUTH_REFRESH", ")", ";", "$", "response", "=", "$", "Endpoint", "->", "execute", "(", ")", "->", "getResponse", "(", ")", ";", "if", "(", "$", "response", "->", "getStatus", "(", ")", "==", "'200'", ")", "{", "//@codeCoverageIgnoreStart", "$", "this", "->", "setToken", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "return", "TRUE", ";", "}", "//@codeCoverageIgnoreEnd", "}", "}", "return", "FALSE", ";", "}" ]
Refreshes the OAuth 2 Token @return bool @throws InvalidToken
[ "Refreshes", "the", "OAuth", "2", "Token" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Auth/Abstracts/AbstractOAuth2Controller.php#L112-L128
train
MichaelJ2324/PHP-REST-Client
src/Auth/Abstracts/AbstractOAuth2Controller.php
AbstractOAuth2Controller.isAuthenticated
public function isAuthenticated() { if (parent::isAuthenticated()) { if (isset($this->token['access_token'])) { $expired = $this->isTokenExpired(); //We err on the side of valid vs invalid, as the API will invalidate if we are wrong, which isn't harmful if ($expired === false || $expired === -1) { return true; } } } return false; }
php
public function isAuthenticated() { if (parent::isAuthenticated()) { if (isset($this->token['access_token'])) { $expired = $this->isTokenExpired(); //We err on the side of valid vs invalid, as the API will invalidate if we are wrong, which isn't harmful if ($expired === false || $expired === -1) { return true; } } } return false; }
[ "public", "function", "isAuthenticated", "(", ")", "{", "if", "(", "parent", "::", "isAuthenticated", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "token", "[", "'access_token'", "]", ")", ")", "{", "$", "expired", "=", "$", "this", "->", "isTokenExpired", "(", ")", ";", "//We err on the side of valid vs invalid, as the API will invalidate if we are wrong, which isn't harmful", "if", "(", "$", "expired", "===", "false", "||", "$", "expired", "===", "-", "1", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks for Access Token property in token, and checks if Token is expired @inheritdoc
[ "Checks", "for", "Access", "Token", "property", "in", "token", "and", "checks", "if", "Token", "is", "expired" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Auth/Abstracts/AbstractOAuth2Controller.php#L134-L146
train
MichaelJ2324/PHP-REST-Client
src/Auth/Abstracts/AbstractOAuth2Controller.php
AbstractOAuth2Controller.configureRefreshEndpoint
protected function configureRefreshEndpoint(EndpointInterface $Endpoint) { $data = array(); $data['client_id'] = $this->credentials['client_id']; $data['client_secret'] = $this->credentials['client_secret']; $data['grant_type'] = self::OAUTH_REFRESH_GRANT; $data['refresh_token'] = $this->token['refresh_token']; return $Endpoint->setData($data); }
php
protected function configureRefreshEndpoint(EndpointInterface $Endpoint) { $data = array(); $data['client_id'] = $this->credentials['client_id']; $data['client_secret'] = $this->credentials['client_secret']; $data['grant_type'] = self::OAUTH_REFRESH_GRANT; $data['refresh_token'] = $this->token['refresh_token']; return $Endpoint->setData($data); }
[ "protected", "function", "configureRefreshEndpoint", "(", "EndpointInterface", "$", "Endpoint", ")", "{", "$", "data", "=", "array", "(", ")", ";", "$", "data", "[", "'client_id'", "]", "=", "$", "this", "->", "credentials", "[", "'client_id'", "]", ";", "$", "data", "[", "'client_secret'", "]", "=", "$", "this", "->", "credentials", "[", "'client_secret'", "]", ";", "$", "data", "[", "'grant_type'", "]", "=", "self", "::", "OAUTH_REFRESH_GRANT", ";", "$", "data", "[", "'refresh_token'", "]", "=", "$", "this", "->", "token", "[", "'refresh_token'", "]", ";", "return", "$", "Endpoint", "->", "setData", "(", "$", "data", ")", ";", "}" ]
Configure the Refresh Data based on Creds, Token, and Refresh Grant Type @param EndpointInterface $Endpoint @return EndpointInterface
[ "Configure", "the", "Refresh", "Data", "based", "on", "Creds", "Token", "and", "Refresh", "Grant", "Type" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Auth/Abstracts/AbstractOAuth2Controller.php#L183-L191
train
MichaelJ2324/PHP-REST-Client
src/Auth/Abstracts/AbstractOAuth2Controller.php
AbstractOAuth2Controller.configureAuthenticationEndpoint
protected function configureAuthenticationEndpoint(EndpointInterface $Endpoint) { $data = $this->credentials; $data['grant_type'] = static::$_DEFAULT_GRANT_TYPE; return $Endpoint->setData($data); }
php
protected function configureAuthenticationEndpoint(EndpointInterface $Endpoint) { $data = $this->credentials; $data['grant_type'] = static::$_DEFAULT_GRANT_TYPE; return $Endpoint->setData($data); }
[ "protected", "function", "configureAuthenticationEndpoint", "(", "EndpointInterface", "$", "Endpoint", ")", "{", "$", "data", "=", "$", "this", "->", "credentials", ";", "$", "data", "[", "'grant_type'", "]", "=", "static", "::", "$", "_DEFAULT_GRANT_TYPE", ";", "return", "$", "Endpoint", "->", "setData", "(", "$", "data", ")", ";", "}" ]
Add OAuth Grant Type for Auth @inheritdoc
[ "Add", "OAuth", "Grant", "Type", "for", "Auth" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Auth/Abstracts/AbstractOAuth2Controller.php#L197-L202
train
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Persister/PersistenceBuilder.php
PersistenceBuilder.prepareAttributeValue
public function prepareAttributeValue($mapping, $value) { if ($value === null) { return Type::getNull(); } $type = $mapping !== null ? $mapping->getType() : TypeFactory::getTypeFromPHPVariable($value); if (is_array($value)) { $value = array_map( function ($v) { $this->prepareAttributeValue(null, $v); }, $value ); } return $type->convertToDatabaseValue($value); }
php
public function prepareAttributeValue($mapping, $value) { if ($value === null) { return Type::getNull(); } $type = $mapping !== null ? $mapping->getType() : TypeFactory::getTypeFromPHPVariable($value); if (is_array($value)) { $value = array_map( function ($v) { $this->prepareAttributeValue(null, $v); }, $value ); } return $type->convertToDatabaseValue($value); }
[ "public", "function", "prepareAttributeValue", "(", "$", "mapping", ",", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "return", "Type", "::", "getNull", "(", ")", ";", "}", "$", "type", "=", "$", "mapping", "!==", "null", "?", "$", "mapping", "->", "getType", "(", ")", ":", "TypeFactory", "::", "getTypeFromPHPVariable", "(", "$", "value", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "array_map", "(", "function", "(", "$", "v", ")", "{", "$", "this", "->", "prepareAttributeValue", "(", "null", ",", "$", "v", ")", ";", "}", ",", "$", "value", ")", ";", "}", "return", "$", "type", "->", "convertToDatabaseValue", "(", "$", "value", ")", ";", "}" ]
Prepares a non-associated attribute value. @param PropertyMetadata|null $mapping @param mixed $value @return array
[ "Prepares", "a", "non", "-", "associated", "attribute", "value", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/PersistenceBuilder.php#L113-L131
train
mylxsw/FocusPHP
src/MVC/SmpView.php
SmpView.assign
public function assign($key, $value) { if (empty($key)) { throw new \RuntimeException('ASSIGN_KEY_EMPTY'); } $this->_data[$key] = $value; return $this; }
php
public function assign($key, $value) { if (empty($key)) { throw new \RuntimeException('ASSIGN_KEY_EMPTY'); } $this->_data[$key] = $value; return $this; }
[ "public", "function", "assign", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'ASSIGN_KEY_EMPTY'", ")", ";", "}", "$", "this", "->", "_data", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
passing data to template parser. @param string $key data key @param mixed $value data body @return View
[ "passing", "data", "to", "template", "parser", "." ]
33922bacbea66f11f874d991d7308a36cdf5831a
https://github.com/mylxsw/FocusPHP/blob/33922bacbea66f11f874d991d7308a36cdf5831a/src/MVC/SmpView.php#L89-L97
train
mylxsw/FocusPHP
src/MVC/SmpView.php
SmpView.setLayout
public function setLayout($layoutName) { $this->_layout = empty($layoutName) ? null : $layoutName.$this->_suffix; }
php
public function setLayout($layoutName) { $this->_layout = empty($layoutName) ? null : $layoutName.$this->_suffix; }
[ "public", "function", "setLayout", "(", "$", "layoutName", ")", "{", "$", "this", "->", "_layout", "=", "empty", "(", "$", "layoutName", ")", "?", "null", ":", "$", "layoutName", ".", "$", "this", "->", "_suffix", ";", "}" ]
set the default layout name. @param string|null $layoutName layout name
[ "set", "the", "default", "layout", "name", "." ]
33922bacbea66f11f874d991d7308a36cdf5831a
https://github.com/mylxsw/FocusPHP/blob/33922bacbea66f11f874d991d7308a36cdf5831a/src/MVC/SmpView.php#L142-L145
train
mylxsw/FocusPHP
src/MVC/SmpView.php
SmpView.remove
public function remove($key) { if (isset($this->_data[$key])) { unset($this->_data[$key]); } return $this; }
php
public function remove($key) { if (isset($this->_data[$key])) { unset($this->_data[$key]); } return $this; }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_data", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "_data", "[", "$", "key", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove a key from data array. @param string $key the key to remove @return View
[ "Remove", "a", "key", "from", "data", "array", "." ]
33922bacbea66f11f874d991d7308a36cdf5831a
https://github.com/mylxsw/FocusPHP/blob/33922bacbea66f11f874d991d7308a36cdf5831a/src/MVC/SmpView.php#L167-L174
train
romm/configuration_object
Classes/Service/Items/Persistence/PersistenceService.php
PersistenceService.configurationObjectAfter
public function configurationObjectAfter(GetConfigurationObjectDTO $serviceDataTransferObject) { // Will save the registered domain object properties paths. $this->delay( self::PRIORITY_SAVE_DOMAIN_OBJECTS_PATHS, function (GetConfigurationObjectDTO $serviceDataTransferObject) { if (false === empty($this->domainObjectsPaths)) { $serviceDataTransferObject->getResult() ->setInternalVar('domainObjectsPaths', $this->domainObjectsPaths); } } ); // Will fetch real object instances of the registered domain object properties. $this->delay( self::PRIORITY_FETCH_DOMAIN_OBJECTS, function (GetConfigurationObjectDTO $serviceDataTransferObject) { $domainObjectPaths = $serviceDataTransferObject->getResult()->getInternalVar('domainObjectsPaths'); if (false === empty($domainObjectPaths)) { foreach ($domainObjectPaths as $path => $type) { $this->fetchDomainObjectsInternal( $serviceDataTransferObject->getResult()->getObject(true), explode('.', $path), $type ); } } } ); }
php
public function configurationObjectAfter(GetConfigurationObjectDTO $serviceDataTransferObject) { // Will save the registered domain object properties paths. $this->delay( self::PRIORITY_SAVE_DOMAIN_OBJECTS_PATHS, function (GetConfigurationObjectDTO $serviceDataTransferObject) { if (false === empty($this->domainObjectsPaths)) { $serviceDataTransferObject->getResult() ->setInternalVar('domainObjectsPaths', $this->domainObjectsPaths); } } ); // Will fetch real object instances of the registered domain object properties. $this->delay( self::PRIORITY_FETCH_DOMAIN_OBJECTS, function (GetConfigurationObjectDTO $serviceDataTransferObject) { $domainObjectPaths = $serviceDataTransferObject->getResult()->getInternalVar('domainObjectsPaths'); if (false === empty($domainObjectPaths)) { foreach ($domainObjectPaths as $path => $type) { $this->fetchDomainObjectsInternal( $serviceDataTransferObject->getResult()->getObject(true), explode('.', $path), $type ); } } } ); }
[ "public", "function", "configurationObjectAfter", "(", "GetConfigurationObjectDTO", "$", "serviceDataTransferObject", ")", "{", "// Will save the registered domain object properties paths.", "$", "this", "->", "delay", "(", "self", "::", "PRIORITY_SAVE_DOMAIN_OBJECTS_PATHS", ",", "function", "(", "GetConfigurationObjectDTO", "$", "serviceDataTransferObject", ")", "{", "if", "(", "false", "===", "empty", "(", "$", "this", "->", "domainObjectsPaths", ")", ")", "{", "$", "serviceDataTransferObject", "->", "getResult", "(", ")", "->", "setInternalVar", "(", "'domainObjectsPaths'", ",", "$", "this", "->", "domainObjectsPaths", ")", ";", "}", "}", ")", ";", "// Will fetch real object instances of the registered domain object properties.", "$", "this", "->", "delay", "(", "self", "::", "PRIORITY_FETCH_DOMAIN_OBJECTS", ",", "function", "(", "GetConfigurationObjectDTO", "$", "serviceDataTransferObject", ")", "{", "$", "domainObjectPaths", "=", "$", "serviceDataTransferObject", "->", "getResult", "(", ")", "->", "getInternalVar", "(", "'domainObjectsPaths'", ")", ";", "if", "(", "false", "===", "empty", "(", "$", "domainObjectPaths", ")", ")", "{", "foreach", "(", "$", "domainObjectPaths", "as", "$", "path", "=>", "$", "type", ")", "{", "$", "this", "->", "fetchDomainObjectsInternal", "(", "$", "serviceDataTransferObject", "->", "getResult", "(", ")", "->", "getObject", "(", "true", ")", ",", "explode", "(", "'.'", ",", "$", "path", ")", ",", "$", "type", ")", ";", "}", "}", "}", ")", ";", "}" ]
This function will first save the entire storage of properties paths set in the function `objectConversionBefore`. Then, each of the properties above will be fetched from Extbase persistence. @param GetConfigurationObjectDTO $serviceDataTransferObject
[ "This", "function", "will", "first", "save", "the", "entire", "storage", "of", "properties", "paths", "set", "in", "the", "function", "objectConversionBefore", "." ]
d3a40903386c2e0766bd8279337fe6da45cf5ce3
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/Items/Persistence/PersistenceService.php#L103-L133
train
romm/configuration_object
Classes/Service/Items/Persistence/PersistenceService.php
PersistenceService.setDomainObjectInProperty
protected function setDomainObjectInProperty($object, $propertyName, $domainObject, $lastObject, array $objectArrayPropertyPath) { if (is_object($object)) { ObjectAccess::setProperty($object, $propertyName, $domainObject); } elseif (is_array($object)) { $this->injectDomainObjectInLastObject($domainObject, $lastObject, $objectArrayPropertyPath); } }
php
protected function setDomainObjectInProperty($object, $propertyName, $domainObject, $lastObject, array $objectArrayPropertyPath) { if (is_object($object)) { ObjectAccess::setProperty($object, $propertyName, $domainObject); } elseif (is_array($object)) { $this->injectDomainObjectInLastObject($domainObject, $lastObject, $objectArrayPropertyPath); } }
[ "protected", "function", "setDomainObjectInProperty", "(", "$", "object", ",", "$", "propertyName", ",", "$", "domainObject", ",", "$", "lastObject", ",", "array", "$", "objectArrayPropertyPath", ")", "{", "if", "(", "is_object", "(", "$", "object", ")", ")", "{", "ObjectAccess", "::", "setProperty", "(", "$", "object", ",", "$", "propertyName", ",", "$", "domainObject", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "object", ")", ")", "{", "$", "this", "->", "injectDomainObjectInLastObject", "(", "$", "domainObject", ",", "$", "lastObject", ",", "$", "objectArrayPropertyPath", ")", ";", "}", "}" ]
Will inject the domain object in the property, at the correct path. @param object|array $object @param string $propertyName @param object $domainObject @param object $lastObject @param array $objectArrayPropertyPath
[ "Will", "inject", "the", "domain", "object", "in", "the", "property", "at", "the", "correct", "path", "." ]
d3a40903386c2e0766bd8279337fe6da45cf5ce3
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/Items/Persistence/PersistenceService.php#L180-L187
train
miknatr/grace-dbal
lib/Grace/DBAL/QueryLogger.php
QueryLogger.startQuery
public function startQuery($queryString) { $this->queries[$this->counter] = array('query' => $queryString); $this->timer = time() + microtime(true); }
php
public function startQuery($queryString) { $this->queries[$this->counter] = array('query' => $queryString); $this->timer = time() + microtime(true); }
[ "public", "function", "startQuery", "(", "$", "queryString", ")", "{", "$", "this", "->", "queries", "[", "$", "this", "->", "counter", "]", "=", "array", "(", "'query'", "=>", "$", "queryString", ")", ";", "$", "this", "->", "timer", "=", "time", "(", ")", "+", "microtime", "(", "true", ")", ";", "}" ]
Start timer for query @param string $queryString sql query string
[ "Start", "timer", "for", "query" ]
b05e03040568631dc6c77477c0eaed6e60db4ba2
https://github.com/miknatr/grace-dbal/blob/b05e03040568631dc6c77477c0eaed6e60db4ba2/lib/Grace/DBAL/QueryLogger.php#L28-L32
train