repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
kevindierkx/elicit | src/Connector/AbstractConnector.php | AbstractConnector.parseResponse | protected function parseResponse(Response $response)
{
$contentType = explode(';', $response->getHeader('content-type'))[0];
switch ($contentType) {
case 'application/json':
case 'application/vnd.api+json':
return $response->json();
case 'application/xml':
return $response->xml();
}
throw new RuntimeException("Unsupported returned content-type [$contentType]");
} | php | protected function parseResponse(Response $response)
{
$contentType = explode(';', $response->getHeader('content-type'))[0];
switch ($contentType) {
case 'application/json':
case 'application/vnd.api+json':
return $response->json();
case 'application/xml':
return $response->xml();
}
throw new RuntimeException("Unsupported returned content-type [$contentType]");
} | [
"protected",
"function",
"parseResponse",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"contentType",
"=",
"explode",
"(",
"';'",
",",
"$",
"response",
"->",
"getHeader",
"(",
"'content-type'",
")",
")",
"[",
"0",
"]",
";",
"switch",
"(",
"$",
"conte... | Parse the returned response.
@param \GuzzleHttp\Message\Response $response
@return array
@throws RuntimeException | [
"Parse",
"the",
"returned",
"response",
"."
] | c277942f5f5f63b175bc37e9d392faa946888f65 | https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Connector/AbstractConnector.php#L190-L204 | train |
phPoirot/Module-Authorization | src/Authorization/Guard/GuardRestrictIP.php | GuardRestrictIP.attachToEvent | function attachToEvent(iEvent $event)
{
if ( \Poirot\isCommandLine() )
// Restriction IP Only Work With Http Sapi
return $this;
$self = $this;
$event->on(EventHeapOfSapi::EVENT_APP_MATCH_REQUEST, function() use ($self) {
$self->_assertAccess();
});
return $this;
} | php | function attachToEvent(iEvent $event)
{
if ( \Poirot\isCommandLine() )
// Restriction IP Only Work With Http Sapi
return $this;
$self = $this;
$event->on(EventHeapOfSapi::EVENT_APP_MATCH_REQUEST, function() use ($self) {
$self->_assertAccess();
});
return $this;
} | [
"function",
"attachToEvent",
"(",
"iEvent",
"$",
"event",
")",
"{",
"if",
"(",
"\\",
"Poirot",
"\\",
"isCommandLine",
"(",
")",
")",
"// Restriction IP Only Work With Http Sapi",
"return",
"$",
"this",
";",
"$",
"self",
"=",
"$",
"this",
";",
"$",
"event",
... | Attach To Event
note: not throw any exception if event type is unknown!
@param iEvent|EventHeapOfSapi $event
@return $this | [
"Attach",
"To",
"Event"
] | 1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06 | https://github.com/phPoirot/Module-Authorization/blob/1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06/src/Authorization/Guard/GuardRestrictIP.php#L59-L72 | train |
phPoirot/Module-Authorization | src/Authorization/Guard/GuardRestrictIP.php | GuardRestrictIP.setBlockList | function setBlockList($list)
{
if ($list instanceof \Traversable)
$list = \Poirot\Std\cast($list)->toArray();
if (! is_array($list) )
throw new \InvalidArgumentException(sprintf(
'List must instanceof Traversable or array; given (%s).'
, \Poirot\Std\flatten($list)
));
$this->blockList = $list;
return $this;
} | php | function setBlockList($list)
{
if ($list instanceof \Traversable)
$list = \Poirot\Std\cast($list)->toArray();
if (! is_array($list) )
throw new \InvalidArgumentException(sprintf(
'List must instanceof Traversable or array; given (%s).'
, \Poirot\Std\flatten($list)
));
$this->blockList = $list;
return $this;
} | [
"function",
"setBlockList",
"(",
"$",
"list",
")",
"{",
"if",
"(",
"$",
"list",
"instanceof",
"\\",
"Traversable",
")",
"$",
"list",
"=",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"cast",
"(",
"$",
"list",
")",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
... | Set IP Block List
@param array|\Traversable $list
@return $this | [
"Set",
"IP",
"Block",
"List"
] | 1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06 | https://github.com/phPoirot/Module-Authorization/blob/1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06/src/Authorization/Guard/GuardRestrictIP.php#L98-L111 | train |
tekkla/core-framework | Core/Framework/Page/Head/Meta.php | Meta.setViewport | public function setViewport($width = 'device-width', $initial_scale = '1', $user_scalable = '', $minimum_scale = '', $maximum_scale = '')
{
$tag = [
'name' => 'viewport',
'content' => 'width=' . $width . ', initial-scale=' . $initial_scale
];
if ($user_scalable) {
$tag['content'] .= ', user-scalable=' . $user_scalable;
}
if ($minimum_scale) {
$tag['content'] .= ', minimum-scale=' . $minimum_scale;
}
if ($maximum_scale) {
$tag['content'] .= ', maximum_scale=' . $maximum_scale;
}
$this->tags['viewport'] = $tag;
} | php | public function setViewport($width = 'device-width', $initial_scale = '1', $user_scalable = '', $minimum_scale = '', $maximum_scale = '')
{
$tag = [
'name' => 'viewport',
'content' => 'width=' . $width . ', initial-scale=' . $initial_scale
];
if ($user_scalable) {
$tag['content'] .= ', user-scalable=' . $user_scalable;
}
if ($minimum_scale) {
$tag['content'] .= ', minimum-scale=' . $minimum_scale;
}
if ($maximum_scale) {
$tag['content'] .= ', maximum_scale=' . $maximum_scale;
}
$this->tags['viewport'] = $tag;
} | [
"public",
"function",
"setViewport",
"(",
"$",
"width",
"=",
"'device-width'",
",",
"$",
"initial_scale",
"=",
"'1'",
",",
"$",
"user_scalable",
"=",
"''",
",",
"$",
"minimum_scale",
"=",
"''",
",",
"$",
"maximum_scale",
"=",
"''",
")",
"{",
"$",
"tag",
... | Sets vieport tag
@param string $width
Description of used device width
@param string $initial_scale
Initial scale factor (Default: '1')
@param string $user_scalable
@param string $minimum_scale
@param string $maximum_scale | [
"Sets",
"vieport",
"tag"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Head/Meta.php#L50-L70 | train |
morrelinko/simple-photo | src/DataStore/MySqlDataStore.php | MySqlDataStore.createConnection | public function createConnection($parameters)
{
$connection = new \PDO(
'mysql:host=' . $parameters['host'] . ';dbname=' . $parameters['database'],
$parameters['username'],
$parameters['password']
);
if (isset($parameters['charset'])) {
$connection->exec('SET CHARACTER SET ' . $parameters['charset']);
}
return $connection;
} | php | public function createConnection($parameters)
{
$connection = new \PDO(
'mysql:host=' . $parameters['host'] . ';dbname=' . $parameters['database'],
$parameters['username'],
$parameters['password']
);
if (isset($parameters['charset'])) {
$connection->exec('SET CHARACTER SET ' . $parameters['charset']);
}
return $connection;
} | [
"public",
"function",
"createConnection",
"(",
"$",
"parameters",
")",
"{",
"$",
"connection",
"=",
"new",
"\\",
"PDO",
"(",
"'mysql:host='",
".",
"$",
"parameters",
"[",
"'host'",
"]",
".",
"';dbname='",
".",
"$",
"parameters",
"[",
"'database'",
"]",
","... | Creates a MySql Connection
@param array $parameters Connection parameters
<pre>
host: eg. localhost
database: eg. my_app
username: eg. root
password: eg. 123456
charset: (Optional)
</pre>
@return \PDO | [
"Creates",
"a",
"MySql",
"Connection"
] | be1fbe3139d32eb39e88cff93f847154bb6a8cb2 | https://github.com/morrelinko/simple-photo/blob/be1fbe3139d32eb39e88cff93f847154bb6a8cb2/src/DataStore/MySqlDataStore.php#L33-L46 | train |
MehrAlsNix/Notifier | src/Notify.php | Notify.fetch | protected static function fetch()
{
$command = array(
'LINUX' => new Commands\Linux(),
'MAC' => new Commands\Mac(),
'WIN' => new Commands\Windows()
);
$instance = 'No valid desktop notifier found.';
if ($command['WIN']->isAvailable()) {
$instance = $command['WIN'];
} elseif($command['LINUX']->isAvailable()) {
$instance = $command['LINUX'];
} elseif($command['MAC']->isAvailable()) {
$instance = $command['MAC'];
}
if (is_string($instance)) {
throw new \RuntimeException($instance);
}
return $instance;
} | php | protected static function fetch()
{
$command = array(
'LINUX' => new Commands\Linux(),
'MAC' => new Commands\Mac(),
'WIN' => new Commands\Windows()
);
$instance = 'No valid desktop notifier found.';
if ($command['WIN']->isAvailable()) {
$instance = $command['WIN'];
} elseif($command['LINUX']->isAvailable()) {
$instance = $command['LINUX'];
} elseif($command['MAC']->isAvailable()) {
$instance = $command['MAC'];
}
if (is_string($instance)) {
throw new \RuntimeException($instance);
}
return $instance;
} | [
"protected",
"static",
"function",
"fetch",
"(",
")",
"{",
"$",
"command",
"=",
"array",
"(",
"'LINUX'",
"=>",
"new",
"Commands",
"\\",
"Linux",
"(",
")",
",",
"'MAC'",
"=>",
"new",
"Commands",
"\\",
"Mac",
"(",
")",
",",
"'WIN'",
"=>",
"new",
"Comma... | Fetches an instance by checking for ability.
@return Commands\Linux|Commands\Mac|Commands\Windows
@throws \RuntimeException | [
"Fetches",
"an",
"instance",
"by",
"checking",
"for",
"ability",
"."
] | 9ac9fed8880537157091ac0607965b30dab20bca | https://github.com/MehrAlsNix/Notifier/blob/9ac9fed8880537157091ac0607965b30dab20bca/src/Notify.php#L63-L86 | train |
tenside/core | src/Task/Composer/WrappedCommand/WrappedCommandTrait.php | WrappedCommandTrait.getComposer | public function getComposer($required = true, $disablePlugins = false)
{
if (null === $this->composer) {
if ($this->composerFactory) {
$this->composer = call_user_func($this->composerFactory, $required, $disablePlugins);
}
if ($required && !$this->composer) {
throw new \RuntimeException(
'You must define a factory closure for wrapped commands to retrieve the ' .
'composer instance.'
);
}
}
return $this->composer;
} | php | public function getComposer($required = true, $disablePlugins = false)
{
if (null === $this->composer) {
if ($this->composerFactory) {
$this->composer = call_user_func($this->composerFactory, $required, $disablePlugins);
}
if ($required && !$this->composer) {
throw new \RuntimeException(
'You must define a factory closure for wrapped commands to retrieve the ' .
'composer instance.'
);
}
}
return $this->composer;
} | [
"public",
"function",
"getComposer",
"(",
"$",
"required",
"=",
"true",
",",
"$",
"disablePlugins",
"=",
"false",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"composer",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"composerFactory",
")",
"{",
... | Retrieve the composer instance.
@param bool $required Flag if the instance is required.
@param bool $disablePlugins Flag if plugins shall get disabled.
@return Composer|null
@throws \RuntimeException When no factory closure has been set. | [
"Retrieve",
"the",
"composer",
"instance",
"."
] | 56422fa8cdecf03cb431bb6654c2942ade39bf7b | https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/Composer/WrappedCommand/WrappedCommandTrait.php#L55-L71 | train |
flipbox/skeleton | src/Collections/AbstractModelCollection.php | AbstractModelCollection.getErrors | public function getErrors($attribute = null)
{
$itemErrors = [];
foreach ($this->getItems() as $item) {
if ($item->hasErrors($attribute)) {
$itemErrors[$this->getItemId($item)] = $item->getErrors($attribute);
}
}
return array_merge(
$this->_traitGetErrors($attribute),
$itemErrors
);
} | php | public function getErrors($attribute = null)
{
$itemErrors = [];
foreach ($this->getItems() as $item) {
if ($item->hasErrors($attribute)) {
$itemErrors[$this->getItemId($item)] = $item->getErrors($attribute);
}
}
return array_merge(
$this->_traitGetErrors($attribute),
$itemErrors
);
} | [
"public",
"function",
"getErrors",
"(",
"$",
"attribute",
"=",
"null",
")",
"{",
"$",
"itemErrors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getItems",
"(",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"hasErrors",... | Merge errors from all
@inheritdoc | [
"Merge",
"errors",
"from",
"all"
] | 98ed2a8f4c201f34135e6573f3071b2a75a67907 | https://github.com/flipbox/skeleton/blob/98ed2a8f4c201f34135e6573f3071b2a75a67907/src/Collections/AbstractModelCollection.php#L42-L56 | train |
webriq/core | module/Paragraph/src/Grid/Paragraph/Model/Snippet/Rpc.php | Rpc.isNameAvailable | public function isNameAvailable( $name, $fields = array() )
{
$fields = (object) $fields;
return ! $this->getMapper()
->isNameExists(
$name .
( empty( $fields->type ) ? '' : '.' . $fields->type )
);
} | php | public function isNameAvailable( $name, $fields = array() )
{
$fields = (object) $fields;
return ! $this->getMapper()
->isNameExists(
$name .
( empty( $fields->type ) ? '' : '.' . $fields->type )
);
} | [
"public",
"function",
"isNameAvailable",
"(",
"$",
"name",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"fields",
"=",
"(",
"object",
")",
"$",
"fields",
";",
"return",
"!",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"isNameExists"... | Find a structure is available
@param string $name
@param array|object $fields [optional]
@return bool | [
"Find",
"a",
"structure",
"is",
"available"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Snippet/Rpc.php#L39-L48 | train |
rezzza/jobflow | src/Rezzza/Jobflow/JobFactory.php | JobFactory.createBuilder | public function createBuilder($type = 'job', array $initOptions = array(), array $execOptions = array())
{
$name = $type instanceof JobTypeInterface || $type instanceof ResolvedJob
? $type->getName()
: $type;
return $this->createNamedBuilder($name, $type, $initOptions, $execOptions);
} | php | public function createBuilder($type = 'job', array $initOptions = array(), array $execOptions = array())
{
$name = $type instanceof JobTypeInterface || $type instanceof ResolvedJob
? $type->getName()
: $type;
return $this->createNamedBuilder($name, $type, $initOptions, $execOptions);
} | [
"public",
"function",
"createBuilder",
"(",
"$",
"type",
"=",
"'job'",
",",
"array",
"$",
"initOptions",
"=",
"array",
"(",
")",
",",
"array",
"$",
"execOptions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"name",
"=",
"$",
"type",
"instanceof",
"JobTypeIn... | Create a builder
@param mixed $type The JobTypeInterface or the alias of the job type registered as a service
@return JobBuilder | [
"Create",
"a",
"builder"
] | 80ded8ac6ed6a2f4500b8f86e2958701ec84fd65 | https://github.com/rezzza/jobflow/blob/80ded8ac6ed6a2f4500b8f86e2958701ec84fd65/src/Rezzza/Jobflow/JobFactory.php#L45-L52 | train |
rezzza/jobflow | src/Rezzza/Jobflow/JobFactory.php | JobFactory.resolveType | public function resolveType(JobTypeInterface $type)
{
$parentType = $type->getParent();
if ($parentType instanceof JobTypeInterface) {
$parentType = $this->resolveType($parentType);
} elseif (null !== $parentType) {
$parentType = $this->registry->getType($parentType);
}
return $this->createResolvedType($type, $parentType);
} | php | public function resolveType(JobTypeInterface $type)
{
$parentType = $type->getParent();
if ($parentType instanceof JobTypeInterface) {
$parentType = $this->resolveType($parentType);
} elseif (null !== $parentType) {
$parentType = $this->registry->getType($parentType);
}
return $this->createResolvedType($type, $parentType);
} | [
"public",
"function",
"resolveType",
"(",
"JobTypeInterface",
"$",
"type",
")",
"{",
"$",
"parentType",
"=",
"$",
"type",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"$",
"parentType",
"instanceof",
"JobTypeInterface",
")",
"{",
"$",
"parentType",
"=",
"$... | Creates wrapper for combination of JobType and JobConnector
@param JobTypeInterface $type
@return ResolvedJob | [
"Creates",
"wrapper",
"for",
"combination",
"of",
"JobType",
"and",
"JobConnector"
] | 80ded8ac6ed6a2f4500b8f86e2958701ec84fd65 | https://github.com/rezzza/jobflow/blob/80ded8ac6ed6a2f4500b8f86e2958701ec84fd65/src/Rezzza/Jobflow/JobFactory.php#L82-L93 | train |
vinala/kernel | src/Processes/Command.php | Command.set | public static function set($file, $command, $database)
{
$database = $database ? 'true' : 'false';
//
$txt = "<?php\n\nnamespace Vinala\App\Support\Lumos;\n\n";
$txt .= "use Vinala\Kernel\Console\Command\Commands;\n\n";
$txt .= self::docs("$file Command");
$txt .= " class $file extends Commands\n{\n\t";
$txt .= "\n\t/**\n\t * The key of the console command.\n\t *\n\t * @var string\n\t */\n\tprotected ".'$key = '."'$command';\n\n";
$txt .= "\n\t/**\n\t * The console command description.\n\t *\n\t * @var string\n\t */\n\tprotected ".'$description = '."'say hello to the world';\n\n";
$txt .= "\n\t/**\n\t * True if the command will use database.\n\t *\n\t * @var bool\n\t */\n\tprotected ".'$database = '."$database ;\n\n";
$txt .= "\n\t/**\n\t * Execute the console command.\n\t *\n\t * @return mixed\n\t */\n\tpublic function handle()\n\t{\n\t\t ".'$this->line("What\'s up!"); '."\n\t}";
$txt .= "\n}";
return $txt;
} | php | public static function set($file, $command, $database)
{
$database = $database ? 'true' : 'false';
//
$txt = "<?php\n\nnamespace Vinala\App\Support\Lumos;\n\n";
$txt .= "use Vinala\Kernel\Console\Command\Commands;\n\n";
$txt .= self::docs("$file Command");
$txt .= " class $file extends Commands\n{\n\t";
$txt .= "\n\t/**\n\t * The key of the console command.\n\t *\n\t * @var string\n\t */\n\tprotected ".'$key = '."'$command';\n\n";
$txt .= "\n\t/**\n\t * The console command description.\n\t *\n\t * @var string\n\t */\n\tprotected ".'$description = '."'say hello to the world';\n\n";
$txt .= "\n\t/**\n\t * True if the command will use database.\n\t *\n\t * @var bool\n\t */\n\tprotected ".'$database = '."$database ;\n\n";
$txt .= "\n\t/**\n\t * Execute the console command.\n\t *\n\t * @return mixed\n\t */\n\tpublic function handle()\n\t{\n\t\t ".'$this->line("What\'s up!"); '."\n\t}";
$txt .= "\n}";
return $txt;
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"file",
",",
"$",
"command",
",",
"$",
"database",
")",
"{",
"$",
"database",
"=",
"$",
"database",
"?",
"'true'",
":",
"'false'",
";",
"//",
"$",
"txt",
"=",
"\"<?php\\n\\nnamespace Vinala\\App\\Support\\Lumo... | prepare the text to put in command file. | [
"prepare",
"the",
"text",
"to",
"put",
"in",
"command",
"file",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Processes/Command.php#L31-L49 | train |
wasabi-cms/core | src/MenuItem.php | MenuItem.alias | public function alias($alias = null)
{
if ($alias === null) {
return $this->_alias;
}
$this->_alias = $alias;
return $this;
} | php | public function alias($alias = null)
{
if ($alias === null) {
return $this->_alias;
}
$this->_alias = $alias;
return $this;
} | [
"public",
"function",
"alias",
"(",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"alias",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_alias",
";",
"}",
"$",
"this",
"->",
"_alias",
"=",
"$",
"alias",
";",
"return",
"$",
"this"... | Get or set the alias.
@param null|string $alias
@return MenuItem|string | [
"Get",
"or",
"set",
"the",
"alias",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L83-L91 | train |
wasabi-cms/core | src/MenuItem.php | MenuItem.name | public function name($name = null)
{
if ($name === null) {
return $name;
}
$this->_name = $name;
return $this;
} | php | public function name($name = null)
{
if ($name === null) {
return $name;
}
$this->_name = $name;
return $this;
} | [
"public",
"function",
"name",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"return",
"$",
"name",
";",
"}",
"$",
"this",
"->",
"_name",
"=",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] | Get or set the name.
@param string $name
@return MenuItem|string | [
"Get",
"or",
"set",
"the",
"name",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L99-L107 | train |
wasabi-cms/core | src/MenuItem.php | MenuItem.shortName | public function shortName($name = null)
{
if ($name === null) {
return $this->_nameShort;
}
$this->_nameShort = $name;
return $this;
} | php | public function shortName($name = null)
{
if ($name === null) {
return $this->_nameShort;
}
$this->_nameShort = $name;
return $this;
} | [
"public",
"function",
"shortName",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_nameShort",
";",
"}",
"$",
"this",
"->",
"_nameShort",
"=",
"$",
"name",
";",
"return",
"$",... | Get or set the short name.
@param null|string $name
@return MenuItem|string | [
"Get",
"or",
"set",
"the",
"short",
"name",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L115-L123 | train |
wasabi-cms/core | src/MenuItem.php | MenuItem.icon | public function icon($icon = null)
{
if ($icon === null) {
return $this->_icon;
}
$this->_icon = $icon;
return $this;
} | php | public function icon($icon = null)
{
if ($icon === null) {
return $this->_icon;
}
$this->_icon = $icon;
return $this;
} | [
"public",
"function",
"icon",
"(",
"$",
"icon",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"icon",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_icon",
";",
"}",
"$",
"this",
"->",
"_icon",
"=",
"$",
"icon",
";",
"return",
"$",
"this",
";... | Get or set the icon class.
@param null|string $icon
@return MenuItem|string | [
"Get",
"or",
"set",
"the",
"icon",
"class",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L147-L155 | train |
wasabi-cms/core | src/MenuItem.php | MenuItem.url | public function url($url = null)
{
if ($url === null) {
return $this->_url;
}
$this->_url = $url;
return $this;
} | php | public function url($url = null)
{
if ($url === null) {
return $this->_url;
}
$this->_url = $url;
return $this;
} | [
"public",
"function",
"url",
"(",
"$",
"url",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"url",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_url",
";",
"}",
"$",
"this",
"->",
"_url",
"=",
"$",
"url",
";",
"return",
"$",
"this",
";",
"... | Get or set the url.
@param null|array $url
@return MenuItem|array | [
"Get",
"or",
"set",
"the",
"url",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L163-L171 | train |
wasabi-cms/core | src/MenuItem.php | MenuItem.parent | public function parent($parent = null)
{
if ($parent === null) {
return $this->_parent;
}
$this->_parent = $parent;
return $this;
} | php | public function parent($parent = null)
{
if ($parent === null) {
return $this->_parent;
}
$this->_parent = $parent;
return $this;
} | [
"public",
"function",
"parent",
"(",
"$",
"parent",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parent",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_parent",
";",
"}",
"$",
"this",
"->",
"_parent",
"=",
"$",
"parent",
";",
"return",
"$",
... | Get or set the parent menu alias.
@param bool|null|string $parent
@return MenuItem|bool|string | [
"Get",
"or",
"set",
"the",
"parent",
"menu",
"alias",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L179-L187 | train |
wasabi-cms/core | src/MenuItem.php | MenuItem.matchAction | public function matchAction($matchAction = null)
{
if ($matchAction === null) {
return $this->_matchAction;
}
$this->_matchAction = $matchAction;
return $this;
} | php | public function matchAction($matchAction = null)
{
if ($matchAction === null) {
return $this->_matchAction;
}
$this->_matchAction = $matchAction;
return $this;
} | [
"public",
"function",
"matchAction",
"(",
"$",
"matchAction",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"matchAction",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_matchAction",
";",
"}",
"$",
"this",
"->",
"_matchAction",
"=",
"$",
"matchAction"... | Get or set match action.
@param array|bool|null $matchAction
@return MenuItem|array|bool | [
"Get",
"or",
"set",
"match",
"action",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L195-L203 | train |
wasabi-cms/core | src/MenuItem.php | MenuItem.doNotMatchAction | public function doNotMatchAction(array $action, $reset = false)
{
if ($reset) {
$this->_doNotMatchAction = [];
}
if (!empty($action)) {
$this->_doNotMatchAction[] = $action;
}
return $this;
} | php | public function doNotMatchAction(array $action, $reset = false)
{
if ($reset) {
$this->_doNotMatchAction = [];
}
if (!empty($action)) {
$this->_doNotMatchAction[] = $action;
}
return $this;
} | [
"public",
"function",
"doNotMatchAction",
"(",
"array",
"$",
"action",
",",
"$",
"reset",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"reset",
")",
"{",
"$",
"this",
"->",
"_doNotMatchAction",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",... | Add an action which this menu item should not match for.
@param array $action
@param bool $reset Whether to reset existing 'doNotMatchAction' entries.
@return MenuItem|array | [
"Add",
"an",
"action",
"which",
"this",
"menu",
"item",
"should",
"not",
"match",
"for",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L212-L222 | train |
chipaau/support | src/Support/Validation/AbstractValidator.php | AbstractValidator.getRules | public function getRules()
{
$rules = empty($this->rules) ? $this->rules($this->request, $this->params) : $this->rules;
return $this->explodeRules($rules);
} | php | public function getRules()
{
$rules = empty($this->rules) ? $this->rules($this->request, $this->params) : $this->rules;
return $this->explodeRules($rules);
} | [
"public",
"function",
"getRules",
"(",
")",
"{",
"$",
"rules",
"=",
"empty",
"(",
"$",
"this",
"->",
"rules",
")",
"?",
"$",
"this",
"->",
"rules",
"(",
"$",
"this",
"->",
"request",
",",
"$",
"this",
"->",
"params",
")",
":",
"$",
"this",
"->",
... | get the rules from child class
@return array | [
"get",
"the",
"rules",
"from",
"child",
"class"
] | 2fe3673ed2330bd064d37b2f0bac3e02ca110bef | https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/Validation/AbstractValidator.php#L147-L151 | train |
chipaau/support | src/Support/Validation/AbstractValidator.php | AbstractValidator.removeRequired | public function removeRequired()
{
foreach ($this->getRules() as $key => $rules) {
$newRules[$key] = preg_grep("/^required/", $rules, PREG_GREP_INVERT);
}
$this->rules = $newRules;
return $this;
} | php | public function removeRequired()
{
foreach ($this->getRules() as $key => $rules) {
$newRules[$key] = preg_grep("/^required/", $rules, PREG_GREP_INVERT);
}
$this->rules = $newRules;
return $this;
} | [
"public",
"function",
"removeRequired",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRules",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"rules",
")",
"{",
"$",
"newRules",
"[",
"$",
"key",
"]",
"=",
"preg_grep",
"(",
"\"/^required/\"",
",",
"$",... | remove required rule from rules function
@return array | [
"remove",
"required",
"rule",
"from",
"rules",
"function"
] | 2fe3673ed2330bd064d37b2f0bac3e02ca110bef | https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/Validation/AbstractValidator.php#L187-L194 | train |
chipaau/support | src/Support/Validation/AbstractValidator.php | AbstractValidator.getDbValues | public function getDbValues(array $input = [], $mappings = [])
{
$response = [];
foreach ($mappings as $inputKey => $dbValue) {
if (is_array($input) && array_get($input, $inputKey) !== null) {
$value = array_get($input, $inputKey);
if ($value instanceof UploadedFile) {
array_set($response, $dbValue, $value);
} elseif (is_array($value)) {
if (class_exists($mappings[$inputKey]['class'])) {
$class = new $mappings[$inputKey]['class']($this->app);
foreach ($value as $v) {
$response[$mappings[$inputKey]['key']][] = $this->getDbValues($v, $class->mappings());
}
} else {
array_set($response, $dbValue, $value);
}
} else {
array_set($response, $dbValue, (is_bool($value) ? $value : trim($value)));
}
}
}
return $response;
} | php | public function getDbValues(array $input = [], $mappings = [])
{
$response = [];
foreach ($mappings as $inputKey => $dbValue) {
if (is_array($input) && array_get($input, $inputKey) !== null) {
$value = array_get($input, $inputKey);
if ($value instanceof UploadedFile) {
array_set($response, $dbValue, $value);
} elseif (is_array($value)) {
if (class_exists($mappings[$inputKey]['class'])) {
$class = new $mappings[$inputKey]['class']($this->app);
foreach ($value as $v) {
$response[$mappings[$inputKey]['key']][] = $this->getDbValues($v, $class->mappings());
}
} else {
array_set($response, $dbValue, $value);
}
} else {
array_set($response, $dbValue, (is_bool($value) ? $value : trim($value)));
}
}
}
return $response;
} | [
"public",
"function",
"getDbValues",
"(",
"array",
"$",
"input",
"=",
"[",
"]",
",",
"$",
"mappings",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"mappings",
"as",
"$",
"inputKey",
"=>",
"$",
"dbValue",
")",
... | conver given array keys to mapper keys
@param array $inputs
@return array | [
"conver",
"given",
"array",
"keys",
"to",
"mapper",
"keys"
] | 2fe3673ed2330bd064d37b2f0bac3e02ca110bef | https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/Validation/AbstractValidator.php#L251-L275 | train |
tadcka/Mapper | src/Tadcka/Mapper/Extension/Source/Tree/MapperTree.php | MapperTree.findTreeItem | public function findTreeItem($id, MapperTreeItemInterface $item)
{
if ($id === $item->getId()) {
return $item;
}
foreach ($item->getChildren() as $child) {
if (null !== $treeItem = $this->findTreeItem($id, $child)) {
return $treeItem;
}
}
return null;
} | php | public function findTreeItem($id, MapperTreeItemInterface $item)
{
if ($id === $item->getId()) {
return $item;
}
foreach ($item->getChildren() as $child) {
if (null !== $treeItem = $this->findTreeItem($id, $child)) {
return $treeItem;
}
}
return null;
} | [
"public",
"function",
"findTreeItem",
"(",
"$",
"id",
",",
"MapperTreeItemInterface",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"$",
"item",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"$",
"item",
";",
"}",
"foreach",
"(",
"$",
"item",
... | Find tree item by id.
@param string $id
@param MapperTreeItemInterface $item
@return null|MapperTreeItemInterface | [
"Find",
"tree",
"item",
"by",
"id",
"."
] | 6853a2be08dcd35a1013c0a4aba9b71a727ff7da | https://github.com/tadcka/Mapper/blob/6853a2be08dcd35a1013c0a4aba9b71a727ff7da/src/Tadcka/Mapper/Extension/Source/Tree/MapperTree.php#L79-L91 | train |
xmlsquad/ping-drive | src/Command/PingDriveCommand.php | PingDriveCommand.getURLData | protected function getURLData(string $driveUrl): array
{
/*
* Known URL types:
* https://drive.google.com/file/d/0B5q9i2h-vGaCc1ZBVnFhRzN2a3c/view?ths=true A Word file from Google Drive
* https://docs.google.com/document/d/1-phrJPVDf1SpQYU5SzJY00Ke0c6QJmILHrtm_pcQk4w/edit A Google Docs file
* https://drive.google.com/drive/u/0/folders/0B5q9i2h-vGaCQXhLZFNLT2JyV0U A Google Drive folder
* https://drive.google.com/open?id=0B5q9i2h-vGaCYUE0ZTM4MDhseTQ A Google Drive shared file
* https://docs.google.com/spreadsheets/d/13QGip-d_Z88Xru64pEFRyFVDKujDOUjciy35Qytw-Qc/edit A Google Sheets file
* https://docs.google.com/presentation/d/1R1oF7zmnSDX3w3FBpyCTJnjvOu68C7Q2MH4kI4xMFWc/edit A Google Slides file
*/
// Is it a Google Drive|Docs URL?
if (preg_match(
'~^(https?://)?(drive|docs)\.google\.[a-z]+/.*(/d/|/folders/|[\?&]id=)([a-z0-9\-_]{20,})([/?&#]|$)~i',
$driveUrl,
$matches
)) {
// Any Google Drive item can be obtained using a single API method: https://developers.google.com/drive/api/v3/reference/files/get
return [
'type' => 'google-drive',
'id' => $matches[4]
];
}
// Is it a URL?
if (preg_match('~^(https?://)?[a-z0-9.@\-_\x{0080}-\x{FFFF}]+(:[0-9]+)?(/|$)~iu', $driveUrl, $matches)) {
return [
'type' => 'http',
'driveUrl' => ($matches[1] ? '' : 'http://').$driveUrl
];
}
return ['type' => 'unknown'];
} | php | protected function getURLData(string $driveUrl): array
{
/*
* Known URL types:
* https://drive.google.com/file/d/0B5q9i2h-vGaCc1ZBVnFhRzN2a3c/view?ths=true A Word file from Google Drive
* https://docs.google.com/document/d/1-phrJPVDf1SpQYU5SzJY00Ke0c6QJmILHrtm_pcQk4w/edit A Google Docs file
* https://drive.google.com/drive/u/0/folders/0B5q9i2h-vGaCQXhLZFNLT2JyV0U A Google Drive folder
* https://drive.google.com/open?id=0B5q9i2h-vGaCYUE0ZTM4MDhseTQ A Google Drive shared file
* https://docs.google.com/spreadsheets/d/13QGip-d_Z88Xru64pEFRyFVDKujDOUjciy35Qytw-Qc/edit A Google Sheets file
* https://docs.google.com/presentation/d/1R1oF7zmnSDX3w3FBpyCTJnjvOu68C7Q2MH4kI4xMFWc/edit A Google Slides file
*/
// Is it a Google Drive|Docs URL?
if (preg_match(
'~^(https?://)?(drive|docs)\.google\.[a-z]+/.*(/d/|/folders/|[\?&]id=)([a-z0-9\-_]{20,})([/?&#]|$)~i',
$driveUrl,
$matches
)) {
// Any Google Drive item can be obtained using a single API method: https://developers.google.com/drive/api/v3/reference/files/get
return [
'type' => 'google-drive',
'id' => $matches[4]
];
}
// Is it a URL?
if (preg_match('~^(https?://)?[a-z0-9.@\-_\x{0080}-\x{FFFF}]+(:[0-9]+)?(/|$)~iu', $driveUrl, $matches)) {
return [
'type' => 'http',
'driveUrl' => ($matches[1] ? '' : 'http://').$driveUrl
];
}
return ['type' => 'unknown'];
} | [
"protected",
"function",
"getURLData",
"(",
"string",
"$",
"driveUrl",
")",
":",
"array",
"{",
"/*\n * Known URL types:\n * https://drive.google.com/file/d/0B5q9i2h-vGaCc1ZBVnFhRzN2a3c/view?ths=true A Word file from Google Drive\n * https://docs.google.com/document/d/1-... | Gets a URL type and data
@param string $driveUrl The driveUrl
@return array The `type` key contains the type name. Other keys depend on the type. | [
"Gets",
"a",
"URL",
"type",
"and",
"data"
] | c2e74309f27c88c07f5e0da6b9ed863217d1b5a3 | https://github.com/xmlsquad/ping-drive/blob/c2e74309f27c88c07f5e0da6b9ed863217d1b5a3/src/Command/PingDriveCommand.php#L117-L151 | train |
xmlsquad/ping-drive | src/Command/PingDriveCommand.php | PingDriveCommand.writeGoogleDriveFolderData | protected function writeGoogleDriveFolderData(
OutputInterface $output,
\Google_Service_Drive $drive,
\Google_Service_Drive_DriveFile $folder
) {
$output->writeln('<info>The URL is a Google Drive folder</info>');
$output->writeln('Name: '.$folder->getName());
$output->writeln('Content:');
$pageToken = null;
do {
$children = $drive->files->listFiles([
'pageSize' => 1000,
'pageToken' => $pageToken,
'q' => "'{$folder->getId()}' in parents",
'fields' => 'nextPageToken, files(id,name,mimeType)'
]);
foreach ($children as $child) {
/** @var \Google_Service_Drive_DriveFile $child */
$output->writeln(
' - A '.($child->getMimeType() === GoogleAPIClient::MIME_TYPE_DRIVE_FOLDER ? 'folder' : 'file')
.'. Name: '.$child->getName()
);
}
$pageToken = $children->getNextPageToken();
} while ($pageToken);
} | php | protected function writeGoogleDriveFolderData(
OutputInterface $output,
\Google_Service_Drive $drive,
\Google_Service_Drive_DriveFile $folder
) {
$output->writeln('<info>The URL is a Google Drive folder</info>');
$output->writeln('Name: '.$folder->getName());
$output->writeln('Content:');
$pageToken = null;
do {
$children = $drive->files->listFiles([
'pageSize' => 1000,
'pageToken' => $pageToken,
'q' => "'{$folder->getId()}' in parents",
'fields' => 'nextPageToken, files(id,name,mimeType)'
]);
foreach ($children as $child) {
/** @var \Google_Service_Drive_DriveFile $child */
$output->writeln(
' - A '.($child->getMimeType() === GoogleAPIClient::MIME_TYPE_DRIVE_FOLDER ? 'folder' : 'file')
.'. Name: '.$child->getName()
);
}
$pageToken = $children->getNextPageToken();
} while ($pageToken);
} | [
"protected",
"function",
"writeGoogleDriveFolderData",
"(",
"OutputInterface",
"$",
"output",
",",
"\\",
"Google_Service_Drive",
"$",
"drive",
",",
"\\",
"Google_Service_Drive_DriveFile",
"$",
"folder",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<info>The URL is... | Prints a URL ping result as if the result is a Google Drive folder
@param OutputInterface $output
@param \Google_Service_Drive $drive The Drive API service
@param \Google_Service_Drive_DriveFile $folder The folder
@link https://stackoverflow.com/a/42055925/1118709 | [
"Prints",
"a",
"URL",
"ping",
"result",
"as",
"if",
"the",
"result",
"is",
"a",
"Google",
"Drive",
"folder"
] | c2e74309f27c88c07f5e0da6b9ed863217d1b5a3 | https://github.com/xmlsquad/ping-drive/blob/c2e74309f27c88c07f5e0da6b9ed863217d1b5a3/src/Command/PingDriveCommand.php#L233-L262 | train |
xmlsquad/ping-drive | src/Command/PingDriveCommand.php | PingDriveCommand.writeGoogleSheetData | protected function writeGoogleSheetData(
OutputInterface $output,
\Google_Service_Sheets $service,
\Google_Service_Drive_DriveFile $spreadsheet
) {
$output->writeln('<info>The URL is a Google Sheets file</info>');
$output->writeln('Name: '.$spreadsheet->getName());
// Getting the list of sheets
$spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [
'includeGridData' => false
]);
$sheetsNames = [];
foreach ($spreadsheetData->getSheets() as $sheet) {
/** @var \Google_Service_Sheets_Sheet $sheet (the SDK type hint is incorrect) */
$sheetsNames[] = $sheet->getProperties()->getTitle();
}
if ($sheetsNames) {
$output->writeln('Sheets: '.implode(', ', $sheetsNames));
} else {
$output->writeln('The file has no sheets');
return;
}
// Getting a piece of the first sheet content
$spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [
'includeGridData' => true,
'ranges' => ['A1:E5'] // Google returns only the data of the first sheet for this request
]);
$output->writeln('A piece of the first sheet content:');
$this->writeGoogleSheetTable($output, $spreadsheetData->getSheets()[0]);
} | php | protected function writeGoogleSheetData(
OutputInterface $output,
\Google_Service_Sheets $service,
\Google_Service_Drive_DriveFile $spreadsheet
) {
$output->writeln('<info>The URL is a Google Sheets file</info>');
$output->writeln('Name: '.$spreadsheet->getName());
// Getting the list of sheets
$spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [
'includeGridData' => false
]);
$sheetsNames = [];
foreach ($spreadsheetData->getSheets() as $sheet) {
/** @var \Google_Service_Sheets_Sheet $sheet (the SDK type hint is incorrect) */
$sheetsNames[] = $sheet->getProperties()->getTitle();
}
if ($sheetsNames) {
$output->writeln('Sheets: '.implode(', ', $sheetsNames));
} else {
$output->writeln('The file has no sheets');
return;
}
// Getting a piece of the first sheet content
$spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [
'includeGridData' => true,
'ranges' => ['A1:E5'] // Google returns only the data of the first sheet for this request
]);
$output->writeln('A piece of the first sheet content:');
$this->writeGoogleSheetTable($output, $spreadsheetData->getSheets()[0]);
} | [
"protected",
"function",
"writeGoogleSheetData",
"(",
"OutputInterface",
"$",
"output",
",",
"\\",
"Google_Service_Sheets",
"$",
"service",
",",
"\\",
"Google_Service_Drive_DriveFile",
"$",
"spreadsheet",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<info>The URL ... | Prints a URL ping result as if the result is a Google Sheets file
@param OutputInterface $output
@param \Google_Service_Sheets $service The Sheets API service
@param \Google_Service_Drive_DriveFile $spreadsheet The file
@link https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get | [
"Prints",
"a",
"URL",
"ping",
"result",
"as",
"if",
"the",
"result",
"is",
"a",
"Google",
"Sheets",
"file"
] | c2e74309f27c88c07f5e0da6b9ed863217d1b5a3 | https://github.com/xmlsquad/ping-drive/blob/c2e74309f27c88c07f5e0da6b9ed863217d1b5a3/src/Command/PingDriveCommand.php#L272-L303 | train |
xmlsquad/ping-drive | src/Command/PingDriveCommand.php | PingDriveCommand.writeGoogleSheetTable | protected function writeGoogleSheetTable(OutputInterface $output, \Google_Service_Sheets_Sheet $sheet)
{
$table = new Table($output);
$merges = $sheet->getMerges(); /** @var \Google_Service_Sheets_GridRange[] $merges (the SDK type hint is incorrect) */
foreach ($sheet->getData()[0]->getRowData() as $rowIndex => $sheetRow) {
/** @var \Google_Service_Sheets_RowData $sheetRow */
// TableSeparator is not used here because it is not compatible with rowspan
$tableRow = [];
foreach ($sheetRow->getValues() as $columnIndex => $sheetCell) {
$colspan = $rowspan = 1;
/** @var \Google_Service_Sheets_CellData $sheetCell (the SDK type hint is incorrect) */
foreach ($merges as $merge) {
// The end indexes are not inclusive
if (
$columnIndex >= $merge->getStartColumnIndex() && $columnIndex < $merge->getEndColumnIndex() &&
$rowIndex >= $merge->getStartRowIndex() && $rowIndex < $merge->getEndRowIndex()
) {
if ($columnIndex === $merge->getStartColumnIndex() && $rowIndex === $merge->getStartRowIndex()) {
$colspan = $merge->getEndColumnIndex() - $columnIndex;
$rowspan = $merge->getEndRowIndex() - $rowIndex;
break;
} else {
continue 2;
}
}
}
$tableRow[] = new TableCell((string)$sheetCell->getFormattedValue(), [
'colspan' => $colspan,
'rowspan' => $rowspan
]);
}
$table->addRow($tableRow);
}
$table->render();
} | php | protected function writeGoogleSheetTable(OutputInterface $output, \Google_Service_Sheets_Sheet $sheet)
{
$table = new Table($output);
$merges = $sheet->getMerges(); /** @var \Google_Service_Sheets_GridRange[] $merges (the SDK type hint is incorrect) */
foreach ($sheet->getData()[0]->getRowData() as $rowIndex => $sheetRow) {
/** @var \Google_Service_Sheets_RowData $sheetRow */
// TableSeparator is not used here because it is not compatible with rowspan
$tableRow = [];
foreach ($sheetRow->getValues() as $columnIndex => $sheetCell) {
$colspan = $rowspan = 1;
/** @var \Google_Service_Sheets_CellData $sheetCell (the SDK type hint is incorrect) */
foreach ($merges as $merge) {
// The end indexes are not inclusive
if (
$columnIndex >= $merge->getStartColumnIndex() && $columnIndex < $merge->getEndColumnIndex() &&
$rowIndex >= $merge->getStartRowIndex() && $rowIndex < $merge->getEndRowIndex()
) {
if ($columnIndex === $merge->getStartColumnIndex() && $rowIndex === $merge->getStartRowIndex()) {
$colspan = $merge->getEndColumnIndex() - $columnIndex;
$rowspan = $merge->getEndRowIndex() - $rowIndex;
break;
} else {
continue 2;
}
}
}
$tableRow[] = new TableCell((string)$sheetCell->getFormattedValue(), [
'colspan' => $colspan,
'rowspan' => $rowspan
]);
}
$table->addRow($tableRow);
}
$table->render();
} | [
"protected",
"function",
"writeGoogleSheetTable",
"(",
"OutputInterface",
"$",
"output",
",",
"\\",
"Google_Service_Sheets_Sheet",
"$",
"sheet",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"$",
"output",
")",
";",
"$",
"merges",
"=",
"$",
"sheet",
"->"... | Prints a Google Sheet to a console output as a table
@param OutputInterface $output
@param \Google_Service_Sheets_Sheet $sheet
@link http://symfony.com/doc/3.4/components/console/helpers/table.html | [
"Prints",
"a",
"Google",
"Sheet",
"to",
"a",
"console",
"output",
"as",
"a",
"table"
] | c2e74309f27c88c07f5e0da6b9ed863217d1b5a3 | https://github.com/xmlsquad/ping-drive/blob/c2e74309f27c88c07f5e0da6b9ed863217d1b5a3/src/Command/PingDriveCommand.php#L333-L374 | train |
Talesoft/tale-stream | src/Stream/Iterator/SplitIterator.php | SplitIterator.getIterator | public function getIterator(): \Generator
{
$line = '';
foreach ($this->readIterator as $content) {
$parts = explode($this->delimiter, $content);
$partCount = \count($parts);
if ($partCount > 1) {
foreach ($parts as $i => $part) {
if ($i === 0) {
yield $line.$part;
continue;
}
if ($i === $partCount - 1) {
$line = $part;
continue;
}
yield $part;
}
continue;
}
$line .= $content;
}
yield $line;
} | php | public function getIterator(): \Generator
{
$line = '';
foreach ($this->readIterator as $content) {
$parts = explode($this->delimiter, $content);
$partCount = \count($parts);
if ($partCount > 1) {
foreach ($parts as $i => $part) {
if ($i === 0) {
yield $line.$part;
continue;
}
if ($i === $partCount - 1) {
$line = $part;
continue;
}
yield $part;
}
continue;
}
$line .= $content;
}
yield $line;
} | [
"public",
"function",
"getIterator",
"(",
")",
":",
"\\",
"Generator",
"{",
"$",
"line",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"readIterator",
"as",
"$",
"content",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"$",
"this",
"->",
"delimit... | Generates parts of an iterator split by the specified delimiter.
@return \Generator|string[] | [
"Generates",
"parts",
"of",
"an",
"iterator",
"split",
"by",
"the",
"specified",
"delimiter",
"."
] | 13cdaa8cbc2daf833af98c67bf14121ea18c80aa | https://github.com/Talesoft/tale-stream/blob/13cdaa8cbc2daf833af98c67bf14121ea18c80aa/src/Stream/Iterator/SplitIterator.php#L71-L95 | train |
osflab/stream | Html.php | Html.buildHtmlElement | public static function buildHtmlElement($name, array $attributes = [], $content = null, $closeEmptyTag = true, array $cssClasses = []): string
{
$html = '<' . $name . self::buildAttrs($attributes, $cssClasses);
if ($content !== null) {
$html .= '>' . $content . '</' . $name . '>';
} else {
$html .= $closeEmptyTag ? ' />' : '>';
}
return $html;
} | php | public static function buildHtmlElement($name, array $attributes = [], $content = null, $closeEmptyTag = true, array $cssClasses = []): string
{
$html = '<' . $name . self::buildAttrs($attributes, $cssClasses);
if ($content !== null) {
$html .= '>' . $content . '</' . $name . '>';
} else {
$html .= $closeEmptyTag ? ' />' : '>';
}
return $html;
} | [
"public",
"static",
"function",
"buildHtmlElement",
"(",
"$",
"name",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"content",
"=",
"null",
",",
"$",
"closeEmptyTag",
"=",
"true",
",",
"array",
"$",
"cssClasses",
"=",
"[",
"]",
")",
":",
... | Build an html element
@param string $name
@param array $attributes
@param string $content
@param bool $closeEmptyTag
@return string | [
"Build",
"an",
"html",
"element"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Html.php#L31-L40 | train |
osflab/stream | Html.php | Html.buildHtmlScript | public static function buildHtmlScript($script, array $attributes = []): string
{
$scriptCleaned = trim($script);
if ($scriptCleaned !== '') {
return self::buildHtmlElement('script', $attributes, "\n" . $scriptCleaned . "\n");
}
return '';
} | php | public static function buildHtmlScript($script, array $attributes = []): string
{
$scriptCleaned = trim($script);
if ($scriptCleaned !== '') {
return self::buildHtmlElement('script', $attributes, "\n" . $scriptCleaned . "\n");
}
return '';
} | [
"public",
"static",
"function",
"buildHtmlScript",
"(",
"$",
"script",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"scriptCleaned",
"=",
"trim",
"(",
"$",
"script",
")",
";",
"if",
"(",
"$",
"scriptCleaned",
"!==",
"''... | Build an html script element
@param mixed $script
@param array $attributes
@return string | [
"Build",
"an",
"html",
"script",
"element"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Html.php#L69-L76 | train |
osflab/stream | Html.php | Html.toText | public static function toText($html, bool $ignoreErrors = false): string
{
return (string) (new \Html2Text\Html2Text())->convert((string) $html, $ignoreErrors);
} | php | public static function toText($html, bool $ignoreErrors = false): string
{
return (string) (new \Html2Text\Html2Text())->convert((string) $html, $ignoreErrors);
} | [
"public",
"static",
"function",
"toText",
"(",
"$",
"html",
",",
"bool",
"$",
"ignoreErrors",
"=",
"false",
")",
":",
"string",
"{",
"return",
"(",
"string",
")",
"(",
"new",
"\\",
"Html2Text",
"\\",
"Html2Text",
"(",
")",
")",
"->",
"convert",
"(",
... | Convert html to text using html2text
@see https://github.com/soundasleep/html2text
@param string $html
@return string | [
"Convert",
"html",
"to",
"text",
"using",
"html2text"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Html.php#L84-L87 | train |
mszewcz/php-light-framework | src/Validator/Specific/Iban.php | Iban.validateIban | private function validateIban(): bool
{
$value = \substr($this->value, 4).\substr($this->value, 0, 4);
$value = \str_replace(
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
['10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22',
'23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35'],
$value
);
$tmp = \intval(\substr($value, 0, 1));
$len = \strlen($value);
for ($i = 1; $i < $len; ++$i) {
$tmp *= 10;
$tmp += \intval(\substr($value, $i, 1));
$tmp %= 97;
}
$valid = $tmp == 1 ? true : false;
if (!$valid) {
$this->setError(self::VALIDATOR_ERROR_IBAN_INVALID_NUMBER);
}
return $valid;
} | php | private function validateIban(): bool
{
$value = \substr($this->value, 4).\substr($this->value, 0, 4);
$value = \str_replace(
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
['10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22',
'23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35'],
$value
);
$tmp = \intval(\substr($value, 0, 1));
$len = \strlen($value);
for ($i = 1; $i < $len; ++$i) {
$tmp *= 10;
$tmp += \intval(\substr($value, $i, 1));
$tmp %= 97;
}
$valid = $tmp == 1 ? true : false;
if (!$valid) {
$this->setError(self::VALIDATOR_ERROR_IBAN_INVALID_NUMBER);
}
return $valid;
} | [
"private",
"function",
"validateIban",
"(",
")",
":",
"bool",
"{",
"$",
"value",
"=",
"\\",
"substr",
"(",
"$",
"this",
"->",
"value",
",",
"4",
")",
".",
"\\",
"substr",
"(",
"$",
"this",
"->",
"value",
",",
"0",
",",
"4",
")",
";",
"$",
"valu... | Validates IBAN number
@return bool | [
"Validates",
"IBAN",
"number"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Validator/Specific/Iban.php#L116-L139 | train |
agalbourdin/agl-core | src/Mysql/Db.php | Db.connect | public function connect($pHost, $pDb, $pUser = NULL, $pPass = NULL)
{
try {
if ($pUser !== NULL and $pPass !== NULL and is_string($pUser) and is_string($pPass)) {
$connection = new PDO("mysql:host=$pHost;dbname=$pDb", $pUser, $pPass);
} else {
$connection = new PDO("mysql:host=$pHost;dbname=$pDb");
}
} catch(PDOException $e) {
throw new Exception("Unable to establish a connection to MySQL: Host '$pHost', DB '$pDb', User '$pUser', Password '$pPass' with message '" . $e->getMessage() . "'");
}
$connection->query("SET NAMES 'utf8';");
return $connection;
} | php | public function connect($pHost, $pDb, $pUser = NULL, $pPass = NULL)
{
try {
if ($pUser !== NULL and $pPass !== NULL and is_string($pUser) and is_string($pPass)) {
$connection = new PDO("mysql:host=$pHost;dbname=$pDb", $pUser, $pPass);
} else {
$connection = new PDO("mysql:host=$pHost;dbname=$pDb");
}
} catch(PDOException $e) {
throw new Exception("Unable to establish a connection to MySQL: Host '$pHost', DB '$pDb', User '$pUser', Password '$pPass' with message '" . $e->getMessage() . "'");
}
$connection->query("SET NAMES 'utf8';");
return $connection;
} | [
"public",
"function",
"connect",
"(",
"$",
"pHost",
",",
"$",
"pDb",
",",
"$",
"pUser",
"=",
"NULL",
",",
"$",
"pPass",
"=",
"NULL",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"pUser",
"!==",
"NULL",
"and",
"$",
"pPass",
"!==",
"NULL",
"and",
"is_stri... | Establish the database connection.
@param string $pHost Database host
@param string $pDb Database name
@param string $pUser Database user
@param string $pPass Database password
@return PDO | [
"Establish",
"the",
"database",
"connection",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mysql/Db.php#L53-L68 | train |
agalbourdin/agl-core | src/Mysql/Db.php | Db.listCollections | public function listCollections(array $pWithFields = array())
{
$tables = array();
$prepared = $this->getConnection()->prepare('SHOW TABLES FROM `' . $this->_dbName . '`');
if ($prepared->execute()) {
while ($row = $prepared->fetchObject()) {
$table = str_replace($this->getDbPrefix(), '', current($row));
foreach ($pWithFields as $field) {
$preparedJoin = $this->getConnection()->prepare('SHOW COLUMNS FROM `' . current($row) . '` LIKE "' . $field . '"');
$preparedJoin->execute();
if ($preparedJoin->execute() and ! $preparedJoin->rowCount()) {
continue 2;
}
}
$tables[] = $table;
}
}
return $tables;
} | php | public function listCollections(array $pWithFields = array())
{
$tables = array();
$prepared = $this->getConnection()->prepare('SHOW TABLES FROM `' . $this->_dbName . '`');
if ($prepared->execute()) {
while ($row = $prepared->fetchObject()) {
$table = str_replace($this->getDbPrefix(), '', current($row));
foreach ($pWithFields as $field) {
$preparedJoin = $this->getConnection()->prepare('SHOW COLUMNS FROM `' . current($row) . '` LIKE "' . $field . '"');
$preparedJoin->execute();
if ($preparedJoin->execute() and ! $preparedJoin->rowCount()) {
continue 2;
}
}
$tables[] = $table;
}
}
return $tables;
} | [
"public",
"function",
"listCollections",
"(",
"array",
"$",
"pWithFields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"tables",
"=",
"array",
"(",
")",
";",
"$",
"prepared",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"'SHOW TA... | List all the database's collections.
@param array $pWithFields Fields that must exist in collections
@return array
@todo Test this method with $pWithFields | [
"List",
"all",
"the",
"database",
"s",
"collections",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mysql/Db.php#L77-L100 | train |
aufa/Encryption | src/Encryption/Cryptography/Util.php | Util.zeroFill | public static function zeroFill($a, $b)
{
$z = hexdec(80000000);
if ($z & $a) {
$a = ($a>>1);
$a &= (~$z & 0xffffffff);
$a |= 0x40000000;
$a = ($a >> ($b-1));
} else {
$a = ($a >> $b);
}
return $a;
} | php | public static function zeroFill($a, $b)
{
$z = hexdec(80000000);
if ($z & $a) {
$a = ($a>>1);
$a &= (~$z & 0xffffffff);
$a |= 0x40000000;
$a = ($a >> ($b-1));
} else {
$a = ($a >> $b);
}
return $a;
} | [
"public",
"static",
"function",
"zeroFill",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"z",
"=",
"hexdec",
"(",
"80000000",
")",
";",
"if",
"(",
"$",
"z",
"&",
"$",
"a",
")",
"{",
"$",
"a",
"=",
"(",
"$",
"a",
">>",
"1",
")",
";",
"$",
... | Fills the zero values
@param int $a
@param int $b
@return int | [
"Fills",
"the",
"zero",
"values"
] | f5772afed2629e3ad2303ff175a7a29c94e3483d | https://github.com/aufa/Encryption/blob/f5772afed2629e3ad2303ff175a7a29c94e3483d/src/Encryption/Cryptography/Util.php#L32-L44 | train |
aufa/Encryption | src/Encryption/Cryptography/Util.php | Util.str2bin | public static function str2bin($string)
{
if (is_array($string) || is_object($string)) {
$caller = next(debug_backtrace());
$error['line'] = $caller['line'];
$error['file'] = strip_tags($caller['file']);
trigger_error(
"str2bin() expects parameter 1 to be string, "
. gettype($string)
. " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n",
E_USER_ERROR
);
return '';
}
if (strlen($string) <= 0) {
return '';
}
$string = str_split($string, 1);
for ($i = 0, $n = count($string); $i < $n; ++$i) {
$string[$i] = decbin(ord($string[$i]));
$string[$i] = str_repeat("0", 8 - strlen($string[$i])) . $string[$i];
}
return implode("", $string);
} | php | public static function str2bin($string)
{
if (is_array($string) || is_object($string)) {
$caller = next(debug_backtrace());
$error['line'] = $caller['line'];
$error['file'] = strip_tags($caller['file']);
trigger_error(
"str2bin() expects parameter 1 to be string, "
. gettype($string)
. " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n",
E_USER_ERROR
);
return '';
}
if (strlen($string) <= 0) {
return '';
}
$string = str_split($string, 1);
for ($i = 0, $n = count($string); $i < $n; ++$i) {
$string[$i] = decbin(ord($string[$i]));
$string[$i] = str_repeat("0", 8 - strlen($string[$i])) . $string[$i];
}
return implode("", $string);
} | [
"public",
"static",
"function",
"str2bin",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"string",
")",
"||",
"is_object",
"(",
"$",
"string",
")",
")",
"{",
"$",
"caller",
"=",
"next",
"(",
"debug_backtrace",
"(",
")",
")",
";",
"... | Converting string into binary
@param string $string the string to convert
@return string | [
"Converting",
"string",
"into",
"binary"
] | f5772afed2629e3ad2303ff175a7a29c94e3483d | https://github.com/aufa/Encryption/blob/f5772afed2629e3ad2303ff175a7a29c94e3483d/src/Encryption/Cryptography/Util.php#L57-L84 | train |
aufa/Encryption | src/Encryption/Cryptography/Util.php | Util.bin2str | public static function bin2str($string)
{
if (is_array($string) || is_object($string)) {
$caller = next(debug_backtrace());
$error['line'] = $caller['line'];
$error['file'] = strip_tags($caller['file']);
trigger_error(
"bin2str() expects parameter 1 to be string, "
. gettype($string)
. " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n",
E_USER_ERROR
);
return '';
}
if (strlen($string) <= 0) {
return '';
}
$string = str_split($string, 8); // NOTE: this function is PHP5 only
for ($i = 0, $n = count($string); $i < $n; ++$i) {
$string[$i] = chr(bindec($string[$i]));
}
return implode('', $string);
} | php | public static function bin2str($string)
{
if (is_array($string) || is_object($string)) {
$caller = next(debug_backtrace());
$error['line'] = $caller['line'];
$error['file'] = strip_tags($caller['file']);
trigger_error(
"bin2str() expects parameter 1 to be string, "
. gettype($string)
. " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n",
E_USER_ERROR
);
return '';
}
if (strlen($string) <= 0) {
return '';
}
$string = str_split($string, 8); // NOTE: this function is PHP5 only
for ($i = 0, $n = count($string); $i < $n; ++$i) {
$string[$i] = chr(bindec($string[$i]));
}
return implode('', $string);
} | [
"public",
"static",
"function",
"bin2str",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"string",
")",
"||",
"is_object",
"(",
"$",
"string",
")",
")",
"{",
"$",
"caller",
"=",
"next",
"(",
"debug_backtrace",
"(",
")",
")",
";",
"... | Converting binary string into normal string
@param string $string the string to convert
@return string | [
"Converting",
"binary",
"string",
"into",
"normal",
"string"
] | f5772afed2629e3ad2303ff175a7a29c94e3483d | https://github.com/aufa/Encryption/blob/f5772afed2629e3ad2303ff175a7a29c94e3483d/src/Encryption/Cryptography/Util.php#L92-L118 | train |
aufa/Encryption | src/Encryption/Cryptography/Util.php | Util.byte2intSplit | public static function byte2intSplit($input)
{
$l = strlen($input);
if ($l <= 0) {
// right...
return 0;
} elseif (($l % 4) != 0) {
// invalid input
return false;
}
$result = array();
for ($i = 0; $i < $l; $i += 4) {
$int_build = (ord($input[$i]) << 24);
$int_build += (ord($input[$i+1]) << 16);
$int_build += (ord($input[$i+2]) << 8);
$int_build += (ord($input[$i+3]));
$result[] = $int_build;
}
return $result;
} | php | public static function byte2intSplit($input)
{
$l = strlen($input);
if ($l <= 0) {
// right...
return 0;
} elseif (($l % 4) != 0) {
// invalid input
return false;
}
$result = array();
for ($i = 0; $i < $l; $i += 4) {
$int_build = (ord($input[$i]) << 24);
$int_build += (ord($input[$i+1]) << 16);
$int_build += (ord($input[$i+2]) << 8);
$int_build += (ord($input[$i+3]));
$result[] = $int_build;
}
return $result;
} | [
"public",
"static",
"function",
"byte2intSplit",
"(",
"$",
"input",
")",
"{",
"$",
"l",
"=",
"strlen",
"(",
"$",
"input",
")",
";",
"if",
"(",
"$",
"l",
"<=",
"0",
")",
"{",
"// right...",
"return",
"0",
";",
"}",
"elseif",
"(",
"(",
"$",
"l",
... | split a byte-string into integer array values
@param string $input
@return array|bool|int | [
"split",
"a",
"byte",
"-",
"string",
"into",
"integer",
"array",
"values"
] | f5772afed2629e3ad2303ff175a7a29c94e3483d | https://github.com/aufa/Encryption/blob/f5772afed2629e3ad2303ff175a7a29c94e3483d/src/Encryption/Cryptography/Util.php#L127-L147 | train |
ThePHPAvengers/UniApi | src/UniApi/Common/FacadeFactory.php | FacadeFactory.find | public function find()
{
foreach ($this->getSupportedGateways() as $gateway) {
$class = $this->helper-getFacadeClassName($gateway);
if (class_exists($class)) {
$this->register($gateway);
}
}
ksort($this->gateways);
return $this->all();
} | php | public function find()
{
foreach ($this->getSupportedGateways() as $gateway) {
$class = $this->helper-getFacadeClassName($gateway);
if (class_exists($class)) {
$this->register($gateway);
}
}
ksort($this->gateways);
return $this->all();
} | [
"public",
"function",
"find",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSupportedGateways",
"(",
")",
"as",
"$",
"gateway",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"helper",
"-",
"getFacadeClassName",
"(",
"$",
"gateway",
")",
";",
... | Automatically find and register all officially supported gateways
@return array An array of gateway names | [
"Automatically",
"find",
"and",
"register",
"all",
"officially",
"supported",
"gateways"
] | e63d79d926cfbaca28860e389c2625aaec81655c | https://github.com/ThePHPAvengers/UniApi/blob/e63d79d926cfbaca28860e389c2625aaec81655c/src/UniApi/Common/FacadeFactory.php#L76-L88 | train |
ThePHPAvengers/UniApi | src/UniApi/Common/FacadeFactory.php | FacadeFactory.create | public function create($className)
{
$facade = $this->helper->getFacadeClassName($className);
if (!class_exists($facade)) {
throw new RuntimeException("Class '$facade' not found");
}
$className = $this->helper->getSDKClassName($className);
return new $facade(new $className($this->httpClient));
} | php | public function create($className)
{
$facade = $this->helper->getFacadeClassName($className);
if (!class_exists($facade)) {
throw new RuntimeException("Class '$facade' not found");
}
$className = $this->helper->getSDKClassName($className);
return new $facade(new $className($this->httpClient));
} | [
"public",
"function",
"create",
"(",
"$",
"className",
")",
"{",
"$",
"facade",
"=",
"$",
"this",
"->",
"helper",
"->",
"getFacadeClassName",
"(",
"$",
"className",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"facade",
")",
")",
"{",
"throw",
... | Get the facade for SDK
@param $className
@return mixed
@throws Exception\RuntimeException | [
"Get",
"the",
"facade",
"for",
"SDK"
] | e63d79d926cfbaca28860e389c2625aaec81655c | https://github.com/ThePHPAvengers/UniApi/blob/e63d79d926cfbaca28860e389c2625aaec81655c/src/UniApi/Common/FacadeFactory.php#L98-L107 | train |
coolms/jquery | src/Stdlib/AbstractObject.php | AbstractObject.getOption | public function getOption($name)
{
$method = 'get' . ucfirst($name);
if (method_exists($this, $method) && $method !== __FUNCTION__) {
return $this->$method();
} elseif (isset($this->options[$name])) {
return $this->options[$name];
}
} | php | public function getOption($name)
{
$method = 'get' . ucfirst($name);
if (method_exists($this, $method) && $method !== __FUNCTION__) {
return $this->$method();
} elseif (isset($this->options[$name])) {
return $this->options[$name];
}
} | [
"public",
"function",
"getOption",
"(",
"$",
"name",
")",
"{",
"$",
"method",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
"&&",
"$",
"method",
"!==",
"__FUNCTION__",... | Get single option
@param string $name name of option
@return mixed | [
"Get",
"single",
"option"
] | e7a8b0890d1888b44a03dd6affe55a300cca9c73 | https://github.com/coolms/jquery/blob/e7a8b0890d1888b44a03dd6affe55a300cca9c73/src/Stdlib/AbstractObject.php#L97-L105 | train |
coolms/jquery | src/Stdlib/AbstractObject.php | AbstractObject.setOption | public function setOption($name, $value)
{
$method = 'set' . ucfirst($name);
if (method_exists($this, $method) && $method !== __FUNCTION__) {
return $this->$method($value);
}
$this->options[$name] = $value;
return $this;
} | php | public function setOption($name, $value)
{
$method = 'set' . ucfirst($name);
if (method_exists($this, $method) && $method !== __FUNCTION__) {
return $this->$method($value);
}
$this->options[$name] = $value;
return $this;
} | [
"public",
"function",
"setOption",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
"&&",
"$",
"method",
... | Set single option
@param string $name name of option
@param mixed $value value of option
@return self | [
"Set",
"single",
"option"
] | e7a8b0890d1888b44a03dd6affe55a300cca9c73 | https://github.com/coolms/jquery/blob/e7a8b0890d1888b44a03dd6affe55a300cca9c73/src/Stdlib/AbstractObject.php#L114-L123 | train |
acantepie/CoreBundle | Form/UmbrellaFileType.php | FileUploadTransformer.transform | public function transform($umbrellaFile)
{
return array(
'file' => null,
'id' => $umbrellaFile ? $umbrellaFile->id : null,
'text' => $umbrellaFile ? $umbrellaFile->name . ' (' . $umbrellaFile->getHumanSize() .')' : null
);
} | php | public function transform($umbrellaFile)
{
return array(
'file' => null,
'id' => $umbrellaFile ? $umbrellaFile->id : null,
'text' => $umbrellaFile ? $umbrellaFile->name . ' (' . $umbrellaFile->getHumanSize() .')' : null
);
} | [
"public",
"function",
"transform",
"(",
"$",
"umbrellaFile",
")",
"{",
"return",
"array",
"(",
"'file'",
"=>",
"null",
",",
"'id'",
"=>",
"$",
"umbrellaFile",
"?",
"$",
"umbrellaFile",
"->",
"id",
":",
"null",
",",
"'text'",
"=>",
"$",
"umbrellaFile",
"?... | Transform UmbrellaFile => array
@param UmbrellaFile $umbrellaFile
@return array | [
"Transform",
"UmbrellaFile",
"=",
">",
"array"
] | e9f19194b105bfcc10c34ff0763e45436d719782 | https://github.com/acantepie/CoreBundle/blob/e9f19194b105bfcc10c34ff0763e45436d719782/Form/UmbrellaFileType.php#L144-L151 | train |
acantepie/CoreBundle | Form/UmbrellaFileType.php | FileUploadTransformer.reverseTransform | public function reverseTransform($array)
{
$id = ArrayUtils::get($array, 'id', null);
$umbrellaFile = $id ? $this->em->getRepository(UmbrellaFile::class)->find($id) : null;
$uploadedFile = ArrayUtils::get($array, 'file', null);
$delete = ArrayUtils::get($array, 'delete', false);
if ($umbrellaFile && $uploadedFile) { // update
$this->em->remove($umbrellaFile);
return $this->manager->createUmbrellaFile($uploadedFile);
}
if ($umbrellaFile && $uploadedFile === null && $delete) { // delete
$this->em->remove($umbrellaFile);
return null;
}
if ($umbrellaFile === null && $uploadedFile) { // create
return $this->manager->createUmbrellaFile($uploadedFile);
}
// nothing to do
return $umbrellaFile;
} | php | public function reverseTransform($array)
{
$id = ArrayUtils::get($array, 'id', null);
$umbrellaFile = $id ? $this->em->getRepository(UmbrellaFile::class)->find($id) : null;
$uploadedFile = ArrayUtils::get($array, 'file', null);
$delete = ArrayUtils::get($array, 'delete', false);
if ($umbrellaFile && $uploadedFile) { // update
$this->em->remove($umbrellaFile);
return $this->manager->createUmbrellaFile($uploadedFile);
}
if ($umbrellaFile && $uploadedFile === null && $delete) { // delete
$this->em->remove($umbrellaFile);
return null;
}
if ($umbrellaFile === null && $uploadedFile) { // create
return $this->manager->createUmbrellaFile($uploadedFile);
}
// nothing to do
return $umbrellaFile;
} | [
"public",
"function",
"reverseTransform",
"(",
"$",
"array",
")",
"{",
"$",
"id",
"=",
"ArrayUtils",
"::",
"get",
"(",
"$",
"array",
",",
"'id'",
",",
"null",
")",
";",
"$",
"umbrellaFile",
"=",
"$",
"id",
"?",
"$",
"this",
"->",
"em",
"->",
"getRe... | Transform array => UmbrellaFile
@param array $array
@return UmbrellaFile|null | [
"Transform",
"array",
"=",
">",
"UmbrellaFile"
] | e9f19194b105bfcc10c34ff0763e45436d719782 | https://github.com/acantepie/CoreBundle/blob/e9f19194b105bfcc10c34ff0763e45436d719782/Form/UmbrellaFileType.php#L159-L182 | train |
znframework/package-console | Result.php | Result.outputSingleResult | protected function outputSingleResult()
{
echo $this->line();
echo $this->title();
echo $this->line();
echo $this->content();
echo $this->line();
} | php | protected function outputSingleResult()
{
echo $this->line();
echo $this->title();
echo $this->line();
echo $this->content();
echo $this->line();
} | [
"protected",
"function",
"outputSingleResult",
"(",
")",
"{",
"echo",
"$",
"this",
"->",
"line",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"title",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"line",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"content... | Protected output single result | [
"Protected",
"output",
"single",
"result"
] | fde428da8b9d926ea4256c235f542e6225c5d788 | https://github.com/znframework/package-console/blob/fde428da8b9d926ea4256c235f542e6225c5d788/Result.php#L129-L136 | train |
znframework/package-console | Result.php | Result.outputMultipleResult | protected function outputMultipleResult()
{
$this->return = $max = max($this->print) . ' ';
echo $this->line();
echo $this->title();
echo $this->line();
foreach( $this->print as $key => $ret )
{
$diff = strlen($max) - strlen($return = $key . ' | ' . $ret);
$this->return = $return . str_repeat(' ', $diff);
echo $this->content();
echo $this->line();
}
} | php | protected function outputMultipleResult()
{
$this->return = $max = max($this->print) . ' ';
echo $this->line();
echo $this->title();
echo $this->line();
foreach( $this->print as $key => $ret )
{
$diff = strlen($max) - strlen($return = $key . ' | ' . $ret);
$this->return = $return . str_repeat(' ', $diff);
echo $this->content();
echo $this->line();
}
} | [
"protected",
"function",
"outputMultipleResult",
"(",
")",
"{",
"$",
"this",
"->",
"return",
"=",
"$",
"max",
"=",
"max",
"(",
"$",
"this",
"->",
"print",
")",
".",
"' '",
";",
"echo",
"$",
"this",
"->",
"line",
"(",
")",
";",
"echo",
"$",
"this... | Protected output multiple result | [
"Protected",
"output",
"multiple",
"result"
] | fde428da8b9d926ea4256c235f542e6225c5d788 | https://github.com/znframework/package-console/blob/fde428da8b9d926ea4256c235f542e6225c5d788/Result.php#L141-L157 | train |
loopsframework/base | src/Loops/ArrayObject.php | ArrayObject.merge | public function merge(ArrayObject $other, $recursive = TRUE) {
foreach($other as $key => $value) {
if($recursive && $this->offsetExists($key)) {
$ownvalue = $this->offsetGet($key);
if($ownvalue instanceof ArrayObject && $value instanceof ArrayObject) {
$ownvalue->merge($value, TRUE);
continue;
}
}
$this->offsetSet($key, $value);
}
return $this;
} | php | public function merge(ArrayObject $other, $recursive = TRUE) {
foreach($other as $key => $value) {
if($recursive && $this->offsetExists($key)) {
$ownvalue = $this->offsetGet($key);
if($ownvalue instanceof ArrayObject && $value instanceof ArrayObject) {
$ownvalue->merge($value, TRUE);
continue;
}
}
$this->offsetSet($key, $value);
}
return $this;
} | [
"public",
"function",
"merge",
"(",
"ArrayObject",
"$",
"other",
",",
"$",
"recursive",
"=",
"TRUE",
")",
"{",
"foreach",
"(",
"$",
"other",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"recursive",
"&&",
"$",
"this",
"->",
"offs... | Merges values from another Loops\ArrayObject into this one by keys
@param Loops\ArrayObject $other Merge values from this array object
@param bool $recursive Recursively merge values (i.e. if both values are of type Loops\ArrayObject) | [
"Merges",
"values",
"from",
"another",
"Loops",
"\\",
"ArrayObject",
"into",
"this",
"one",
"by",
"keys"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/ArrayObject.php#L31-L45 | train |
loopsframework/base | src/Loops/ArrayObject.php | ArrayObject.toArray | public function toArray() {
$result = iterator_to_array($this);
foreach($result as $key => &$value) {
if($value instanceof ArrayObject) {
$value = $value->toArray();
}
}
return $result;
} | php | public function toArray() {
$result = iterator_to_array($this);
foreach($result as $key => &$value) {
if($value instanceof ArrayObject) {
$value = $value->toArray();
}
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"result",
"=",
"iterator_to_array",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"ArrayObje... | Returns the keys and values of this object as a standard array
@return array<mixed> The keys and values as an array | [
"Returns",
"the",
"keys",
"and",
"values",
"of",
"this",
"object",
"as",
"a",
"standard",
"array"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/ArrayObject.php#L52-L61 | train |
loopsframework/base | src/Loops/ArrayObject.php | ArrayObject.fromArray | public static function fromArray(array $input) {
$input = array_map(function($value) {
return is_array($value) ? ArrayObject::fromArray($value) : $value;
}, $input);
return new ArrayObject($input);
} | php | public static function fromArray(array $input) {
$input = array_map(function($value) {
return is_array($value) ? ArrayObject::fromArray($value) : $value;
}, $input);
return new ArrayObject($input);
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"input",
")",
"{",
"$",
"input",
"=",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"is_array",
"(",
"$",
"value",
")",
"?",
"ArrayObject",
"::",
"fromArray",
"(",
"... | Creates an "Loops\ArrayObject" from a normal PHP array.
Nested arrays will recursively converted.
@param array $input The input array
@return Loops\ArrayObject The input array as a "Loops\ArrayObject". | [
"Creates",
"an",
"Loops",
"\\",
"ArrayObject",
"from",
"a",
"normal",
"PHP",
"array",
".",
"Nested",
"arrays",
"will",
"recursively",
"converted",
"."
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/ArrayObject.php#L70-L76 | train |
bishopb/vanilla | applications/dashboard/settings/class.hooks.php | DashboardHooks.Gdn_Dispatcher_AppStartup_Handler | public function Gdn_Dispatcher_AppStartup_Handler($Sender) {
header('P3P: CP="CAO PSA OUR"', TRUE);
if (!Gdn::Session()->IsValid() && $SSO = Gdn::Request()->Get('sso')) {
SaveToConfig('Garden.Registration.SendConnectEmail', FALSE, FALSE);
$UserID = FALSE;
try {
$UserID = Gdn::UserModel()->SSO($SSO);
} catch (Exception $Ex) {
Trace($Ex, TRACE_ERROR);
}
if ($UserID) {
Gdn::Session()->Start($UserID, TRUE, TRUE);
Gdn::UserModel()->FireEvent('AfterSignIn');
} else {
// There was some sort of error. Let's print that out.
Trace(Gdn::UserModel()->Validation->ResultsText(), TRACE_WARNING);
}
}
} | php | public function Gdn_Dispatcher_AppStartup_Handler($Sender) {
header('P3P: CP="CAO PSA OUR"', TRUE);
if (!Gdn::Session()->IsValid() && $SSO = Gdn::Request()->Get('sso')) {
SaveToConfig('Garden.Registration.SendConnectEmail', FALSE, FALSE);
$UserID = FALSE;
try {
$UserID = Gdn::UserModel()->SSO($SSO);
} catch (Exception $Ex) {
Trace($Ex, TRACE_ERROR);
}
if ($UserID) {
Gdn::Session()->Start($UserID, TRUE, TRUE);
Gdn::UserModel()->FireEvent('AfterSignIn');
} else {
// There was some sort of error. Let's print that out.
Trace(Gdn::UserModel()->Validation->ResultsText(), TRACE_WARNING);
}
}
} | [
"public",
"function",
"Gdn_Dispatcher_AppStartup_Handler",
"(",
"$",
"Sender",
")",
"{",
"header",
"(",
"'P3P: CP=\"CAO PSA OUR\"'",
",",
"TRUE",
")",
";",
"if",
"(",
"!",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"IsValid",
"(",
")",
"&&",
"$",
"SSO",
"=",
... | Set P3P header because IE won't allow cookies thru the iFrame without it.
This must be done in the Dispatcher because of PrivateCommunity.
That precludes using Controller->SetHeader.
This is done so comment & forum embedding can work in old IE. | [
"Set",
"P3P",
"header",
"because",
"IE",
"won",
"t",
"allow",
"cookies",
"thru",
"the",
"iFrame",
"without",
"it",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/settings/class.hooks.php#L178-L199 | train |
lciolecki/zf-extensions-library | library/Extlib/Cli/Action.php | Action.console | public function console($message, $eolBefor = false)
{
$befor = '';
if ($eolBefor) {
$befor = PHP_EOL;
}
echo $befor, $message, PHP_EOL;
return $this;
} | php | public function console($message, $eolBefor = false)
{
$befor = '';
if ($eolBefor) {
$befor = PHP_EOL;
}
echo $befor, $message, PHP_EOL;
return $this;
} | [
"public",
"function",
"console",
"(",
"$",
"message",
",",
"$",
"eolBefor",
"=",
"false",
")",
"{",
"$",
"befor",
"=",
"''",
";",
"if",
"(",
"$",
"eolBefor",
")",
"{",
"$",
"befor",
"=",
"PHP_EOL",
";",
"}",
"echo",
"$",
"befor",
",",
"$",
"messa... | Show message in cli
@param string $message
@param boolean $eolBefor
@return \Extlib\Cli\Action | [
"Show",
"message",
"in",
"cli"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Cli/Action.php#L52-L61 | train |
lciolecki/zf-extensions-library | library/Extlib/Cli/Action.php | Action.run | public function run()
{
if ($this->initialized) {
$this->console(sprintf("Start running '%s' method of script '%s'.", $this->opts->action, get_class($this)));
$this->{$this->action}();
$this->console(sprintf("End of running '%s' cli script.", get_class($this)), true);
}
return $this;
} | php | public function run()
{
if ($this->initialized) {
$this->console(sprintf("Start running '%s' method of script '%s'.", $this->opts->action, get_class($this)));
$this->{$this->action}();
$this->console(sprintf("End of running '%s' cli script.", get_class($this)), true);
}
return $this;
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"$",
"this",
"->",
"console",
"(",
"sprintf",
"(",
"\"Start running '%s' method of script '%s'.\"",
",",
"$",
"this",
"->",
"opts",
"->",
"action",
",",
"get... | Run cli script
@return \Extlib\Cli\Action | [
"Run",
"cli",
"script"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Cli/Action.php#L68-L77 | train |
indigophp-archive/pdf | src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php | WkhtmltopdfAdapter.createTmpFile | protected function createTmpFile($content = null)
{
$tmpPath = $this->getConfig('tmp', sys_get_temp_dir());
$tmpFile = tempnam($tmpPath,'tmp_WkHtmlToPdf_');
rename($tmpFile, $tmpFile .= '.html');
if (!is_null($content)) {
file_put_contents($tmpFile, $content);
}
$this->tmpFiles[] = $tmpFile;
return $tmpFile;
} | php | protected function createTmpFile($content = null)
{
$tmpPath = $this->getConfig('tmp', sys_get_temp_dir());
$tmpFile = tempnam($tmpPath,'tmp_WkHtmlToPdf_');
rename($tmpFile, $tmpFile .= '.html');
if (!is_null($content)) {
file_put_contents($tmpFile, $content);
}
$this->tmpFiles[] = $tmpFile;
return $tmpFile;
} | [
"protected",
"function",
"createTmpFile",
"(",
"$",
"content",
"=",
"null",
")",
"{",
"$",
"tmpPath",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'tmp'",
",",
"sys_get_temp_dir",
"(",
")",
")",
";",
"$",
"tmpFile",
"=",
"tempnam",
"(",
"$",
"tmpPath",
"... | Create a tmp file, optionally with given content
@param mixed $content The file content
@return string The path to the created file | [
"Create",
"a",
"tmp",
"file",
"optionally",
"with",
"given",
"content"
] | 060dcccbcd33066d012bc3d5c8300a5310e87a7a | https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L347-L360 | train |
indigophp-archive/pdf | src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php | WkhtmltopdfAdapter.buildArguments | protected function buildArguments(array $options = array())
{
$arguments = array();
foreach ($options as $key => $value) {
// Validate value and format it
if ($value === false or is_int($key)) {
continue;
}
$arguments[] = "--$key";
if (is_array($value)) {
$arguments = array_merge($arguments, $this->buildArrayArguments($value));
} elseif ($value !== true) {
$arguments[] = $value;
}
}
return $arguments;
} | php | protected function buildArguments(array $options = array())
{
$arguments = array();
foreach ($options as $key => $value) {
// Validate value and format it
if ($value === false or is_int($key)) {
continue;
}
$arguments[] = "--$key";
if (is_array($value)) {
$arguments = array_merge($arguments, $this->buildArrayArguments($value));
} elseif ($value !== true) {
$arguments[] = $value;
}
}
return $arguments;
} | [
"protected",
"function",
"buildArguments",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"arguments",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// Validate value... | Build command line options from array
@param array $options Input parameters
@param bool $recursive Should NEVER been set manually
@return string Argument string | [
"Build",
"command",
"line",
"options",
"from",
"array"
] | 060dcccbcd33066d012bc3d5c8300a5310e87a7a | https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L399-L419 | train |
indigophp-archive/pdf | src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php | WkhtmltopdfAdapter.buildArrayArguments | private function buildArrayArguments($value)
{
$arguments = array();
foreach ($value as $index => $option) {
if (is_string($index)) {
$arguments[] = $index;
}
$arguments[] = $option;
}
return $arguments;
} | php | private function buildArrayArguments($value)
{
$arguments = array();
foreach ($value as $index => $option) {
if (is_string($index)) {
$arguments[] = $index;
}
$arguments[] = $option;
}
return $arguments;
} | [
"private",
"function",
"buildArrayArguments",
"(",
"$",
"value",
")",
"{",
"$",
"arguments",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"index",
"=>",
"$",
"option",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"index",
")",... | Build array arguments
@param array $value
@return array | [
"Build",
"array",
"arguments"
] | 060dcccbcd33066d012bc3d5c8300a5310e87a7a | https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L427-L440 | train |
indigophp-archive/pdf | src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php | WkhtmltopdfAdapter.sendHeaders | protected function sendHeaders($tmpFile)
{
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/pdf');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($tmpFile));
} | php | protected function sendHeaders($tmpFile)
{
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/pdf');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($tmpFile));
} | [
"protected",
"function",
"sendHeaders",
"(",
"$",
"tmpFile",
")",
"{",
"header",
"(",
"'Pragma: public'",
")",
";",
"header",
"(",
"'Expires: 0'",
")",
";",
"header",
"(",
"'Cache-Control: must-revalidate, post-check=0, pre-check=0'",
")",
";",
"header",
"(",
"'Cont... | Send PDF file headers
@param string $tmpFile Temp file path | [
"Send",
"PDF",
"file",
"headers"
] | 060dcccbcd33066d012bc3d5c8300a5310e87a7a | https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L501-L509 | train |
indigophp-archive/pdf | src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php | WkhtmltopdfAdapter.help | public function help()
{
$builder = new ProcessBuilder(array('--extended-help'));
$builder->setPrefix($this->config['bin']);
$process = $builder->getProcess();
$process->run();
if ($process->isSuccessful()) {
return $process->getOutput();
}
} | php | public function help()
{
$builder = new ProcessBuilder(array('--extended-help'));
$builder->setPrefix($this->config['bin']);
$process = $builder->getProcess();
$process->run();
if ($process->isSuccessful()) {
return $process->getOutput();
}
} | [
"public",
"function",
"help",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"ProcessBuilder",
"(",
"array",
"(",
"'--extended-help'",
")",
")",
";",
"$",
"builder",
"->",
"setPrefix",
"(",
"$",
"this",
"->",
"config",
"[",
"'bin'",
"]",
")",
";",
"$",
"... | Return the extended help of WkHtmlToPdf
@return string | [
"Return",
"the",
"extended",
"help",
"of",
"WkHtmlToPdf"
] | 060dcccbcd33066d012bc3d5c8300a5310e87a7a | https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L549-L560 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.setRoot | private static function setRoot($url)
{
$segements = explode('/', $url);
$count = count($segements) - 2;
$path = '';
for ($i = 0; $i < $count; $i++) {
$path .= '../';
}
Application::$path .= $path;
return Application::$path;
} | php | private static function setRoot($url)
{
$segements = explode('/', $url);
$count = count($segements) - 2;
$path = '';
for ($i = 0; $i < $count; $i++) {
$path .= '../';
}
Application::$path .= $path;
return Application::$path;
} | [
"private",
"static",
"function",
"setRoot",
"(",
"$",
"url",
")",
"{",
"$",
"segements",
"=",
"explode",
"(",
"'/'",
",",
"$",
"url",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"segements",
")",
"-",
"2",
";",
"$",
"path",
"=",
"''",
";",
... | Set the app root param.
@param string $url
@return string | [
"Set",
"the",
"app",
"root",
"param",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L129-L143 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.treat | private static function treat(Route $route, $params)
{
// in case of get request or post request
if (($route->getMethod() == 'post' && Request::isPost()) || ($route->getMethod() == 'get') || ($route->getMethod() == 'resource') || ($route->getMethod() == 'call')) {
return static::execute($route, $params);
}
return false;
} | php | private static function treat(Route $route, $params)
{
// in case of get request or post request
if (($route->getMethod() == 'post' && Request::isPost()) || ($route->getMethod() == 'get') || ($route->getMethod() == 'resource') || ($route->getMethod() == 'call')) {
return static::execute($route, $params);
}
return false;
} | [
"private",
"static",
"function",
"treat",
"(",
"Route",
"$",
"route",
",",
"$",
"params",
")",
"{",
"// in case of get request or post request",
"if",
"(",
"(",
"$",
"route",
"->",
"getMethod",
"(",
")",
"==",
"'post'",
"&&",
"Request",
"::",
"isPost",
"(",
... | Treat the request according to it's method.
@param Route $route
@param array $params
@return bool | [
"Treat",
"the",
"request",
"according",
"to",
"it",
"s",
"method",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L212-L220 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.execute | private static function execute(&$route, $params)
{
array_shift($params);
if (static::runAppMiddleware() && static::runRouteMiddleware($route)) {
static::prepare($route, $params);
return true;
}
} | php | private static function execute(&$route, $params)
{
array_shift($params);
if (static::runAppMiddleware() && static::runRouteMiddleware($route)) {
static::prepare($route, $params);
return true;
}
} | [
"private",
"static",
"function",
"execute",
"(",
"&",
"$",
"route",
",",
"$",
"params",
")",
"{",
"array_shift",
"(",
"$",
"params",
")",
";",
"if",
"(",
"static",
"::",
"runAppMiddleware",
"(",
")",
"&&",
"static",
"::",
"runRouteMiddleware",
"(",
"$",
... | Execute the route.
@param Route $one
@param array $params
@return bool | [
"Execute",
"the",
"route",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L230-L239 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.runAppMiddleware | private static function runAppMiddleware()
{
$appMiddleware = Filter::$middleware;
foreach ($appMiddleware as $middleware) {
$middleware = instance($middleware);
$middleware->handle(new Request());
}
return true;
} | php | private static function runAppMiddleware()
{
$appMiddleware = Filter::$middleware;
foreach ($appMiddleware as $middleware) {
$middleware = instance($middleware);
$middleware->handle(new Request());
}
return true;
} | [
"private",
"static",
"function",
"runAppMiddleware",
"(",
")",
"{",
"$",
"appMiddleware",
"=",
"Filter",
"::",
"$",
"middleware",
";",
"foreach",
"(",
"$",
"appMiddleware",
"as",
"$",
"middleware",
")",
"{",
"$",
"middleware",
"=",
"instance",
"(",
"$",
"m... | Check app middlewares before run the route.
@return null | [
"Check",
"app",
"middlewares",
"before",
"run",
"the",
"route",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L246-L257 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.runRouteMiddleware | private static function runRouteMiddleware($route)
{
$routeMiddleware = Filter::$routeMiddleware;
if (!is_null($route->getMiddleware())) {
// if ($route->getMiddleware()['type'] == 'route' && ! is_null($route->getMiddleware()['middlewares'])) {
foreach ($route->getMiddleware() as $middleware) {
//Check if the routes middlewares are in filter class
exception_if(!array_has($routeMiddleware, $middleware), RouteMiddlewareNotFoundException::class, $middleware);
$middleware = instance($routeMiddleware[$middleware]);
$middleware->handle(new Request());
}
}
return true;
} | php | private static function runRouteMiddleware($route)
{
$routeMiddleware = Filter::$routeMiddleware;
if (!is_null($route->getMiddleware())) {
// if ($route->getMiddleware()['type'] == 'route' && ! is_null($route->getMiddleware()['middlewares'])) {
foreach ($route->getMiddleware() as $middleware) {
//Check if the routes middlewares are in filter class
exception_if(!array_has($routeMiddleware, $middleware), RouteMiddlewareNotFoundException::class, $middleware);
$middleware = instance($routeMiddleware[$middleware]);
$middleware->handle(new Request());
}
}
return true;
} | [
"private",
"static",
"function",
"runRouteMiddleware",
"(",
"$",
"route",
")",
"{",
"$",
"routeMiddleware",
"=",
"Filter",
"::",
"$",
"routeMiddleware",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"route",
"->",
"getMiddleware",
"(",
")",
")",
")",
"{",
"/... | Check route middlewares before run the route
and check if the requested middleware are realy in filter class.
@return null | [
"Check",
"route",
"middlewares",
"before",
"run",
"the",
"route",
"and",
"check",
"if",
"the",
"requested",
"middleware",
"are",
"realy",
"in",
"filter",
"class",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L265-L282 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.prepare | private static function prepare(Route $route, $params)
{
static::$current = $route;
if ($route->getMethod() == 'resource') {
if ($route->getTarget()['method'] == 'update') {
$id = $params[0];
$params[0] = new Request();
$params[] = $id;
} elseif ($route->getTarget()['method'] == 'insert') {
$params[] = new Request();
}
self::treatment(call_user_func_array($route->getClosure(), $params));
} elseif ($route->getMethod() == 'call') {
$target = $route->getResource()[$route->name]->getTarget();
self::treatment(call_user_func_array([$target['controller'], $target['method']], $params));
} else {
self::treatment(call_user_func_array($route->getClosure(), $params));
}
} | php | private static function prepare(Route $route, $params)
{
static::$current = $route;
if ($route->getMethod() == 'resource') {
if ($route->getTarget()['method'] == 'update') {
$id = $params[0];
$params[0] = new Request();
$params[] = $id;
} elseif ($route->getTarget()['method'] == 'insert') {
$params[] = new Request();
}
self::treatment(call_user_func_array($route->getClosure(), $params));
} elseif ($route->getMethod() == 'call') {
$target = $route->getResource()[$route->name]->getTarget();
self::treatment(call_user_func_array([$target['controller'], $target['method']], $params));
} else {
self::treatment(call_user_func_array($route->getClosure(), $params));
}
} | [
"private",
"static",
"function",
"prepare",
"(",
"Route",
"$",
"route",
",",
"$",
"params",
")",
"{",
"static",
"::",
"$",
"current",
"=",
"$",
"route",
";",
"if",
"(",
"$",
"route",
"->",
"getMethod",
"(",
")",
"==",
"'resource'",
")",
"{",
"if",
... | prepare the route to be executed.
@param Route $request
@param array $params
@return null | [
"prepare",
"the",
"route",
"to",
"be",
"executed",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L292-L312 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.treatment | private static function treatment($result)
{
if (is_string($result)) {
echo $result;
} elseif ($result instanceof Views) {
View::show($result);
}
} | php | private static function treatment($result)
{
if (is_string($result)) {
echo $result;
} elseif ($result instanceof Views) {
View::show($result);
}
} | [
"private",
"static",
"function",
"treatment",
"(",
"$",
"result",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"result",
")",
")",
"{",
"echo",
"$",
"result",
";",
"}",
"elseif",
"(",
"$",
"result",
"instanceof",
"Views",
")",
"{",
"View",
"::",
"show... | Treat the result of the route closure.
@param mixed $result
@return string | [
"Treat",
"the",
"result",
"of",
"the",
"route",
"closure",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L321-L328 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.add | public static function add(Route $route)
{
exception_if(self::checkDuplicated($route), RouteDuplicatedException::class, $route);
// Create new route for url ended with '/'
$routeWithoutSlash = $route;
$routeWithSlash = $route->getWithSlash();
self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash;
self::$register[$routeWithSlash->getName()] = $routeWithSlash;
} | php | public static function add(Route $route)
{
exception_if(self::checkDuplicated($route), RouteDuplicatedException::class, $route);
// Create new route for url ended with '/'
$routeWithoutSlash = $route;
$routeWithSlash = $route->getWithSlash();
self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash;
self::$register[$routeWithSlash->getName()] = $routeWithSlash;
} | [
"public",
"static",
"function",
"add",
"(",
"Route",
"$",
"route",
")",
"{",
"exception_if",
"(",
"self",
"::",
"checkDuplicated",
"(",
"$",
"route",
")",
",",
"RouteDuplicatedException",
"::",
"class",
",",
"$",
"route",
")",
";",
"// Create new route for url... | Add new route to register.
@param Route $route
@return null | [
"Add",
"new",
"route",
"to",
"register",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L337-L347 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.edit | public static function edit(Route $route)
{
$routeWithoutSlash = $route;
$routeWithSlash = $route->getWithSlash();
self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash;
self::$register[$routeWithSlash->getName()] = $routeWithSlash;
} | php | public static function edit(Route $route)
{
$routeWithoutSlash = $route;
$routeWithSlash = $route->getWithSlash();
self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash;
self::$register[$routeWithSlash->getName()] = $routeWithSlash;
} | [
"public",
"static",
"function",
"edit",
"(",
"Route",
"$",
"route",
")",
"{",
"$",
"routeWithoutSlash",
"=",
"$",
"route",
";",
"$",
"routeWithSlash",
"=",
"$",
"route",
"->",
"getWithSlash",
"(",
")",
";",
"self",
"::",
"$",
"register",
"[",
"$",
"rou... | Update an existant route in register.
@param Route $route
@return null | [
"Update",
"an",
"existant",
"route",
"in",
"register",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L356-L363 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.delete | public static function delete(Route $route)
{
$routeWithoutSlash = $route;
$routeWithSlash = $route->getWithSlash();
// exception_if(! check(self::$register[$routeWithoutSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithoutSlash);
// exception_if(! check(self::$register[$routeWithSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithSlash);
if (check(self::$register[$routeWithoutSlash->getName()])) {
unset(self::$register[$routeWithoutSlash->getName()]);
}
if (check(self::$register[$routeWithSlash->getName()])) {
unset(self::$register[$routeWithSlash->getName()]);
}
} | php | public static function delete(Route $route)
{
$routeWithoutSlash = $route;
$routeWithSlash = $route->getWithSlash();
// exception_if(! check(self::$register[$routeWithoutSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithoutSlash);
// exception_if(! check(self::$register[$routeWithSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithSlash);
if (check(self::$register[$routeWithoutSlash->getName()])) {
unset(self::$register[$routeWithoutSlash->getName()]);
}
if (check(self::$register[$routeWithSlash->getName()])) {
unset(self::$register[$routeWithSlash->getName()]);
}
} | [
"public",
"static",
"function",
"delete",
"(",
"Route",
"$",
"route",
")",
"{",
"$",
"routeWithoutSlash",
"=",
"$",
"route",
";",
"$",
"routeWithSlash",
"=",
"$",
"route",
"->",
"getWithSlash",
"(",
")",
";",
"// exception_if(! check(self::$register[$routeWithoutS... | Remove an existant route from register.
@param Route $route
@return null | [
"Remove",
"an",
"existant",
"route",
"from",
"register",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L372-L387 | train |
vinala/kernel | src/Http/Router/Routes.php | Routes.checkDuplicated | private static function checkDuplicated(Route $route)
{
foreach (self::$register as $registeredRoute) {
if ($registeredRoute->getName() == $route->getName()) {
return true;
}
}
return false;
} | php | private static function checkDuplicated(Route $route)
{
foreach (self::$register as $registeredRoute) {
if ($registeredRoute->getName() == $route->getName()) {
return true;
}
}
return false;
} | [
"private",
"static",
"function",
"checkDuplicated",
"(",
"Route",
"$",
"route",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"register",
"as",
"$",
"registeredRoute",
")",
"{",
"if",
"(",
"$",
"registeredRoute",
"->",
"getName",
"(",
")",
"==",
"$",
"rou... | Check if route is duplicated.
@param Route $route
@return bool | [
"Check",
"if",
"route",
"is",
"duplicated",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L396-L405 | train |
kiler129/CherryHttp | src/_legacyCode/HttpResponse.php | HttpResponse.setCode | public function setCode($code)
{
$code = (int)$code;
if (!empty($this->body) && !HttpCode::isBodyAllowed($code)) { //InvalidArgumentException can be thrown here
throw new LogicException('HTTP response already contains body - response "' . HttpCode::getName($code) . '" cannot contain body.');
}
$this->code = $code;
$this->messageCache = null;
} | php | public function setCode($code)
{
$code = (int)$code;
if (!empty($this->body) && !HttpCode::isBodyAllowed($code)) { //InvalidArgumentException can be thrown here
throw new LogicException('HTTP response already contains body - response "' . HttpCode::getName($code) . '" cannot contain body.');
}
$this->code = $code;
$this->messageCache = null;
} | [
"public",
"function",
"setCode",
"(",
"$",
"code",
")",
"{",
"$",
"code",
"=",
"(",
"int",
")",
"$",
"code",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"body",
")",
"&&",
"!",
"HttpCode",
"::",
"isBodyAllowed",
"(",
"$",
"code",
")",
... | Sets HTTP code for response.
@param integer $code Any valid HTTP code
@throws InvalidArgumentException Exception is raised if you try to set invalid HTTP code.
@throws LogicException Exception is raised if you try to set code which should not contain a body and body is
already present. | [
"Sets",
"HTTP",
"code",
"for",
"response",
"."
] | 05927f26183cbd6fd5ccb0853befecdea279308d | https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/_legacyCode/HttpResponse.php#L62-L72 | train |
kiler129/CherryHttp | src/_legacyCode/HttpResponse.php | HttpResponse.setBody | public function setBody($body)
{
if (!empty($body) && !HttpCode::isBodyAllowed($this->code)) {
throw new LogicException('You cannot set non-empty body for currently set code');
}
$this->body = (string)$body;
$this->setHeader('Content-Length', strlen($this->body));
$this->messageCache = null;
} | php | public function setBody($body)
{
if (!empty($body) && !HttpCode::isBodyAllowed($this->code)) {
throw new LogicException('You cannot set non-empty body for currently set code');
}
$this->body = (string)$body;
$this->setHeader('Content-Length', strlen($this->body));
$this->messageCache = null;
} | [
"public",
"function",
"setBody",
"(",
"$",
"body",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"body",
")",
"&&",
"!",
"HttpCode",
"::",
"isBodyAllowed",
"(",
"$",
"this",
"->",
"code",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'You can... | Sets body for response.
It also automatically sets correct Content-Length header.
@param string $body
@throws LogicException Thrown when you try to set body, but request code (eg. 204) denotes that no body is
allowed. | [
"Sets",
"body",
"for",
"response",
".",
"It",
"also",
"automatically",
"sets",
"correct",
"Content",
"-",
"Length",
"header",
"."
] | 05927f26183cbd6fd5ccb0853befecdea279308d | https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/_legacyCode/HttpResponse.php#L83-L92 | train |
bhavitk/micro-struct | src/Controller.php | Controller.enableSmarty | private function enableSmarty()
{
if ($this->smarty !== NULL)
{
return;
}
$this->smarty = new Smarty;
$this->smarty->setTemplateDir(PUBLIC_DIR);
$this->smarty->setCompileDir(PUBLIC_DIR . 'smarty' . DSC . 'compile');
$this->smarty->setCacheDir(PUBLIC_DIR . 'smarty' . DSC . 'cache');
} | php | private function enableSmarty()
{
if ($this->smarty !== NULL)
{
return;
}
$this->smarty = new Smarty;
$this->smarty->setTemplateDir(PUBLIC_DIR);
$this->smarty->setCompileDir(PUBLIC_DIR . 'smarty' . DSC . 'compile');
$this->smarty->setCacheDir(PUBLIC_DIR . 'smarty' . DSC . 'cache');
} | [
"private",
"function",
"enableSmarty",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"smarty",
"!==",
"NULL",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"smarty",
"=",
"new",
"Smarty",
";",
"$",
"this",
"->",
"smarty",
"->",
"setTemplateDir",
"(... | Enables Smarty. | [
"Enables",
"Smarty",
"."
] | 119632405a91658388ef15a327603ac81b838de5 | https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Controller.php#L62-L73 | train |
bhavitk/micro-struct | src/Controller.php | Controller.getViewPath | private function getViewPath($name)
{
$module = $this->module_name !== NULL ? ($this->module_name) . DSC : '';
return $this->getRealPath('views' . DSC . $module . $name);
} | php | private function getViewPath($name)
{
$module = $this->module_name !== NULL ? ($this->module_name) . DSC : '';
return $this->getRealPath('views' . DSC . $module . $name);
} | [
"private",
"function",
"getViewPath",
"(",
"$",
"name",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"module_name",
"!==",
"NULL",
"?",
"(",
"$",
"this",
"->",
"module_name",
")",
".",
"DSC",
":",
"''",
";",
"return",
"$",
"this",
"->",
"getRealP... | Returns path to view file.
@param string $name
@return string | [
"Returns",
"path",
"to",
"view",
"file",
"."
] | 119632405a91658388ef15a327603ac81b838de5 | https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Controller.php#L81-L86 | train |
bhavitk/micro-struct | src/Controller.php | Controller.renderTemplate | public function renderTemplate($name)
{
$data = array_merge($this->view_data, $this->view);
$template = $this->getRealPath('template' . DSC . $name);
$this->loadView($template, $data);
} | php | public function renderTemplate($name)
{
$data = array_merge($this->view_data, $this->view);
$template = $this->getRealPath('template' . DSC . $name);
$this->loadView($template, $data);
} | [
"public",
"function",
"renderTemplate",
"(",
"$",
"name",
")",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"view_data",
",",
"$",
"this",
"->",
"view",
")",
";",
"$",
"template",
"=",
"$",
"this",
"->",
"getRealPath",
"(",
"'template'... | Render given template with all added view.
@param string $name | [
"Render",
"given",
"template",
"with",
"all",
"added",
"view",
"."
] | 119632405a91658388ef15a327603ac81b838de5 | https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Controller.php#L111-L116 | train |
bhavitk/micro-struct | src/Controller.php | Controller.renderView | public function renderView($name, $data = array(), $return = FALSE)
{
$file = $this->getViewPath($name);
return $this->loadView($file, $data, $return);
} | php | public function renderView($name, $data = array(), $return = FALSE)
{
$file = $this->getViewPath($name);
return $this->loadView($file, $data, $return);
} | [
"public",
"function",
"renderView",
"(",
"$",
"name",
",",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"return",
"=",
"FALSE",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getViewPath",
"(",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->... | Render View.
@param string $name
@param array $data
@param boolean $return
@return string|NULL | [
"Render",
"View",
"."
] | 119632405a91658388ef15a327603ac81b838de5 | https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Controller.php#L126-L130 | train |
MINISTRYGmbH/morrow-core | src/Benchmark.php | Benchmark.stop | public function stop() {
$temp['section'] = $this->section;
// set start value for system + user time
if (function_exists('getrusage')) {
$use = getrusage();
$user = sprintf('%6d.%06d', $use['ru_utime.tv_sec'], $use['ru_utime.tv_usec']);
$system = sprintf('%6d.%06d', $use['ru_stime.tv_sec'], $use['ru_stime.tv_usec']);
$proctime_end = $user+$system;
$temp['proctime'] = $proctime_end - $this->proctime;
} else {
$temp['proctime'] = 'n/a';
}
$realtime_end = microtime(true);
$temp['realtime'] = $realtime_end - $this->realtime;
if (function_exists('memory_get_usage')) $temp['mem'] = memory_get_usage();
else $temp['mem'] = 'n/a';
$this->data[] = $temp;
$this->active = false;
} | php | public function stop() {
$temp['section'] = $this->section;
// set start value for system + user time
if (function_exists('getrusage')) {
$use = getrusage();
$user = sprintf('%6d.%06d', $use['ru_utime.tv_sec'], $use['ru_utime.tv_usec']);
$system = sprintf('%6d.%06d', $use['ru_stime.tv_sec'], $use['ru_stime.tv_usec']);
$proctime_end = $user+$system;
$temp['proctime'] = $proctime_end - $this->proctime;
} else {
$temp['proctime'] = 'n/a';
}
$realtime_end = microtime(true);
$temp['realtime'] = $realtime_end - $this->realtime;
if (function_exists('memory_get_usage')) $temp['mem'] = memory_get_usage();
else $temp['mem'] = 'n/a';
$this->data[] = $temp;
$this->active = false;
} | [
"public",
"function",
"stop",
"(",
")",
"{",
"$",
"temp",
"[",
"'section'",
"]",
"=",
"$",
"this",
"->",
"section",
";",
"// set start value for system + user time",
"if",
"(",
"function_exists",
"(",
"'getrusage'",
")",
")",
"{",
"$",
"use",
"=",
"getrusage... | Stops benchmarking of the actual section.
@return null | [
"Stops",
"benchmarking",
"of",
"the",
"actual",
"section",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Benchmark.php#L105-L127 | train |
MINISTRYGmbH/morrow-core | src/Benchmark.php | Benchmark.get | public function get() {
if ($this->active) $this->stop();
foreach (array_keys($this->data) as $key) {
$row =& $this->data[$key];
$row['realtime_ms'] = $row['realtime']*1000;
if (is_numeric($row['proctime'])) {
$row['proctime_ms'] = $row['proctime']*1000;
} else {
$row['proctime_ms'] = 'n/a';
}
}
$returner = $this->data;
unset($this->data);
return $returner;
} | php | public function get() {
if ($this->active) $this->stop();
foreach (array_keys($this->data) as $key) {
$row =& $this->data[$key];
$row['realtime_ms'] = $row['realtime']*1000;
if (is_numeric($row['proctime'])) {
$row['proctime_ms'] = $row['proctime']*1000;
} else {
$row['proctime_ms'] = 'n/a';
}
}
$returner = $this->data;
unset($this->data);
return $returner;
} | [
"public",
"function",
"get",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"active",
")",
"$",
"this",
"->",
"stop",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"data",
")",
"as",
"$",
"key",
")",
"{",
"$",
"row",
"=",
... | Returns an array of all so far benchmarked sections with the measured times.
@return array Returns an array with the keys `section`, `proctime`, `realtime`, `mem`, `realtime_ms`, `proctime_ms`. | [
"Returns",
"an",
"array",
"of",
"all",
"so",
"far",
"benchmarked",
"sections",
"with",
"the",
"measured",
"times",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Benchmark.php#L134-L151 | train |
inri13666/AkumaBootswatchBundle | Twig/BootstrapFormExtension.php | BootstrapFormExtension.restoreFormSettings | public function restoreFormSettings()
{
if (count($this->settingsStack) < 1) {
throw new \UnderflowException("No settings on the stack to restore");
}
$settings = array_pop($this->settingsStack);
$this->style = $settings['style'];
$this->colSize = $settings['colSize'];
$this->widgetCol = $settings['widgetCol'];
$this->labelCol = $settings['labelCol'];
$this->simpleCol = $settings['simpleCol'];
} | php | public function restoreFormSettings()
{
if (count($this->settingsStack) < 1) {
throw new \UnderflowException("No settings on the stack to restore");
}
$settings = array_pop($this->settingsStack);
$this->style = $settings['style'];
$this->colSize = $settings['colSize'];
$this->widgetCol = $settings['widgetCol'];
$this->labelCol = $settings['labelCol'];
$this->simpleCol = $settings['simpleCol'];
} | [
"public",
"function",
"restoreFormSettings",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"settingsStack",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"UnderflowException",
"(",
"\"No settings on the stack to restore\"",
")",
";",
"}",
"$",
... | Restore the form settings from the stack.
@internal Should only be used at the end of form_end.
@see backupFormSettings
@throws \UnderflowException | [
"Restore",
"the",
"form",
"settings",
"from",
"the",
"stack",
"."
] | f18e68933345fd29da712ecfb62b7be6e539191d | https://github.com/inri13666/AkumaBootswatchBundle/blob/f18e68933345fd29da712ecfb62b7be6e539191d/Twig/BootstrapFormExtension.php#L212-L225 | train |
phergie/phergie-irc-plugin-react-eventfilter | src/ChannelFilter.php | ChannelFilter.filter | public function filter(EventInterface $event)
{
if (!$event instanceof UserEventInterface) {
return null;
}
$channels = $this->getChannels($event);
if (empty($channels)) {
return null;
}
$commonChannels = array_intersect($channels, $this->channels);
if ($commonChannels) {
return true;
}
return false;
} | php | public function filter(EventInterface $event)
{
if (!$event instanceof UserEventInterface) {
return null;
}
$channels = $this->getChannels($event);
if (empty($channels)) {
return null;
}
$commonChannels = array_intersect($channels, $this->channels);
if ($commonChannels) {
return true;
}
return false;
} | [
"public",
"function",
"filter",
"(",
"EventInterface",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"event",
"instanceof",
"UserEventInterface",
")",
"{",
"return",
"null",
";",
"}",
"$",
"channels",
"=",
"$",
"this",
"->",
"getChannels",
"(",
"$",
"even... | Filters events that are not channel-specific or originate in specified
channels.
@param \Phergie\Irc\Event\EventInterface $event
@return boolean|null TRUE if the event originated from a matching channel
associated with this filter, FALSE if it originated from a non-matching
channel, or NULL if it is not associated with a channel. | [
"Filters",
"events",
"that",
"are",
"not",
"channel",
"-",
"specific",
"or",
"originate",
"in",
"specified",
"channels",
"."
] | 8fdde571a23ab1379d62a48e9de4570845c0e9dd | https://github.com/phergie/phergie-irc-plugin-react-eventfilter/blob/8fdde571a23ab1379d62a48e9de4570845c0e9dd/src/ChannelFilter.php#L95-L112 | train |
phergie/phergie-irc-plugin-react-eventfilter | src/ChannelFilter.php | ChannelFilter.getChannels | protected function getChannels(UserEventInterface $event)
{
$command = $event->getCommand();
if (isset($this->parameters[$command])) {
$params = $event->getParams();
$param = $this->parameters[$command];
return preg_grep('/^[#&]/', explode(',', $params[$param]));
}
return array();
} | php | protected function getChannels(UserEventInterface $event)
{
$command = $event->getCommand();
if (isset($this->parameters[$command])) {
$params = $event->getParams();
$param = $this->parameters[$command];
return preg_grep('/^[#&]/', explode(',', $params[$param]));
}
return array();
} | [
"protected",
"function",
"getChannels",
"(",
"UserEventInterface",
"$",
"event",
")",
"{",
"$",
"command",
"=",
"$",
"event",
"->",
"getCommand",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parameters",
"[",
"$",
"command",
"]",
")",
")... | Extracts a list of channel names from a user event.
@param \Phergie\Irc\Event\UserEventInterface $event
@return array | [
"Extracts",
"a",
"list",
"of",
"channel",
"names",
"from",
"a",
"user",
"event",
"."
] | 8fdde571a23ab1379d62a48e9de4570845c0e9dd | https://github.com/phergie/phergie-irc-plugin-react-eventfilter/blob/8fdde571a23ab1379d62a48e9de4570845c0e9dd/src/ChannelFilter.php#L120-L129 | train |
Jinxes/layton | Layton/Library/Http/Request.php | Request.getMethod | public function getMethod()
{
if ($this->method === null) {
if (is_null($this->method_override)) {
$this->method = $this->server->get('request-method');
} else {
$this->method = $this->method_override;
}
$this->method = strtoupper($this->method);
}
return $this->method;
} | php | public function getMethod()
{
if ($this->method === null) {
if (is_null($this->method_override)) {
$this->method = $this->server->get('request-method');
} else {
$this->method = $this->method_override;
}
$this->method = strtoupper($this->method);
}
return $this->method;
} | [
"public",
"function",
"getMethod",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"method",
"===",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"method_override",
")",
")",
"{",
"$",
"this",
"->",
"method",
"=",
"$",
"this",
"->",
... | Get Http Method to lower case.
@return string | [
"Get",
"Http",
"Method",
"to",
"lower",
"case",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L62-L73 | train |
Jinxes/layton | Layton/Library/Http/Request.php | Request.getBodyParams | public function getBodyParams()
{
if (is_array($this->bodyParams)) {
return $this->bodyParams;
}
$content = $this->getBody()->getContents();
$contentType = $this->headers->get('content-type');
if ($contentType === 'application/json') {
$bodyParams = json_decode($content, true);
$this->bodyParams = $bodyParams ? $bodyParams : [];
} else {
parse_str($content, $this->bodyParams);
}
return $this->bodyParams;
} | php | public function getBodyParams()
{
if (is_array($this->bodyParams)) {
return $this->bodyParams;
}
$content = $this->getBody()->getContents();
$contentType = $this->headers->get('content-type');
if ($contentType === 'application/json') {
$bodyParams = json_decode($content, true);
$this->bodyParams = $bodyParams ? $bodyParams : [];
} else {
parse_str($content, $this->bodyParams);
}
return $this->bodyParams;
} | [
"public",
"function",
"getBodyParams",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"bodyParams",
")",
")",
"{",
"return",
"$",
"this",
"->",
"bodyParams",
";",
"}",
"$",
"content",
"=",
"$",
"this",
"->",
"getBody",
"(",
")",
"->",
... | Get all params of input body.
@return array | [
"Get",
"all",
"params",
"of",
"input",
"body",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L176-L191 | train |
Jinxes/layton | Layton/Library/Http/Request.php | Request.getBodyParam | public function getBodyParam($key, $default = null)
{
$params = $this->getBodyParams();
if (array_key_exists($key, $params)) {
return $params[$key];
}
return $default;
} | php | public function getBodyParam($key, $default = null)
{
$params = $this->getBodyParams();
if (array_key_exists($key, $params)) {
return $params[$key];
}
return $default;
} | [
"public",
"function",
"getBodyParam",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getBodyParams",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"params",
")",
")",
... | Get one param of input body.
@param string $key
@return mixed | [
"Get",
"one",
"param",
"of",
"input",
"body",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L200-L207 | train |
Jinxes/layton | Layton/Library/Http/Request.php | Request.withBodyParam | public function withBodyParam($key, $value)
{
$params = $this->getBodyParams();
$params[$key] = $value;
$this->bodyParams = $params;
} | php | public function withBodyParam($key, $value)
{
$params = $this->getBodyParams();
$params[$key] = $value;
$this->bodyParams = $params;
} | [
"public",
"function",
"withBodyParam",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getBodyParams",
"(",
")",
";",
"$",
"params",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"bodyParams"... | Set a body param.
@param string $key
@param string $value | [
"Set",
"a",
"body",
"param",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L215-L220 | train |
Jinxes/layton | Layton/Library/Http/Request.php | Request.withBodyParams | public function withBodyParams(array $values)
{
$params = $this->getBodyParams();
foreach ($values as $key => $value) {
$params[$key] = $value;
}
$this->bodyParams = $params;
} | php | public function withBodyParams(array $values)
{
$params = $this->getBodyParams();
foreach ($values as $key => $value) {
$params[$key] = $value;
}
$this->bodyParams = $params;
} | [
"public",
"function",
"withBodyParams",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getBodyParams",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"params",
"[",
... | Set many body param.
@param array $values | [
"Set",
"many",
"body",
"param",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L227-L234 | train |
Jinxes/layton | Layton/Library/Http/Request.php | Request.getQueryParams | public function getQueryParams()
{
if (is_array($this->queryParams)) {
return $this->queryParams;
}
if (empty($_SERVER['QUERY_STRING'])) {
return [];
}
parse_str($_SERVER['QUERY_STRING'], $this->queryParams);
return $this->queryParams;
} | php | public function getQueryParams()
{
if (is_array($this->queryParams)) {
return $this->queryParams;
}
if (empty($_SERVER['QUERY_STRING'])) {
return [];
}
parse_str($_SERVER['QUERY_STRING'], $this->queryParams);
return $this->queryParams;
} | [
"public",
"function",
"getQueryParams",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"queryParams",
")",
")",
"{",
"return",
"$",
"this",
"->",
"queryParams",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"_SERVER",
"[",
"'QUERY_STRING'",
"]... | Get url params.
@return array | [
"Get",
"url",
"params",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L241-L254 | train |
Jinxes/layton | Layton/Library/Http/Request.php | Request.withQueryParams | public function withQueryParams(array $query)
{
$params = $this->getQueryParams();
foreach ($query as $key => $value) {
$params[$key] = $value;
}
$this->queryParams = $params;
} | php | public function withQueryParams(array $query)
{
$params = $this->getQueryParams();
foreach ($query as $key => $value) {
$params[$key] = $value;
}
$this->queryParams = $params;
} | [
"public",
"function",
"withQueryParams",
"(",
"array",
"$",
"query",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getQueryParams",
"(",
")",
";",
"foreach",
"(",
"$",
"query",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"params",
"[",
... | Set many query param.
@param array $values | [
"Set",
"many",
"query",
"param",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L261-L270 | train |
Jinxes/layton | Layton/Library/Http/Request.php | Request.withQueryParam | public function withQueryParam($key, $value)
{
$params = $this->getQueryParams();
$params[$key] = $value;
$this->queryParams = $params;
} | php | public function withQueryParam($key, $value)
{
$params = $this->getQueryParams();
$params[$key] = $value;
$this->queryParams = $params;
} | [
"public",
"function",
"withQueryParam",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getQueryParams",
"(",
")",
";",
"$",
"params",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"queryPara... | Set a query param.
@param string $key
@param string $value | [
"Set",
"a",
"query",
"param",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L278-L283 | train |
mostofreddy/resty | src/Api.php | Api.redefineErrorHandlers | protected function redefineErrorHandlers(&$container)
{
// Redefine - errors
$container['errorHandler'] = BuilderJsonErrorResponses::jsonError();
$container['phpErrorHandler'] = BuilderJsonErrorResponses::jsonPhpError();
$container['notFoundHandler'] = BuilderJsonErrorResponses::jsonNotFound();
$container['notAllowedHandler'] = BuilderJsonErrorResponses::jsonNotAllowed();
} | php | protected function redefineErrorHandlers(&$container)
{
// Redefine - errors
$container['errorHandler'] = BuilderJsonErrorResponses::jsonError();
$container['phpErrorHandler'] = BuilderJsonErrorResponses::jsonPhpError();
$container['notFoundHandler'] = BuilderJsonErrorResponses::jsonNotFound();
$container['notAllowedHandler'] = BuilderJsonErrorResponses::jsonNotAllowed();
} | [
"protected",
"function",
"redefineErrorHandlers",
"(",
"&",
"$",
"container",
")",
"{",
"// Redefine - errors",
"$",
"container",
"[",
"'errorHandler'",
"]",
"=",
"BuilderJsonErrorResponses",
"::",
"jsonError",
"(",
")",
";",
"$",
"container",
"[",
"'phpErrorHandler... | Redefine error handlers
@param array|ContainerInterface $container Instancia de Container o array de configuración.
@return void | [
"Redefine",
"error",
"handlers"
] | e20d8596bb14ee6db99aded82ed0221cc6d08462 | https://github.com/mostofreddy/resty/blob/e20d8596bb14ee6db99aded82ed0221cc6d08462/src/Api.php#L60-L67 | train |
mostofreddy/resty | src/Api.php | Api.redefineResponse | protected function redefineResponse(&$container)
{
// Redefine - response
$container['response'] = function (Container $container) {
$headers = new Headers(['Content-Type' => 'application/json;charset=utf-8']);
$response = new Response(200, $headers);
return $response->withProtocolVersion($container->get('settings')['httpVersion']);
};
} | php | protected function redefineResponse(&$container)
{
// Redefine - response
$container['response'] = function (Container $container) {
$headers = new Headers(['Content-Type' => 'application/json;charset=utf-8']);
$response = new Response(200, $headers);
return $response->withProtocolVersion($container->get('settings')['httpVersion']);
};
} | [
"protected",
"function",
"redefineResponse",
"(",
"&",
"$",
"container",
")",
"{",
"// Redefine - response",
"$",
"container",
"[",
"'response'",
"]",
"=",
"function",
"(",
"Container",
"$",
"container",
")",
"{",
"$",
"headers",
"=",
"new",
"Headers",
"(",
... | Redefine Response object
@param array|ContainerInterface $container Instancia de Container o array de configuración.
@return void | [
"Redefine",
"Response",
"object"
] | e20d8596bb14ee6db99aded82ed0221cc6d08462 | https://github.com/mostofreddy/resty/blob/e20d8596bb14ee6db99aded82ed0221cc6d08462/src/Api.php#L76-L84 | train |
remote-office/libx | src/External/SimplePay/Authenticator.php | Authenticator.setAuthenticationUrl | public function setAuthenticationUrl($authenticationUrl)
{
if(!is_string($authenticationUrl) || strlen(trim($authenticationUrl)) == 0)
throw new InvalidArgumentException(__METHOD__ . '; Invalid authentication url, must be a non empty string');
$this->authenticationUrl = $authenticationUrl;
} | php | public function setAuthenticationUrl($authenticationUrl)
{
if(!is_string($authenticationUrl) || strlen(trim($authenticationUrl)) == 0)
throw new InvalidArgumentException(__METHOD__ . '; Invalid authentication url, must be a non empty string');
$this->authenticationUrl = $authenticationUrl;
} | [
"public",
"function",
"setAuthenticationUrl",
"(",
"$",
"authenticationUrl",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"authenticationUrl",
")",
"||",
"strlen",
"(",
"trim",
"(",
"$",
"authenticationUrl",
")",
")",
"==",
"0",
")",
"throw",
"new",
"I... | Set authentication url of this Authenticator
@param string $authenticationUrl
@return void | [
"Set",
"authentication",
"url",
"of",
"this",
"Authenticator"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/SimplePay/Authenticator.php#L100-L106 | train |
samsonos/cms_input | src/Field.php | Field.save | public function save($value, & $response = null)
{
/** @var mixed $previousValue Previous instance value for transfer in event handlers */
$previousValue = $this->dbObject[$this->param];
// Set field value
$this->dbObject[$this->param] = $this->convert($value);
// Create new event on object updating
Event::fire('samson.cms.input.change', array(& $this->dbObject, $this->param, $previousValue, & $response));
// Save object
$this->dbObject->save();
} | php | public function save($value, & $response = null)
{
/** @var mixed $previousValue Previous instance value for transfer in event handlers */
$previousValue = $this->dbObject[$this->param];
// Set field value
$this->dbObject[$this->param] = $this->convert($value);
// Create new event on object updating
Event::fire('samson.cms.input.change', array(& $this->dbObject, $this->param, $previousValue, & $response));
// Save object
$this->dbObject->save();
} | [
"public",
"function",
"save",
"(",
"$",
"value",
",",
"&",
"$",
"response",
"=",
"null",
")",
"{",
"/** @var mixed $previousValue Previous instance value for transfer in event handlers */",
"$",
"previousValue",
"=",
"$",
"this",
"->",
"dbObject",
"[",
"$",
"this",
... | Save input field value
@param mixed $value Field value | [
"Save",
"input",
"field",
"value"
] | 88df132aba488e403265ddaa0b1d54f12def8173 | https://github.com/samsonos/cms_input/blob/88df132aba488e403265ddaa0b1d54f12def8173/src/Field.php#L102-L115 | train |
samsonos/cms_input | src/Field.php | Field.view | public function view($renderer, $saveHandler = 'save')
{
// TODO: Context rewriting if in one chain!
$fieldView = $this->viewField($renderer);
return $renderer->view($this->defaultView)
->set($this->cssClass, 'cssClass')
->set($this->value(), 'value')
->set(url_build(preg_replace('/(_\d+)/', '', $renderer->id()), $saveHandler), 'action')
->set($this->entity, 'entity')
->set($this->param, 'param')
->set($this->dbObject->id, 'objectId')
->set($renderer->id(), 'applicationId')
->set($fieldView, 'fieldView')
->output();
} | php | public function view($renderer, $saveHandler = 'save')
{
// TODO: Context rewriting if in one chain!
$fieldView = $this->viewField($renderer);
return $renderer->view($this->defaultView)
->set($this->cssClass, 'cssClass')
->set($this->value(), 'value')
->set(url_build(preg_replace('/(_\d+)/', '', $renderer->id()), $saveHandler), 'action')
->set($this->entity, 'entity')
->set($this->param, 'param')
->set($this->dbObject->id, 'objectId')
->set($renderer->id(), 'applicationId')
->set($fieldView, 'fieldView')
->output();
} | [
"public",
"function",
"view",
"(",
"$",
"renderer",
",",
"$",
"saveHandler",
"=",
"'save'",
")",
"{",
"// TODO: Context rewriting if in one chain!",
"$",
"fieldView",
"=",
"$",
"this",
"->",
"viewField",
"(",
"$",
"renderer",
")",
";",
"return",
"$",
"renderer... | Function to render class
@param Application $renderer Renderer object
@param string $saveHandler Save controller name
@return string HTML string | [
"Function",
"to",
"render",
"class"
] | 88df132aba488e403265ddaa0b1d54f12def8173 | https://github.com/samsonos/cms_input/blob/88df132aba488e403265ddaa0b1d54f12def8173/src/Field.php#L138-L152 | train |
Niirrty/Niirrty.IO.VFS | src/VfsHandler.php | VfsHandler.setProtocol | public function setProtocol( string $name, string $separator = '://' ) : VfsHandler
{
$this->_protocolName = $name ?? '';
$this->_protocolSeparator = $separator ?? '';
return $this;
} | php | public function setProtocol( string $name, string $separator = '://' ) : VfsHandler
{
$this->_protocolName = $name ?? '';
$this->_protocolSeparator = $separator ?? '';
return $this;
} | [
"public",
"function",
"setProtocol",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"separator",
"=",
"'://'",
")",
":",
"VfsHandler",
"{",
"$",
"this",
"->",
"_protocolName",
"=",
"$",
"name",
"??",
"''",
";",
"$",
"this",
"->",
"_protocolSeparator",
"... | Sets the VFS protocol name and separator.
@param string $name
@param string $separator
@return \Niirrty\IO\Vfs\VfsHandler | [
"Sets",
"the",
"VFS",
"protocol",
"name",
"and",
"separator",
"."
] | cd5aaea57a27c712a0b6656b5d068aa7a317dbfc | https://github.com/Niirrty/Niirrty.IO.VFS/blob/cd5aaea57a27c712a0b6656b5d068aa7a317dbfc/src/VfsHandler.php#L99-L107 | train |
Niirrty/Niirrty.IO.VFS | src/VfsHandler.php | VfsHandler.addReplacement | public function addReplacement( string $name, ?string $value ) : VfsHandler
{
if ( null === $value )
{
unset( $this->_replacements[ $name ] );
return $this;
}
$this->_replacements[ $name ] = $value;
return $this;
} | php | public function addReplacement( string $name, ?string $value ) : VfsHandler
{
if ( null === $value )
{
unset( $this->_replacements[ $name ] );
return $this;
}
$this->_replacements[ $name ] = $value;
return $this;
} | [
"public",
"function",
"addReplacement",
"(",
"string",
"$",
"name",
",",
"?",
"string",
"$",
"value",
")",
":",
"VfsHandler",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_replacements",
"[",
"$",
"name",
"... | Add or set a replacement.
It replaces a part of a path with format ${replacementName}
@param string $name The name of the replacement
@param string|null $value The replacement string value (or NULL to remove a replacement)
@return \Niirrty\IO\Vfs\VfsHandler | [
"Add",
"or",
"set",
"a",
"replacement",
"."
] | cd5aaea57a27c712a0b6656b5d068aa7a317dbfc | https://github.com/Niirrty/Niirrty.IO.VFS/blob/cd5aaea57a27c712a0b6656b5d068aa7a317dbfc/src/VfsHandler.php#L245-L261 | train |
Niirrty/Niirrty.IO.VFS | src/VfsHandler.php | VfsHandler.addReplacements | public function addReplacements( array $replacements ) : VfsHandler
{
foreach ( $replacements as $name => $value )
{
if ( null === $value )
{
unset( $this->_replacements[ $name ] );
continue;
}
$this->_replacements[ $name ] = $value;
}
return $this;
} | php | public function addReplacements( array $replacements ) : VfsHandler
{
foreach ( $replacements as $name => $value )
{
if ( null === $value )
{
unset( $this->_replacements[ $name ] );
continue;
}
$this->_replacements[ $name ] = $value;
}
return $this;
} | [
"public",
"function",
"addReplacements",
"(",
"array",
"$",
"replacements",
")",
":",
"VfsHandler",
"{",
"foreach",
"(",
"$",
"replacements",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"unset",
"(... | Add or set one or more replacements.
It replaces a part of a path with format ${replacementName}
@param array $replacements Associative array with replacements (keys are the names)
@return \Niirrty\IO\Vfs\VfsHandler | [
"Add",
"or",
"set",
"one",
"or",
"more",
"replacements",
"."
] | cd5aaea57a27c712a0b6656b5d068aa7a317dbfc | https://github.com/Niirrty/Niirrty.IO.VFS/blob/cd5aaea57a27c712a0b6656b5d068aa7a317dbfc/src/VfsHandler.php#L271-L289 | train |
Niirrty/Niirrty.IO.VFS | src/VfsHandler.php | VfsHandler.tryParse | public function tryParse( string &$pathRef, array $dynamicReplacements = [] ) : bool
{
$protocol = $this->getProtocol();
if ( '' === $protocol || ! strStartsWith( $pathRef, $protocol ) )
{
return false;
}
if ( \count( $dynamicReplacements ) > 0 )
{
$this->addReplacements( $dynamicReplacements );
}
$pathRef = $this->_rootFolder . DIRECTORY_SEPARATOR . substring( $pathRef, \mb_strlen( $protocol ) );
$pathRef = \preg_replace_callback(
'~\$\{([A-Za-z0-9_.-]+)\}~',
function ( $matches )
{
if ( ! isset( $this->_replacements[ $matches[ 1 ] ] ) )
{
return $matches[ 0 ];
}
return $this->_replacements[ $matches[ 1 ] ];
},
$pathRef
);
return true;
} | php | public function tryParse( string &$pathRef, array $dynamicReplacements = [] ) : bool
{
$protocol = $this->getProtocol();
if ( '' === $protocol || ! strStartsWith( $pathRef, $protocol ) )
{
return false;
}
if ( \count( $dynamicReplacements ) > 0 )
{
$this->addReplacements( $dynamicReplacements );
}
$pathRef = $this->_rootFolder . DIRECTORY_SEPARATOR . substring( $pathRef, \mb_strlen( $protocol ) );
$pathRef = \preg_replace_callback(
'~\$\{([A-Za-z0-9_.-]+)\}~',
function ( $matches )
{
if ( ! isset( $this->_replacements[ $matches[ 1 ] ] ) )
{
return $matches[ 0 ];
}
return $this->_replacements[ $matches[ 1 ] ];
},
$pathRef
);
return true;
} | [
"public",
"function",
"tryParse",
"(",
"string",
"&",
"$",
"pathRef",
",",
"array",
"$",
"dynamicReplacements",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"protocol",
"=",
"$",
"this",
"->",
"getProtocol",
"(",
")",
";",
"if",
"(",
"''",
"===",
"$",
... | Tries to parse a path, using a VFS protocol and replaces the protocol with a path
@param string $pathRef
@param array $dynamicReplacements
@return bool Return TRUE on success or false otherwise. | [
"Tries",
"to",
"parse",
"a",
"path",
"using",
"a",
"VFS",
"protocol",
"and",
"replaces",
"the",
"protocol",
"with",
"a",
"path"
] | cd5aaea57a27c712a0b6656b5d068aa7a317dbfc | https://github.com/Niirrty/Niirrty.IO.VFS/blob/cd5aaea57a27c712a0b6656b5d068aa7a317dbfc/src/VfsHandler.php#L311-L345 | train |
alevilar/account | Model/Gasto.php | Gasto._calcularImporteNeto | private function _calcularImporteNeto(){
if (!empty($this->data['Gasto']['Impuesto']) && empty($this->data['Gasto']['importe_neto'])) {
if (!empty($this->data['Gasto']['Impuesto'])) {
foreach ($this->data['Gasto']['Impuesto'] as $imp){
$this->data['Gasto']['importe_neto'] += $imp['neto'];
}
}
}
} | php | private function _calcularImporteNeto(){
if (!empty($this->data['Gasto']['Impuesto']) && empty($this->data['Gasto']['importe_neto'])) {
if (!empty($this->data['Gasto']['Impuesto'])) {
foreach ($this->data['Gasto']['Impuesto'] as $imp){
$this->data['Gasto']['importe_neto'] += $imp['neto'];
}
}
}
} | [
"private",
"function",
"_calcularImporteNeto",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'Gasto'",
"]",
"[",
"'Impuesto'",
"]",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'Gasto'",
"]",
"[",
"'import... | Calcula el neto sumando los impuestos y lo setea en el data | [
"Calcula",
"el",
"neto",
"sumando",
"los",
"impuestos",
"y",
"lo",
"setea",
"en",
"el",
"data"
] | dfb3744d2c5db2875bc49ba39132fec6946d0cca | https://github.com/alevilar/account/blob/dfb3744d2c5db2875bc49ba39132fec6946d0cca/Model/Gasto.php#L278-L286 | train |
alevilar/account | Model/Gasto.php | Gasto._refreshImpuestos | private function _refreshImpuestos($created){
if (!empty($this->data['Gasto']['Impuesto'])) {
if (!$created){
$this->Impuesto->deleteAll(array('Impuesto.gasto_id'=>$this->id ));
}
foreach ($this->data['Gasto']['Impuesto'] as $impId=>$imp){
if (!empty($imp)) {
if (!empty($imp['checked']) && (!empty($imp['importe']) || !empty($imp['neto'])) ) {
$importe = empty($imp['importe'])?0:$imp['importe'];
$neto = empty($imp['neto'])?0:$imp['neto'];
$nuevoImp = array(
'gasto_id' => $this->id,
'tipo_impuesto_id' => $impId,
'importe' => $importe,
'neto' => $neto,
);
$this->Impuesto->create($nuevoImp);
if (!$this->Impuesto->save()){
return false;
}
}
}
}
}
return true;
} | php | private function _refreshImpuestos($created){
if (!empty($this->data['Gasto']['Impuesto'])) {
if (!$created){
$this->Impuesto->deleteAll(array('Impuesto.gasto_id'=>$this->id ));
}
foreach ($this->data['Gasto']['Impuesto'] as $impId=>$imp){
if (!empty($imp)) {
if (!empty($imp['checked']) && (!empty($imp['importe']) || !empty($imp['neto'])) ) {
$importe = empty($imp['importe'])?0:$imp['importe'];
$neto = empty($imp['neto'])?0:$imp['neto'];
$nuevoImp = array(
'gasto_id' => $this->id,
'tipo_impuesto_id' => $impId,
'importe' => $importe,
'neto' => $neto,
);
$this->Impuesto->create($nuevoImp);
if (!$this->Impuesto->save()){
return false;
}
}
}
}
}
return true;
} | [
"private",
"function",
"_refreshImpuestos",
"(",
"$",
"created",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'Gasto'",
"]",
"[",
"'Impuesto'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"created",
")",
"{",
"$",
"this",
... | Ante un cambio en e gasto, resetea los valores anteriores
@param boolean $created
@return boolean | [
"Ante",
"un",
"cambio",
"en",
"e",
"gasto",
"resetea",
"los",
"valores",
"anteriores"
] | dfb3744d2c5db2875bc49ba39132fec6946d0cca | https://github.com/alevilar/account/blob/dfb3744d2c5db2875bc49ba39132fec6946d0cca/Model/Gasto.php#L293-L319 | train |
alevilar/account | Model/Gasto.php | Gasto.enDeuda | public function enDeuda($conditions = array()){
$dbo = $this->getDataSource();
$subQuery = $dbo->buildStatement(
array(
'fields' => array('SUM( `Aeg`.`importe` )'),
'table' => 'account_egresos_gastos',
'alias' => 'Aeg',
'limit' => null,
'offset' => null,
'joins' => array(),
'conditions' => array(
'Aeg.gasto_id = `Gasto`.`id`',
),
'order' => null,
'group' => array('Aeg.gasto_id')
), $this
);
$conditions[] = "IFNULL(($subQuery), 0) <> `Gasto`.`importe_total`";
$fieldContain['recursive'] = -1;
$fieldContain['fields'] = array('Gasto.id','Gasto.id');
$fieldContain['conditions'] = $conditions;
$ret = parent::find('list', $fieldContain);
$gastos = $this->find('all', array('conditions'=>array('Gasto.id'=>$ret)));
return $gastos;
} | php | public function enDeuda($conditions = array()){
$dbo = $this->getDataSource();
$subQuery = $dbo->buildStatement(
array(
'fields' => array('SUM( `Aeg`.`importe` )'),
'table' => 'account_egresos_gastos',
'alias' => 'Aeg',
'limit' => null,
'offset' => null,
'joins' => array(),
'conditions' => array(
'Aeg.gasto_id = `Gasto`.`id`',
),
'order' => null,
'group' => array('Aeg.gasto_id')
), $this
);
$conditions[] = "IFNULL(($subQuery), 0) <> `Gasto`.`importe_total`";
$fieldContain['recursive'] = -1;
$fieldContain['fields'] = array('Gasto.id','Gasto.id');
$fieldContain['conditions'] = $conditions;
$ret = parent::find('list', $fieldContain);
$gastos = $this->find('all', array('conditions'=>array('Gasto.id'=>$ret)));
return $gastos;
} | [
"public",
"function",
"enDeuda",
"(",
"$",
"conditions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"dbo",
"=",
"$",
"this",
"->",
"getDataSource",
"(",
")",
";",
"$",
"subQuery",
"=",
"$",
"dbo",
"->",
"buildStatement",
"(",
"array",
"(",
"'fields'",
"=... | Devuelve todos los gastos que adeudan pagos
o sea, cuyo importe_total no llega a ser cubierto con los pagos realizados
@return array de Gastos | [
"Devuelve",
"todos",
"los",
"gastos",
"que",
"adeudan",
"pagos",
"o",
"sea",
"cuyo",
"importe_total",
"no",
"llega",
"a",
"ser",
"cubierto",
"con",
"los",
"pagos",
"realizados"
] | dfb3744d2c5db2875bc49ba39132fec6946d0cca | https://github.com/alevilar/account/blob/dfb3744d2c5db2875bc49ba39132fec6946d0cca/Model/Gasto.php#L327-L356 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.