id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
11,900 | phapi/log | src/Phapi/Di/Validator/Log.php | Log.validate | public function validate($logger)
{
$original = $logger;
if (is_callable($logger)) {
$logger = $logger($this->container);
}
// Check if logger is an instance of the PSR-3 logger interface
if ($logger instanceof LoggerInterface) {
return $original;
}
// A PSR-3 compatible log writer hasn't been configured so we don't know if it is
// compatible with Phapi. Therefore we create an instance of the NullLogger instead
return function ($app) {
return new NullLogger();
};
} | php | public function validate($logger)
{
$original = $logger;
if (is_callable($logger)) {
$logger = $logger($this->container);
}
// Check if logger is an instance of the PSR-3 logger interface
if ($logger instanceof LoggerInterface) {
return $original;
}
// A PSR-3 compatible log writer hasn't been configured so we don't know if it is
// compatible with Phapi. Therefore we create an instance of the NullLogger instead
return function ($app) {
return new NullLogger();
};
} | [
"public",
"function",
"validate",
"(",
"$",
"logger",
")",
"{",
"$",
"original",
"=",
"$",
"logger",
";",
"if",
"(",
"is_callable",
"(",
"$",
"logger",
")",
")",
"{",
"$",
"logger",
"=",
"$",
"logger",
"(",
"$",
"this",
"->",
"container",
")",
";",
"}",
"// Check if logger is an instance of the PSR-3 logger interface",
"if",
"(",
"$",
"logger",
"instanceof",
"LoggerInterface",
")",
"{",
"return",
"$",
"original",
";",
"}",
"// A PSR-3 compatible log writer hasn't been configured so we don't know if it is",
"// compatible with Phapi. Therefore we create an instance of the NullLogger instead",
"return",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"NullLogger",
"(",
")",
";",
"}",
";",
"}"
] | Validates the configured logger. If no logger is configured or if the configured
logger isn't PSR-3 compliant an instance of NullLogger will be used instead.
The PSR-3 package includes a NullLogger that does not do anything with
the input but it also prevents the application from failing.
This simplifies the development since we don't have to check if there
actually are a valid cache to use. We can just ask the Cache (even
if its a NullCache) and we will get a response.
@param $logger
@return callable | [
"Validates",
"the",
"configured",
"logger",
".",
"If",
"no",
"logger",
"is",
"configured",
"or",
"if",
"the",
"configured",
"logger",
"isn",
"t",
"PSR",
"-",
"3",
"compliant",
"an",
"instance",
"of",
"NullLogger",
"will",
"be",
"used",
"instead",
"."
] | acb289b47263470aaf6f271f721e4a690bd6eb23 | https://github.com/phapi/log/blob/acb289b47263470aaf6f271f721e4a690bd6eb23/src/Phapi/Di/Validator/Log.php#L48-L66 |
11,901 | phplegends/assets | src/Assets/Manager.php | Manager.buildVersion | protected function buildVersion($asset)
{
$version = $this->getVersion();
if (is_callable($version)) {
$version = $version($this->getBasePath() . $asset, $this);
}
return $version;
} | php | protected function buildVersion($asset)
{
$version = $this->getVersion();
if (is_callable($version)) {
$version = $version($this->getBasePath() . $asset, $this);
}
return $version;
} | [
"protected",
"function",
"buildVersion",
"(",
"$",
"asset",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"version",
")",
")",
"{",
"$",
"version",
"=",
"$",
"version",
"(",
"$",
"this",
"->",
"getBasePath",
"(",
")",
".",
"$",
"asset",
",",
"$",
"this",
")",
";",
"}",
"return",
"$",
"version",
";",
"}"
] | Build the version of the asset.
If callable is given, the arguments are full filename and this instance
@param string $asset
@return string|null | [
"Build",
"the",
"version",
"of",
"the",
"asset",
".",
"If",
"callable",
"is",
"given",
"the",
"arguments",
"are",
"full",
"filename",
"and",
"this",
"instance"
] | 0f36502b4728425388a6bbcafe00663c2371039d | https://github.com/phplegends/assets/blob/0f36502b4728425388a6bbcafe00663c2371039d/src/Assets/Manager.php#L357-L367 |
11,902 | phplegends/assets | src/Assets/Manager.php | Manager.buildCompileDirectory | protected function buildCompileDirectory()
{
$directory = $this->getBasePath() . '/' . $this->getCompileDirectory();
if (! is_dir($directory)) mkdir($directory, 0777, true);
return $directory;
} | php | protected function buildCompileDirectory()
{
$directory = $this->getBasePath() . '/' . $this->getCompileDirectory();
if (! is_dir($directory)) mkdir($directory, 0777, true);
return $directory;
} | [
"protected",
"function",
"buildCompileDirectory",
"(",
")",
"{",
"$",
"directory",
"=",
"$",
"this",
"->",
"getBasePath",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getCompileDirectory",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"mkdir",
"(",
"$",
"directory",
",",
"0777",
",",
"true",
")",
";",
"return",
"$",
"directory",
";",
"}"
] | Build the directory name of the compile. If directory not exists, it's created.
@return string | [
"Build",
"the",
"directory",
"name",
"of",
"the",
"compile",
".",
"If",
"directory",
"not",
"exists",
"it",
"s",
"created",
"."
] | 0f36502b4728425388a6bbcafe00663c2371039d | https://github.com/phplegends/assets/blob/0f36502b4728425388a6bbcafe00663c2371039d/src/Assets/Manager.php#L469-L476 |
11,903 | phplegends/assets | src/Assets/Manager.php | Manager.createFromConfig | public static function createFromConfig(array $config)
{
$manager = static::createEmptyFromConfig($config);
$manager->addCollection(new CssCollection)
->addCollection(new JavascriptCollection);
return $manager;
} | php | public static function createFromConfig(array $config)
{
$manager = static::createEmptyFromConfig($config);
$manager->addCollection(new CssCollection)
->addCollection(new JavascriptCollection);
return $manager;
} | [
"public",
"static",
"function",
"createFromConfig",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"manager",
"=",
"static",
"::",
"createEmptyFromConfig",
"(",
"$",
"config",
")",
";",
"$",
"manager",
"->",
"addCollection",
"(",
"new",
"CssCollection",
")",
"->",
"addCollection",
"(",
"new",
"JavascriptCollection",
")",
";",
"return",
"$",
"manager",
";",
"}"
] | Creates and configure a manager instance via array options
@param array $config
@return \PHPLegends\Assets\Manager | [
"Creates",
"and",
"configure",
"a",
"manager",
"instance",
"via",
"array",
"options"
] | 0f36502b4728425388a6bbcafe00663c2371039d | https://github.com/phplegends/assets/blob/0f36502b4728425388a6bbcafe00663c2371039d/src/Assets/Manager.php#L527-L536 |
11,904 | phplegends/assets | src/Assets/Manager.php | Manager.createEmptyFromConfig | public static function createEmptyFromConfig(array $config)
{
$manager = new self();
if (isset($config['base_uri'])) {
$manager->setBaseUri($config['base_uri']);
}
if (isset($config['path'])) {
$manager->setBasePath($config['path']);
}
if (isset($config['path_aliases']) && is_array($config['path_aliases'])) {
foreach ($config['path_aliases'] as $alias => $path) {
$manager->addPathAlias($alias, $path);
}
}
if (isset($config['compiled'])) {
$manager->setCompileDirectory($config['compiled']);
}
if (isset($config['version'])) {
$manager->setVersion($config['version']);
}
return $manager;
} | php | public static function createEmptyFromConfig(array $config)
{
$manager = new self();
if (isset($config['base_uri'])) {
$manager->setBaseUri($config['base_uri']);
}
if (isset($config['path'])) {
$manager->setBasePath($config['path']);
}
if (isset($config['path_aliases']) && is_array($config['path_aliases'])) {
foreach ($config['path_aliases'] as $alias => $path) {
$manager->addPathAlias($alias, $path);
}
}
if (isset($config['compiled'])) {
$manager->setCompileDirectory($config['compiled']);
}
if (isset($config['version'])) {
$manager->setVersion($config['version']);
}
return $manager;
} | [
"public",
"static",
"function",
"createEmptyFromConfig",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"manager",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'base_uri'",
"]",
")",
")",
"{",
"$",
"manager",
"->",
"setBaseUri",
"(",
"$",
"config",
"[",
"'base_uri'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"manager",
"->",
"setBasePath",
"(",
"$",
"config",
"[",
"'path'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'path_aliases'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'path_aliases'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'path_aliases'",
"]",
"as",
"$",
"alias",
"=>",
"$",
"path",
")",
"{",
"$",
"manager",
"->",
"addPathAlias",
"(",
"$",
"alias",
",",
"$",
"path",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'compiled'",
"]",
")",
")",
"{",
"$",
"manager",
"->",
"setCompileDirectory",
"(",
"$",
"config",
"[",
"'compiled'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'version'",
"]",
")",
")",
"{",
"$",
"manager",
"->",
"setVersion",
"(",
"$",
"config",
"[",
"'version'",
"]",
")",
";",
"}",
"return",
"$",
"manager",
";",
"}"
] | Creates and configure a empty manager instance via array options
@param array $config
@return \PHPLegends\Assets\Manager | [
"Creates",
"and",
"configure",
"a",
"empty",
"manager",
"instance",
"via",
"array",
"options"
] | 0f36502b4728425388a6bbcafe00663c2371039d | https://github.com/phplegends/assets/blob/0f36502b4728425388a6bbcafe00663c2371039d/src/Assets/Manager.php#L543-L576 |
11,905 | phplegends/assets | src/Assets/Manager.php | Manager.url | public function url($asset)
{
$url = $this->parsePathAlias($asset, false);
return $this->buildUrl($url);
} | php | public function url($asset)
{
$url = $this->parsePathAlias($asset, false);
return $this->buildUrl($url);
} | [
"public",
"function",
"url",
"(",
"$",
"asset",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"parsePathAlias",
"(",
"$",
"asset",
",",
"false",
")",
";",
"return",
"$",
"this",
"->",
"buildUrl",
"(",
"$",
"url",
")",
";",
"}"
] | Create an url to a any asset. Is a way to use images with this class
@param string $asset
@return string | [
"Create",
"an",
"url",
"to",
"a",
"any",
"asset",
".",
"Is",
"a",
"way",
"to",
"use",
"images",
"with",
"this",
"class"
] | 0f36502b4728425388a6bbcafe00663c2371039d | https://github.com/phplegends/assets/blob/0f36502b4728425388a6bbcafe00663c2371039d/src/Assets/Manager.php#L593-L598 |
11,906 | railsphp/framework | src/Rails/ActiveRecord/Persistence/PersistedModel/Methods/PersistenceMethodsTrait.php | PersistenceMethodsTrait.recover | public function recover()
{
if (!$this->isRecoverable()) {
throw new Exception\BadMethodCallException(
sprintf(
"Object of class %s isn't recoverable",
get_class($this)
)
);
}
if ($this->isDeleted()) {
$this->runCallbacks('recover', function() {
$this->directUpdate(static::deletedAtAttribute(), static::deletedAtEmptyValue());
$this->reload();
});
}
return true;
} | php | public function recover()
{
if (!$this->isRecoverable()) {
throw new Exception\BadMethodCallException(
sprintf(
"Object of class %s isn't recoverable",
get_class($this)
)
);
}
if ($this->isDeleted()) {
$this->runCallbacks('recover', function() {
$this->directUpdate(static::deletedAtAttribute(), static::deletedAtEmptyValue());
$this->reload();
});
}
return true;
} | [
"public",
"function",
"recover",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isRecoverable",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"BadMethodCallException",
"(",
"sprintf",
"(",
"\"Object of class %s isn't recoverable\"",
",",
"get_class",
"(",
"$",
"this",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isDeleted",
"(",
")",
")",
"{",
"$",
"this",
"->",
"runCallbacks",
"(",
"'recover'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"directUpdate",
"(",
"static",
"::",
"deletedAtAttribute",
"(",
")",
",",
"static",
"::",
"deletedAtEmptyValue",
"(",
")",
")",
";",
"$",
"this",
"->",
"reload",
"(",
")",
";",
"}",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Recovers a deleted object by setting the DELETED_AT_ATTRIBUTE to null.
If the object is not deleted, no action is taken.
If the object isn't recoverable, however, an exception is thrown.
`recover` callbacks are ran if the record is recovered. Note that the
attribute is directly updated in the database, so no `save` or `update`
callbacks are ran. Also, any change made to the model is discarted as it is
reloaded.
@return bool
@throws BadMethodCallException | [
"Recovers",
"a",
"deleted",
"object",
"by",
"setting",
"the",
"DELETED_AT_ATTRIBUTE",
"to",
"null",
".",
"If",
"the",
"object",
"is",
"not",
"deleted",
"no",
"action",
"is",
"taken",
".",
"If",
"the",
"object",
"isn",
"t",
"recoverable",
"however",
"an",
"exception",
"is",
"thrown",
".",
"recover",
"callbacks",
"are",
"ran",
"if",
"the",
"record",
"is",
"recovered",
".",
"Note",
"that",
"the",
"attribute",
"is",
"directly",
"updated",
"in",
"the",
"database",
"so",
"no",
"save",
"or",
"update",
"callbacks",
"are",
"ran",
".",
"Also",
"any",
"change",
"made",
"to",
"the",
"model",
"is",
"discarted",
"as",
"it",
"is",
"reloaded",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Persistence/PersistedModel/Methods/PersistenceMethodsTrait.php#L208-L227 |
11,907 | railsphp/framework | src/Rails/ActiveRecord/Persistence/PersistedModel/Methods/PersistenceMethodsTrait.php | PersistenceMethodsTrait.deleteRecord | protected function deleteRecord(array $options = [])
{
$this->runCallbacks('delete', function() {
if (!$this->deletedAt()) {
$this->directUpdate(static::deletedAtAttribute(), static::deletedAtValue());
$this->reload();
}
});
return true;
} | php | protected function deleteRecord(array $options = [])
{
$this->runCallbacks('delete', function() {
if (!$this->deletedAt()) {
$this->directUpdate(static::deletedAtAttribute(), static::deletedAtValue());
$this->reload();
}
});
return true;
} | [
"protected",
"function",
"deleteRecord",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"runCallbacks",
"(",
"'delete'",
",",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"deletedAt",
"(",
")",
")",
"{",
"$",
"this",
"->",
"directUpdate",
"(",
"static",
"::",
"deletedAtAttribute",
"(",
")",
",",
"static",
"::",
"deletedAtValue",
"(",
")",
")",
";",
"$",
"this",
"->",
"reload",
"(",
")",
";",
"}",
"}",
")",
";",
"return",
"true",
";",
"}"
] | Soft-deletes the record. If the record is already deleted, no action is taken.
The `delete` callbacks are ran if the record is deleted. Like in `recover`, the
attribute is directly updated in the database, so no `save` or `update`
callbacks are ran, and any change made to the model is discarted as it is
reloaded.
@return bool | [
"Soft",
"-",
"deletes",
"the",
"record",
".",
"If",
"the",
"record",
"is",
"already",
"deleted",
"no",
"action",
"is",
"taken",
".",
"The",
"delete",
"callbacks",
"are",
"ran",
"if",
"the",
"record",
"is",
"deleted",
".",
"Like",
"in",
"recover",
"the",
"attribute",
"is",
"directly",
"updated",
"in",
"the",
"database",
"so",
"no",
"save",
"or",
"update",
"callbacks",
"are",
"ran",
"and",
"any",
"change",
"made",
"to",
"the",
"model",
"is",
"discarted",
"as",
"it",
"is",
"reloaded",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Persistence/PersistedModel/Methods/PersistenceMethodsTrait.php#L357-L366 |
11,908 | railsphp/framework | src/Rails/ActiveRecord/Persistence/PersistedModel/Methods/PersistenceMethodsTrait.php | PersistenceMethodsTrait.destroyRecord | protected function destroyRecord(array $options = [])
{
return $this->runCallbacks('destroy', function() {
if (static::persistence()->delete($this)) {
$this->isDestroyed = true;
return true;
}
return false;
});
} | php | protected function destroyRecord(array $options = [])
{
return $this->runCallbacks('destroy', function() {
if (static::persistence()->delete($this)) {
$this->isDestroyed = true;
return true;
}
return false;
});
} | [
"protected",
"function",
"destroyRecord",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"runCallbacks",
"(",
"'destroy'",
",",
"function",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"persistence",
"(",
")",
"->",
"delete",
"(",
"$",
"this",
")",
")",
"{",
"$",
"this",
"->",
"isDestroyed",
"=",
"true",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
")",
";",
"}"
] | Removes the record from the database. The `destroy` callbacks are ran.
@return bool | [
"Removes",
"the",
"record",
"from",
"the",
"database",
".",
"The",
"destroy",
"callbacks",
"are",
"ran",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Persistence/PersistedModel/Methods/PersistenceMethodsTrait.php#L373-L382 |
11,909 | magdev/php-assimp | src/Converter/FileConverter.php | FileConverter.convert | public function convert(string $outputFile, string $format, array $params = array()): ExportResult
{
try {
$this->getVerb()->setOutputFile($outputFile)
->setFormat($format)
->setParameters($params);
$result = self::getCommand()->execute($this->getVerb());
if (!$result->isSuccess()) {
if ($result->hasException()) {
throw $result->getException();
}
throw new \RuntimeException('Unknown error: ', $result->getExitCode());
}
return $result;
} catch (\Exception $e) {
throw new ConverterException('Conversion failed', ErrorCodes::EXECUTION_FAILURE, $e);
}
} | php | public function convert(string $outputFile, string $format, array $params = array()): ExportResult
{
try {
$this->getVerb()->setOutputFile($outputFile)
->setFormat($format)
->setParameters($params);
$result = self::getCommand()->execute($this->getVerb());
if (!$result->isSuccess()) {
if ($result->hasException()) {
throw $result->getException();
}
throw new \RuntimeException('Unknown error: ', $result->getExitCode());
}
return $result;
} catch (\Exception $e) {
throw new ConverterException('Conversion failed', ErrorCodes::EXECUTION_FAILURE, $e);
}
} | [
"public",
"function",
"convert",
"(",
"string",
"$",
"outputFile",
",",
"string",
"$",
"format",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
":",
"ExportResult",
"{",
"try",
"{",
"$",
"this",
"->",
"getVerb",
"(",
")",
"->",
"setOutputFile",
"(",
"$",
"outputFile",
")",
"->",
"setFormat",
"(",
"$",
"format",
")",
"->",
"setParameters",
"(",
"$",
"params",
")",
";",
"$",
"result",
"=",
"self",
"::",
"getCommand",
"(",
")",
"->",
"execute",
"(",
"$",
"this",
"->",
"getVerb",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"result",
"->",
"isSuccess",
"(",
")",
")",
"{",
"if",
"(",
"$",
"result",
"->",
"hasException",
"(",
")",
")",
"{",
"throw",
"$",
"result",
"->",
"getException",
"(",
")",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unknown error: '",
",",
"$",
"result",
"->",
"getExitCode",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"ConverterException",
"(",
"'Conversion failed'",
",",
"ErrorCodes",
"::",
"EXECUTION_FAILURE",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Convert a file
@param string $outputFile
@param string $format
@param array $params
@return \Assimp\Command\Result\ExportResult
@throws \Assimp\Converter\ConverterException | [
"Convert",
"a",
"file"
] | 206e9c341f8be271a80fbeea7c32ec33b0f2fc90 | https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Converter/FileConverter.php#L79-L97 |
11,910 | magdev/php-assimp | src/Converter/FileConverter.php | FileConverter.getCommand | public static function getCommand(): Command
{
if (is_null(self::$exec)) {
self::$exec = new Command();
}
return self::$exec;
} | php | public static function getCommand(): Command
{
if (is_null(self::$exec)) {
self::$exec = new Command();
}
return self::$exec;
} | [
"public",
"static",
"function",
"getCommand",
"(",
")",
":",
"Command",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"exec",
")",
")",
"{",
"self",
"::",
"$",
"exec",
"=",
"new",
"Command",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"exec",
";",
"}"
] | Get the command singleton
@return \Assimp\Command\Command | [
"Get",
"the",
"command",
"singleton"
] | 206e9c341f8be271a80fbeea7c32ec33b0f2fc90 | https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Converter/FileConverter.php#L132-L138 |
11,911 | twister-php/twister | src/Schema/Types/ArrayType.php | ArrayType.combine | public function combine(array $keys = null, array $values = null)
{
return array_combine($keys ?: $this->members, $values ?: $this->members);
} | php | public function combine(array $keys = null, array $values = null)
{
return array_combine($keys ?: $this->members, $values ?: $this->members);
} | [
"public",
"function",
"combine",
"(",
"array",
"$",
"keys",
"=",
"null",
",",
"array",
"$",
"values",
"=",
"null",
")",
"{",
"return",
"array_combine",
"(",
"$",
"keys",
"?",
":",
"$",
"this",
"->",
"members",
",",
"$",
"values",
"?",
":",
"$",
"this",
"->",
"members",
")",
";",
"}"
] | pass null to the component for members to use | [
"pass",
"null",
"to",
"the",
"component",
"for",
"members",
"to",
"use"
] | c06ea2650331faf11590c017c850dc5f0bbc5c13 | https://github.com/twister-php/twister/blob/c06ea2650331faf11590c017c850dc5f0bbc5c13/src/Schema/Types/ArrayType.php#L28-L31 |
11,912 | opsbears/piccolo-web-processor-controller | src/ControllerProcessorWebModule.php | ControllerProcessorWebModule.registerRequestFilter | public function registerRequestFilter(array &$globalConfig, string $requestFilterClass) {
if (!isset($moduleConfig[self::CONFIG_FILTERS_REQUEST])) {
$moduleConfig[self::CONFIG_FILTERS_REQUEST] = [];
}
$globalConfig[$this->getModuleKey()][self::CONFIG_FILTERS_REQUEST][] = $requestFilterClass;
} | php | public function registerRequestFilter(array &$globalConfig, string $requestFilterClass) {
if (!isset($moduleConfig[self::CONFIG_FILTERS_REQUEST])) {
$moduleConfig[self::CONFIG_FILTERS_REQUEST] = [];
}
$globalConfig[$this->getModuleKey()][self::CONFIG_FILTERS_REQUEST][] = $requestFilterClass;
} | [
"public",
"function",
"registerRequestFilter",
"(",
"array",
"&",
"$",
"globalConfig",
",",
"string",
"$",
"requestFilterClass",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FILTERS_REQUEST",
"]",
")",
")",
"{",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FILTERS_REQUEST",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"globalConfig",
"[",
"$",
"this",
"->",
"getModuleKey",
"(",
")",
"]",
"[",
"self",
"::",
"CONFIG_FILTERS_REQUEST",
"]",
"[",
"]",
"=",
"$",
"requestFilterClass",
";",
"}"
] | Register a filter for a PSR-7 request. The filter must implement the RequestFilter interface.
@param array $globalConfig
@param string $requestFilterClass | [
"Register",
"a",
"filter",
"for",
"a",
"PSR",
"-",
"7",
"request",
".",
"The",
"filter",
"must",
"implement",
"the",
"RequestFilter",
"interface",
"."
] | ae446658f53940aaba63b7bb0ebcebf522a85254 | https://github.com/opsbears/piccolo-web-processor-controller/blob/ae446658f53940aaba63b7bb0ebcebf522a85254/src/ControllerProcessorWebModule.php#L28-L33 |
11,913 | opsbears/piccolo-web-processor-controller | src/ControllerProcessorWebModule.php | ControllerProcessorWebModule.registerResponseFilterClass | public function registerResponseFilterClass(array &$globalConfig, string $responseFilterClass) {
if (!isset($moduleConfig[self::CONFIG_FILTERS_RESPONSE])) {
$moduleConfig[self::CONFIG_FILTERS_RESPONSE] = [];
}
$globalConfig[$this->getModuleKey()][self::CONFIG_FILTERS_RESPONSE][] = $responseFilterClass;
} | php | public function registerResponseFilterClass(array &$globalConfig, string $responseFilterClass) {
if (!isset($moduleConfig[self::CONFIG_FILTERS_RESPONSE])) {
$moduleConfig[self::CONFIG_FILTERS_RESPONSE] = [];
}
$globalConfig[$this->getModuleKey()][self::CONFIG_FILTERS_RESPONSE][] = $responseFilterClass;
} | [
"public",
"function",
"registerResponseFilterClass",
"(",
"array",
"&",
"$",
"globalConfig",
",",
"string",
"$",
"responseFilterClass",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FILTERS_RESPONSE",
"]",
")",
")",
"{",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FILTERS_RESPONSE",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"globalConfig",
"[",
"$",
"this",
"->",
"getModuleKey",
"(",
")",
"]",
"[",
"self",
"::",
"CONFIG_FILTERS_RESPONSE",
"]",
"[",
"]",
"=",
"$",
"responseFilterClass",
";",
"}"
] | Register a filter for a PSR-7 response. The filter must implement the ResponseFilter interface.
@param array $globalConfig
@param string $responseFilterClass | [
"Register",
"a",
"filter",
"for",
"a",
"PSR",
"-",
"7",
"response",
".",
"The",
"filter",
"must",
"implement",
"the",
"ResponseFilter",
"interface",
"."
] | ae446658f53940aaba63b7bb0ebcebf522a85254 | https://github.com/opsbears/piccolo-web-processor-controller/blob/ae446658f53940aaba63b7bb0ebcebf522a85254/src/ControllerProcessorWebModule.php#L41-L46 |
11,914 | opsbears/piccolo-web-processor-controller | src/ControllerProcessorWebModule.php | ControllerProcessorWebModule.registerRoutingResponseFilterClass | public function registerRoutingResponseFilterClass(array &$globalConfig, string $routingResponseFilterClass) {
if (!isset($moduleConfig[self::CONFIG_FILTERS_ROUTING_RESPONSE])) {
$moduleConfig[self::CONFIG_FILTERS_ROUTING_RESPONSE] = [];
}
$globalConfig[$this->getModuleKey()][self::CONFIG_FILTERS_ROUTING_RESPONSE][] = $routingResponseFilterClass;
} | php | public function registerRoutingResponseFilterClass(array &$globalConfig, string $routingResponseFilterClass) {
if (!isset($moduleConfig[self::CONFIG_FILTERS_ROUTING_RESPONSE])) {
$moduleConfig[self::CONFIG_FILTERS_ROUTING_RESPONSE] = [];
}
$globalConfig[$this->getModuleKey()][self::CONFIG_FILTERS_ROUTING_RESPONSE][] = $routingResponseFilterClass;
} | [
"public",
"function",
"registerRoutingResponseFilterClass",
"(",
"array",
"&",
"$",
"globalConfig",
",",
"string",
"$",
"routingResponseFilterClass",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FILTERS_ROUTING_RESPONSE",
"]",
")",
")",
"{",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FILTERS_ROUTING_RESPONSE",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"globalConfig",
"[",
"$",
"this",
"->",
"getModuleKey",
"(",
")",
"]",
"[",
"self",
"::",
"CONFIG_FILTERS_ROUTING_RESPONSE",
"]",
"[",
"]",
"=",
"$",
"routingResponseFilterClass",
";",
"}"
] | Register a filter for the routing response response. The filter must implement the RoutingResponseFilter
interface.
@param array $globalConfig
@param string $routingResponseFilterClass | [
"Register",
"a",
"filter",
"for",
"the",
"routing",
"response",
"response",
".",
"The",
"filter",
"must",
"implement",
"the",
"RoutingResponseFilter",
"interface",
"."
] | ae446658f53940aaba63b7bb0ebcebf522a85254 | https://github.com/opsbears/piccolo-web-processor-controller/blob/ae446658f53940aaba63b7bb0ebcebf522a85254/src/ControllerProcessorWebModule.php#L55-L60 |
11,915 | opsbears/piccolo-web-processor-controller | src/ControllerProcessorWebModule.php | ControllerProcessorWebModule.makeFilters | private function makeFilters(array $filterSpecification, DependencyInjectionContainer $dic) : array {
$filters = [];
foreach ($filterSpecification as $requestFilterClass) {
$filters[] = $dic->make($requestFilterClass);
}
return $filters;
} | php | private function makeFilters(array $filterSpecification, DependencyInjectionContainer $dic) : array {
$filters = [];
foreach ($filterSpecification as $requestFilterClass) {
$filters[] = $dic->make($requestFilterClass);
}
return $filters;
} | [
"private",
"function",
"makeFilters",
"(",
"array",
"$",
"filterSpecification",
",",
"DependencyInjectionContainer",
"$",
"dic",
")",
":",
"array",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"filterSpecification",
"as",
"$",
"requestFilterClass",
")",
"{",
"$",
"filters",
"[",
"]",
"=",
"$",
"dic",
"->",
"make",
"(",
"$",
"requestFilterClass",
")",
";",
"}",
"return",
"$",
"filters",
";",
"}"
] | Create an array of filter objects from an array of filter class names.
@param array $filterSpecification
@param DependencyInjectionContainer $dic
@return array | [
"Create",
"an",
"array",
"of",
"filter",
"objects",
"from",
"an",
"array",
"of",
"filter",
"class",
"names",
"."
] | ae446658f53940aaba63b7bb0ebcebf522a85254 | https://github.com/opsbears/piccolo-web-processor-controller/blob/ae446658f53940aaba63b7bb0ebcebf522a85254/src/ControllerProcessorWebModule.php#L103-L109 |
11,916 | yii2module/yii2-tool | src/console/controllers/PasswordController.php | PasswordController.actionGenerate | public function actionGenerate()
{
$passwordList = \App::$domain->tool->password->generate();
$text = implode(SPC, $passwordList);
Output::line();
Output::pipe('Generated passwords');
Output::autoWrap($text);
Output::pipe();
Output::line();
} | php | public function actionGenerate()
{
$passwordList = \App::$domain->tool->password->generate();
$text = implode(SPC, $passwordList);
Output::line();
Output::pipe('Generated passwords');
Output::autoWrap($text);
Output::pipe();
Output::line();
} | [
"public",
"function",
"actionGenerate",
"(",
")",
"{",
"$",
"passwordList",
"=",
"\\",
"App",
"::",
"$",
"domain",
"->",
"tool",
"->",
"password",
"->",
"generate",
"(",
")",
";",
"$",
"text",
"=",
"implode",
"(",
"SPC",
",",
"$",
"passwordList",
")",
";",
"Output",
"::",
"line",
"(",
")",
";",
"Output",
"::",
"pipe",
"(",
"'Generated passwords'",
")",
";",
"Output",
"::",
"autoWrap",
"(",
"$",
"text",
")",
";",
"Output",
"::",
"pipe",
"(",
")",
";",
"Output",
"::",
"line",
"(",
")",
";",
"}"
] | Generate random password list | [
"Generate",
"random",
"password",
"list"
] | c2efd7bc8550590f0afbf44ae66243f462766593 | https://github.com/yii2module/yii2-tool/blob/c2efd7bc8550590f0afbf44ae66243f462766593/src/console/controllers/PasswordController.php#L18-L27 |
11,917 | osflab/stream | Text.php | Text.crop | public static function crop($txt, int $maxChars = 20, string $etc = '...'): string
{
$txt = (string) $txt;
if (mb_strlen($txt, self::ENCODING) > $maxChars) {
return mb_substr($txt, 0, $maxChars - mb_strlen($etc, self::ENCODING), self::ENCODING) . $etc;
}
return $txt;
} | php | public static function crop($txt, int $maxChars = 20, string $etc = '...'): string
{
$txt = (string) $txt;
if (mb_strlen($txt, self::ENCODING) > $maxChars) {
return mb_substr($txt, 0, $maxChars - mb_strlen($etc, self::ENCODING), self::ENCODING) . $etc;
}
return $txt;
} | [
"public",
"static",
"function",
"crop",
"(",
"$",
"txt",
",",
"int",
"$",
"maxChars",
"=",
"20",
",",
"string",
"$",
"etc",
"=",
"'...'",
")",
":",
"string",
"{",
"$",
"txt",
"=",
"(",
"string",
")",
"$",
"txt",
";",
"if",
"(",
"mb_strlen",
"(",
"$",
"txt",
",",
"self",
"::",
"ENCODING",
")",
">",
"$",
"maxChars",
")",
"{",
"return",
"mb_substr",
"(",
"$",
"txt",
",",
"0",
",",
"$",
"maxChars",
"-",
"mb_strlen",
"(",
"$",
"etc",
",",
"self",
"::",
"ENCODING",
")",
",",
"self",
"::",
"ENCODING",
")",
".",
"$",
"etc",
";",
"}",
"return",
"$",
"txt",
";",
"}"
] | Crop a string with a '...' if too long
@param type $txt
@param int $maxChars
@param string $etc
@return string | [
"Crop",
"a",
"string",
"with",
"a",
"...",
"if",
"too",
"long"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L37-L44 |
11,918 | osflab/stream | Text.php | Text.phoneFormat | public static function phoneFormat($phoneNumber): string
{
if (!$phoneNumber) {
return (string) $phoneNumber;
}
$prefix = trim($phoneNumber)[0] == '+';
$value = preg_replace('/[^0-9]/', '', (string) $phoneNumber);
$valueLen = mb_strlen($value, self::ENCODING);
if ($prefix && $valueLen == 11) {
$pattern[] = '/([0-9][0-9])([0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])/';
$replace[] = '$1 ($2) $3 $4 $5 $6';
} else if ($prefix && $valueLen == 12 && $value[2] == 0) {
$pattern[] = '/([0-9][0-9]).([0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])/';
$replace[] = '$1 ($2) $3 $4 $5 $6';
} elseif ($valueLen == 12) {
$pattern[] = '/^([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])$/';
$replace[] = '$1 $2 $3 $4 $5';
} elseif ($valueLen == 11) {
$pattern[] = '/^([0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3 $4';
} elseif ($valueLen == 10) {
$pattern[] = '/^([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3 $4 $5';
} elseif ($valueLen == 9) {
$pattern[] = '/^([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])$/';
$replace[] = '$1 $2 $3';
} elseif ($valueLen == 8) {
$pattern[] = '/^([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3 $4';
} elseif ($valueLen == 7) {
$pattern[] = '/^([0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3';
} elseif ($valueLen == 6) {
$pattern[] = '/^([0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3';
}
if (!isset($pattern)) {
return ($prefix ? '+' : '') . $value;
}
return ($prefix ? '+' : '') . trim(preg_replace($pattern, $replace, $value));
} | php | public static function phoneFormat($phoneNumber): string
{
if (!$phoneNumber) {
return (string) $phoneNumber;
}
$prefix = trim($phoneNumber)[0] == '+';
$value = preg_replace('/[^0-9]/', '', (string) $phoneNumber);
$valueLen = mb_strlen($value, self::ENCODING);
if ($prefix && $valueLen == 11) {
$pattern[] = '/([0-9][0-9])([0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])/';
$replace[] = '$1 ($2) $3 $4 $5 $6';
} else if ($prefix && $valueLen == 12 && $value[2] == 0) {
$pattern[] = '/([0-9][0-9]).([0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])/';
$replace[] = '$1 ($2) $3 $4 $5 $6';
} elseif ($valueLen == 12) {
$pattern[] = '/^([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])$/';
$replace[] = '$1 $2 $3 $4 $5';
} elseif ($valueLen == 11) {
$pattern[] = '/^([0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3 $4';
} elseif ($valueLen == 10) {
$pattern[] = '/^([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3 $4 $5';
} elseif ($valueLen == 9) {
$pattern[] = '/^([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])$/';
$replace[] = '$1 $2 $3';
} elseif ($valueLen == 8) {
$pattern[] = '/^([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3 $4';
} elseif ($valueLen == 7) {
$pattern[] = '/^([0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3';
} elseif ($valueLen == 6) {
$pattern[] = '/^([0-9][0-9])([0-9][0-9])([0-9][0-9])$/';
$replace[] = '$1 $2 $3';
}
if (!isset($pattern)) {
return ($prefix ? '+' : '') . $value;
}
return ($prefix ? '+' : '') . trim(preg_replace($pattern, $replace, $value));
} | [
"public",
"static",
"function",
"phoneFormat",
"(",
"$",
"phoneNumber",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"phoneNumber",
")",
"{",
"return",
"(",
"string",
")",
"$",
"phoneNumber",
";",
"}",
"$",
"prefix",
"=",
"trim",
"(",
"$",
"phoneNumber",
")",
"[",
"0",
"]",
"==",
"'+'",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"'/[^0-9]/'",
",",
"''",
",",
"(",
"string",
")",
"$",
"phoneNumber",
")",
";",
"$",
"valueLen",
"=",
"mb_strlen",
"(",
"$",
"value",
",",
"self",
"::",
"ENCODING",
")",
";",
"if",
"(",
"$",
"prefix",
"&&",
"$",
"valueLen",
"==",
"11",
")",
"{",
"$",
"pattern",
"[",
"]",
"=",
"'/([0-9][0-9])([0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])/'",
";",
"$",
"replace",
"[",
"]",
"=",
"'$1 ($2) $3 $4 $5 $6'",
";",
"}",
"else",
"if",
"(",
"$",
"prefix",
"&&",
"$",
"valueLen",
"==",
"12",
"&&",
"$",
"value",
"[",
"2",
"]",
"==",
"0",
")",
"{",
"$",
"pattern",
"[",
"]",
"=",
"'/([0-9][0-9]).([0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])/'",
";",
"$",
"replace",
"[",
"]",
"=",
"'$1 ($2) $3 $4 $5 $6'",
";",
"}",
"elseif",
"(",
"$",
"valueLen",
"==",
"12",
")",
"{",
"$",
"pattern",
"[",
"]",
"=",
"'/^([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])$/'",
";",
"$",
"replace",
"[",
"]",
"=",
"'$1 $2 $3 $4 $5'",
";",
"}",
"elseif",
"(",
"$",
"valueLen",
"==",
"11",
")",
"{",
"$",
"pattern",
"[",
"]",
"=",
"'/^([0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/'",
";",
"$",
"replace",
"[",
"]",
"=",
"'$1 $2 $3 $4'",
";",
"}",
"elseif",
"(",
"$",
"valueLen",
"==",
"10",
")",
"{",
"$",
"pattern",
"[",
"]",
"=",
"'/^([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/'",
";",
"$",
"replace",
"[",
"]",
"=",
"'$1 $2 $3 $4 $5'",
";",
"}",
"elseif",
"(",
"$",
"valueLen",
"==",
"9",
")",
"{",
"$",
"pattern",
"[",
"]",
"=",
"'/^([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])$/'",
";",
"$",
"replace",
"[",
"]",
"=",
"'$1 $2 $3'",
";",
"}",
"elseif",
"(",
"$",
"valueLen",
"==",
"8",
")",
"{",
"$",
"pattern",
"[",
"]",
"=",
"'/^([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/'",
";",
"$",
"replace",
"[",
"]",
"=",
"'$1 $2 $3 $4'",
";",
"}",
"elseif",
"(",
"$",
"valueLen",
"==",
"7",
")",
"{",
"$",
"pattern",
"[",
"]",
"=",
"'/^([0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/'",
";",
"$",
"replace",
"[",
"]",
"=",
"'$1 $2 $3'",
";",
"}",
"elseif",
"(",
"$",
"valueLen",
"==",
"6",
")",
"{",
"$",
"pattern",
"[",
"]",
"=",
"'/^([0-9][0-9])([0-9][0-9])([0-9][0-9])$/'",
";",
"$",
"replace",
"[",
"]",
"=",
"'$1 $2 $3'",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"pattern",
")",
")",
"{",
"return",
"(",
"$",
"prefix",
"?",
"'+'",
":",
"''",
")",
".",
"$",
"value",
";",
"}",
"return",
"(",
"$",
"prefix",
"?",
"'+'",
":",
"''",
")",
".",
"trim",
"(",
"preg_replace",
"(",
"$",
"pattern",
",",
"$",
"replace",
",",
"$",
"value",
")",
")",
";",
"}"
] | Format a phone number
@param mixed $phoneNumber
@return string | [
"Format",
"a",
"phone",
"number"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L71-L112 |
11,919 | osflab/stream | Text.php | Text.ucPhrase | public static function ucPhrase($str): string
{
$str = mb_strtolower(self::cleanPhrase($str), self::ENCODING);
$names = explode(' ', $str);
array_walk($names, 'self::ucFirstTouch');
$names = explode('-', implode(' ', $names));
array_walk($names, 'self::ucFirstTouch');
return implode('-', $names);
} | php | public static function ucPhrase($str): string
{
$str = mb_strtolower(self::cleanPhrase($str), self::ENCODING);
$names = explode(' ', $str);
array_walk($names, 'self::ucFirstTouch');
$names = explode('-', implode(' ', $names));
array_walk($names, 'self::ucFirstTouch');
return implode('-', $names);
} | [
"public",
"static",
"function",
"ucPhrase",
"(",
"$",
"str",
")",
":",
"string",
"{",
"$",
"str",
"=",
"mb_strtolower",
"(",
"self",
"::",
"cleanPhrase",
"(",
"$",
"str",
")",
",",
"self",
"::",
"ENCODING",
")",
";",
"$",
"names",
"=",
"explode",
"(",
"' '",
",",
"$",
"str",
")",
";",
"array_walk",
"(",
"$",
"names",
",",
"'self::ucFirstTouch'",
")",
";",
"$",
"names",
"=",
"explode",
"(",
"'-'",
",",
"implode",
"(",
"' '",
",",
"$",
"names",
")",
")",
";",
"array_walk",
"(",
"$",
"names",
",",
"'self::ucFirstTouch'",
")",
";",
"return",
"implode",
"(",
"'-'",
",",
"$",
"names",
")",
";",
"}"
] | jean-albert dupont -> Jean-Albert Dupont
@param mixed $str
@return string | [
"jean",
"-",
"albert",
"dupont",
"-",
">",
"Jean",
"-",
"Albert",
"Dupont"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L149-L157 |
11,920 | osflab/stream | Text.php | Text.percentageFormat | public static function percentageFormat($value, bool $withSymbol = true, int $precision = 0): string
{
$percentValue = round((float) $value, $precision);
return $percentValue . ($withSymbol ? ' %' : '');
} | php | public static function percentageFormat($value, bool $withSymbol = true, int $precision = 0): string
{
$percentValue = round((float) $value, $precision);
return $percentValue . ($withSymbol ? ' %' : '');
} | [
"public",
"static",
"function",
"percentageFormat",
"(",
"$",
"value",
",",
"bool",
"$",
"withSymbol",
"=",
"true",
",",
"int",
"$",
"precision",
"=",
"0",
")",
":",
"string",
"{",
"$",
"percentValue",
"=",
"round",
"(",
"(",
"float",
")",
"$",
"value",
",",
"$",
"precision",
")",
";",
"return",
"$",
"percentValue",
".",
"(",
"$",
"withSymbol",
"?",
"' %'",
":",
"''",
")",
";",
"}"
] | Round and add the % symbol
@param mixed $value
@param bool $withSymbol
@param int $precision
@return string | [
"Round",
"and",
"add",
"the",
"%",
"symbol"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L272-L276 |
11,921 | osflab/stream | Text.php | Text.formatDate | public static function formatDate(DateTime $date, $locale = null, bool $short = false)
{
$locale = $locale ?? 'fr';
$localDates = [
'fr' => $short ? 'd/m/y' : 'd/m/Y',
'en' => $short ? 'd/m/y' : 'd/m/Y',
'en_US' => $short ? 'm/d/y' : 'm/d/Y'
];
return (string) $date->format($localDates[$locale]);
} | php | public static function formatDate(DateTime $date, $locale = null, bool $short = false)
{
$locale = $locale ?? 'fr';
$localDates = [
'fr' => $short ? 'd/m/y' : 'd/m/Y',
'en' => $short ? 'd/m/y' : 'd/m/Y',
'en_US' => $short ? 'm/d/y' : 'm/d/Y'
];
return (string) $date->format($localDates[$locale]);
} | [
"public",
"static",
"function",
"formatDate",
"(",
"DateTime",
"$",
"date",
",",
"$",
"locale",
"=",
"null",
",",
"bool",
"$",
"short",
"=",
"false",
")",
"{",
"$",
"locale",
"=",
"$",
"locale",
"??",
"'fr'",
";",
"$",
"localDates",
"=",
"[",
"'fr'",
"=>",
"$",
"short",
"?",
"'d/m/y'",
":",
"'d/m/Y'",
",",
"'en'",
"=>",
"$",
"short",
"?",
"'d/m/y'",
":",
"'d/m/Y'",
",",
"'en_US'",
"=>",
"$",
"short",
"?",
"'m/d/y'",
":",
"'m/d/Y'",
"]",
";",
"return",
"(",
"string",
")",
"$",
"date",
"->",
"format",
"(",
"$",
"localDates",
"[",
"$",
"locale",
"]",
")",
";",
"}"
] | Format a date with the specified locale
@param DateTime $date
@param string $locale
@param bool $short
@return string
@todo use an external library ? | [
"Format",
"a",
"date",
"with",
"the",
"specified",
"locale"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L286-L295 |
11,922 | osflab/stream | Text.php | Text.formatDateTime | public static function formatDateTime(DateTime $date, $locale = null, string $mask = null, bool $short = false): string
{
$locale = $locale ?? 'fr';
if ($mask === null) {
$localDates = [
'fr' => $short ? __("d/m/y H:i") : __("d/m/Y H:i"),
'en' => $short ? __("d/m/y H:i") : __("d/m/Y H:i"),
'en_US' => $short ? __("m/d/y H:i") : __("m/d/Y H:i")
];
$mask = $localDates[$locale];
}
return (string) $date->format($mask);
} | php | public static function formatDateTime(DateTime $date, $locale = null, string $mask = null, bool $short = false): string
{
$locale = $locale ?? 'fr';
if ($mask === null) {
$localDates = [
'fr' => $short ? __("d/m/y H:i") : __("d/m/Y H:i"),
'en' => $short ? __("d/m/y H:i") : __("d/m/Y H:i"),
'en_US' => $short ? __("m/d/y H:i") : __("m/d/Y H:i")
];
$mask = $localDates[$locale];
}
return (string) $date->format($mask);
} | [
"public",
"static",
"function",
"formatDateTime",
"(",
"DateTime",
"$",
"date",
",",
"$",
"locale",
"=",
"null",
",",
"string",
"$",
"mask",
"=",
"null",
",",
"bool",
"$",
"short",
"=",
"false",
")",
":",
"string",
"{",
"$",
"locale",
"=",
"$",
"locale",
"??",
"'fr'",
";",
"if",
"(",
"$",
"mask",
"===",
"null",
")",
"{",
"$",
"localDates",
"=",
"[",
"'fr'",
"=>",
"$",
"short",
"?",
"__",
"(",
"\"d/m/y H:i\"",
")",
":",
"__",
"(",
"\"d/m/Y H:i\"",
")",
",",
"'en'",
"=>",
"$",
"short",
"?",
"__",
"(",
"\"d/m/y H:i\"",
")",
":",
"__",
"(",
"\"d/m/Y H:i\"",
")",
",",
"'en_US'",
"=>",
"$",
"short",
"?",
"__",
"(",
"\"m/d/y H:i\"",
")",
":",
"__",
"(",
"\"m/d/Y H:i\"",
")",
"]",
";",
"$",
"mask",
"=",
"$",
"localDates",
"[",
"$",
"locale",
"]",
";",
"}",
"return",
"(",
"string",
")",
"$",
"date",
"->",
"format",
"(",
"$",
"mask",
")",
";",
"}"
] | Format a datetime with the specified locale
@param DateTime $date
@param string $locale
@return string
@todo use an external library ? | [
"Format",
"a",
"datetime",
"with",
"the",
"specified",
"locale"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L321-L333 |
11,923 | osflab/stream | Text.php | Text.camelCase | public static function camelCase($word, bool $ucFirstWord = true): string
{
static $words = [];
if (!isset($words[$word])) {
$words[$word] = str_replace(' ', '', ucwords(strtr($word, '_', ' ')));
if (!$ucFirstWord) {
substr_replace($words[$word], $word{0}, 0, 1);
}
}
return $words[$word];
} | php | public static function camelCase($word, bool $ucFirstWord = true): string
{
static $words = [];
if (!isset($words[$word])) {
$words[$word] = str_replace(' ', '', ucwords(strtr($word, '_', ' ')));
if (!$ucFirstWord) {
substr_replace($words[$word], $word{0}, 0, 1);
}
}
return $words[$word];
} | [
"public",
"static",
"function",
"camelCase",
"(",
"$",
"word",
",",
"bool",
"$",
"ucFirstWord",
"=",
"true",
")",
":",
"string",
"{",
"static",
"$",
"words",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"words",
"[",
"$",
"word",
"]",
")",
")",
"{",
"$",
"words",
"[",
"$",
"word",
"]",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",
"(",
"strtr",
"(",
"$",
"word",
",",
"'_'",
",",
"' '",
")",
")",
")",
";",
"if",
"(",
"!",
"$",
"ucFirstWord",
")",
"{",
"substr_replace",
"(",
"$",
"words",
"[",
"$",
"word",
"]",
",",
"$",
"word",
"{",
"0",
"}",
",",
"0",
",",
"1",
")",
";",
"}",
"}",
"return",
"$",
"words",
"[",
"$",
"word",
"]",
";",
"}"
] | some_phrase => SomePhrase
@param mixed $word
@param bool $ucFirstWord
@return string | [
"some_phrase",
"=",
">",
"SomePhrase"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L359-L370 |
11,924 | osflab/stream | Text.php | Text.fromCamelCaseToLower | public static function fromCamelCaseToLower($word, string $separator = '-'): string
{
$str = '';
$active = false;
$word = (string) $word;
for ($i = 0; $i <= mb_strlen($word); $i++) {
$char = mb_substr($word, $i, 1, self::ENCODING);
$str .= ($active && $char >= 'A' && $char <= 'Z' ? $separator : '') . mb_strtolower($char);
$active = $char !== ' ';
}
return $str;
} | php | public static function fromCamelCaseToLower($word, string $separator = '-'): string
{
$str = '';
$active = false;
$word = (string) $word;
for ($i = 0; $i <= mb_strlen($word); $i++) {
$char = mb_substr($word, $i, 1, self::ENCODING);
$str .= ($active && $char >= 'A' && $char <= 'Z' ? $separator : '') . mb_strtolower($char);
$active = $char !== ' ';
}
return $str;
} | [
"public",
"static",
"function",
"fromCamelCaseToLower",
"(",
"$",
"word",
",",
"string",
"$",
"separator",
"=",
"'-'",
")",
":",
"string",
"{",
"$",
"str",
"=",
"''",
";",
"$",
"active",
"=",
"false",
";",
"$",
"word",
"=",
"(",
"string",
")",
"$",
"word",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"mb_strlen",
"(",
"$",
"word",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"char",
"=",
"mb_substr",
"(",
"$",
"word",
",",
"$",
"i",
",",
"1",
",",
"self",
"::",
"ENCODING",
")",
";",
"$",
"str",
".=",
"(",
"$",
"active",
"&&",
"$",
"char",
">=",
"'A'",
"&&",
"$",
"char",
"<=",
"'Z'",
"?",
"$",
"separator",
":",
"''",
")",
".",
"mb_strtolower",
"(",
"$",
"char",
")",
";",
"$",
"active",
"=",
"$",
"char",
"!==",
"' '",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | CamelCase -> camel-case
@param string $word
@param string $separator
@return string | [
"CamelCase",
"-",
">",
"camel",
"-",
"case"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L378-L389 |
11,925 | osflab/stream | Text.php | Text.transliterate | public static function transliterate($txt)
{
if ($txt === null) {
return null;
}
return strtolower(\Patchwork\Utf8::toAscii((string) $txt));
} | php | public static function transliterate($txt)
{
if ($txt === null) {
return null;
}
return strtolower(\Patchwork\Utf8::toAscii((string) $txt));
} | [
"public",
"static",
"function",
"transliterate",
"(",
"$",
"txt",
")",
"{",
"if",
"(",
"$",
"txt",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"strtolower",
"(",
"\\",
"Patchwork",
"\\",
"Utf8",
"::",
"toAscii",
"(",
"(",
"string",
")",
"$",
"txt",
")",
")",
";",
"}"
] | Transliteration for a search engine
@param string|null $txt
@return string|null | [
"Transliteration",
"for",
"a",
"search",
"engine"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L396-L402 |
11,926 | osflab/stream | Text.php | Text.formatSiret | public static function formatSiret($value): string
{
$value = (string) (int) $value;
if (!self::isSiret($value)) {
return '';
}
return preg_replace('/^([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{5})$/', '$1 $2 $3 $4', $value);
} | php | public static function formatSiret($value): string
{
$value = (string) (int) $value;
if (!self::isSiret($value)) {
return '';
}
return preg_replace('/^([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{5})$/', '$1 $2 $3 $4', $value);
} | [
"public",
"static",
"function",
"formatSiret",
"(",
"$",
"value",
")",
":",
"string",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"(",
"int",
")",
"$",
"value",
";",
"if",
"(",
"!",
"self",
"::",
"isSiret",
"(",
"$",
"value",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"preg_replace",
"(",
"'/^([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{5})$/'",
",",
"'$1 $2 $3 $4'",
",",
"$",
"value",
")",
";",
"}"
] | Format a siret number with 14 digits
@param string $value
@return string | [
"Format",
"a",
"siret",
"number",
"with",
"14",
"digits"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L431-L438 |
11,927 | osflab/stream | Text.php | Text.siretToSiren | public static function siretToSiren($siret, bool $format = false): string
{
$value = (string) (int) $siret;
if (!self::isSiret($value)) {
return '';
}
return $format
? preg_replace('/^([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{5})$/', '$1 $2 $3', $value)
: substr($value, 0, 9);
} | php | public static function siretToSiren($siret, bool $format = false): string
{
$value = (string) (int) $siret;
if (!self::isSiret($value)) {
return '';
}
return $format
? preg_replace('/^([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{5})$/', '$1 $2 $3', $value)
: substr($value, 0, 9);
} | [
"public",
"static",
"function",
"siretToSiren",
"(",
"$",
"siret",
",",
"bool",
"$",
"format",
"=",
"false",
")",
":",
"string",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"(",
"int",
")",
"$",
"siret",
";",
"if",
"(",
"!",
"self",
"::",
"isSiret",
"(",
"$",
"value",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"format",
"?",
"preg_replace",
"(",
"'/^([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{5})$/'",
",",
"'$1 $2 $3'",
",",
"$",
"value",
")",
":",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"9",
")",
";",
"}"
] | Extract french siren from siret
@param string $siret
@param bool $format
@return string | [
"Extract",
"french",
"siren",
"from",
"siret"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L446-L455 |
11,928 | osflab/stream | Text.php | Text.formatTvaIntra | public static function formatTvaIntra($value)
{
$value = self::toUpper(trim(str_replace(' ', '', $value)));
return preg_replace('/^([A-Z]{2})([0-9]{2})([0-9]{3})([0-9]{3})([0-9]{3})$/', '$1 $2 $3 $4 $5', $value);
} | php | public static function formatTvaIntra($value)
{
$value = self::toUpper(trim(str_replace(' ', '', $value)));
return preg_replace('/^([A-Z]{2})([0-9]{2})([0-9]{3})([0-9]{3})([0-9]{3})$/', '$1 $2 $3 $4 $5', $value);
} | [
"public",
"static",
"function",
"formatTvaIntra",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"toUpper",
"(",
"trim",
"(",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"value",
")",
")",
")",
";",
"return",
"preg_replace",
"(",
"'/^([A-Z]{2})([0-9]{2})([0-9]{3})([0-9]{3})([0-9]{3})$/'",
",",
"'$1 $2 $3 $4 $5'",
",",
"$",
"value",
")",
";",
"}"
] | Intracom TVA formatting
@param string $value
@return string | [
"Intracom",
"TVA",
"formatting"
] | 7cec5e1eb36d20d36c08504580bd163576d68fd9 | https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Text.php#L471-L475 |
11,929 | plinker-rpc/core | src/lib/Signer.php | Signer.encode | public function encode($data)
{
// loop over params, look for closure
if (
// not a server exception
!($data instanceof \Plinker\Core\Exception\Server) &&
// params should be set & array
isset($data['params']) && is_array($data['params'])) {
foreach ($data['params'] as $key => $param) {
if (is_object($param) && ($param instanceof \Closure)) {
$data['params'][$key] = new SerializableClosure($param);
}
}
}
$data = serialize($data);
return [
"data" => $this->encrypt($data, $this->config["secret"]),
"token" => hash_hmac(
"sha256",
$data,
$this->config["secret"]
)
];
} | php | public function encode($data)
{
// loop over params, look for closure
if (
// not a server exception
!($data instanceof \Plinker\Core\Exception\Server) &&
// params should be set & array
isset($data['params']) && is_array($data['params'])) {
foreach ($data['params'] as $key => $param) {
if (is_object($param) && ($param instanceof \Closure)) {
$data['params'][$key] = new SerializableClosure($param);
}
}
}
$data = serialize($data);
return [
"data" => $this->encrypt($data, $this->config["secret"]),
"token" => hash_hmac(
"sha256",
$data,
$this->config["secret"]
)
];
} | [
"public",
"function",
"encode",
"(",
"$",
"data",
")",
"{",
"// loop over params, look for closure",
"if",
"(",
"// not a server exception",
"!",
"(",
"$",
"data",
"instanceof",
"\\",
"Plinker",
"\\",
"Core",
"\\",
"Exception",
"\\",
"Server",
")",
"&&",
"// params should be set & array",
"isset",
"(",
"$",
"data",
"[",
"'params'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"data",
"[",
"'params'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'params'",
"]",
"as",
"$",
"key",
"=>",
"$",
"param",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"param",
")",
"&&",
"(",
"$",
"param",
"instanceof",
"\\",
"Closure",
")",
")",
"{",
"$",
"data",
"[",
"'params'",
"]",
"[",
"$",
"key",
"]",
"=",
"new",
"SerializableClosure",
"(",
"$",
"param",
")",
";",
"}",
"}",
"}",
"$",
"data",
"=",
"serialize",
"(",
"$",
"data",
")",
";",
"return",
"[",
"\"data\"",
"=>",
"$",
"this",
"->",
"encrypt",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"config",
"[",
"\"secret\"",
"]",
")",
",",
"\"token\"",
"=>",
"hash_hmac",
"(",
"\"sha256\"",
",",
"$",
"data",
",",
"$",
"this",
"->",
"config",
"[",
"\"secret\"",
"]",
")",
"]",
";",
"}"
] | Sign and encrypt into payload array.
@codeCoverageIgnore
@return array | [
"Sign",
"and",
"encrypt",
"into",
"payload",
"array",
"."
] | c9039cfa840cfe2d6377455e6668364d910626fd | https://github.com/plinker-rpc/core/blob/c9039cfa840cfe2d6377455e6668364d910626fd/src/lib/Signer.php#L94-L119 |
11,930 | plinker-rpc/core | src/lib/Signer.php | Signer.decode | public function decode($data)
{
$data["data"] = $this->decrypt($data["data"], $this->config["secret"]);
if (hash_hmac(
"sha256",
$data["data"],
$this->config["secret"]
) == $data["token"]) {
return unserialize($data["data"]);
} else {
throw new \Exception('Failed to verify payload');
}
} | php | public function decode($data)
{
$data["data"] = $this->decrypt($data["data"], $this->config["secret"]);
if (hash_hmac(
"sha256",
$data["data"],
$this->config["secret"]
) == $data["token"]) {
return unserialize($data["data"]);
} else {
throw new \Exception('Failed to verify payload');
}
} | [
"public",
"function",
"decode",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"[",
"\"data\"",
"]",
"=",
"$",
"this",
"->",
"decrypt",
"(",
"$",
"data",
"[",
"\"data\"",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"\"secret\"",
"]",
")",
";",
"if",
"(",
"hash_hmac",
"(",
"\"sha256\"",
",",
"$",
"data",
"[",
"\"data\"",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"\"secret\"",
"]",
")",
"==",
"$",
"data",
"[",
"\"token\"",
"]",
")",
"{",
"return",
"unserialize",
"(",
"$",
"data",
"[",
"\"data\"",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Failed to verify payload'",
")",
";",
"}",
"}"
] | Decrypt, verify and unserialize payload.
@codeCoverageIgnore
@return mixed | [
"Decrypt",
"verify",
"and",
"unserialize",
"payload",
"."
] | c9039cfa840cfe2d6377455e6668364d910626fd | https://github.com/plinker-rpc/core/blob/c9039cfa840cfe2d6377455e6668364d910626fd/src/lib/Signer.php#L128-L141 |
11,931 | activecollab/payments | src/Dispatcher/Dispatcher.php | Dispatcher.listen | public function listen($event, callable $handler)
{
if (empty($this->handlers[$event])) {
$this->handlers[$event] = [];
}
$this->handlers[$event][] = $handler;
} | php | public function listen($event, callable $handler)
{
if (empty($this->handlers[$event])) {
$this->handlers[$event] = [];
}
$this->handlers[$event][] = $handler;
} | [
"public",
"function",
"listen",
"(",
"$",
"event",
",",
"callable",
"$",
"handler",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"event",
"]",
")",
")",
"{",
"$",
"this",
"->",
"handlers",
"[",
"$",
"event",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"handlers",
"[",
"$",
"event",
"]",
"[",
"]",
"=",
"$",
"handler",
";",
"}"
] | Specify an event listener for a project.
@param string $event
@param callable $handler | [
"Specify",
"an",
"event",
"listener",
"for",
"a",
"project",
"."
] | 9fab8060ccc496756cf6aed36e3006acfa0c1546 | https://github.com/activecollab/payments/blob/9fab8060ccc496756cf6aed36e3006acfa0c1546/src/Dispatcher/Dispatcher.php#L39-L46 |
11,932 | activecollab/payments | src/Dispatcher/Dispatcher.php | Dispatcher.trigger | protected function trigger($event, ...$arguments)
{
if (!empty($this->handlers[$event])) {
/** @var callable $handler */
foreach ($this->handlers[$event] as $handler) {
call_user_func_array($handler, $arguments);
}
}
} | php | protected function trigger($event, ...$arguments)
{
if (!empty($this->handlers[$event])) {
/** @var callable $handler */
foreach ($this->handlers[$event] as $handler) {
call_user_func_array($handler, $arguments);
}
}
} | [
"protected",
"function",
"trigger",
"(",
"$",
"event",
",",
"...",
"$",
"arguments",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"event",
"]",
")",
")",
"{",
"/** @var callable $handler */",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"event",
"]",
"as",
"$",
"handler",
")",
"{",
"call_user_func_array",
"(",
"$",
"handler",
",",
"$",
"arguments",
")",
";",
"}",
"}",
"}"
] | Trigger a particular event.
@param string $event
@param mixed ...$arguments | [
"Trigger",
"a",
"particular",
"event",
"."
] | 9fab8060ccc496756cf6aed36e3006acfa0c1546 | https://github.com/activecollab/payments/blob/9fab8060ccc496756cf6aed36e3006acfa0c1546/src/Dispatcher/Dispatcher.php#L54-L62 |
11,933 | activecollab/payments | src/Dispatcher/Dispatcher.php | Dispatcher.triggerOrderCompleted | public function triggerOrderCompleted(GatewayInterface $gateway, OrderInterface $order)
{
$this->trigger(self::ON_ORDER_COMPLETED, $gateway, $order);
} | php | public function triggerOrderCompleted(GatewayInterface $gateway, OrderInterface $order)
{
$this->trigger(self::ON_ORDER_COMPLETED, $gateway, $order);
} | [
"public",
"function",
"triggerOrderCompleted",
"(",
"GatewayInterface",
"$",
"gateway",
",",
"OrderInterface",
"$",
"order",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"ON_ORDER_COMPLETED",
",",
"$",
"gateway",
",",
"$",
"order",
")",
";",
"}"
] | Trigger product order completed.
@param \ActiveCollab\Payments\Gateway\GatewayInterface $gateway
@param OrderInterface $order | [
"Trigger",
"product",
"order",
"completed",
"."
] | 9fab8060ccc496756cf6aed36e3006acfa0c1546 | https://github.com/activecollab/payments/blob/9fab8060ccc496756cf6aed36e3006acfa0c1546/src/Dispatcher/Dispatcher.php#L70-L73 |
11,934 | activecollab/payments | src/Dispatcher/Dispatcher.php | Dispatcher.triggerSubscriptionDeactivated | public function triggerSubscriptionDeactivated(GatewayInterface $gateway, SubscriptionInterface $subscription, CancelationInterface $cancelation)
{
$this->trigger(self::ON_SUBSCRIPTION_DEACTIVATED, $gateway, $subscription, $cancelation);
} | php | public function triggerSubscriptionDeactivated(GatewayInterface $gateway, SubscriptionInterface $subscription, CancelationInterface $cancelation)
{
$this->trigger(self::ON_SUBSCRIPTION_DEACTIVATED, $gateway, $subscription, $cancelation);
} | [
"public",
"function",
"triggerSubscriptionDeactivated",
"(",
"GatewayInterface",
"$",
"gateway",
",",
"SubscriptionInterface",
"$",
"subscription",
",",
"CancelationInterface",
"$",
"cancelation",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"ON_SUBSCRIPTION_DEACTIVATED",
",",
"$",
"gateway",
",",
"$",
"subscription",
",",
"$",
"cancelation",
")",
";",
"}"
] | Trigger an event when subscription is deactivated.
@param GatewayInterface $gateway
@param SubscriptionInterface $subscription
@param CancelationInterface $cancelation | [
"Trigger",
"an",
"event",
"when",
"subscription",
"is",
"deactivated",
"."
] | 9fab8060ccc496756cf6aed36e3006acfa0c1546 | https://github.com/activecollab/payments/blob/9fab8060ccc496756cf6aed36e3006acfa0c1546/src/Dispatcher/Dispatcher.php#L145-L148 |
11,935 | activecollab/payments | src/Dispatcher/Dispatcher.php | Dispatcher.triggerSubscriptionCustomActivated | public function triggerSubscriptionCustomActivated(SubscriptionInterface $subscription, $note)
{
$this->trigger(self::ON_SUBSCRIPTION_CUSTOM_ACTIVATED, $subscription, $note);
} | php | public function triggerSubscriptionCustomActivated(SubscriptionInterface $subscription, $note)
{
$this->trigger(self::ON_SUBSCRIPTION_CUSTOM_ACTIVATED, $subscription, $note);
} | [
"public",
"function",
"triggerSubscriptionCustomActivated",
"(",
"SubscriptionInterface",
"$",
"subscription",
",",
"$",
"note",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"ON_SUBSCRIPTION_CUSTOM_ACTIVATED",
",",
"$",
"subscription",
",",
"$",
"note",
")",
";",
"}"
] | Trigger an event when account is activated manually.
@param SubscriptionInterface $subscription
@param string $note | [
"Trigger",
"an",
"event",
"when",
"account",
"is",
"activated",
"manually",
"."
] | 9fab8060ccc496756cf6aed36e3006acfa0c1546 | https://github.com/activecollab/payments/blob/9fab8060ccc496756cf6aed36e3006acfa0c1546/src/Dispatcher/Dispatcher.php#L169-L172 |
11,936 | activecollab/payments | src/Dispatcher/Dispatcher.php | Dispatcher.triggerSubscriptionExpired | public function triggerSubscriptionExpired(SubscriptionInterface $subscription, $note)
{
$this->trigger(self::ON_SUBSCRIPTION_EXPIRED, $subscription, $note);
} | php | public function triggerSubscriptionExpired(SubscriptionInterface $subscription, $note)
{
$this->trigger(self::ON_SUBSCRIPTION_EXPIRED, $subscription, $note);
} | [
"public",
"function",
"triggerSubscriptionExpired",
"(",
"SubscriptionInterface",
"$",
"subscription",
",",
"$",
"note",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"ON_SUBSCRIPTION_EXPIRED",
",",
"$",
"subscription",
",",
"$",
"note",
")",
";",
"}"
] | Trigger an event when account subscription is expired.
@param SubscriptionInterface $subscription
@param string $note | [
"Trigger",
"an",
"event",
"when",
"account",
"subscription",
"is",
"expired",
"."
] | 9fab8060ccc496756cf6aed36e3006acfa0c1546 | https://github.com/activecollab/payments/blob/9fab8060ccc496756cf6aed36e3006acfa0c1546/src/Dispatcher/Dispatcher.php#L180-L183 |
11,937 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayObject.php | ArrayObject.unserialize | public function unserialize($data)
{
$ar = unserialize($data);
$this->protectedProperties = array_keys(get_object_vars($this));
$this->setFlags($ar['flag']);
$this->exchangeArray($ar['storage']);
$this->setIteratorClass($ar['iteratorClass']);
foreach ($ar as $k => $v) {
switch ($k) {
case 'flag':
$this->setFlags($v);
break;
case 'storage':
$this->exchangeArray($v);
break;
case 'iteratorClass':
$this->setIteratorClass($v);
break;
case 'protectedProperties':
continue;
default:
$this->__set($k, $v);
}
}
} | php | public function unserialize($data)
{
$ar = unserialize($data);
$this->protectedProperties = array_keys(get_object_vars($this));
$this->setFlags($ar['flag']);
$this->exchangeArray($ar['storage']);
$this->setIteratorClass($ar['iteratorClass']);
foreach ($ar as $k => $v) {
switch ($k) {
case 'flag':
$this->setFlags($v);
break;
case 'storage':
$this->exchangeArray($v);
break;
case 'iteratorClass':
$this->setIteratorClass($v);
break;
case 'protectedProperties':
continue;
default:
$this->__set($k, $v);
}
}
} | [
"public",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"$",
"ar",
"=",
"unserialize",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"protectedProperties",
"=",
"array_keys",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
")",
";",
"$",
"this",
"->",
"setFlags",
"(",
"$",
"ar",
"[",
"'flag'",
"]",
")",
";",
"$",
"this",
"->",
"exchangeArray",
"(",
"$",
"ar",
"[",
"'storage'",
"]",
")",
";",
"$",
"this",
"->",
"setIteratorClass",
"(",
"$",
"ar",
"[",
"'iteratorClass'",
"]",
")",
";",
"foreach",
"(",
"$",
"ar",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"switch",
"(",
"$",
"k",
")",
"{",
"case",
"'flag'",
":",
"$",
"this",
"->",
"setFlags",
"(",
"$",
"v",
")",
";",
"break",
";",
"case",
"'storage'",
":",
"$",
"this",
"->",
"exchangeArray",
"(",
"$",
"v",
")",
";",
"break",
";",
"case",
"'iteratorClass'",
":",
"$",
"this",
"->",
"setIteratorClass",
"(",
"$",
"v",
")",
";",
"break",
";",
"case",
"'protectedProperties'",
":",
"continue",
";",
"default",
":",
"$",
"this",
"->",
"__set",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"}"
] | Unserialize an ArrayObject
@param string $data
@return void | [
"Unserialize",
"an",
"ArrayObject"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/ArrayObject.php#L405-L431 |
11,938 | synapsestudios/synapse-base | src/Synapse/Mapper/UpdaterTrait.php | UpdaterTrait.update | public function update(AbstractEntity $entity)
{
if ($this->updatedTimestampColumn) {
$entity->exchangeArray([$this->updatedTimestampColumn => time()]);
}
if ($this->updatedDatetimeColumn) {
$entity->exchangeArray([$this->updatedDatetimeColumn => date('Y-m-d H:i:s')]);
}
$this->updateRow($entity);
return $entity;
} | php | public function update(AbstractEntity $entity)
{
if ($this->updatedTimestampColumn) {
$entity->exchangeArray([$this->updatedTimestampColumn => time()]);
}
if ($this->updatedDatetimeColumn) {
$entity->exchangeArray([$this->updatedDatetimeColumn => date('Y-m-d H:i:s')]);
}
$this->updateRow($entity);
return $entity;
} | [
"public",
"function",
"update",
"(",
"AbstractEntity",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"updatedTimestampColumn",
")",
"{",
"$",
"entity",
"->",
"exchangeArray",
"(",
"[",
"$",
"this",
"->",
"updatedTimestampColumn",
"=>",
"time",
"(",
")",
"]",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"updatedDatetimeColumn",
")",
"{",
"$",
"entity",
"->",
"exchangeArray",
"(",
"[",
"$",
"this",
"->",
"updatedDatetimeColumn",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
"]",
")",
";",
"}",
"$",
"this",
"->",
"updateRow",
"(",
"$",
"entity",
")",
";",
"return",
"$",
"entity",
";",
"}"
] | Update the given entity in the database.
@param AbstractEntity $entity
@return AbstractEntity | [
"Update",
"the",
"given",
"entity",
"in",
"the",
"database",
"."
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Mapper/UpdaterTrait.php#L18-L31 |
11,939 | slickframework/orm | src/Mapper/Relation/HasAndBelongsToMany.php | HasAndBelongsToMany.getRelatedForeignKey | public function getRelatedForeignKey()
{
if (null == $this->relatedForeignKey) {
$name = $this->getParentTableName();
$this->relatedForeignKey = "{$this->normalizeFieldName($name)}_id";
}
return $this->relatedForeignKey;
} | php | public function getRelatedForeignKey()
{
if (null == $this->relatedForeignKey) {
$name = $this->getParentTableName();
$this->relatedForeignKey = "{$this->normalizeFieldName($name)}_id";
}
return $this->relatedForeignKey;
} | [
"public",
"function",
"getRelatedForeignKey",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"relatedForeignKey",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getParentTableName",
"(",
")",
";",
"$",
"this",
"->",
"relatedForeignKey",
"=",
"\"{$this->normalizeFieldName($name)}_id\"",
";",
"}",
"return",
"$",
"this",
"->",
"relatedForeignKey",
";",
"}"
] | Gets the related foreign key
@return string | [
"Gets",
"the",
"related",
"foreign",
"key"
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/HasAndBelongsToMany.php#L45-L52 |
11,940 | slickframework/orm | src/Mapper/Relation/HasAndBelongsToMany.php | HasAndBelongsToMany.getRelationTable | public function getRelationTable()
{
if (is_null($this->relationTable)) {
$parentTable = $this->getParentTableName();
$table = $this->getEntityDescriptor()->getTableName();
$names = [$parentTable, $table];
asort($names);
$first = array_shift($names);
$tableName = $this->normalizeFieldName($first);
array_unshift($names, $tableName);
$this->relationTable = implode('_', $names);
}
return $this->relationTable;
} | php | public function getRelationTable()
{
if (is_null($this->relationTable)) {
$parentTable = $this->getParentTableName();
$table = $this->getEntityDescriptor()->getTableName();
$names = [$parentTable, $table];
asort($names);
$first = array_shift($names);
$tableName = $this->normalizeFieldName($first);
array_unshift($names, $tableName);
$this->relationTable = implode('_', $names);
}
return $this->relationTable;
} | [
"public",
"function",
"getRelationTable",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"relationTable",
")",
")",
"{",
"$",
"parentTable",
"=",
"$",
"this",
"->",
"getParentTableName",
"(",
")",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"getEntityDescriptor",
"(",
")",
"->",
"getTableName",
"(",
")",
";",
"$",
"names",
"=",
"[",
"$",
"parentTable",
",",
"$",
"table",
"]",
";",
"asort",
"(",
"$",
"names",
")",
";",
"$",
"first",
"=",
"array_shift",
"(",
"$",
"names",
")",
";",
"$",
"tableName",
"=",
"$",
"this",
"->",
"normalizeFieldName",
"(",
"$",
"first",
")",
";",
"array_unshift",
"(",
"$",
"names",
",",
"$",
"tableName",
")",
";",
"$",
"this",
"->",
"relationTable",
"=",
"implode",
"(",
"'_'",
",",
"$",
"names",
")",
";",
"}",
"return",
"$",
"this",
"->",
"relationTable",
";",
"}"
] | Gets the related table
@return string | [
"Gets",
"the",
"related",
"table"
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/HasAndBelongsToMany.php#L59-L72 |
11,941 | slickframework/orm | src/Mapper/Relation/HasAndBelongsToMany.php | HasAndBelongsToMany.add | public function add(EntityAdded $event)
{
$entity = $event->getEntity();
$collection = $event->getCollection();
$this->deleteRelation($entity, $collection);
$repository = $this->getParentRepository();
$adapter = $repository->getAdapter();
$value = $collection->parentEntity()->getId();
Sql::createSql($adapter)
->insert($this->getRelationTable())
->set(
[
"{$this->getRelatedForeignKey()}" => $entity->getId(),
"{$this->getForeignKey()}" => $value
]
)
->execute();
} | php | public function add(EntityAdded $event)
{
$entity = $event->getEntity();
$collection = $event->getCollection();
$this->deleteRelation($entity, $collection);
$repository = $this->getParentRepository();
$adapter = $repository->getAdapter();
$value = $collection->parentEntity()->getId();
Sql::createSql($adapter)
->insert($this->getRelationTable())
->set(
[
"{$this->getRelatedForeignKey()}" => $entity->getId(),
"{$this->getForeignKey()}" => $value
]
)
->execute();
} | [
"public",
"function",
"add",
"(",
"EntityAdded",
"$",
"event",
")",
"{",
"$",
"entity",
"=",
"$",
"event",
"->",
"getEntity",
"(",
")",
";",
"$",
"collection",
"=",
"$",
"event",
"->",
"getCollection",
"(",
")",
";",
"$",
"this",
"->",
"deleteRelation",
"(",
"$",
"entity",
",",
"$",
"collection",
")",
";",
"$",
"repository",
"=",
"$",
"this",
"->",
"getParentRepository",
"(",
")",
";",
"$",
"adapter",
"=",
"$",
"repository",
"->",
"getAdapter",
"(",
")",
";",
"$",
"value",
"=",
"$",
"collection",
"->",
"parentEntity",
"(",
")",
"->",
"getId",
"(",
")",
";",
"Sql",
"::",
"createSql",
"(",
"$",
"adapter",
")",
"->",
"insert",
"(",
"$",
"this",
"->",
"getRelationTable",
"(",
")",
")",
"->",
"set",
"(",
"[",
"\"{$this->getRelatedForeignKey()}\"",
"=>",
"$",
"entity",
"->",
"getId",
"(",
")",
",",
"\"{$this->getForeignKey()}\"",
"=>",
"$",
"value",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Saves the relation row upon entity add
@param EntityAdded $event | [
"Saves",
"the",
"relation",
"row",
"upon",
"entity",
"add"
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/HasAndBelongsToMany.php#L109-L128 |
11,942 | slickframework/orm | src/Mapper/Relation/HasAndBelongsToMany.php | HasAndBelongsToMany.remove | public function remove(EntityRemoved $event)
{
$entity = $event->getEntity();
$collection = $event->getCollection();
$this->deleteRelation($entity, $collection);
} | php | public function remove(EntityRemoved $event)
{
$entity = $event->getEntity();
$collection = $event->getCollection();
$this->deleteRelation($entity, $collection);
} | [
"public",
"function",
"remove",
"(",
"EntityRemoved",
"$",
"event",
")",
"{",
"$",
"entity",
"=",
"$",
"event",
"->",
"getEntity",
"(",
")",
";",
"$",
"collection",
"=",
"$",
"event",
"->",
"getCollection",
"(",
")",
";",
"$",
"this",
"->",
"deleteRelation",
"(",
"$",
"entity",
",",
"$",
"collection",
")",
";",
"}"
] | Deletes the relation row upon entity remove
@param EntityRemoved $event | [
"Deletes",
"the",
"relation",
"row",
"upon",
"entity",
"remove"
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/HasAndBelongsToMany.php#L135-L140 |
11,943 | slickframework/orm | src/Mapper/Relation/HasAndBelongsToMany.php | HasAndBelongsToMany.deleteRelation | protected function deleteRelation(
EntityInterface $entity,
EntityCollectionInterface $collection
) {
$repository = $this->getParentRepository();
$adapter = $repository->getAdapter();
$parts = explode('\\', $this->getEntityDescriptor()->className());
$entityName = lcfirst(array_pop($parts));
$parts = explode('\\', $this->getParentEntityDescriptor()->className());
$relatedName = lcfirst(array_pop($parts));
$value = $collection->parentEntity()->getId();
Sql::createSql($adapter)
->delete($this->getRelationTable())
->where(
[
"{$this->getRelatedForeignKey()} = :{$relatedName} AND
{$this->getForeignKey()} = :{$entityName}" => [
":{$relatedName}" => $entity->getId(),
":{$entityName}" => $value
]
]
)
->execute();
return $this;
} | php | protected function deleteRelation(
EntityInterface $entity,
EntityCollectionInterface $collection
) {
$repository = $this->getParentRepository();
$adapter = $repository->getAdapter();
$parts = explode('\\', $this->getEntityDescriptor()->className());
$entityName = lcfirst(array_pop($parts));
$parts = explode('\\', $this->getParentEntityDescriptor()->className());
$relatedName = lcfirst(array_pop($parts));
$value = $collection->parentEntity()->getId();
Sql::createSql($adapter)
->delete($this->getRelationTable())
->where(
[
"{$this->getRelatedForeignKey()} = :{$relatedName} AND
{$this->getForeignKey()} = :{$entityName}" => [
":{$relatedName}" => $entity->getId(),
":{$entityName}" => $value
]
]
)
->execute();
return $this;
} | [
"protected",
"function",
"deleteRelation",
"(",
"EntityInterface",
"$",
"entity",
",",
"EntityCollectionInterface",
"$",
"collection",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"getParentRepository",
"(",
")",
";",
"$",
"adapter",
"=",
"$",
"repository",
"->",
"getAdapter",
"(",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"getEntityDescriptor",
"(",
")",
"->",
"className",
"(",
")",
")",
";",
"$",
"entityName",
"=",
"lcfirst",
"(",
"array_pop",
"(",
"$",
"parts",
")",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"getParentEntityDescriptor",
"(",
")",
"->",
"className",
"(",
")",
")",
";",
"$",
"relatedName",
"=",
"lcfirst",
"(",
"array_pop",
"(",
"$",
"parts",
")",
")",
";",
"$",
"value",
"=",
"$",
"collection",
"->",
"parentEntity",
"(",
")",
"->",
"getId",
"(",
")",
";",
"Sql",
"::",
"createSql",
"(",
"$",
"adapter",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"getRelationTable",
"(",
")",
")",
"->",
"where",
"(",
"[",
"\"{$this->getRelatedForeignKey()} = :{$relatedName} AND\n {$this->getForeignKey()} = :{$entityName}\"",
"=>",
"[",
"\":{$relatedName}\"",
"=>",
"$",
"entity",
"->",
"getId",
"(",
")",
",",
"\":{$entityName}\"",
"=>",
"$",
"value",
"]",
"]",
")",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes existing relations
@param EntityInterface $entity
@param EntityCollectionInterface $collection
@return self | [
"Removes",
"existing",
"relations"
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/HasAndBelongsToMany.php#L150-L174 |
11,944 | slickframework/orm | src/Mapper/Relation/HasAndBelongsToMany.php | HasAndBelongsToMany.addJoinTable | protected function addJoinTable(Select $query)
{
$relationTable = $this->getRelationTable();
$table = $this->getParentTableName();
$pmk = $this->getParentPrimaryKey();
$rfk = $this->getRelatedForeignKey();
$query->join(
$relationTable,
"rel.{$rfk} = {$table}.{$pmk}",
null,
'rel'
);
return $this;
} | php | protected function addJoinTable(Select $query)
{
$relationTable = $this->getRelationTable();
$table = $this->getParentTableName();
$pmk = $this->getParentPrimaryKey();
$rfk = $this->getRelatedForeignKey();
$query->join(
$relationTable,
"rel.{$rfk} = {$table}.{$pmk}",
null,
'rel'
);
return $this;
} | [
"protected",
"function",
"addJoinTable",
"(",
"Select",
"$",
"query",
")",
"{",
"$",
"relationTable",
"=",
"$",
"this",
"->",
"getRelationTable",
"(",
")",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"getParentTableName",
"(",
")",
";",
"$",
"pmk",
"=",
"$",
"this",
"->",
"getParentPrimaryKey",
"(",
")",
";",
"$",
"rfk",
"=",
"$",
"this",
"->",
"getRelatedForeignKey",
"(",
")",
";",
"$",
"query",
"->",
"join",
"(",
"$",
"relationTable",
",",
"\"rel.{$rfk} = {$table}.{$pmk}\"",
",",
"null",
",",
"'rel'",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the join table to the query
@param Select $query
@return self | [
"Adds",
"the",
"join",
"table",
"to",
"the",
"query"
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/HasAndBelongsToMany.php#L199-L212 |
11,945 | jaredtking/jaqb | src/Query/SelectQuery.php | SelectQuery.groupBy | public function groupBy($fields, $direction = false)
{
$this->groupBy->addFields($fields, $direction);
return $this;
} | php | public function groupBy($fields, $direction = false)
{
$this->groupBy->addFields($fields, $direction);
return $this;
} | [
"public",
"function",
"groupBy",
"(",
"$",
"fields",
",",
"$",
"direction",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"groupBy",
"->",
"addFields",
"(",
"$",
"fields",
",",
"$",
"direction",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the group by fields for the query.
@param string|array $fields
@param string $direction
@return self | [
"Sets",
"the",
"group",
"by",
"fields",
"for",
"the",
"query",
"."
] | 04a853b530fcc12a9863349d3d0da6377d1b9995 | https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/SelectQuery.php#L177-L182 |
11,946 | jaredtking/jaqb | src/Query/SelectQuery.php | SelectQuery.having | public function having($field, $condition = false, $operator = '=')
{
if (func_num_args() >= 2) {
$this->having->addCondition($field, $condition, $operator);
} else {
$this->having->addCondition($field);
}
return $this;
} | php | public function having($field, $condition = false, $operator = '=')
{
if (func_num_args() >= 2) {
$this->having->addCondition($field, $condition, $operator);
} else {
$this->having->addCondition($field);
}
return $this;
} | [
"public",
"function",
"having",
"(",
"$",
"field",
",",
"$",
"condition",
"=",
"false",
",",
"$",
"operator",
"=",
"'='",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">=",
"2",
")",
"{",
"$",
"this",
"->",
"having",
"->",
"addCondition",
"(",
"$",
"field",
",",
"$",
"condition",
",",
"$",
"operator",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"having",
"->",
"addCondition",
"(",
"$",
"field",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the having conditions for the query.
@param array|string $field
@param string|bool $condition condition value (optional)
@param string $operator operator (optional)
@return self | [
"Sets",
"the",
"having",
"conditions",
"for",
"the",
"query",
"."
] | 04a853b530fcc12a9863349d3d0da6377d1b9995 | https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/SelectQuery.php#L193-L202 |
11,947 | jaredtking/jaqb | src/Query/SelectQuery.php | SelectQuery.union | public function union(self $query, $type = '')
{
$this->union->addQuery($query, $type);
return $this;
} | php | public function union(self $query, $type = '')
{
$this->union->addQuery($query, $type);
return $this;
} | [
"public",
"function",
"union",
"(",
"self",
"$",
"query",
",",
"$",
"type",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"union",
"->",
"addQuery",
"(",
"$",
"query",
",",
"$",
"type",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Unions another select query with this query.
@param SelectQuery $query
@param string $type optional union type
@return self | [
"Unions",
"another",
"select",
"query",
"with",
"this",
"query",
"."
] | 04a853b530fcc12a9863349d3d0da6377d1b9995 | https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/SelectQuery.php#L212-L217 |
11,948 | open-orchestra/open-orchestra-media-file-bundle | MediaFileBundle/Controller/MediaController.php | MediaController.getAction | public function getAction($key)
{
$mediaStorageManager = $this->get('open_orchestra_media_file.manager.storage');
$fileContent = $mediaStorageManager->getFileContent($key);
$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_buffer($finfo, $fileContent);
finfo_close($finfo);
$response = new Response();
$response->headers->set('Content-Type', $mimetype);
$response->headers->set('Content-Length', strlen($fileContent));
$response->setContent($fileContent);
$response->setPublic();
$response->setMaxAge(2629743);
$date = new \DateTime();
$date->modify('+'.$response->getMaxAge().' seconds');
$response->setExpires($date);
return $response;
} | php | public function getAction($key)
{
$mediaStorageManager = $this->get('open_orchestra_media_file.manager.storage');
$fileContent = $mediaStorageManager->getFileContent($key);
$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_buffer($finfo, $fileContent);
finfo_close($finfo);
$response = new Response();
$response->headers->set('Content-Type', $mimetype);
$response->headers->set('Content-Length', strlen($fileContent));
$response->setContent($fileContent);
$response->setPublic();
$response->setMaxAge(2629743);
$date = new \DateTime();
$date->modify('+'.$response->getMaxAge().' seconds');
$response->setExpires($date);
return $response;
} | [
"public",
"function",
"getAction",
"(",
"$",
"key",
")",
"{",
"$",
"mediaStorageManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'open_orchestra_media_file.manager.storage'",
")",
";",
"$",
"fileContent",
"=",
"$",
"mediaStorageManager",
"->",
"getFileContent",
"(",
"$",
"key",
")",
";",
"$",
"finfo",
"=",
"finfo_open",
"(",
"FILEINFO_MIME",
")",
";",
"$",
"mimetype",
"=",
"finfo_buffer",
"(",
"$",
"finfo",
",",
"$",
"fileContent",
")",
";",
"finfo_close",
"(",
"$",
"finfo",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Content-Type'",
",",
"$",
"mimetype",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Content-Length'",
",",
"strlen",
"(",
"$",
"fileContent",
")",
")",
";",
"$",
"response",
"->",
"setContent",
"(",
"$",
"fileContent",
")",
";",
"$",
"response",
"->",
"setPublic",
"(",
")",
";",
"$",
"response",
"->",
"setMaxAge",
"(",
"2629743",
")",
";",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"date",
"->",
"modify",
"(",
"'+'",
".",
"$",
"response",
"->",
"getMaxAge",
"(",
")",
".",
"' seconds'",
")",
";",
"$",
"response",
"->",
"setExpires",
"(",
"$",
"date",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Send a media stored via the UploadedFileManager
@Config\Route("/{key}", name="open_orchestra_media_get")
@Config\Method({"GET"})
@return Response | [
"Send",
"a",
"media",
"stored",
"via",
"the",
"UploadedFileManager"
] | fa3d2c5332182236937e204fa74e84fefa077204 | https://github.com/open-orchestra/open-orchestra-media-file-bundle/blob/fa3d2c5332182236937e204fa74e84fefa077204/MediaFileBundle/Controller/MediaController.php#L22-L42 |
11,949 | jnjxp/html | src/Helper/Modal.php | Modal.resetProperties | protected function resetProperties()
{
$this->effect = 'fade';
$this->titleTag = 'h4';
$this->button = [];
$this->attr = [];
$this->title = null;
$this->body = null;
$this->footer = null;
$this->html = '';
} | php | protected function resetProperties()
{
$this->effect = 'fade';
$this->titleTag = 'h4';
$this->button = [];
$this->attr = [];
$this->title = null;
$this->body = null;
$this->footer = null;
$this->html = '';
} | [
"protected",
"function",
"resetProperties",
"(",
")",
"{",
"$",
"this",
"->",
"effect",
"=",
"'fade'",
";",
"$",
"this",
"->",
"titleTag",
"=",
"'h4'",
";",
"$",
"this",
"->",
"button",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"attr",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"title",
"=",
"null",
";",
"$",
"this",
"->",
"body",
"=",
"null",
";",
"$",
"this",
"->",
"footer",
"=",
"null",
";",
"$",
"this",
"->",
"html",
"=",
"''",
";",
"}"
] | reset properties of modal
@return void
@access protected | [
"reset",
"properties",
"of",
"modal"
] | a38f130c19ab0a60ea52bc1d2560a68d2048d292 | https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Modal.php#L185-L195 |
11,950 | jnjxp/html | src/Helper/Modal.php | Modal.buildButton | protected function buildButton()
{
list($content, $attr) = $this->button;
$mid = $this->attr['id'];
$attr = $this->escaper->attr(
array_merge_recursive(
$attr,
[
'type' => 'button',
'data-toggle' => 'modal',
'data-target' => "#{$mid}"
]
)
);
$this->html .= $this->indent(0, "<button $attr>");
$this->html .= $this->indent(1, $content);
$this->html .= $this->indent(0, '</button>');
} | php | protected function buildButton()
{
list($content, $attr) = $this->button;
$mid = $this->attr['id'];
$attr = $this->escaper->attr(
array_merge_recursive(
$attr,
[
'type' => 'button',
'data-toggle' => 'modal',
'data-target' => "#{$mid}"
]
)
);
$this->html .= $this->indent(0, "<button $attr>");
$this->html .= $this->indent(1, $content);
$this->html .= $this->indent(0, '</button>');
} | [
"protected",
"function",
"buildButton",
"(",
")",
"{",
"list",
"(",
"$",
"content",
",",
"$",
"attr",
")",
"=",
"$",
"this",
"->",
"button",
";",
"$",
"mid",
"=",
"$",
"this",
"->",
"attr",
"[",
"'id'",
"]",
";",
"$",
"attr",
"=",
"$",
"this",
"->",
"escaper",
"->",
"attr",
"(",
"array_merge_recursive",
"(",
"$",
"attr",
",",
"[",
"'type'",
"=>",
"'button'",
",",
"'data-toggle'",
"=>",
"'modal'",
",",
"'data-target'",
"=>",
"\"#{$mid}\"",
"]",
")",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"0",
",",
"\"<button $attr>\"",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"1",
",",
"$",
"content",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"0",
",",
"'</button>'",
")",
";",
"}"
] | build modal launch button
@return void
@access protected | [
"build",
"modal",
"launch",
"button"
] | a38f130c19ab0a60ea52bc1d2560a68d2048d292 | https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Modal.php#L204-L224 |
11,951 | jnjxp/html | src/Helper/Modal.php | Modal.buildHeader | protected function buildHeader()
{
$close = '<button type="button" class="close" data-dismiss="modal" '
. 'aria-label="Close"><span aria-hidden="true">×</span></button>';
$tag = $this->titleTag;
$tid = $this->attr['id'] . '-label';
$ttl = $this->title;
$title = "<${tag} class=\"modal-title\" id=\"$tid\">{$ttl}</{$tag}>";
$this->html .= $this->indent(3, '<div class="modal-header">');
$this->html .= $this->indent(4, $close);
$this->html .= $this->indent(4, $title);
$this->html .= $this->indent(3, '</div>');
} | php | protected function buildHeader()
{
$close = '<button type="button" class="close" data-dismiss="modal" '
. 'aria-label="Close"><span aria-hidden="true">×</span></button>';
$tag = $this->titleTag;
$tid = $this->attr['id'] . '-label';
$ttl = $this->title;
$title = "<${tag} class=\"modal-title\" id=\"$tid\">{$ttl}</{$tag}>";
$this->html .= $this->indent(3, '<div class="modal-header">');
$this->html .= $this->indent(4, $close);
$this->html .= $this->indent(4, $title);
$this->html .= $this->indent(3, '</div>');
} | [
"protected",
"function",
"buildHeader",
"(",
")",
"{",
"$",
"close",
"=",
"'<button type=\"button\" class=\"close\" data-dismiss=\"modal\" '",
".",
"'aria-label=\"Close\"><span aria-hidden=\"true\">×</span></button>'",
";",
"$",
"tag",
"=",
"$",
"this",
"->",
"titleTag",
";",
"$",
"tid",
"=",
"$",
"this",
"->",
"attr",
"[",
"'id'",
"]",
".",
"'-label'",
";",
"$",
"ttl",
"=",
"$",
"this",
"->",
"title",
";",
"$",
"title",
"=",
"\"<${tag} class=\\\"modal-title\\\" id=\\\"$tid\\\">{$ttl}</{$tag}>\"",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"3",
",",
"'<div class=\"modal-header\">'",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"4",
",",
"$",
"close",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"4",
",",
"$",
"title",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"3",
",",
"'</div>'",
")",
";",
"}"
] | build modal header
@return void
@access protected | [
"build",
"modal",
"header"
] | a38f130c19ab0a60ea52bc1d2560a68d2048d292 | https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Modal.php#L233-L249 |
11,952 | jnjxp/html | src/Helper/Modal.php | Modal.buildBody | protected function buildBody()
{
$this->html .= $this->indent(3, '<div class="modal-body">');
$this->html .= $this->indent(4, $this->body);
$this->html .= $this->indent(3, '</div>');
} | php | protected function buildBody()
{
$this->html .= $this->indent(3, '<div class="modal-body">');
$this->html .= $this->indent(4, $this->body);
$this->html .= $this->indent(3, '</div>');
} | [
"protected",
"function",
"buildBody",
"(",
")",
"{",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"3",
",",
"'<div class=\"modal-body\">'",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"4",
",",
"$",
"this",
"->",
"body",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"3",
",",
"'</div>'",
")",
";",
"}"
] | build modal body
@return void
@access protected | [
"build",
"modal",
"body"
] | a38f130c19ab0a60ea52bc1d2560a68d2048d292 | https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Modal.php#L258-L263 |
11,953 | jnjxp/html | src/Helper/Modal.php | Modal.buildFooter | protected function buildFooter()
{
if (! $this->footer) {
return;
}
$this->html .= $this->indent(3, '<div class="modal-footer">');
$this->html .= $this->indent(4, $this->footer);
$this->html .= $this->indent(3, '</div>');
} | php | protected function buildFooter()
{
if (! $this->footer) {
return;
}
$this->html .= $this->indent(3, '<div class="modal-footer">');
$this->html .= $this->indent(4, $this->footer);
$this->html .= $this->indent(3, '</div>');
} | [
"protected",
"function",
"buildFooter",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"footer",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"3",
",",
"'<div class=\"modal-footer\">'",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"4",
",",
"$",
"this",
"->",
"footer",
")",
";",
"$",
"this",
"->",
"html",
".=",
"$",
"this",
"->",
"indent",
"(",
"3",
",",
"'</div>'",
")",
";",
"}"
] | build modal footer if set
@return void
@access protected | [
"build",
"modal",
"footer",
"if",
"set"
] | a38f130c19ab0a60ea52bc1d2560a68d2048d292 | https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Modal.php#L272-L281 |
11,954 | jnjxp/html | src/Helper/Modal.php | Modal.setButton | public function setButton($content, array $attr = [])
{
if (is_array($content)) {
$attr = $content[1];
$content = $content[0];
}
$this->button = [
$content, $attr
];
return $this;
} | php | public function setButton($content, array $attr = [])
{
if (is_array($content)) {
$attr = $content[1];
$content = $content[0];
}
$this->button = [
$content, $attr
];
return $this;
} | [
"public",
"function",
"setButton",
"(",
"$",
"content",
",",
"array",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"$",
"attr",
"=",
"$",
"content",
"[",
"1",
"]",
";",
"$",
"content",
"=",
"$",
"content",
"[",
"0",
"]",
";",
"}",
"$",
"this",
"->",
"button",
"=",
"[",
"$",
"content",
",",
"$",
"attr",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | set button properties
@param string $content content of button
@param array $attr button attributes
@return Modal
@access public | [
"set",
"button",
"properties"
] | a38f130c19ab0a60ea52bc1d2560a68d2048d292 | https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Modal.php#L368-L380 |
11,955 | jnjxp/html | src/Helper/Modal.php | Modal.setSpec | public function setSpec(array $spec)
{
foreach ($spec as $key => $value) {
$method = 'set' . ucfirst($key);
if (method_exists($this, $method)) {
$this->$method($value);
}
}
return $this;
} | php | public function setSpec(array $spec)
{
foreach ($spec as $key => $value) {
$method = 'set' . ucfirst($key);
if (method_exists($this, $method)) {
$this->$method($value);
}
}
return $this;
} | [
"public",
"function",
"setSpec",
"(",
"array",
"$",
"spec",
")",
"{",
"foreach",
"(",
"$",
"spec",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | set modal specs. Call setters based on array.
@param array $spec array specification
@return Modal
@access public | [
"set",
"modal",
"specs",
".",
"Call",
"setters",
"based",
"on",
"array",
"."
] | a38f130c19ab0a60ea52bc1d2560a68d2048d292 | https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Modal.php#L409-L418 |
11,956 | phower/container | src/ContainerFactory.php | ContainerFactory.create | public static function create(array $config = [])
{
$container = new Container();
foreach (self::$booleanSetters as $key => $method) {
if (isset($config[$key])) {
$container->$method((bool) $config[$key]);
}
}
foreach (self::$arraySetters as $key => $method) {
if (isset($config[$key]) && is_array($config[$key])) {
foreach ($config[$key] as $name => $value) {
$container->$method($name, $value);
}
}
}
if (isset($config[Container::CONFIG_ENTRIES]) && is_array($config[Container::CONFIG_ENTRIES])) {
self::createEntries($container, $config[Container::CONFIG_ENTRIES]);
}
return $container;
} | php | public static function create(array $config = [])
{
$container = new Container();
foreach (self::$booleanSetters as $key => $method) {
if (isset($config[$key])) {
$container->$method((bool) $config[$key]);
}
}
foreach (self::$arraySetters as $key => $method) {
if (isset($config[$key]) && is_array($config[$key])) {
foreach ($config[$key] as $name => $value) {
$container->$method($name, $value);
}
}
}
if (isset($config[Container::CONFIG_ENTRIES]) && is_array($config[Container::CONFIG_ENTRIES])) {
self::createEntries($container, $config[Container::CONFIG_ENTRIES]);
}
return $container;
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"container",
"=",
"new",
"Container",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"booleanSetters",
"as",
"$",
"key",
"=>",
"$",
"method",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"container",
"->",
"$",
"method",
"(",
"(",
"bool",
")",
"$",
"config",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"foreach",
"(",
"self",
"::",
"$",
"arraySetters",
"as",
"$",
"key",
"=>",
"$",
"method",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"$",
"key",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"$",
"key",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"$",
"key",
"]",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"container",
"->",
"$",
"method",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"Container",
"::",
"CONFIG_ENTRIES",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"Container",
"::",
"CONFIG_ENTRIES",
"]",
")",
")",
"{",
"self",
"::",
"createEntries",
"(",
"$",
"container",
",",
"$",
"config",
"[",
"Container",
"::",
"CONFIG_ENTRIES",
"]",
")",
";",
"}",
"return",
"$",
"container",
";",
"}"
] | Static factory method to create a new container
@param array $config
@return \Phower\Container\Container | [
"Static",
"factory",
"method",
"to",
"create",
"a",
"new",
"container"
] | 25326726ddbac9f382e1a56b68e0f54483bbd392 | https://github.com/phower/container/blob/25326726ddbac9f382e1a56b68e0f54483bbd392/src/ContainerFactory.php#L74-L97 |
11,957 | phower/container | src/ContainerFactory.php | ContainerFactory.createEntries | protected static function createEntries(Container $container, array $entries)
{
$defaultShared = $container->isSharedByDefault();
foreach ($entries as $entry) {
foreach (self::$requiredEntryKeys as $key) {
if (!isset($entry[$key])) {
$message = sprintf('Missing required entry key "%s" in "%s".', $key, __METHOD__);
throw new Exception\InvalidArgumentException($message);
}
}
if (!in_array($entry[ContainerInterface::CONFIG_ENTRY_TYPE], self::$entryTypes)) {
throw new Exception\InvalidArgumentException(sprintf(
'Value "%s" for "%s" is not valid; it must be one of "%s" in "%s".',
$entry[ContainerInterface::CONFIG_ENTRY_TYPE],
$key,
implode(', ', self::$types),
__METHOD__
));
}
$shared = isset($entry[ContainerInterface::CONFIG_ENTRY_SHARED]) ? (bool) $entry[ContainerInterface::CONFIG_ENTRY_SHARED] : $defaultShared;
$container->add($entry[ContainerInterface::CONFIG_ENTRY_NAME], $entry[ContainerInterface::CONFIG_ENTRY_VALUE], $entry[ContainerInterface::CONFIG_ENTRY_TYPE], $shared);
}
} | php | protected static function createEntries(Container $container, array $entries)
{
$defaultShared = $container->isSharedByDefault();
foreach ($entries as $entry) {
foreach (self::$requiredEntryKeys as $key) {
if (!isset($entry[$key])) {
$message = sprintf('Missing required entry key "%s" in "%s".', $key, __METHOD__);
throw new Exception\InvalidArgumentException($message);
}
}
if (!in_array($entry[ContainerInterface::CONFIG_ENTRY_TYPE], self::$entryTypes)) {
throw new Exception\InvalidArgumentException(sprintf(
'Value "%s" for "%s" is not valid; it must be one of "%s" in "%s".',
$entry[ContainerInterface::CONFIG_ENTRY_TYPE],
$key,
implode(', ', self::$types),
__METHOD__
));
}
$shared = isset($entry[ContainerInterface::CONFIG_ENTRY_SHARED]) ? (bool) $entry[ContainerInterface::CONFIG_ENTRY_SHARED] : $defaultShared;
$container->add($entry[ContainerInterface::CONFIG_ENTRY_NAME], $entry[ContainerInterface::CONFIG_ENTRY_VALUE], $entry[ContainerInterface::CONFIG_ENTRY_TYPE], $shared);
}
} | [
"protected",
"static",
"function",
"createEntries",
"(",
"Container",
"$",
"container",
",",
"array",
"$",
"entries",
")",
"{",
"$",
"defaultShared",
"=",
"$",
"container",
"->",
"isSharedByDefault",
"(",
")",
";",
"foreach",
"(",
"$",
"entries",
"as",
"$",
"entry",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"requiredEntryKeys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entry",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Missing required entry key \"%s\" in \"%s\".'",
",",
"$",
"key",
",",
"__METHOD__",
")",
";",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"$",
"message",
")",
";",
"}",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"entry",
"[",
"ContainerInterface",
"::",
"CONFIG_ENTRY_TYPE",
"]",
",",
"self",
"::",
"$",
"entryTypes",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Value \"%s\" for \"%s\" is not valid; it must be one of \"%s\" in \"%s\".'",
",",
"$",
"entry",
"[",
"ContainerInterface",
"::",
"CONFIG_ENTRY_TYPE",
"]",
",",
"$",
"key",
",",
"implode",
"(",
"', '",
",",
"self",
"::",
"$",
"types",
")",
",",
"__METHOD__",
")",
")",
";",
"}",
"$",
"shared",
"=",
"isset",
"(",
"$",
"entry",
"[",
"ContainerInterface",
"::",
"CONFIG_ENTRY_SHARED",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"entry",
"[",
"ContainerInterface",
"::",
"CONFIG_ENTRY_SHARED",
"]",
":",
"$",
"defaultShared",
";",
"$",
"container",
"->",
"add",
"(",
"$",
"entry",
"[",
"ContainerInterface",
"::",
"CONFIG_ENTRY_NAME",
"]",
",",
"$",
"entry",
"[",
"ContainerInterface",
"::",
"CONFIG_ENTRY_VALUE",
"]",
",",
"$",
"entry",
"[",
"ContainerInterface",
"::",
"CONFIG_ENTRY_TYPE",
"]",
",",
"$",
"shared",
")",
";",
"}",
"}"
] | Create entries.
@param \Phower\Container\Container $container
@param array $entries
@throws Exception\InvalidArgumentException | [
"Create",
"entries",
"."
] | 25326726ddbac9f382e1a56b68e0f54483bbd392 | https://github.com/phower/container/blob/25326726ddbac9f382e1a56b68e0f54483bbd392/src/ContainerFactory.php#L106-L132 |
11,958 | colorium/runtime | src/Colorium/Runtime/Annotation.php | Annotation.parser | public static function parser(ParserInterface $parser = null)
{
if($parser) {
static::$parser = $parser;
}
elseif(!static::$parser) {
static::$parser = new Annotation\KeyValuePairParser;
}
return static::$parser;
} | php | public static function parser(ParserInterface $parser = null)
{
if($parser) {
static::$parser = $parser;
}
elseif(!static::$parser) {
static::$parser = new Annotation\KeyValuePairParser;
}
return static::$parser;
} | [
"public",
"static",
"function",
"parser",
"(",
"ParserInterface",
"$",
"parser",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parser",
")",
"{",
"static",
"::",
"$",
"parser",
"=",
"$",
"parser",
";",
"}",
"elseif",
"(",
"!",
"static",
"::",
"$",
"parser",
")",
"{",
"static",
"::",
"$",
"parser",
"=",
"new",
"Annotation",
"\\",
"KeyValuePairParser",
";",
"}",
"return",
"static",
"::",
"$",
"parser",
";",
"}"
] | Load annotation parser
@param ParserInterface $parser
@return ParserInterface | [
"Load",
"annotation",
"parser"
] | 8905bb7370aa6aa5c89494aa020a2922d8feb32d | https://github.com/colorium/runtime/blob/8905bb7370aa6aa5c89494aa020a2922d8feb32d/src/Colorium/Runtime/Annotation.php#L24-L34 |
11,959 | colorium/runtime | src/Colorium/Runtime/Annotation.php | Annotation.cache | public static function cache(CacheInterface $cache = null)
{
if($cache) {
static::$cache = $cache;
}
elseif(!static::$cache) {
static::$cache = new Annotation\EphemeralCache;
}
return static::$cache;
} | php | public static function cache(CacheInterface $cache = null)
{
if($cache) {
static::$cache = $cache;
}
elseif(!static::$cache) {
static::$cache = new Annotation\EphemeralCache;
}
return static::$cache;
} | [
"public",
"static",
"function",
"cache",
"(",
"CacheInterface",
"$",
"cache",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"cache",
")",
"{",
"static",
"::",
"$",
"cache",
"=",
"$",
"cache",
";",
"}",
"elseif",
"(",
"!",
"static",
"::",
"$",
"cache",
")",
"{",
"static",
"::",
"$",
"cache",
"=",
"new",
"Annotation",
"\\",
"EphemeralCache",
";",
"}",
"return",
"static",
"::",
"$",
"cache",
";",
"}"
] | Load annotation cache strategy
@param CacheInterface $cache
@return CacheInterface | [
"Load",
"annotation",
"cache",
"strategy"
] | 8905bb7370aa6aa5c89494aa020a2922d8feb32d | https://github.com/colorium/runtime/blob/8905bb7370aa6aa5c89494aa020a2922d8feb32d/src/Colorium/Runtime/Annotation.php#L43-L53 |
11,960 | colorium/runtime | src/Colorium/Runtime/Annotation.php | Annotation.ofClass | public static function ofClass($class, $key = null)
{
$reflector = is_object($class) ? new \ReflectionObject($class) : new \ReflectionClass($class);
if(!static::cache()->hasClass($reflector->getName())) {
$annotations = static::parser()->parse($reflector->getDocComment());
static::cache()->storeClass($reflector->getName(), $annotations);
}
else {
$annotations = static::cache()->getClass($reflector->getName());
}
if($key) {
return isset($annotations[$key]) ? $annotations[$key] : null;
}
return $annotations;
} | php | public static function ofClass($class, $key = null)
{
$reflector = is_object($class) ? new \ReflectionObject($class) : new \ReflectionClass($class);
if(!static::cache()->hasClass($reflector->getName())) {
$annotations = static::parser()->parse($reflector->getDocComment());
static::cache()->storeClass($reflector->getName(), $annotations);
}
else {
$annotations = static::cache()->getClass($reflector->getName());
}
if($key) {
return isset($annotations[$key]) ? $annotations[$key] : null;
}
return $annotations;
} | [
"public",
"static",
"function",
"ofClass",
"(",
"$",
"class",
",",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"reflector",
"=",
"is_object",
"(",
"$",
"class",
")",
"?",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"class",
")",
":",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"static",
"::",
"cache",
"(",
")",
"->",
"hasClass",
"(",
"$",
"reflector",
"->",
"getName",
"(",
")",
")",
")",
"{",
"$",
"annotations",
"=",
"static",
"::",
"parser",
"(",
")",
"->",
"parse",
"(",
"$",
"reflector",
"->",
"getDocComment",
"(",
")",
")",
";",
"static",
"::",
"cache",
"(",
")",
"->",
"storeClass",
"(",
"$",
"reflector",
"->",
"getName",
"(",
")",
",",
"$",
"annotations",
")",
";",
"}",
"else",
"{",
"$",
"annotations",
"=",
"static",
"::",
"cache",
"(",
")",
"->",
"getClass",
"(",
"$",
"reflector",
"->",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"annotations",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"annotations",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}",
"return",
"$",
"annotations",
";",
"}"
] | Parse class annotations
@param $class
@param string $key
@return array | [
"Parse",
"class",
"annotations"
] | 8905bb7370aa6aa5c89494aa020a2922d8feb32d | https://github.com/colorium/runtime/blob/8905bb7370aa6aa5c89494aa020a2922d8feb32d/src/Colorium/Runtime/Annotation.php#L63-L80 |
11,961 | osflab/view | Helper/Bootstrap/Markdown.php | Markdown.renderText | public function renderText($text, bool $escape = true): string
{
if ($escape) {
$text = $this->esc($text);
}
return (string) Container::getMarkdown()->text((string) $text);
} | php | public function renderText($text, bool $escape = true): string
{
if ($escape) {
$text = $this->esc($text);
}
return (string) Container::getMarkdown()->text((string) $text);
} | [
"public",
"function",
"renderText",
"(",
"$",
"text",
",",
"bool",
"$",
"escape",
"=",
"true",
")",
":",
"string",
"{",
"if",
"(",
"$",
"escape",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"esc",
"(",
"$",
"text",
")",
";",
"}",
"return",
"(",
"string",
")",
"Container",
"::",
"getMarkdown",
"(",
")",
"->",
"text",
"(",
"(",
"string",
")",
"$",
"text",
")",
";",
"}"
] | Render text content
@param string $text
@return string | [
"Render",
"text",
"content"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Markdown.php#L91-L97 |
11,962 | osflab/view | Helper/Bootstrap/Markdown.php | Markdown.getMetaContent | protected function getMetaContent()
{
if ($this->mdFile && !file_exists($this->mdFile)) {
throw new ArchException('Wrong markdown file [' . $this->mdFile . ']');
}
if ($this->mdFile && !$this->getContent()) {
return Container::getMarkdown()->file($this->mdFile, $this->separator);
} else {
$txt = '';
if ($this->mdFile) {
$txt .= file_get_contents($this->mdFile);
}
if ($this->getContent()) {
$txt .= "\n" . $this->getContent();
}
return Container::getMarkdown()->txt($txt, $this->separator);
}
} | php | protected function getMetaContent()
{
if ($this->mdFile && !file_exists($this->mdFile)) {
throw new ArchException('Wrong markdown file [' . $this->mdFile . ']');
}
if ($this->mdFile && !$this->getContent()) {
return Container::getMarkdown()->file($this->mdFile, $this->separator);
} else {
$txt = '';
if ($this->mdFile) {
$txt .= file_get_contents($this->mdFile);
}
if ($this->getContent()) {
$txt .= "\n" . $this->getContent();
}
return Container::getMarkdown()->txt($txt, $this->separator);
}
} | [
"protected",
"function",
"getMetaContent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mdFile",
"&&",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"mdFile",
")",
")",
"{",
"throw",
"new",
"ArchException",
"(",
"'Wrong markdown file ['",
".",
"$",
"this",
"->",
"mdFile",
".",
"']'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mdFile",
"&&",
"!",
"$",
"this",
"->",
"getContent",
"(",
")",
")",
"{",
"return",
"Container",
"::",
"getMarkdown",
"(",
")",
"->",
"file",
"(",
"$",
"this",
"->",
"mdFile",
",",
"$",
"this",
"->",
"separator",
")",
";",
"}",
"else",
"{",
"$",
"txt",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"mdFile",
")",
"{",
"$",
"txt",
".=",
"file_get_contents",
"(",
"$",
"this",
"->",
"mdFile",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getContent",
"(",
")",
")",
"{",
"$",
"txt",
".=",
"\"\\n\"",
".",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"}",
"return",
"Container",
"::",
"getMarkdown",
"(",
")",
"->",
"txt",
"(",
"$",
"txt",
",",
"$",
"this",
"->",
"separator",
")",
";",
"}",
"}"
] | If file and text, append file and text
@return type
@throws ArchException | [
"If",
"file",
"and",
"text",
"append",
"file",
"and",
"text"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Markdown.php#L104-L121 |
11,963 | reflex-php/lockdown | src/Reflex/Lockdown/Users/Eloquent/User.php | User.has | public function has($permissions, $all = true)
{
if (! is_array($permissions)) {
$permissions = (array) $permissions;
}
$permissions= array_unique($permissions);
$filtered = [];
$usersRoles = $this->roles;
$allowed = false;
$filtered = array_where($permissions, [$this, 'permissionFilter']);
$filteredCount = count($filtered);
// Does the permission lookup require all permissions to be found?
if (true === $all) {
return count($permissions) === $filteredCount;
}
// Nope, just as long as they have one of them
return 0 < $filteredCount;
} | php | public function has($permissions, $all = true)
{
if (! is_array($permissions)) {
$permissions = (array) $permissions;
}
$permissions= array_unique($permissions);
$filtered = [];
$usersRoles = $this->roles;
$allowed = false;
$filtered = array_where($permissions, [$this, 'permissionFilter']);
$filteredCount = count($filtered);
// Does the permission lookup require all permissions to be found?
if (true === $all) {
return count($permissions) === $filteredCount;
}
// Nope, just as long as they have one of them
return 0 < $filteredCount;
} | [
"public",
"function",
"has",
"(",
"$",
"permissions",
",",
"$",
"all",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"permissions",
")",
")",
"{",
"$",
"permissions",
"=",
"(",
"array",
")",
"$",
"permissions",
";",
"}",
"$",
"permissions",
"=",
"array_unique",
"(",
"$",
"permissions",
")",
";",
"$",
"filtered",
"=",
"[",
"]",
";",
"$",
"usersRoles",
"=",
"$",
"this",
"->",
"roles",
";",
"$",
"allowed",
"=",
"false",
";",
"$",
"filtered",
"=",
"array_where",
"(",
"$",
"permissions",
",",
"[",
"$",
"this",
",",
"'permissionFilter'",
"]",
")",
";",
"$",
"filteredCount",
"=",
"count",
"(",
"$",
"filtered",
")",
";",
"// Does the permission lookup require all permissions to be found?",
"if",
"(",
"true",
"===",
"$",
"all",
")",
"{",
"return",
"count",
"(",
"$",
"permissions",
")",
"===",
"$",
"filteredCount",
";",
"}",
"// Nope, just as long as they have one of them",
"return",
"0",
"<",
"$",
"filteredCount",
";",
"}"
] | Does the user have the permission?
@param string|array $permissions Permission to lookup
@return boolean | [
"Does",
"the",
"user",
"have",
"the",
"permission?"
] | 2798e448608eef469f2924d75013deccfd6aca44 | https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Users/Eloquent/User.php#L212-L232 |
11,964 | reflex-php/lockdown | src/Reflex/Lockdown/Users/Eloquent/User.php | User.give | public function give(PermissionInterface $permission, $level = 'allow')
{
$current = $this->getPermission($permission->key);
if (isset($current)) {
if ($current->level === $level) {
return true;
}
$this->remove($permission);
}
$this->removeFromLocalCache($permission->key);
$this->permissions()->attach($permission, compact('level'));
return false === is_null($this->getPermission($permission));
} | php | public function give(PermissionInterface $permission, $level = 'allow')
{
$current = $this->getPermission($permission->key);
if (isset($current)) {
if ($current->level === $level) {
return true;
}
$this->remove($permission);
}
$this->removeFromLocalCache($permission->key);
$this->permissions()->attach($permission, compact('level'));
return false === is_null($this->getPermission($permission));
} | [
"public",
"function",
"give",
"(",
"PermissionInterface",
"$",
"permission",
",",
"$",
"level",
"=",
"'allow'",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"getPermission",
"(",
"$",
"permission",
"->",
"key",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"current",
")",
")",
"{",
"if",
"(",
"$",
"current",
"->",
"level",
"===",
"$",
"level",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"remove",
"(",
"$",
"permission",
")",
";",
"}",
"$",
"this",
"->",
"removeFromLocalCache",
"(",
"$",
"permission",
"->",
"key",
")",
";",
"$",
"this",
"->",
"permissions",
"(",
")",
"->",
"attach",
"(",
"$",
"permission",
",",
"compact",
"(",
"'level'",
")",
")",
";",
"return",
"false",
"===",
"is_null",
"(",
"$",
"this",
"->",
"getPermission",
"(",
"$",
"permission",
")",
")",
";",
"}"
] | Give a permission to the user
@param PermissionInterface $permission
@param string $level
@return boolean | [
"Give",
"a",
"permission",
"to",
"the",
"user"
] | 2798e448608eef469f2924d75013deccfd6aca44 | https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Users/Eloquent/User.php#L266-L281 |
11,965 | reflex-php/lockdown | src/Reflex/Lockdown/Users/Eloquent/User.php | User.remove | public function remove(PermissionInterface $permission)
{
$this->removeFromLocalCache($permission->key);
if (! is_null($this->getPermission($permission))) {
$this->permissions()
->detach($permission);
}
return true;
} | php | public function remove(PermissionInterface $permission)
{
$this->removeFromLocalCache($permission->key);
if (! is_null($this->getPermission($permission))) {
$this->permissions()
->detach($permission);
}
return true;
} | [
"public",
"function",
"remove",
"(",
"PermissionInterface",
"$",
"permission",
")",
"{",
"$",
"this",
"->",
"removeFromLocalCache",
"(",
"$",
"permission",
"->",
"key",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getPermission",
"(",
"$",
"permission",
")",
")",
")",
"{",
"$",
"this",
"->",
"permissions",
"(",
")",
"->",
"detach",
"(",
"$",
"permission",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Remove a permission from the user
@param PermissionInterface $permission
@return boolean | [
"Remove",
"a",
"permission",
"from",
"the",
"user"
] | 2798e448608eef469f2924d75013deccfd6aca44 | https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Users/Eloquent/User.php#L288-L298 |
11,966 | reflex-php/lockdown | src/Reflex/Lockdown/Users/Eloquent/User.php | User.join | public function join(RoleInterface $role)
{
$this->roles()
->attach($role);
return $this->is($role);
} | php | public function join(RoleInterface $role)
{
$this->roles()
->attach($role);
return $this->is($role);
} | [
"public",
"function",
"join",
"(",
"RoleInterface",
"$",
"role",
")",
"{",
"$",
"this",
"->",
"roles",
"(",
")",
"->",
"attach",
"(",
"$",
"role",
")",
";",
"return",
"$",
"this",
"->",
"is",
"(",
"$",
"role",
")",
";",
"}"
] | Join a role
@param RoleInterface $role
@return boolean | [
"Join",
"a",
"role"
] | 2798e448608eef469f2924d75013deccfd6aca44 | https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Users/Eloquent/User.php#L305-L311 |
11,967 | reflex-php/lockdown | src/Reflex/Lockdown/Users/Eloquent/User.php | User.leave | public function leave(RoleInterface $role)
{
$this->roles()
->detach($role);
return $this->isnt($role);
} | php | public function leave(RoleInterface $role)
{
$this->roles()
->detach($role);
return $this->isnt($role);
} | [
"public",
"function",
"leave",
"(",
"RoleInterface",
"$",
"role",
")",
"{",
"$",
"this",
"->",
"roles",
"(",
")",
"->",
"detach",
"(",
"$",
"role",
")",
";",
"return",
"$",
"this",
"->",
"isnt",
"(",
"$",
"role",
")",
";",
"}"
] | Leave a role
@param RoleInterface $role
@return boolean | [
"Leave",
"a",
"role"
] | 2798e448608eef469f2924d75013deccfd6aca44 | https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Users/Eloquent/User.php#L318-L324 |
11,968 | webriq/core | module/Core/src/Grid/Core/Controller/UploadController.php | UploadController.getValidators | protected function getValidators( $types )
{
$validators = array();
if ( 'image/*' == $types )
{
$validators[] = array(
'name' => 'Zend\Validator\File\IsImage',
);
}
else if ( ! empty( $types ) && '*' !== $types && '*/*' !== $types )
{
$validators[] = array(
'name' => 'Zend\Validator\File\MimeType',
'options' => array(
'mimeType' => $types
),
);
}
return $validators;
} | php | protected function getValidators( $types )
{
$validators = array();
if ( 'image/*' == $types )
{
$validators[] = array(
'name' => 'Zend\Validator\File\IsImage',
);
}
else if ( ! empty( $types ) && '*' !== $types && '*/*' !== $types )
{
$validators[] = array(
'name' => 'Zend\Validator\File\MimeType',
'options' => array(
'mimeType' => $types
),
);
}
return $validators;
} | [
"protected",
"function",
"getValidators",
"(",
"$",
"types",
")",
"{",
"$",
"validators",
"=",
"array",
"(",
")",
";",
"if",
"(",
"'image/*'",
"==",
"$",
"types",
")",
"{",
"$",
"validators",
"[",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"'Zend\\Validator\\File\\IsImage'",
",",
")",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"types",
")",
"&&",
"'*'",
"!==",
"$",
"types",
"&&",
"'*/*'",
"!==",
"$",
"types",
")",
"{",
"$",
"validators",
"[",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"'Zend\\Validator\\File\\MimeType'",
",",
"'options'",
"=>",
"array",
"(",
"'mimeType'",
"=>",
"$",
"types",
")",
",",
")",
";",
"}",
"return",
"$",
"validators",
";",
"}"
] | Get mime-validators for a file
@param string $types
@return array | [
"Get",
"mime",
"-",
"validators",
"for",
"a",
"file"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Controller/UploadController.php#L45-L66 |
11,969 | webriq/core | module/Core/src/Grid/Core/Controller/UploadController.php | UploadController.getForm | protected function getForm( $types, $pattern )
{
$types = preg_replace( '/\s+/', '', implode( ',', (array) $types ) );
if ( '*/*' === $types )
{
$types = '*';
}
if ( empty( $types ) )
{
$label = 'mime.sets.*';
}
else if ( strstr( $types, '*' ) || strstr( $types, ',' ) )
{
$label = 'mime.sets.' . $types;
}
else
{
$label = 'mime.type.' . $types;
}
$accept = '*' == $types ? '*/*' : $types;
return $this->getServiceLocator()
->get( 'Zork\Form\Factory' )
->createForm( array(
'attributes' => array(
'action' => '?',
'method' => 'post',
),
'elements' => array(
'types' => array(
'spec' => array(
'type' => 'Zork\Form\Element\Hidden',
'name' => 'types',
'attributes' => array(
'value' => $accept,
),
),
),
'pattern' => array(
'spec' => array(
'type' => 'Zork\Form\Element\Hidden',
'name' => 'pattern',
'attributes' => array(
'value' => $pattern,
),
),
),
'file' => array(
'spec' => array(
'type' => 'Zork\Form\Element\File',
'name' => 'file',
'options' => array(
'required' => true,
'label' => $label,
'accept' => $accept,
'validators' => $this->getValidators( $types )
),
),
),
'upload' => array(
'spec' => array(
'type' => 'Zork\Form\Element\Submit',
'name' => 'upload',
'attributes' => array(
'value' => 'default.upload',
),
),
),
),
) );
} | php | protected function getForm( $types, $pattern )
{
$types = preg_replace( '/\s+/', '', implode( ',', (array) $types ) );
if ( '*/*' === $types )
{
$types = '*';
}
if ( empty( $types ) )
{
$label = 'mime.sets.*';
}
else if ( strstr( $types, '*' ) || strstr( $types, ',' ) )
{
$label = 'mime.sets.' . $types;
}
else
{
$label = 'mime.type.' . $types;
}
$accept = '*' == $types ? '*/*' : $types;
return $this->getServiceLocator()
->get( 'Zork\Form\Factory' )
->createForm( array(
'attributes' => array(
'action' => '?',
'method' => 'post',
),
'elements' => array(
'types' => array(
'spec' => array(
'type' => 'Zork\Form\Element\Hidden',
'name' => 'types',
'attributes' => array(
'value' => $accept,
),
),
),
'pattern' => array(
'spec' => array(
'type' => 'Zork\Form\Element\Hidden',
'name' => 'pattern',
'attributes' => array(
'value' => $pattern,
),
),
),
'file' => array(
'spec' => array(
'type' => 'Zork\Form\Element\File',
'name' => 'file',
'options' => array(
'required' => true,
'label' => $label,
'accept' => $accept,
'validators' => $this->getValidators( $types )
),
),
),
'upload' => array(
'spec' => array(
'type' => 'Zork\Form\Element\Submit',
'name' => 'upload',
'attributes' => array(
'value' => 'default.upload',
),
),
),
),
) );
} | [
"protected",
"function",
"getForm",
"(",
"$",
"types",
",",
"$",
"pattern",
")",
"{",
"$",
"types",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"''",
",",
"implode",
"(",
"','",
",",
"(",
"array",
")",
"$",
"types",
")",
")",
";",
"if",
"(",
"'*/*'",
"===",
"$",
"types",
")",
"{",
"$",
"types",
"=",
"'*'",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"types",
")",
")",
"{",
"$",
"label",
"=",
"'mime.sets.*'",
";",
"}",
"else",
"if",
"(",
"strstr",
"(",
"$",
"types",
",",
"'*'",
")",
"||",
"strstr",
"(",
"$",
"types",
",",
"','",
")",
")",
"{",
"$",
"label",
"=",
"'mime.sets.'",
".",
"$",
"types",
";",
"}",
"else",
"{",
"$",
"label",
"=",
"'mime.type.'",
".",
"$",
"types",
";",
"}",
"$",
"accept",
"=",
"'*'",
"==",
"$",
"types",
"?",
"'*/*'",
":",
"$",
"types",
";",
"return",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'Zork\\Form\\Factory'",
")",
"->",
"createForm",
"(",
"array",
"(",
"'attributes'",
"=>",
"array",
"(",
"'action'",
"=>",
"'?'",
",",
"'method'",
"=>",
"'post'",
",",
")",
",",
"'elements'",
"=>",
"array",
"(",
"'types'",
"=>",
"array",
"(",
"'spec'",
"=>",
"array",
"(",
"'type'",
"=>",
"'Zork\\Form\\Element\\Hidden'",
",",
"'name'",
"=>",
"'types'",
",",
"'attributes'",
"=>",
"array",
"(",
"'value'",
"=>",
"$",
"accept",
",",
")",
",",
")",
",",
")",
",",
"'pattern'",
"=>",
"array",
"(",
"'spec'",
"=>",
"array",
"(",
"'type'",
"=>",
"'Zork\\Form\\Element\\Hidden'",
",",
"'name'",
"=>",
"'pattern'",
",",
"'attributes'",
"=>",
"array",
"(",
"'value'",
"=>",
"$",
"pattern",
",",
")",
",",
")",
",",
")",
",",
"'file'",
"=>",
"array",
"(",
"'spec'",
"=>",
"array",
"(",
"'type'",
"=>",
"'Zork\\Form\\Element\\File'",
",",
"'name'",
"=>",
"'file'",
",",
"'options'",
"=>",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'label'",
"=>",
"$",
"label",
",",
"'accept'",
"=>",
"$",
"accept",
",",
"'validators'",
"=>",
"$",
"this",
"->",
"getValidators",
"(",
"$",
"types",
")",
")",
",",
")",
",",
")",
",",
"'upload'",
"=>",
"array",
"(",
"'spec'",
"=>",
"array",
"(",
"'type'",
"=>",
"'Zork\\Form\\Element\\Submit'",
",",
"'name'",
"=>",
"'upload'",
",",
"'attributes'",
"=>",
"array",
"(",
"'value'",
"=>",
"'default.upload'",
",",
")",
",",
")",
",",
")",
",",
")",
",",
")",
")",
";",
"}"
] | Get the upload-form
@param string|array $types
@param string $pattern
@return \Zend\Form\Form | [
"Get",
"the",
"upload",
"-",
"form"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Controller/UploadController.php#L75-L148 |
11,970 | jaimeeee/laravelpanel | src/LaravelPanel/controllers/PanelController.php | PanelController.formList | public function formList($entity)
{
if ($entity = Entity::fromYamlFile($entity)) {
$list = new FormList($entity);
return $list->view();
} else {
abort(404);
}
} | php | public function formList($entity)
{
if ($entity = Entity::fromYamlFile($entity)) {
$list = new FormList($entity);
return $list->view();
} else {
abort(404);
}
} | [
"public",
"function",
"formList",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"entity",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"list",
"=",
"new",
"FormList",
"(",
"$",
"entity",
")",
";",
"return",
"$",
"list",
"->",
"view",
"(",
")",
";",
"}",
"else",
"{",
"abort",
"(",
"404",
")",
";",
"}",
"}"
] | Show an entity list.
@return \Illuminate\Http\Response | [
"Show",
"an",
"entity",
"list",
"."
] | 211599ba0be7dc5ea11af292a75d4104c41512ca | https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/controllers/PanelController.php#L41-L50 |
11,971 | jaimeeee/laravelpanel | src/LaravelPanel/controllers/PanelController.php | PanelController.create | public function create($entity, $record = null, $child = null)
{
if (!$record && !$child && ($entityObject = Entity::fromYamlFile($entity))) {
$form = new Form($entityObject, null, Session::get('errors'));
return $form->view();
} elseif (($parentEntity = Entity::fromYamlFile($entity)) && ($entityObject = Entity::fromYamlFile($child))) {
// Get parent's record
$parentRecord = $parentEntity->class::findOrFail($record);
$form = new Form($entityObject, null, Session::get('errors'), $parentEntity, $parentRecord);
return $form->view();
} else {
abort(404);
}
} | php | public function create($entity, $record = null, $child = null)
{
if (!$record && !$child && ($entityObject = Entity::fromYamlFile($entity))) {
$form = new Form($entityObject, null, Session::get('errors'));
return $form->view();
} elseif (($parentEntity = Entity::fromYamlFile($entity)) && ($entityObject = Entity::fromYamlFile($child))) {
// Get parent's record
$parentRecord = $parentEntity->class::findOrFail($record);
$form = new Form($entityObject, null, Session::get('errors'), $parentEntity, $parentRecord);
return $form->view();
} else {
abort(404);
}
} | [
"public",
"function",
"create",
"(",
"$",
"entity",
",",
"$",
"record",
"=",
"null",
",",
"$",
"child",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"record",
"&&",
"!",
"$",
"child",
"&&",
"(",
"$",
"entityObject",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"entity",
")",
")",
")",
"{",
"$",
"form",
"=",
"new",
"Form",
"(",
"$",
"entityObject",
",",
"null",
",",
"Session",
"::",
"get",
"(",
"'errors'",
")",
")",
";",
"return",
"$",
"form",
"->",
"view",
"(",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"parentEntity",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"entity",
")",
")",
"&&",
"(",
"$",
"entityObject",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"child",
")",
")",
")",
"{",
"// Get parent's record",
"$",
"parentRecord",
"=",
"$",
"parentEntity",
"->",
"class",
"::",
"findOrFail",
"(",
"$",
"record",
")",
";",
"$",
"form",
"=",
"new",
"Form",
"(",
"$",
"entityObject",
",",
"null",
",",
"Session",
"::",
"get",
"(",
"'errors'",
")",
",",
"$",
"parentEntity",
",",
"$",
"parentRecord",
")",
";",
"return",
"$",
"form",
"->",
"view",
"(",
")",
";",
"}",
"else",
"{",
"abort",
"(",
"404",
")",
";",
"}",
"}"
] | Show the form to create a new record.
@return \Illuminate\Http\Response | [
"Show",
"the",
"form",
"to",
"create",
"a",
"new",
"record",
"."
] | 211599ba0be7dc5ea11af292a75d4104c41512ca | https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/controllers/PanelController.php#L70-L86 |
11,972 | jaimeeee/laravelpanel | src/LaravelPanel/controllers/PanelController.php | PanelController.publish | public function publish(Request $request, $entity, $record = null, $child = null)
{
if (!$record && !$child && ($entityObject = Entity::fromYamlFile($entity))) {
} elseif (($parentEntity = Entity::fromYamlFile($entity)) && ($entityObject = Entity::fromYamlFile($child))) {
// Get parent's record
$parentRecord = $parentEntity->class::findOrFail($record);
} else {
abort(404);
}
// Get validation from entity rules and validate
$this->validate($request, $this->validationRules($entityObject->fields));
// If data is validated and everything seems good, lets create the record
$record = new $entityObject->class();
foreach ($entityObject->fields as $field => $options) {
$type = ucwords($options['type']);
$className = 'Jaimeeee\\Panel\\Fields\\'.$type.'\\'.$type.'Field';
if (!isset($className::$ignore) || !$className::$ignore) {
$record->$field = $request->input($field);
}
}
// Save slug
if (isset($entityObject->slug['field']) && $entityObject->slug['field'] &&
isset($entityObject->slug['column']) && $entityObject->slug['column']) {
$field = $entityObject->slug['field'];
$column = $entityObject->slug['column'];
$record->$column = str_slug($record->$field,
isset($entityObject->slug['separator']) ? $entityObject->slug['separator'] : '-');
}
// Save parent
if (isset($parentRecord) && $parentRecord) {
$row = snake_case(class_basename($parentEntity->class)).'_id';
$record->$row = $parentRecord->id;
}
$record->save();
foreach ($entityObject->fields as $field => $options) {
$type = ucwords($options['type']);
$className = 'Jaimeeee\\Panel\\Fields\\'.$type.'\\'.$type.'Field';
// Lets see if the call method exists, and if it does, we should trust the field ¯\_(ツ)_/¯
if (method_exists($className, 'call')) {
$className::call($request, $record, $field, $options);
}
}
$record->save();
// Upload single images
// $this->uploadImages($request, $record, $entityObject);
if (isset($parentRecord) && $parentRecord) {
return redirect(config('panel.url').'/'.$parentEntity->url.'/'.$parentRecord->id.'/'.$entityObject->url.'?created=1');
} else {
return redirect(config('panel.url').'/'.$entityObject->url.'?created=1');
}
} | php | public function publish(Request $request, $entity, $record = null, $child = null)
{
if (!$record && !$child && ($entityObject = Entity::fromYamlFile($entity))) {
} elseif (($parentEntity = Entity::fromYamlFile($entity)) && ($entityObject = Entity::fromYamlFile($child))) {
// Get parent's record
$parentRecord = $parentEntity->class::findOrFail($record);
} else {
abort(404);
}
// Get validation from entity rules and validate
$this->validate($request, $this->validationRules($entityObject->fields));
// If data is validated and everything seems good, lets create the record
$record = new $entityObject->class();
foreach ($entityObject->fields as $field => $options) {
$type = ucwords($options['type']);
$className = 'Jaimeeee\\Panel\\Fields\\'.$type.'\\'.$type.'Field';
if (!isset($className::$ignore) || !$className::$ignore) {
$record->$field = $request->input($field);
}
}
// Save slug
if (isset($entityObject->slug['field']) && $entityObject->slug['field'] &&
isset($entityObject->slug['column']) && $entityObject->slug['column']) {
$field = $entityObject->slug['field'];
$column = $entityObject->slug['column'];
$record->$column = str_slug($record->$field,
isset($entityObject->slug['separator']) ? $entityObject->slug['separator'] : '-');
}
// Save parent
if (isset($parentRecord) && $parentRecord) {
$row = snake_case(class_basename($parentEntity->class)).'_id';
$record->$row = $parentRecord->id;
}
$record->save();
foreach ($entityObject->fields as $field => $options) {
$type = ucwords($options['type']);
$className = 'Jaimeeee\\Panel\\Fields\\'.$type.'\\'.$type.'Field';
// Lets see if the call method exists, and if it does, we should trust the field ¯\_(ツ)_/¯
if (method_exists($className, 'call')) {
$className::call($request, $record, $field, $options);
}
}
$record->save();
// Upload single images
// $this->uploadImages($request, $record, $entityObject);
if (isset($parentRecord) && $parentRecord) {
return redirect(config('panel.url').'/'.$parentEntity->url.'/'.$parentRecord->id.'/'.$entityObject->url.'?created=1');
} else {
return redirect(config('panel.url').'/'.$entityObject->url.'?created=1');
}
} | [
"public",
"function",
"publish",
"(",
"Request",
"$",
"request",
",",
"$",
"entity",
",",
"$",
"record",
"=",
"null",
",",
"$",
"child",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"record",
"&&",
"!",
"$",
"child",
"&&",
"(",
"$",
"entityObject",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"entity",
")",
")",
")",
"{",
"}",
"elseif",
"(",
"(",
"$",
"parentEntity",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"entity",
")",
")",
"&&",
"(",
"$",
"entityObject",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"child",
")",
")",
")",
"{",
"// Get parent's record",
"$",
"parentRecord",
"=",
"$",
"parentEntity",
"->",
"class",
"::",
"findOrFail",
"(",
"$",
"record",
")",
";",
"}",
"else",
"{",
"abort",
"(",
"404",
")",
";",
"}",
"// Get validation from entity rules and validate",
"$",
"this",
"->",
"validate",
"(",
"$",
"request",
",",
"$",
"this",
"->",
"validationRules",
"(",
"$",
"entityObject",
"->",
"fields",
")",
")",
";",
"// If data is validated and everything seems good, lets create the record",
"$",
"record",
"=",
"new",
"$",
"entityObject",
"->",
"class",
"(",
")",
";",
"foreach",
"(",
"$",
"entityObject",
"->",
"fields",
"as",
"$",
"field",
"=>",
"$",
"options",
")",
"{",
"$",
"type",
"=",
"ucwords",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"$",
"className",
"=",
"'Jaimeeee\\\\Panel\\\\Fields\\\\'",
".",
"$",
"type",
".",
"'\\\\'",
".",
"$",
"type",
".",
"'Field'",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"className",
"::",
"$",
"ignore",
")",
"||",
"!",
"$",
"className",
"::",
"$",
"ignore",
")",
"{",
"$",
"record",
"->",
"$",
"field",
"=",
"$",
"request",
"->",
"input",
"(",
"$",
"field",
")",
";",
"}",
"}",
"// Save slug",
"if",
"(",
"isset",
"(",
"$",
"entityObject",
"->",
"slug",
"[",
"'field'",
"]",
")",
"&&",
"$",
"entityObject",
"->",
"slug",
"[",
"'field'",
"]",
"&&",
"isset",
"(",
"$",
"entityObject",
"->",
"slug",
"[",
"'column'",
"]",
")",
"&&",
"$",
"entityObject",
"->",
"slug",
"[",
"'column'",
"]",
")",
"{",
"$",
"field",
"=",
"$",
"entityObject",
"->",
"slug",
"[",
"'field'",
"]",
";",
"$",
"column",
"=",
"$",
"entityObject",
"->",
"slug",
"[",
"'column'",
"]",
";",
"$",
"record",
"->",
"$",
"column",
"=",
"str_slug",
"(",
"$",
"record",
"->",
"$",
"field",
",",
"isset",
"(",
"$",
"entityObject",
"->",
"slug",
"[",
"'separator'",
"]",
")",
"?",
"$",
"entityObject",
"->",
"slug",
"[",
"'separator'",
"]",
":",
"'-'",
")",
";",
"}",
"// Save parent",
"if",
"(",
"isset",
"(",
"$",
"parentRecord",
")",
"&&",
"$",
"parentRecord",
")",
"{",
"$",
"row",
"=",
"snake_case",
"(",
"class_basename",
"(",
"$",
"parentEntity",
"->",
"class",
")",
")",
".",
"'_id'",
";",
"$",
"record",
"->",
"$",
"row",
"=",
"$",
"parentRecord",
"->",
"id",
";",
"}",
"$",
"record",
"->",
"save",
"(",
")",
";",
"foreach",
"(",
"$",
"entityObject",
"->",
"fields",
"as",
"$",
"field",
"=>",
"$",
"options",
")",
"{",
"$",
"type",
"=",
"ucwords",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"$",
"className",
"=",
"'Jaimeeee\\\\Panel\\\\Fields\\\\'",
".",
"$",
"type",
".",
"'\\\\'",
".",
"$",
"type",
".",
"'Field'",
";",
"// Lets see if the call method exists, and if it does, we should trust the field ¯\\_(ツ)_/¯",
"if",
"(",
"method_exists",
"(",
"$",
"className",
",",
"'call'",
")",
")",
"{",
"$",
"className",
"::",
"call",
"(",
"$",
"request",
",",
"$",
"record",
",",
"$",
"field",
",",
"$",
"options",
")",
";",
"}",
"}",
"$",
"record",
"->",
"save",
"(",
")",
";",
"// Upload single images",
"// $this->uploadImages($request, $record, $entityObject);",
"if",
"(",
"isset",
"(",
"$",
"parentRecord",
")",
"&&",
"$",
"parentRecord",
")",
"{",
"return",
"redirect",
"(",
"config",
"(",
"'panel.url'",
")",
".",
"'/'",
".",
"$",
"parentEntity",
"->",
"url",
".",
"'/'",
".",
"$",
"parentRecord",
"->",
"id",
".",
"'/'",
".",
"$",
"entityObject",
"->",
"url",
".",
"'?created=1'",
")",
";",
"}",
"else",
"{",
"return",
"redirect",
"(",
"config",
"(",
"'panel.url'",
")",
".",
"'/'",
".",
"$",
"entityObject",
"->",
"url",
".",
"'?created=1'",
")",
";",
"}",
"}"
] | Submit the new record.
@return \Illuminate\Http\Response | [
"Submit",
"the",
"new",
"record",
"."
] | 211599ba0be7dc5ea11af292a75d4104c41512ca | https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/controllers/PanelController.php#L93-L157 |
11,973 | jaimeeee/laravelpanel | src/LaravelPanel/controllers/PanelController.php | PanelController.edit | public function edit($entity, $id, $child = null, $record = null)
{
if (!$record && !$child && ($entityObject = Entity::fromYamlFile($entity))) {
// Get the record from the database, or fail if it is not found
$entityClass = $entityObject->class;
$record = $entityClass::findOrFail($id);
$form = new Form($entityObject, $record, Session::get('errors'));
return $form->view();
} elseif (($parentEntity = Entity::fromYamlFile($entity)) && ($entityObject = Entity::fromYamlFile($child))) {
// Get parent's record
$parentRecord = $parentEntity->class::findOrFail($id);
// Get the record from the database, or fail if it is not found
$entityClass = $entityObject->class;
$childObject = $entityClass::findOrFail($record);
$form = new Form($entityObject, $childObject, Session::get('errors'), $parentEntity, $parentRecord);
return $form->view();
} else {
abort(404);
}
} | php | public function edit($entity, $id, $child = null, $record = null)
{
if (!$record && !$child && ($entityObject = Entity::fromYamlFile($entity))) {
// Get the record from the database, or fail if it is not found
$entityClass = $entityObject->class;
$record = $entityClass::findOrFail($id);
$form = new Form($entityObject, $record, Session::get('errors'));
return $form->view();
} elseif (($parentEntity = Entity::fromYamlFile($entity)) && ($entityObject = Entity::fromYamlFile($child))) {
// Get parent's record
$parentRecord = $parentEntity->class::findOrFail($id);
// Get the record from the database, or fail if it is not found
$entityClass = $entityObject->class;
$childObject = $entityClass::findOrFail($record);
$form = new Form($entityObject, $childObject, Session::get('errors'), $parentEntity, $parentRecord);
return $form->view();
} else {
abort(404);
}
} | [
"public",
"function",
"edit",
"(",
"$",
"entity",
",",
"$",
"id",
",",
"$",
"child",
"=",
"null",
",",
"$",
"record",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"record",
"&&",
"!",
"$",
"child",
"&&",
"(",
"$",
"entityObject",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"entity",
")",
")",
")",
"{",
"// Get the record from the database, or fail if it is not found",
"$",
"entityClass",
"=",
"$",
"entityObject",
"->",
"class",
";",
"$",
"record",
"=",
"$",
"entityClass",
"::",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"form",
"=",
"new",
"Form",
"(",
"$",
"entityObject",
",",
"$",
"record",
",",
"Session",
"::",
"get",
"(",
"'errors'",
")",
")",
";",
"return",
"$",
"form",
"->",
"view",
"(",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"parentEntity",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"entity",
")",
")",
"&&",
"(",
"$",
"entityObject",
"=",
"Entity",
"::",
"fromYamlFile",
"(",
"$",
"child",
")",
")",
")",
"{",
"// Get parent's record",
"$",
"parentRecord",
"=",
"$",
"parentEntity",
"->",
"class",
"::",
"findOrFail",
"(",
"$",
"id",
")",
";",
"// Get the record from the database, or fail if it is not found",
"$",
"entityClass",
"=",
"$",
"entityObject",
"->",
"class",
";",
"$",
"childObject",
"=",
"$",
"entityClass",
"::",
"findOrFail",
"(",
"$",
"record",
")",
";",
"$",
"form",
"=",
"new",
"Form",
"(",
"$",
"entityObject",
",",
"$",
"childObject",
",",
"Session",
"::",
"get",
"(",
"'errors'",
")",
",",
"$",
"parentEntity",
",",
"$",
"parentRecord",
")",
";",
"return",
"$",
"form",
"->",
"view",
"(",
")",
";",
"}",
"else",
"{",
"abort",
"(",
"404",
")",
";",
"}",
"}"
] | Show the form to edit a record.
@return \Illuminate\Http\Response | [
"Show",
"the",
"form",
"to",
"edit",
"a",
"record",
"."
] | 211599ba0be7dc5ea11af292a75d4104c41512ca | https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/controllers/PanelController.php#L164-L188 |
11,974 | jaimeeee/laravelpanel | src/LaravelPanel/controllers/PanelController.php | PanelController.validationRules | private function validationRules($fields, $edit = false)
{
$validationRules = [];
// Go through each field to find validation rules
foreach ($fields as $name => $options) {
if (isset($options['validate'])) {
$validationRules[$name] = $options['validate'];
// Change validation rules if there's validations as edit
if ($edit && isset($options['validateAtEdit'])) {
$validationRules[$name] = $options['validateAtEdit'];
}
if ($options['type'] == 'image') {
$rules = explode('|', $validationRules[$name]);
// If there isn't a validation rule for the image, add it
if (!in_array('image', $rules)) {
$rules[] = 'image';
}
$validationRules[$name] = implode('|', $rules);
}
}
}
return $validationRules;
} | php | private function validationRules($fields, $edit = false)
{
$validationRules = [];
// Go through each field to find validation rules
foreach ($fields as $name => $options) {
if (isset($options['validate'])) {
$validationRules[$name] = $options['validate'];
// Change validation rules if there's validations as edit
if ($edit && isset($options['validateAtEdit'])) {
$validationRules[$name] = $options['validateAtEdit'];
}
if ($options['type'] == 'image') {
$rules = explode('|', $validationRules[$name]);
// If there isn't a validation rule for the image, add it
if (!in_array('image', $rules)) {
$rules[] = 'image';
}
$validationRules[$name] = implode('|', $rules);
}
}
}
return $validationRules;
} | [
"private",
"function",
"validationRules",
"(",
"$",
"fields",
",",
"$",
"edit",
"=",
"false",
")",
"{",
"$",
"validationRules",
"=",
"[",
"]",
";",
"// Go through each field to find validation rules",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"name",
"=>",
"$",
"options",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'validate'",
"]",
")",
")",
"{",
"$",
"validationRules",
"[",
"$",
"name",
"]",
"=",
"$",
"options",
"[",
"'validate'",
"]",
";",
"// Change validation rules if there's validations as edit",
"if",
"(",
"$",
"edit",
"&&",
"isset",
"(",
"$",
"options",
"[",
"'validateAtEdit'",
"]",
")",
")",
"{",
"$",
"validationRules",
"[",
"$",
"name",
"]",
"=",
"$",
"options",
"[",
"'validateAtEdit'",
"]",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'type'",
"]",
"==",
"'image'",
")",
"{",
"$",
"rules",
"=",
"explode",
"(",
"'|'",
",",
"$",
"validationRules",
"[",
"$",
"name",
"]",
")",
";",
"// If there isn't a validation rule for the image, add it",
"if",
"(",
"!",
"in_array",
"(",
"'image'",
",",
"$",
"rules",
")",
")",
"{",
"$",
"rules",
"[",
"]",
"=",
"'image'",
";",
"}",
"$",
"validationRules",
"[",
"$",
"name",
"]",
"=",
"implode",
"(",
"'|'",
",",
"$",
"rules",
")",
";",
"}",
"}",
"}",
"return",
"$",
"validationRules",
";",
"}"
] | Return the validation rules for each field.
@param array $fields Array of fields
@param bool $edit If it needs to read additional rules at edit
@return string | [
"Return",
"the",
"validation",
"rules",
"for",
"each",
"field",
"."
] | 211599ba0be7dc5ea11af292a75d4104c41512ca | https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/controllers/PanelController.php#L295-L323 |
11,975 | phPoirot/Events | Event.php | Event.setName | function setName($name)
{
if ($this->name !== null)
throw new \Exception(sprintf(
"Event with name (%s) are immutable. can`t set name (%s)."
, $this->name, \Poirot\Std\flatten($name)
));
$this->name = (string) $name;
return $this;
} | php | function setName($name)
{
if ($this->name !== null)
throw new \Exception(sprintf(
"Event with name (%s) are immutable. can`t set name (%s)."
, $this->name, \Poirot\Std\flatten($name)
));
$this->name = (string) $name;
return $this;
} | [
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
"!==",
"null",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"Event with name (%s) are immutable. can`t set name (%s).\"",
",",
"$",
"this",
"->",
"name",
",",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"flatten",
"(",
"$",
"name",
")",
")",
")",
";",
"$",
"this",
"->",
"name",
"=",
"(",
"string",
")",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] | Set Events Entitle Name
- Events name are immutable
@param string $name
@throws \Exception
@return $this | [
"Set",
"Events",
"Entitle",
"Name"
] | d8a6b08a11b356999286e841e04b7580a826bd5b | https://github.com/phPoirot/Events/blob/d8a6b08a11b356999286e841e04b7580a826bd5b/Event.php#L108-L118 |
11,976 | phPoirot/Events | Event.php | Event.getName | function getName()
{
if ($this->name == '' || $this->name === null) {
$name = str_replace('\\', '.', get_class($this));
$this->setName($name);
}
return $this->name;
} | php | function getName()
{
if ($this->name == '' || $this->name === null) {
$name = str_replace('\\', '.', get_class($this));
$this->setName($name);
}
return $this->name;
} | [
"function",
"getName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
"==",
"''",
"||",
"$",
"this",
"->",
"name",
"===",
"null",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'.'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"$",
"this",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"name",
";",
"}"
] | Event Entitle Name
!! default name for events that has no name yet:
\App\Event\Mvc\Dispatch -> App.Event.Mvc.Dispatch
class -> name
@return string | [
"Event",
"Entitle",
"Name"
] | d8a6b08a11b356999286e841e04b7580a826bd5b | https://github.com/phPoirot/Events/blob/d8a6b08a11b356999286e841e04b7580a826bd5b/Event.php#L129-L137 |
11,977 | phPoirot/Events | Event.php | Event.collector | function collector($options = null)
{
if (! $this->collector )
$this->collector = new DataCollector;
if (null !== $options) {
$this->collector->import($options);
return $this;
}
return $this->collector;
} | php | function collector($options = null)
{
if (! $this->collector )
$this->collector = new DataCollector;
if (null !== $options) {
$this->collector->import($options);
return $this;
}
return $this->collector;
} | [
"function",
"collector",
"(",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"collector",
")",
"$",
"this",
"->",
"collector",
"=",
"new",
"DataCollector",
";",
"if",
"(",
"null",
"!==",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"collector",
"->",
"import",
"(",
"$",
"options",
")",
";",
"return",
"$",
"this",
";",
"}",
"return",
"$",
"this",
"->",
"collector",
";",
"}"
] | Events Result Collector
- collector(['key_as_option' => $value])
@param null|array|\Traversable $options
@return DataCollector|$this | [
"Events",
"Result",
"Collector"
] | d8a6b08a11b356999286e841e04b7580a826bd5b | https://github.com/phPoirot/Events/blob/d8a6b08a11b356999286e841e04b7580a826bd5b/Event.php#L161-L172 |
11,978 | phPoirot/Events | Event.php | Event.emit | function emit($dataMerge = null, $meeter = null)
{
# Prepare given arguments:
if ($dataMerge instanceof iMeeter) {
$meeter = $dataMerge;
$dataMerge = null;
}
$Event = clone $this;
$Collector = $Event->collector();
if ($dataMerge !== null)
## build collector with default data
## we have to keep defaults untouched
$Collector->import($dataMerge);
if ($meeter === null)
$meeter = $this->_getMeeter();
# Emit listeners:
$this->_tmp__isEmiting = true;
$result = null;
/** @var iListener $listener */
foreach(clone $this->_listenerQueue() as $listener)
{
# propagation stopped by listener
if ( $Event->isStopPropagation() )
break;
$this->_c_lastEmitted = $listener;
/** @var iMeeter $meeter */
$meeter = clone $meeter; // reset meter to execute new listener
$meeter->setEventBelong($Event);
try {
$result = $meeter->invokeListener($listener, $Collector);
} catch(\Exception $e) {
if ($this->failure)
return call_user_func($this->failure, $e, $Event);
throw $e;
}
if ($result !== null) {
if (is_array($result) || $result instanceof \Traversable)
## set result into collector
$Collector->import($result);
// TODO determine result to merge with Collector \
// or store in collector with listener name.
}
}
$this->_tmp__isEmiting = false;
return $Event;
} | php | function emit($dataMerge = null, $meeter = null)
{
# Prepare given arguments:
if ($dataMerge instanceof iMeeter) {
$meeter = $dataMerge;
$dataMerge = null;
}
$Event = clone $this;
$Collector = $Event->collector();
if ($dataMerge !== null)
## build collector with default data
## we have to keep defaults untouched
$Collector->import($dataMerge);
if ($meeter === null)
$meeter = $this->_getMeeter();
# Emit listeners:
$this->_tmp__isEmiting = true;
$result = null;
/** @var iListener $listener */
foreach(clone $this->_listenerQueue() as $listener)
{
# propagation stopped by listener
if ( $Event->isStopPropagation() )
break;
$this->_c_lastEmitted = $listener;
/** @var iMeeter $meeter */
$meeter = clone $meeter; // reset meter to execute new listener
$meeter->setEventBelong($Event);
try {
$result = $meeter->invokeListener($listener, $Collector);
} catch(\Exception $e) {
if ($this->failure)
return call_user_func($this->failure, $e, $Event);
throw $e;
}
if ($result !== null) {
if (is_array($result) || $result instanceof \Traversable)
## set result into collector
$Collector->import($result);
// TODO determine result to merge with Collector \
// or store in collector with listener name.
}
}
$this->_tmp__isEmiting = false;
return $Event;
} | [
"function",
"emit",
"(",
"$",
"dataMerge",
"=",
"null",
",",
"$",
"meeter",
"=",
"null",
")",
"{",
"# Prepare given arguments:",
"if",
"(",
"$",
"dataMerge",
"instanceof",
"iMeeter",
")",
"{",
"$",
"meeter",
"=",
"$",
"dataMerge",
";",
"$",
"dataMerge",
"=",
"null",
";",
"}",
"$",
"Event",
"=",
"clone",
"$",
"this",
";",
"$",
"Collector",
"=",
"$",
"Event",
"->",
"collector",
"(",
")",
";",
"if",
"(",
"$",
"dataMerge",
"!==",
"null",
")",
"## build collector with default data",
"## we have to keep defaults untouched",
"$",
"Collector",
"->",
"import",
"(",
"$",
"dataMerge",
")",
";",
"if",
"(",
"$",
"meeter",
"===",
"null",
")",
"$",
"meeter",
"=",
"$",
"this",
"->",
"_getMeeter",
"(",
")",
";",
"# Emit listeners:",
"$",
"this",
"->",
"_tmp__isEmiting",
"=",
"true",
";",
"$",
"result",
"=",
"null",
";",
"/** @var iListener $listener */",
"foreach",
"(",
"clone",
"$",
"this",
"->",
"_listenerQueue",
"(",
")",
"as",
"$",
"listener",
")",
"{",
"# propagation stopped by listener",
"if",
"(",
"$",
"Event",
"->",
"isStopPropagation",
"(",
")",
")",
"break",
";",
"$",
"this",
"->",
"_c_lastEmitted",
"=",
"$",
"listener",
";",
"/** @var iMeeter $meeter */",
"$",
"meeter",
"=",
"clone",
"$",
"meeter",
";",
"// reset meter to execute new listener",
"$",
"meeter",
"->",
"setEventBelong",
"(",
"$",
"Event",
")",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"meeter",
"->",
"invokeListener",
"(",
"$",
"listener",
",",
"$",
"Collector",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"failure",
")",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"failure",
",",
"$",
"e",
",",
"$",
"Event",
")",
";",
"throw",
"$",
"e",
";",
"}",
"if",
"(",
"$",
"result",
"!==",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"result",
")",
"||",
"$",
"result",
"instanceof",
"\\",
"Traversable",
")",
"## set result into collector",
"$",
"Collector",
"->",
"import",
"(",
"$",
"result",
")",
";",
"// TODO determine result to merge with Collector \\",
"// or store in collector with listener name. ",
"}",
"}",
"$",
"this",
"->",
"_tmp__isEmiting",
"=",
"false",
";",
"return",
"$",
"Event",
";",
"}"
] | Trigger Listeners Within Events
- reset propagation value
- iterate over listeners priority and fire actions
- readable props of this event can resolved as listener
arguments.
- this event can be resolved to listener as $e or $event __invoke($e)
- implement to know last emitted listener
note: collecting listeners results can implemented with meeter watch
note: each event after emit has collected of data result in Emitter
Collector. if you want it can be merged with event collector.
$results = $emitter->collector()
$emitter->event()->collector()->from($result)
@param array|\Traversable|iMeeter $dataMerge
@param iMeeter|null $meeter
@return iEvent Clone/Copy of self
@throws \Exception | [
"Trigger",
"Listeners",
"Within",
"Events"
] | d8a6b08a11b356999286e841e04b7580a826bd5b | https://github.com/phPoirot/Events/blob/d8a6b08a11b356999286e841e04b7580a826bd5b/Event.php#L196-L254 |
11,979 | phPoirot/Events | Event.php | Event.attachListener | function attachListener($listener, $name = null, $priority = 10)
{
if ($priority == null)
$priority = 10;
if ($this->_tmp__isEmiting)
throw new \RuntimeException('Can`t Attach Listener While Emit Events.');
if ( is_int($name) ) {
## listener without specified name
$priority = $name;
$name = null;
}
if ($name === null) {
## achieve default name if given listener is class
if (is_object($listener) && !$listener instanceof \Closure)
$name = get_class($listener);
}
if ($name !== null) {
## store listener with name, listener is not anonymous!
if (isset($this->_c_listeners[$name]))
throw new \RuntimeException("Listener with same name ({$name}) not allowed.");
$this->_c_listeners[$name] = $listener;
}
$this->_listenerQueue()->insert($listener, $priority);
return $this;
} | php | function attachListener($listener, $name = null, $priority = 10)
{
if ($priority == null)
$priority = 10;
if ($this->_tmp__isEmiting)
throw new \RuntimeException('Can`t Attach Listener While Emit Events.');
if ( is_int($name) ) {
## listener without specified name
$priority = $name;
$name = null;
}
if ($name === null) {
## achieve default name if given listener is class
if (is_object($listener) && !$listener instanceof \Closure)
$name = get_class($listener);
}
if ($name !== null) {
## store listener with name, listener is not anonymous!
if (isset($this->_c_listeners[$name]))
throw new \RuntimeException("Listener with same name ({$name}) not allowed.");
$this->_c_listeners[$name] = $listener;
}
$this->_listenerQueue()->insert($listener, $priority);
return $this;
} | [
"function",
"attachListener",
"(",
"$",
"listener",
",",
"$",
"name",
"=",
"null",
",",
"$",
"priority",
"=",
"10",
")",
"{",
"if",
"(",
"$",
"priority",
"==",
"null",
")",
"$",
"priority",
"=",
"10",
";",
"if",
"(",
"$",
"this",
"->",
"_tmp__isEmiting",
")",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Can`t Attach Listener While Emit Events.'",
")",
";",
"if",
"(",
"is_int",
"(",
"$",
"name",
")",
")",
"{",
"## listener without specified name",
"$",
"priority",
"=",
"$",
"name",
";",
"$",
"name",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"## achieve default name if given listener is class",
"if",
"(",
"is_object",
"(",
"$",
"listener",
")",
"&&",
"!",
"$",
"listener",
"instanceof",
"\\",
"Closure",
")",
"$",
"name",
"=",
"get_class",
"(",
"$",
"listener",
")",
";",
"}",
"if",
"(",
"$",
"name",
"!==",
"null",
")",
"{",
"## store listener with name, listener is not anonymous!",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_c_listeners",
"[",
"$",
"name",
"]",
")",
")",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Listener with same name ({$name}) not allowed.\"",
")",
";",
"$",
"this",
"->",
"_c_listeners",
"[",
"$",
"name",
"]",
"=",
"$",
"listener",
";",
"}",
"$",
"this",
"->",
"_listenerQueue",
"(",
")",
"->",
"insert",
"(",
"$",
"listener",
",",
"$",
"priority",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Attach Listener To This Events
[code:]
attachListener($listener, $priority)
attachListener($listener, $nameOverride, $priority)
[code]
- store attached listener so we can list theme back
- listener with same name ({$name}) not allowed
- can`t Attach Listener While Emit Events
@param callable $listener
@param int |string $name priority, null | name, priority
@param null|int $priority null | priority
@throws \RuntimeException Listener exists
@return $this | [
"Attach",
"Listener",
"To",
"This",
"Events"
] | d8a6b08a11b356999286e841e04b7580a826bd5b | https://github.com/phPoirot/Events/blob/d8a6b08a11b356999286e841e04b7580a826bd5b/Event.php#L341-L371 |
11,980 | phPoirot/Events | Event.php | Event.findListener | function findListener($listener)
{
if (is_string($listener))
return (isset($this->_c_listeners[$listener])) ? $this->_c_listeners[$listener] : false;
elseif (is_object($listener)) {
foreach (clone $this->_listenerQueue() as $l) {
if ($l === $listener)
return $listener;
}
}
return false;
} | php | function findListener($listener)
{
if (is_string($listener))
return (isset($this->_c_listeners[$listener])) ? $this->_c_listeners[$listener] : false;
elseif (is_object($listener)) {
foreach (clone $this->_listenerQueue() as $l) {
if ($l === $listener)
return $listener;
}
}
return false;
} | [
"function",
"findListener",
"(",
"$",
"listener",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"listener",
")",
")",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"_c_listeners",
"[",
"$",
"listener",
"]",
")",
")",
"?",
"$",
"this",
"->",
"_c_listeners",
"[",
"$",
"listener",
"]",
":",
"false",
";",
"elseif",
"(",
"is_object",
"(",
"$",
"listener",
")",
")",
"{",
"foreach",
"(",
"clone",
"$",
"this",
"->",
"_listenerQueue",
"(",
")",
"as",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"l",
"===",
"$",
"listener",
")",
"return",
"$",
"listener",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Find For Listener with name or object
@param iListener|string $listener
@throws \InvalidArgumentException
@return iListener|false | [
"Find",
"For",
"Listener",
"with",
"name",
"or",
"object"
] | d8a6b08a11b356999286e841e04b7580a826bd5b | https://github.com/phPoirot/Events/blob/d8a6b08a11b356999286e841e04b7580a826bd5b/Event.php#L381-L393 |
11,981 | phPoirot/Events | Event.php | Event.detachListener | function detachListener(iListener $listener)
{
$this->_listenerQueue()->del($listener);
if (in_array($listener, $this->_c_listeners)) {
foreach ($this->_c_listeners as $k => $l) {
if ($l === $listener) {
unset($this->_c_listeners[$k]);
break;
}
}
}
return $this;
} | php | function detachListener(iListener $listener)
{
$this->_listenerQueue()->del($listener);
if (in_array($listener, $this->_c_listeners)) {
foreach ($this->_c_listeners as $k => $l) {
if ($l === $listener) {
unset($this->_c_listeners[$k]);
break;
}
}
}
return $this;
} | [
"function",
"detachListener",
"(",
"iListener",
"$",
"listener",
")",
"{",
"$",
"this",
"->",
"_listenerQueue",
"(",
")",
"->",
"del",
"(",
"$",
"listener",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"listener",
",",
"$",
"this",
"->",
"_c_listeners",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_c_listeners",
"as",
"$",
"k",
"=>",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"l",
"===",
"$",
"listener",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_c_listeners",
"[",
"$",
"k",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Detach A Listener From List
- to detach by name you have to findListener() first
@param iListener $listener
@return $this | [
"Detach",
"A",
"Listener",
"From",
"List"
] | d8a6b08a11b356999286e841e04b7580a826bd5b | https://github.com/phPoirot/Events/blob/d8a6b08a11b356999286e841e04b7580a826bd5b/Event.php#L404-L418 |
11,982 | chigix/php-io-component | src/OutputStream.php | OutputStream.write | public function write($content) {
if (is_string($content) || is_numeric($content)) {
$this->writeString($content);
} elseif (is_bool($content)) {
$this->writeString($content ? "TRUE" : "FALSE");
} elseif (is_array($content)) {
$this->writeString("Array(" . count($content) . ")");
} elseif (is_object($content) && method_exists($content, "__toString")) {
$this->writeString(strval($content));
} elseif (is_null($content)) {
$this->writeString("NULL");
} elseif (is_resource($content)) {
$this->writeString("Resource###");
} else {
throw new InvalidContentException();
}
} | php | public function write($content) {
if (is_string($content) || is_numeric($content)) {
$this->writeString($content);
} elseif (is_bool($content)) {
$this->writeString($content ? "TRUE" : "FALSE");
} elseif (is_array($content)) {
$this->writeString("Array(" . count($content) . ")");
} elseif (is_object($content) && method_exists($content, "__toString")) {
$this->writeString(strval($content));
} elseif (is_null($content)) {
$this->writeString("NULL");
} elseif (is_resource($content)) {
$this->writeString("Resource###");
} else {
throw new InvalidContentException();
}
} | [
"public",
"function",
"write",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"content",
")",
"||",
"is_numeric",
"(",
"$",
"content",
")",
")",
"{",
"$",
"this",
"->",
"writeString",
"(",
"$",
"content",
")",
";",
"}",
"elseif",
"(",
"is_bool",
"(",
"$",
"content",
")",
")",
"{",
"$",
"this",
"->",
"writeString",
"(",
"$",
"content",
"?",
"\"TRUE\"",
":",
"\"FALSE\"",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"$",
"this",
"->",
"writeString",
"(",
"\"Array(\"",
".",
"count",
"(",
"$",
"content",
")",
".",
"\")\"",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"content",
")",
"&&",
"method_exists",
"(",
"$",
"content",
",",
"\"__toString\"",
")",
")",
"{",
"$",
"this",
"->",
"writeString",
"(",
"strval",
"(",
"$",
"content",
")",
")",
";",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"content",
")",
")",
"{",
"$",
"this",
"->",
"writeString",
"(",
"\"NULL\"",
")",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"content",
")",
")",
"{",
"$",
"this",
"->",
"writeString",
"(",
"\"Resource###\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidContentException",
"(",
")",
";",
"}",
"}"
] | Writes The provided content to this output stream.
@param mixed $content
@throws InvalidContentException | [
"Writes",
"The",
"provided",
"content",
"to",
"this",
"output",
"stream",
"."
] | 0b24f18c62089e0a21181e34238cf45f517ca3e0 | https://github.com/chigix/php-io-component/blob/0b24f18c62089e0a21181e34238cf45f517ca3e0/src/OutputStream.php#L40-L56 |
11,983 | silinternational/ssp-utilities | src/AuthStateUtils.php | AuthStateUtils.getSpEntityIdForMultiAuth | public static function getSpEntityIdForMultiAuth($authState)
{
//
$idParam = '?spentityid';
// remove the text up to the start of the parameter key
$paramStart = strpos($authState, $idParam);
$entityId = substr($authState, $paramStart);
// remove the parameter key from the start
$valueStart = strpos($entityId, '=') + 1;
$entityId = substr($entityId, $valueStart);
// remove the text after the end of the parameter value
$valueEnd = strpos($entityId, '&');
$entityId = substr($entityId, 0, $valueEnd);
$entityId = urldecode(urldecode($entityId));
return $entityId;
} | php | public static function getSpEntityIdForMultiAuth($authState)
{
//
$idParam = '?spentityid';
// remove the text up to the start of the parameter key
$paramStart = strpos($authState, $idParam);
$entityId = substr($authState, $paramStart);
// remove the parameter key from the start
$valueStart = strpos($entityId, '=') + 1;
$entityId = substr($entityId, $valueStart);
// remove the text after the end of the parameter value
$valueEnd = strpos($entityId, '&');
$entityId = substr($entityId, 0, $valueEnd);
$entityId = urldecode(urldecode($entityId));
return $entityId;
} | [
"public",
"static",
"function",
"getSpEntityIdForMultiAuth",
"(",
"$",
"authState",
")",
"{",
"//",
"$",
"idParam",
"=",
"'?spentityid'",
";",
"// remove the text up to the start of the parameter key",
"$",
"paramStart",
"=",
"strpos",
"(",
"$",
"authState",
",",
"$",
"idParam",
")",
";",
"$",
"entityId",
"=",
"substr",
"(",
"$",
"authState",
",",
"$",
"paramStart",
")",
";",
"// remove the parameter key from the start",
"$",
"valueStart",
"=",
"strpos",
"(",
"$",
"entityId",
",",
"'='",
")",
"+",
"1",
";",
"$",
"entityId",
"=",
"substr",
"(",
"$",
"entityId",
",",
"$",
"valueStart",
")",
";",
"// remove the text after the end of the parameter value",
"$",
"valueEnd",
"=",
"strpos",
"(",
"$",
"entityId",
",",
"'&'",
")",
";",
"$",
"entityId",
"=",
"substr",
"(",
"$",
"entityId",
",",
"0",
",",
"$",
"valueEnd",
")",
";",
"$",
"entityId",
"=",
"urldecode",
"(",
"urldecode",
"(",
"$",
"entityId",
")",
")",
";",
"return",
"$",
"entityId",
";",
"}"
] | Gets the SP entityID out of the AuthState parameter
@param string $authState | [
"Gets",
"the",
"SP",
"entityID",
"out",
"of",
"the",
"AuthState",
"parameter"
] | e8c05bd8e4688aea2960bca74b7d6aa5f9f34286 | https://github.com/silinternational/ssp-utilities/blob/e8c05bd8e4688aea2960bca74b7d6aa5f9f34286/src/AuthStateUtils.php#L13-L33 |
11,984 | Renegade334/phergie-irc-plugin-react-seen | src/Plugin.php | Plugin.ago | protected function ago($time)
{
$time = time() - $time;
if ($time < 60) {
return 'a moment ago';
}
$secs = array(
'year' => 365.25 * 24 * 60 * 60,
'month' => 30 * 24 * 60 * 60,
'week' => 7 * 24 * 60 * 60,
'day' => 24 * 60 * 60,
'hour' => 60 * 60,
'minute' => 60,
);
foreach ($secs as $str => $s) {
$d = $time / $s;
if ($d >= 1) {
$r = round($d);
return sprintf('%d %s%s ago', $r, $str, ($r > 1) ? 's' : '');
}
}
} | php | protected function ago($time)
{
$time = time() - $time;
if ($time < 60) {
return 'a moment ago';
}
$secs = array(
'year' => 365.25 * 24 * 60 * 60,
'month' => 30 * 24 * 60 * 60,
'week' => 7 * 24 * 60 * 60,
'day' => 24 * 60 * 60,
'hour' => 60 * 60,
'minute' => 60,
);
foreach ($secs as $str => $s) {
$d = $time / $s;
if ($d >= 1) {
$r = round($d);
return sprintf('%d %s%s ago', $r, $str, ($r > 1) ? 's' : '');
}
}
} | [
"protected",
"function",
"ago",
"(",
"$",
"time",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
"-",
"$",
"time",
";",
"if",
"(",
"$",
"time",
"<",
"60",
")",
"{",
"return",
"'a moment ago'",
";",
"}",
"$",
"secs",
"=",
"array",
"(",
"'year'",
"=>",
"365.25",
"*",
"24",
"*",
"60",
"*",
"60",
",",
"'month'",
"=>",
"30",
"*",
"24",
"*",
"60",
"*",
"60",
",",
"'week'",
"=>",
"7",
"*",
"24",
"*",
"60",
"*",
"60",
",",
"'day'",
"=>",
"24",
"*",
"60",
"*",
"60",
",",
"'hour'",
"=>",
"60",
"*",
"60",
",",
"'minute'",
"=>",
"60",
",",
")",
";",
"foreach",
"(",
"$",
"secs",
"as",
"$",
"str",
"=>",
"$",
"s",
")",
"{",
"$",
"d",
"=",
"$",
"time",
"/",
"$",
"s",
";",
"if",
"(",
"$",
"d",
">=",
"1",
")",
"{",
"$",
"r",
"=",
"round",
"(",
"$",
"d",
")",
";",
"return",
"sprintf",
"(",
"'%d %s%s ago'",
",",
"$",
"r",
",",
"$",
"str",
",",
"(",
"$",
"r",
">",
"1",
")",
"?",
"'s'",
":",
"''",
")",
";",
"}",
"}",
"}"
] | Returns a crude time ago string.
@param int $time Origin timestamp
@return string | [
"Returns",
"a",
"crude",
"time",
"ago",
"string",
"."
] | 7a6ee88a1868a510bb4c6a31b290d1753b31b8ae | https://github.com/Renegade334/phergie-irc-plugin-react-seen/blob/7a6ee88a1868a510bb4c6a31b290d1753b31b8ae/src/Plugin.php#L69-L94 |
11,985 | Renegade334/phergie-irc-plugin-react-seen | src/Plugin.php | Plugin.isInChannel | protected function isInChannel($server, $channel, $user)
{
if (!isset($this->channels[$server][$channel]))
{
return false;
}
$names = array_keys($this->channels[$server][$channel], true, true);
foreach ($names as $name) {
if (!strcasecmp($name, $user)) {
return true;
}
}
return false;
} | php | protected function isInChannel($server, $channel, $user)
{
if (!isset($this->channels[$server][$channel]))
{
return false;
}
$names = array_keys($this->channels[$server][$channel], true, true);
foreach ($names as $name) {
if (!strcasecmp($name, $user)) {
return true;
}
}
return false;
} | [
"protected",
"function",
"isInChannel",
"(",
"$",
"server",
",",
"$",
"channel",
",",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"server",
"]",
"[",
"$",
"channel",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"names",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"server",
"]",
"[",
"$",
"channel",
"]",
",",
"true",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"strcasecmp",
"(",
"$",
"name",
",",
"$",
"user",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks whether a given nickname is currently on a channel.
@param string $server
@param string $channel
@param string $user (case-insensitive)
@return bool | [
"Checks",
"whether",
"a",
"given",
"nickname",
"is",
"currently",
"on",
"a",
"channel",
"."
] | 7a6ee88a1868a510bb4c6a31b290d1753b31b8ae | https://github.com/Renegade334/phergie-irc-plugin-react-seen/blob/7a6ee88a1868a510bb4c6a31b290d1753b31b8ae/src/Plugin.php#L105-L120 |
11,986 | Renegade334/phergie-irc-plugin-react-seen | src/Plugin.php | Plugin.processKick | public function processKick(UserEvent $event, Queue $queue)
{
$logger = $this->getLogger();
$server = strtolower($event->getConnection()->getServerHostname());
$params = $event->getParams();
$channel = $params['channel'];
$nick = $params['user'];
$message = isset($params['comment']) ? $params['comment'] : null;
if ($nick == $event->getConnection()->getNickname()) {
$logger->debug('Removing channel', array('server' => $server, 'channel' => $channel));
unset($this->channels[$server][$channel]);
return;
}
$logger->debug('Processing incoming KICK', array(
'server' => $server,
'channel' => $channel,
'nick' => $nick,
'message' => $message,
));
unset($this->channels[$server][$channel][$nick]);
try {
$this->db->fetchAssoc(self::SQL_UPDATE, array(
':time' => time(),
':server' => $server,
':channel' => $channel,
':nick' => $nick,
':type' => self::TYPE_KICK,
':text' => $message,
));
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
} | php | public function processKick(UserEvent $event, Queue $queue)
{
$logger = $this->getLogger();
$server = strtolower($event->getConnection()->getServerHostname());
$params = $event->getParams();
$channel = $params['channel'];
$nick = $params['user'];
$message = isset($params['comment']) ? $params['comment'] : null;
if ($nick == $event->getConnection()->getNickname()) {
$logger->debug('Removing channel', array('server' => $server, 'channel' => $channel));
unset($this->channels[$server][$channel]);
return;
}
$logger->debug('Processing incoming KICK', array(
'server' => $server,
'channel' => $channel,
'nick' => $nick,
'message' => $message,
));
unset($this->channels[$server][$channel][$nick]);
try {
$this->db->fetchAssoc(self::SQL_UPDATE, array(
':time' => time(),
':server' => $server,
':channel' => $channel,
':nick' => $nick,
':type' => self::TYPE_KICK,
':text' => $message,
));
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
} | [
"public",
"function",
"processKick",
"(",
"UserEvent",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"server",
"=",
"strtolower",
"(",
"$",
"event",
"->",
"getConnection",
"(",
")",
"->",
"getServerHostname",
"(",
")",
")",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"channel",
"=",
"$",
"params",
"[",
"'channel'",
"]",
";",
"$",
"nick",
"=",
"$",
"params",
"[",
"'user'",
"]",
";",
"$",
"message",
"=",
"isset",
"(",
"$",
"params",
"[",
"'comment'",
"]",
")",
"?",
"$",
"params",
"[",
"'comment'",
"]",
":",
"null",
";",
"if",
"(",
"$",
"nick",
"==",
"$",
"event",
"->",
"getConnection",
"(",
")",
"->",
"getNickname",
"(",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'Removing channel'",
",",
"array",
"(",
"'server'",
"=>",
"$",
"server",
",",
"'channel'",
"=>",
"$",
"channel",
")",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"server",
"]",
"[",
"$",
"channel",
"]",
")",
";",
"return",
";",
"}",
"$",
"logger",
"->",
"debug",
"(",
"'Processing incoming KICK'",
",",
"array",
"(",
"'server'",
"=>",
"$",
"server",
",",
"'channel'",
"=>",
"$",
"channel",
",",
"'nick'",
"=>",
"$",
"nick",
",",
"'message'",
"=>",
"$",
"message",
",",
")",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"server",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
")",
";",
"try",
"{",
"$",
"this",
"->",
"db",
"->",
"fetchAssoc",
"(",
"self",
"::",
"SQL_UPDATE",
",",
"array",
"(",
"':time'",
"=>",
"time",
"(",
")",
",",
"':server'",
"=>",
"$",
"server",
",",
"':channel'",
"=>",
"$",
"channel",
",",
"':nick'",
"=>",
"$",
"nick",
",",
"':type'",
"=>",
"self",
"::",
"TYPE_KICK",
",",
"':text'",
"=>",
"$",
"message",
",",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"logger",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Monitor channel kicks.
@param \Phergie\Irc\Event\UserEventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue | [
"Monitor",
"channel",
"kicks",
"."
] | 7a6ee88a1868a510bb4c6a31b290d1753b31b8ae | https://github.com/Renegade334/phergie-irc-plugin-react-seen/blob/7a6ee88a1868a510bb4c6a31b290d1753b31b8ae/src/Plugin.php#L427-L464 |
11,987 | Renegade334/phergie-irc-plugin-react-seen | src/Plugin.php | Plugin.processNick | public function processNick(UserEvent $event, Queue $queue)
{
$logger = $this->getLogger();
$nick = $event->getNick();
if ($nick == $event->getConnection()->getNickname()) {
$logger->debug('Nickname of incoming NICK is ours, ignoring');
return;
}
$server = strtolower($event->getConnection()->getServerHostname());
$params = $event->getParams();
$newnick = $params['nickname'];
$logger->debug('Processing incoming NICK', array(
'server' => $server,
'nick' => $nick,
'newnick' => $newnick,
));
foreach ($this->channels[$server] as $channel => $users) {
if (isset($users[$nick])) {
$logger->debug('Processing channel nick change', array(
'server' => $server,
'channel' => $channel,
'nick' => $nick,
'newnick' => $newnick,
));
unset($this->channels[$server][$channel][$nick]);
$this->channels[$server][$channel][$newnick] = true;
try {
$this->db->fetchAssoc(self::SQL_UPDATE, array(
':time' => time(),
':server' => $server,
':channel' => $channel,
':nick' => $nick,
':type' => self::TYPE_NICK,
':text' => $newnick,
));
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
}
}
} | php | public function processNick(UserEvent $event, Queue $queue)
{
$logger = $this->getLogger();
$nick = $event->getNick();
if ($nick == $event->getConnection()->getNickname()) {
$logger->debug('Nickname of incoming NICK is ours, ignoring');
return;
}
$server = strtolower($event->getConnection()->getServerHostname());
$params = $event->getParams();
$newnick = $params['nickname'];
$logger->debug('Processing incoming NICK', array(
'server' => $server,
'nick' => $nick,
'newnick' => $newnick,
));
foreach ($this->channels[$server] as $channel => $users) {
if (isset($users[$nick])) {
$logger->debug('Processing channel nick change', array(
'server' => $server,
'channel' => $channel,
'nick' => $nick,
'newnick' => $newnick,
));
unset($this->channels[$server][$channel][$nick]);
$this->channels[$server][$channel][$newnick] = true;
try {
$this->db->fetchAssoc(self::SQL_UPDATE, array(
':time' => time(),
':server' => $server,
':channel' => $channel,
':nick' => $nick,
':type' => self::TYPE_NICK,
':text' => $newnick,
));
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
}
}
} | [
"public",
"function",
"processNick",
"(",
"UserEvent",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"nick",
"=",
"$",
"event",
"->",
"getNick",
"(",
")",
";",
"if",
"(",
"$",
"nick",
"==",
"$",
"event",
"->",
"getConnection",
"(",
")",
"->",
"getNickname",
"(",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'Nickname of incoming NICK is ours, ignoring'",
")",
";",
"return",
";",
"}",
"$",
"server",
"=",
"strtolower",
"(",
"$",
"event",
"->",
"getConnection",
"(",
")",
"->",
"getServerHostname",
"(",
")",
")",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"newnick",
"=",
"$",
"params",
"[",
"'nickname'",
"]",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Processing incoming NICK'",
",",
"array",
"(",
"'server'",
"=>",
"$",
"server",
",",
"'nick'",
"=>",
"$",
"nick",
",",
"'newnick'",
"=>",
"$",
"newnick",
",",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"server",
"]",
"as",
"$",
"channel",
"=>",
"$",
"users",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"users",
"[",
"$",
"nick",
"]",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'Processing channel nick change'",
",",
"array",
"(",
"'server'",
"=>",
"$",
"server",
",",
"'channel'",
"=>",
"$",
"channel",
",",
"'nick'",
"=>",
"$",
"nick",
",",
"'newnick'",
"=>",
"$",
"newnick",
",",
")",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"server",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
")",
";",
"$",
"this",
"->",
"channels",
"[",
"$",
"server",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"newnick",
"]",
"=",
"true",
";",
"try",
"{",
"$",
"this",
"->",
"db",
"->",
"fetchAssoc",
"(",
"self",
"::",
"SQL_UPDATE",
",",
"array",
"(",
"':time'",
"=>",
"time",
"(",
")",
",",
"':server'",
"=>",
"$",
"server",
",",
"':channel'",
"=>",
"$",
"channel",
",",
"':nick'",
"=>",
"$",
"nick",
",",
"':type'",
"=>",
"self",
"::",
"TYPE_NICK",
",",
"':text'",
"=>",
"$",
"newnick",
",",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"logger",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] | Monitor nick changes.
@param \Phergie\Irc\Event\UserEventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue | [
"Monitor",
"nick",
"changes",
"."
] | 7a6ee88a1868a510bb4c6a31b290d1753b31b8ae | https://github.com/Renegade334/phergie-irc-plugin-react-seen/blob/7a6ee88a1868a510bb4c6a31b290d1753b31b8ae/src/Plugin.php#L524-L570 |
11,988 | Renegade334/phergie-irc-plugin-react-seen | src/Plugin.php | Plugin.processPrivmsg | public function processPrivmsg(UserEvent $event, Queue $queue)
{
$logger = $this->getLogger();
$source = $event->getSource();
$nick = $event->getNick();
if ($source === null || $nick === null || $source == $nick) {
$logger->debug('Incoming PRIVMSG not in channel, ignoring');
return;
}
$server = strtolower($event->getConnection()->getServerHostname());
$channel = $source;
$params = $event->getParams();
$message = $params['text'];
$logger->debug('Processing incoming PRIVMSG', array(
'server' => $server,
'channel' => $channel,
'nick' => $nick,
'message' => $message,
));
try {
$this->db->fetchAssoc(self::SQL_UPDATE, array(
':time' => time(),
':server' => $server,
':channel' => $channel,
':nick' => $nick,
':type' => self::TYPE_PRIVMSG,
':text' => $message,
));
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
} | php | public function processPrivmsg(UserEvent $event, Queue $queue)
{
$logger = $this->getLogger();
$source = $event->getSource();
$nick = $event->getNick();
if ($source === null || $nick === null || $source == $nick) {
$logger->debug('Incoming PRIVMSG not in channel, ignoring');
return;
}
$server = strtolower($event->getConnection()->getServerHostname());
$channel = $source;
$params = $event->getParams();
$message = $params['text'];
$logger->debug('Processing incoming PRIVMSG', array(
'server' => $server,
'channel' => $channel,
'nick' => $nick,
'message' => $message,
));
try {
$this->db->fetchAssoc(self::SQL_UPDATE, array(
':time' => time(),
':server' => $server,
':channel' => $channel,
':nick' => $nick,
':type' => self::TYPE_PRIVMSG,
':text' => $message,
));
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
} | [
"public",
"function",
"processPrivmsg",
"(",
"UserEvent",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"source",
"=",
"$",
"event",
"->",
"getSource",
"(",
")",
";",
"$",
"nick",
"=",
"$",
"event",
"->",
"getNick",
"(",
")",
";",
"if",
"(",
"$",
"source",
"===",
"null",
"||",
"$",
"nick",
"===",
"null",
"||",
"$",
"source",
"==",
"$",
"nick",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'Incoming PRIVMSG not in channel, ignoring'",
")",
";",
"return",
";",
"}",
"$",
"server",
"=",
"strtolower",
"(",
"$",
"event",
"->",
"getConnection",
"(",
")",
"->",
"getServerHostname",
"(",
")",
")",
";",
"$",
"channel",
"=",
"$",
"source",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"message",
"=",
"$",
"params",
"[",
"'text'",
"]",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Processing incoming PRIVMSG'",
",",
"array",
"(",
"'server'",
"=>",
"$",
"server",
",",
"'channel'",
"=>",
"$",
"channel",
",",
"'nick'",
"=>",
"$",
"nick",
",",
"'message'",
"=>",
"$",
"message",
",",
")",
")",
";",
"try",
"{",
"$",
"this",
"->",
"db",
"->",
"fetchAssoc",
"(",
"self",
"::",
"SQL_UPDATE",
",",
"array",
"(",
"':time'",
"=>",
"time",
"(",
")",
",",
"':server'",
"=>",
"$",
"server",
",",
"':channel'",
"=>",
"$",
"channel",
",",
"':nick'",
"=>",
"$",
"nick",
",",
"':type'",
"=>",
"self",
"::",
"TYPE_PRIVMSG",
",",
"':text'",
"=>",
"$",
"message",
",",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"logger",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Monitor channel messages.
@param \Phergie\Irc\Event\UserEventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue | [
"Monitor",
"channel",
"messages",
"."
] | 7a6ee88a1868a510bb4c6a31b290d1753b31b8ae | https://github.com/Renegade334/phergie-irc-plugin-react-seen/blob/7a6ee88a1868a510bb4c6a31b290d1753b31b8ae/src/Plugin.php#L578-L613 |
11,989 | Renegade334/phergie-irc-plugin-react-seen | src/Plugin.php | Plugin.processAction | public function processAction(CtcpEvent $event, Queue $queue)
{
$logger = $this->getLogger();
$source = $event->getSource();
$nick = $event->getNick();
if ($source === null || $nick === null || $source == $nick) {
$logger->debug('Incoming CTCP ACTION not in channel, ignoring');
return;
}
$server = strtolower($event->getConnection()->getServerHostname());
$channel = $event->getSource();
$params = $event->getCtcpParams();
$message = $params['action'];
$logger->debug('Processing incoming CTCP ACTION', array(
'server' => $server,
'channel' => $channel,
'nick' => $nick,
'message' => $message,
));
try {
$this->db->fetchAssoc(self::SQL_UPDATE, array(
':time' => time(),
':server' => $server,
':channel' => $channel,
':nick' => $nick,
':type' => self::TYPE_ACTION,
':text' => $message,
));
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
} | php | public function processAction(CtcpEvent $event, Queue $queue)
{
$logger = $this->getLogger();
$source = $event->getSource();
$nick = $event->getNick();
if ($source === null || $nick === null || $source == $nick) {
$logger->debug('Incoming CTCP ACTION not in channel, ignoring');
return;
}
$server = strtolower($event->getConnection()->getServerHostname());
$channel = $event->getSource();
$params = $event->getCtcpParams();
$message = $params['action'];
$logger->debug('Processing incoming CTCP ACTION', array(
'server' => $server,
'channel' => $channel,
'nick' => $nick,
'message' => $message,
));
try {
$this->db->fetchAssoc(self::SQL_UPDATE, array(
':time' => time(),
':server' => $server,
':channel' => $channel,
':nick' => $nick,
':type' => self::TYPE_ACTION,
':text' => $message,
));
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
} | [
"public",
"function",
"processAction",
"(",
"CtcpEvent",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"source",
"=",
"$",
"event",
"->",
"getSource",
"(",
")",
";",
"$",
"nick",
"=",
"$",
"event",
"->",
"getNick",
"(",
")",
";",
"if",
"(",
"$",
"source",
"===",
"null",
"||",
"$",
"nick",
"===",
"null",
"||",
"$",
"source",
"==",
"$",
"nick",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'Incoming CTCP ACTION not in channel, ignoring'",
")",
";",
"return",
";",
"}",
"$",
"server",
"=",
"strtolower",
"(",
"$",
"event",
"->",
"getConnection",
"(",
")",
"->",
"getServerHostname",
"(",
")",
")",
";",
"$",
"channel",
"=",
"$",
"event",
"->",
"getSource",
"(",
")",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"getCtcpParams",
"(",
")",
";",
"$",
"message",
"=",
"$",
"params",
"[",
"'action'",
"]",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Processing incoming CTCP ACTION'",
",",
"array",
"(",
"'server'",
"=>",
"$",
"server",
",",
"'channel'",
"=>",
"$",
"channel",
",",
"'nick'",
"=>",
"$",
"nick",
",",
"'message'",
"=>",
"$",
"message",
",",
")",
")",
";",
"try",
"{",
"$",
"this",
"->",
"db",
"->",
"fetchAssoc",
"(",
"self",
"::",
"SQL_UPDATE",
",",
"array",
"(",
"':time'",
"=>",
"time",
"(",
")",
",",
"':server'",
"=>",
"$",
"server",
",",
"':channel'",
"=>",
"$",
"channel",
",",
"':nick'",
"=>",
"$",
"nick",
",",
"':type'",
"=>",
"self",
"::",
"TYPE_ACTION",
",",
"':text'",
"=>",
"$",
"message",
",",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"logger",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Monitor channel actions.
@param \Phergie\Irc\Event\CtcpEventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue | [
"Monitor",
"channel",
"actions",
"."
] | 7a6ee88a1868a510bb4c6a31b290d1753b31b8ae | https://github.com/Renegade334/phergie-irc-plugin-react-seen/blob/7a6ee88a1868a510bb4c6a31b290d1753b31b8ae/src/Plugin.php#L664-L699 |
11,990 | Renegade334/phergie-irc-plugin-react-seen | src/Plugin.php | Plugin.processNames | public function processNames(ServerEvent $event, Queue $queue)
{
$special = '\[\]\\`_\^\{\|\}';
$server = strtolower($event->getConnection()->getServerHostname());
$params = array_slice($event->getParams(), 2);
$channel = array_shift($params);
$this->getLogger()->debug('Adding names to channel', array('server' => $server, 'channel' => $channel));
$names = (count($params) == 1) ? explode(' ', $params[0]) : $params;
foreach (array_filter($names) as $name) {
// Strip prefix characters
$name = preg_replace("/^[^A-Za-z$special]+/", '', $name);
$this->channels[$server][$channel][$name] = true;
}
} | php | public function processNames(ServerEvent $event, Queue $queue)
{
$special = '\[\]\\`_\^\{\|\}';
$server = strtolower($event->getConnection()->getServerHostname());
$params = array_slice($event->getParams(), 2);
$channel = array_shift($params);
$this->getLogger()->debug('Adding names to channel', array('server' => $server, 'channel' => $channel));
$names = (count($params) == 1) ? explode(' ', $params[0]) : $params;
foreach (array_filter($names) as $name) {
// Strip prefix characters
$name = preg_replace("/^[^A-Za-z$special]+/", '', $name);
$this->channels[$server][$channel][$name] = true;
}
} | [
"public",
"function",
"processNames",
"(",
"ServerEvent",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"$",
"special",
"=",
"'\\[\\]\\\\`_\\^\\{\\|\\}'",
";",
"$",
"server",
"=",
"strtolower",
"(",
"$",
"event",
"->",
"getConnection",
"(",
")",
"->",
"getServerHostname",
"(",
")",
")",
";",
"$",
"params",
"=",
"array_slice",
"(",
"$",
"event",
"->",
"getParams",
"(",
")",
",",
"2",
")",
";",
"$",
"channel",
"=",
"array_shift",
"(",
"$",
"params",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Adding names to channel'",
",",
"array",
"(",
"'server'",
"=>",
"$",
"server",
",",
"'channel'",
"=>",
"$",
"channel",
")",
")",
";",
"$",
"names",
"=",
"(",
"count",
"(",
"$",
"params",
")",
"==",
"1",
")",
"?",
"explode",
"(",
"' '",
",",
"$",
"params",
"[",
"0",
"]",
")",
":",
"$",
"params",
";",
"foreach",
"(",
"array_filter",
"(",
"$",
"names",
")",
"as",
"$",
"name",
")",
"{",
"// Strip prefix characters",
"$",
"name",
"=",
"preg_replace",
"(",
"\"/^[^A-Za-z$special]+/\"",
",",
"''",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"channels",
"[",
"$",
"server",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"name",
"]",
"=",
"true",
";",
"}",
"}"
] | Populate channels with names on join.
@param \Phergie\Irc\Event\ServerEventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue | [
"Populate",
"channels",
"with",
"names",
"on",
"join",
"."
] | 7a6ee88a1868a510bb4c6a31b290d1753b31b8ae | https://github.com/Renegade334/phergie-irc-plugin-react-seen/blob/7a6ee88a1868a510bb4c6a31b290d1753b31b8ae/src/Plugin.php#L707-L725 |
11,991 | maoberlehner/cultusrego | src/cultusrego.php | cultusrego.render | public function render() {
// Initialize Markdown and Twig
$engine = new MarkdownEngine\MichelfMarkdownEngine();
$twig_loader = new Twig_Loader_Filesystem($this->template_folder);
$twig = new Twig_Environment($twig_loader, array(
'cache' => $this->twig_cache,
));
$twig->addExtension(new MarkdownExtension($engine));
print $twig->render('index.html', array(
'title' => $this->title,
'description' => $this->description,
'source' => $this->source,
'sections' => $this->sections,
'base_path' => $this->base_path,
'asset_path' => $this->asset_path,
));
} | php | public function render() {
// Initialize Markdown and Twig
$engine = new MarkdownEngine\MichelfMarkdownEngine();
$twig_loader = new Twig_Loader_Filesystem($this->template_folder);
$twig = new Twig_Environment($twig_loader, array(
'cache' => $this->twig_cache,
));
$twig->addExtension(new MarkdownExtension($engine));
print $twig->render('index.html', array(
'title' => $this->title,
'description' => $this->description,
'source' => $this->source,
'sections' => $this->sections,
'base_path' => $this->base_path,
'asset_path' => $this->asset_path,
));
} | [
"public",
"function",
"render",
"(",
")",
"{",
"// Initialize Markdown and Twig",
"$",
"engine",
"=",
"new",
"MarkdownEngine",
"\\",
"MichelfMarkdownEngine",
"(",
")",
";",
"$",
"twig_loader",
"=",
"new",
"Twig_Loader_Filesystem",
"(",
"$",
"this",
"->",
"template_folder",
")",
";",
"$",
"twig",
"=",
"new",
"Twig_Environment",
"(",
"$",
"twig_loader",
",",
"array",
"(",
"'cache'",
"=>",
"$",
"this",
"->",
"twig_cache",
",",
")",
")",
";",
"$",
"twig",
"->",
"addExtension",
"(",
"new",
"MarkdownExtension",
"(",
"$",
"engine",
")",
")",
";",
"print",
"$",
"twig",
"->",
"render",
"(",
"'index.html'",
",",
"array",
"(",
"'title'",
"=>",
"$",
"this",
"->",
"title",
",",
"'description'",
"=>",
"$",
"this",
"->",
"description",
",",
"'source'",
"=>",
"$",
"this",
"->",
"source",
",",
"'sections'",
"=>",
"$",
"this",
"->",
"sections",
",",
"'base_path'",
"=>",
"$",
"this",
"->",
"base_path",
",",
"'asset_path'",
"=>",
"$",
"this",
"->",
"asset_path",
",",
")",
")",
";",
"}"
] | Loads Markdown and Twig engines and renders the styleguide
@return rendered HTML | [
"Loads",
"Markdown",
"and",
"Twig",
"engines",
"and",
"renders",
"the",
"styleguide"
] | 60f77a9590a1dfb605b2ca630ab0ca10e023f3ff | https://github.com/maoberlehner/cultusrego/blob/60f77a9590a1dfb605b2ca630ab0ca10e023f3ff/src/cultusrego.php#L51-L68 |
11,992 | maoberlehner/cultusrego | src/cultusrego.php | cultusrego.find_sections | private function find_sections() {
$sections = array();
$level_memory = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$last_section = FALSE;
// Match multiline comments
preg_match_all('#\/\*((?:(?!\*\/).)*)\*\/#s', $this->code, $matches);
foreach ($matches[1] as $match) {
$section = array();
$elements = $this->parse_match($match);
if (isset($elements['title']) && isset($elements['level'])) {
// Default htag to the lowest level htag
$elements['htag'] = 'h6';
// Find the depth of the level value
$level_depth_arr = array_filter(explode('.', $elements['level']));
$level_depth = count($level_depth_arr);
if (isset($this->section_htags[$level_depth])) {
$elements['htag'] = $this->section_htags[$level_depth];
}
// Reset the level memory to the depth of sub levels
$level_memory = array_slice($level_memory, 0, $level_depth);
$level_memory = array_pad($level_memory, 10, 0);
// Set / unset and count up the levels
foreach ($level_depth_arr as $key => $level) {
if (is_numeric($level)) {
$level_memory[$key] = $level;
}
else {
// Only count up the last level
if ($key > 0 && $key + 1 == $level_depth) {
$level_memory[$key]++;
}
// Set the level depth
$level_depth_arr[$key] = $level_memory[$key];
}
}
$elements['level'] = implode('.', $level_depth_arr) . '.';
$sections[$elements['level']] = $elements;
$last_section = $elements['level'];
}
// If no title or level is provided scan for other styleguide elements
// and append them to the previous section
else if (!empty($elements)) {
foreach ($elements as $element_label => $element_value) {
$sections[$last_section][$element_label] = isset($sections[$last_section][$element_label])
? $sections[$last_section][$element_label] . "\n" . $element_value
: $element_value;
}
}
}
ksort($sections);
$this->build_section_tree($sections);
} | php | private function find_sections() {
$sections = array();
$level_memory = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$last_section = FALSE;
// Match multiline comments
preg_match_all('#\/\*((?:(?!\*\/).)*)\*\/#s', $this->code, $matches);
foreach ($matches[1] as $match) {
$section = array();
$elements = $this->parse_match($match);
if (isset($elements['title']) && isset($elements['level'])) {
// Default htag to the lowest level htag
$elements['htag'] = 'h6';
// Find the depth of the level value
$level_depth_arr = array_filter(explode('.', $elements['level']));
$level_depth = count($level_depth_arr);
if (isset($this->section_htags[$level_depth])) {
$elements['htag'] = $this->section_htags[$level_depth];
}
// Reset the level memory to the depth of sub levels
$level_memory = array_slice($level_memory, 0, $level_depth);
$level_memory = array_pad($level_memory, 10, 0);
// Set / unset and count up the levels
foreach ($level_depth_arr as $key => $level) {
if (is_numeric($level)) {
$level_memory[$key] = $level;
}
else {
// Only count up the last level
if ($key > 0 && $key + 1 == $level_depth) {
$level_memory[$key]++;
}
// Set the level depth
$level_depth_arr[$key] = $level_memory[$key];
}
}
$elements['level'] = implode('.', $level_depth_arr) . '.';
$sections[$elements['level']] = $elements;
$last_section = $elements['level'];
}
// If no title or level is provided scan for other styleguide elements
// and append them to the previous section
else if (!empty($elements)) {
foreach ($elements as $element_label => $element_value) {
$sections[$last_section][$element_label] = isset($sections[$last_section][$element_label])
? $sections[$last_section][$element_label] . "\n" . $element_value
: $element_value;
}
}
}
ksort($sections);
$this->build_section_tree($sections);
} | [
"private",
"function",
"find_sections",
"(",
")",
"{",
"$",
"sections",
"=",
"array",
"(",
")",
";",
"$",
"level_memory",
"=",
"array",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"$",
"last_section",
"=",
"FALSE",
";",
"// Match multiline comments",
"preg_match_all",
"(",
"'#\\/\\*((?:(?!\\*\\/).)*)\\*\\/#s'",
",",
"$",
"this",
"->",
"code",
",",
"$",
"matches",
")",
";",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"match",
")",
"{",
"$",
"section",
"=",
"array",
"(",
")",
";",
"$",
"elements",
"=",
"$",
"this",
"->",
"parse_match",
"(",
"$",
"match",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"elements",
"[",
"'title'",
"]",
")",
"&&",
"isset",
"(",
"$",
"elements",
"[",
"'level'",
"]",
")",
")",
"{",
"// Default htag to the lowest level htag",
"$",
"elements",
"[",
"'htag'",
"]",
"=",
"'h6'",
";",
"// Find the depth of the level value",
"$",
"level_depth_arr",
"=",
"array_filter",
"(",
"explode",
"(",
"'.'",
",",
"$",
"elements",
"[",
"'level'",
"]",
")",
")",
";",
"$",
"level_depth",
"=",
"count",
"(",
"$",
"level_depth_arr",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"section_htags",
"[",
"$",
"level_depth",
"]",
")",
")",
"{",
"$",
"elements",
"[",
"'htag'",
"]",
"=",
"$",
"this",
"->",
"section_htags",
"[",
"$",
"level_depth",
"]",
";",
"}",
"// Reset the level memory to the depth of sub levels",
"$",
"level_memory",
"=",
"array_slice",
"(",
"$",
"level_memory",
",",
"0",
",",
"$",
"level_depth",
")",
";",
"$",
"level_memory",
"=",
"array_pad",
"(",
"$",
"level_memory",
",",
"10",
",",
"0",
")",
";",
"// Set / unset and count up the levels",
"foreach",
"(",
"$",
"level_depth_arr",
"as",
"$",
"key",
"=>",
"$",
"level",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"level",
")",
")",
"{",
"$",
"level_memory",
"[",
"$",
"key",
"]",
"=",
"$",
"level",
";",
"}",
"else",
"{",
"// Only count up the last level",
"if",
"(",
"$",
"key",
">",
"0",
"&&",
"$",
"key",
"+",
"1",
"==",
"$",
"level_depth",
")",
"{",
"$",
"level_memory",
"[",
"$",
"key",
"]",
"++",
";",
"}",
"// Set the level depth",
"$",
"level_depth_arr",
"[",
"$",
"key",
"]",
"=",
"$",
"level_memory",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"$",
"elements",
"[",
"'level'",
"]",
"=",
"implode",
"(",
"'.'",
",",
"$",
"level_depth_arr",
")",
".",
"'.'",
";",
"$",
"sections",
"[",
"$",
"elements",
"[",
"'level'",
"]",
"]",
"=",
"$",
"elements",
";",
"$",
"last_section",
"=",
"$",
"elements",
"[",
"'level'",
"]",
";",
"}",
"// If no title or level is provided scan for other styleguide elements",
"// and append them to the previous section",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"elements",
")",
")",
"{",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"element_label",
"=>",
"$",
"element_value",
")",
"{",
"$",
"sections",
"[",
"$",
"last_section",
"]",
"[",
"$",
"element_label",
"]",
"=",
"isset",
"(",
"$",
"sections",
"[",
"$",
"last_section",
"]",
"[",
"$",
"element_label",
"]",
")",
"?",
"$",
"sections",
"[",
"$",
"last_section",
"]",
"[",
"$",
"element_label",
"]",
".",
"\"\\n\"",
".",
"$",
"element_value",
":",
"$",
"element_value",
";",
"}",
"}",
"}",
"ksort",
"(",
"$",
"sections",
")",
";",
"$",
"this",
"->",
"build_section_tree",
"(",
"$",
"sections",
")",
";",
"}"
] | Parse the provided code for valid styleguide sections | [
"Parse",
"the",
"provided",
"code",
"for",
"valid",
"styleguide",
"sections"
] | 60f77a9590a1dfb605b2ca630ab0ca10e023f3ff | https://github.com/maoberlehner/cultusrego/blob/60f77a9590a1dfb605b2ca630ab0ca10e023f3ff/src/cultusrego.php#L73-L132 |
11,993 | maoberlehner/cultusrego | src/cultusrego.php | cultusrego.build_section_tree | private function build_section_tree($sections) {
$level_tree = array();
foreach ($sections as $level => $section) {
// array_filter removes the last, empty value
// from the level array that is created by the explode function
$level_depth_arr = array_filter(explode('.', $level));
$level_depth = count($level_depth_arr);
// Get the parent level
array_pop($level_depth_arr);
$level_parent = $level_depth > 1 ? implode('.', $level_depth_arr) . '.' : $level;
// Add the current section to the level tree
$level_tree[$level_depth][$level_parent][$level] = $section;
}
// Run over all main sections in $level_tree[1]
foreach ($level_tree[1] as $section_level => $section) {
// Add corresponding sub levels to the main level
$section[$section_level]['sub'] = $this->build_section_sub_tree($level_tree, 2, $section_level);
$this->sections += $section;
}
} | php | private function build_section_tree($sections) {
$level_tree = array();
foreach ($sections as $level => $section) {
// array_filter removes the last, empty value
// from the level array that is created by the explode function
$level_depth_arr = array_filter(explode('.', $level));
$level_depth = count($level_depth_arr);
// Get the parent level
array_pop($level_depth_arr);
$level_parent = $level_depth > 1 ? implode('.', $level_depth_arr) . '.' : $level;
// Add the current section to the level tree
$level_tree[$level_depth][$level_parent][$level] = $section;
}
// Run over all main sections in $level_tree[1]
foreach ($level_tree[1] as $section_level => $section) {
// Add corresponding sub levels to the main level
$section[$section_level]['sub'] = $this->build_section_sub_tree($level_tree, 2, $section_level);
$this->sections += $section;
}
} | [
"private",
"function",
"build_section_tree",
"(",
"$",
"sections",
")",
"{",
"$",
"level_tree",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"sections",
"as",
"$",
"level",
"=>",
"$",
"section",
")",
"{",
"// array_filter removes the last, empty value",
"// from the level array that is created by the explode function",
"$",
"level_depth_arr",
"=",
"array_filter",
"(",
"explode",
"(",
"'.'",
",",
"$",
"level",
")",
")",
";",
"$",
"level_depth",
"=",
"count",
"(",
"$",
"level_depth_arr",
")",
";",
"// Get the parent level",
"array_pop",
"(",
"$",
"level_depth_arr",
")",
";",
"$",
"level_parent",
"=",
"$",
"level_depth",
">",
"1",
"?",
"implode",
"(",
"'.'",
",",
"$",
"level_depth_arr",
")",
".",
"'.'",
":",
"$",
"level",
";",
"// Add the current section to the level tree",
"$",
"level_tree",
"[",
"$",
"level_depth",
"]",
"[",
"$",
"level_parent",
"]",
"[",
"$",
"level",
"]",
"=",
"$",
"section",
";",
"}",
"// Run over all main sections in $level_tree[1]",
"foreach",
"(",
"$",
"level_tree",
"[",
"1",
"]",
"as",
"$",
"section_level",
"=>",
"$",
"section",
")",
"{",
"// Add corresponding sub levels to the main level",
"$",
"section",
"[",
"$",
"section_level",
"]",
"[",
"'sub'",
"]",
"=",
"$",
"this",
"->",
"build_section_sub_tree",
"(",
"$",
"level_tree",
",",
"2",
",",
"$",
"section_level",
")",
";",
"$",
"this",
"->",
"sections",
"+=",
"$",
"section",
";",
"}",
"}"
] | Build a nested array according to the section levels
@param array $sections | [
"Build",
"a",
"nested",
"array",
"according",
"to",
"the",
"section",
"levels"
] | 60f77a9590a1dfb605b2ca630ab0ca10e023f3ff | https://github.com/maoberlehner/cultusrego/blob/60f77a9590a1dfb605b2ca630ab0ca10e023f3ff/src/cultusrego.php#L138-L163 |
11,994 | maoberlehner/cultusrego | src/cultusrego.php | cultusrego.build_section_sub_tree | private function build_section_sub_tree($main_tree, $tree_level, $section_level) {
$sub_sections = array();
if (isset($main_tree[$tree_level]) && isset($main_tree[$tree_level][$section_level])) {
$sub_sections = $main_tree[$tree_level][$section_level];
$sub_tree_level = $tree_level + 1;
foreach ($sub_sections as $sub_section_level => $sub_section) {
$sub_sections[$sub_section_level]['sub'] = $this->build_section_sub_tree($main_tree, $sub_tree_level, $sub_section_level);
}
}
return $sub_sections;
} | php | private function build_section_sub_tree($main_tree, $tree_level, $section_level) {
$sub_sections = array();
if (isset($main_tree[$tree_level]) && isset($main_tree[$tree_level][$section_level])) {
$sub_sections = $main_tree[$tree_level][$section_level];
$sub_tree_level = $tree_level + 1;
foreach ($sub_sections as $sub_section_level => $sub_section) {
$sub_sections[$sub_section_level]['sub'] = $this->build_section_sub_tree($main_tree, $sub_tree_level, $sub_section_level);
}
}
return $sub_sections;
} | [
"private",
"function",
"build_section_sub_tree",
"(",
"$",
"main_tree",
",",
"$",
"tree_level",
",",
"$",
"section_level",
")",
"{",
"$",
"sub_sections",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"main_tree",
"[",
"$",
"tree_level",
"]",
")",
"&&",
"isset",
"(",
"$",
"main_tree",
"[",
"$",
"tree_level",
"]",
"[",
"$",
"section_level",
"]",
")",
")",
"{",
"$",
"sub_sections",
"=",
"$",
"main_tree",
"[",
"$",
"tree_level",
"]",
"[",
"$",
"section_level",
"]",
";",
"$",
"sub_tree_level",
"=",
"$",
"tree_level",
"+",
"1",
";",
"foreach",
"(",
"$",
"sub_sections",
"as",
"$",
"sub_section_level",
"=>",
"$",
"sub_section",
")",
"{",
"$",
"sub_sections",
"[",
"$",
"sub_section_level",
"]",
"[",
"'sub'",
"]",
"=",
"$",
"this",
"->",
"build_section_sub_tree",
"(",
"$",
"main_tree",
",",
"$",
"sub_tree_level",
",",
"$",
"sub_section_level",
")",
";",
"}",
"}",
"return",
"$",
"sub_sections",
";",
"}"
] | Build an array of sub sections for the given section
@param array $main_tree
@param integer $tree_level
@param string $section_level
@return array Sub sections for the given section | [
"Build",
"an",
"array",
"of",
"sub",
"sections",
"for",
"the",
"given",
"section"
] | 60f77a9590a1dfb605b2ca630ab0ca10e023f3ff | https://github.com/maoberlehner/cultusrego/blob/60f77a9590a1dfb605b2ca630ab0ca10e023f3ff/src/cultusrego.php#L172-L182 |
11,995 | maoberlehner/cultusrego | src/cultusrego.php | cultusrego.parse_match | private function parse_match($match) {
$match = trim($match);
$docblock = new Docblock($match);
$tags = $docblock->getTags();
$element_values = array();
if ($title = $docblock->getShortDescription()) {
// Skip text strings that start with #
// (e.g. source map comment)
if (strpos($title, '#') === 0) {
return $element_values;
}
$element_values['title'] = $title;
}
if ($description = $docblock->getLongDescription()) {
$element_values['description'] = $description;
}
foreach ($tags as $tag) {
$tag_name = $tag->getTagName();
$tag_description = $this->clean_description($tag->getDescription());
switch ($tag_name) {
case 'code':
case 'markup':
// Default code language is markup
$element_values['code_language'] = 'markup';
// Hide rendered output by default
$element_values['code_render'] = FALSE;
// If tag name is markup render by default
if ($tag_name == 'markup') {
$element_values['code_render'] = TRUE;
}
// Look if a other code language is defined
if (preg_match("#^\[(.*?)\]\n#s", $tag_description, $code_language_match)) {
$element_values['code_language'] = $code_language_match[1];
$tag_description = str_replace('[' . $code_language_match[1] . ']', '', $tag_description);
}
$element_values['code'] = trim($tag_description);
break;
case 'color':
$colorsets = array();
$colorset_elements = explode("\n", $tag_description);
foreach ($colorset_elements as $colorset) {
$color_elements = explode('|', $colorset);
$colors = array();
foreach ($color_elements as $color) {
$color_arr = explode(':', $color);
if (count($color_arr) > 1) {
$colors[] = array(
'name' => trim($color_arr[0]),
'value' => trim($color_arr[1]),
);
}
else {
$colors[] = array('value' => $color_arr[0]);
}
}
$colorsets[] = $colors;
}
$element_values['color'] = $colorsets;
break;
case 'variable':
$variables = explode('|', $tag_description);
$element_values['variable'] = '- ' . implode(";\n- ", $variables) . ';';
break;
default:
$element_values[$tag_name] = $tag_description;
break;
}
}
return $element_values;
} | php | private function parse_match($match) {
$match = trim($match);
$docblock = new Docblock($match);
$tags = $docblock->getTags();
$element_values = array();
if ($title = $docblock->getShortDescription()) {
// Skip text strings that start with #
// (e.g. source map comment)
if (strpos($title, '#') === 0) {
return $element_values;
}
$element_values['title'] = $title;
}
if ($description = $docblock->getLongDescription()) {
$element_values['description'] = $description;
}
foreach ($tags as $tag) {
$tag_name = $tag->getTagName();
$tag_description = $this->clean_description($tag->getDescription());
switch ($tag_name) {
case 'code':
case 'markup':
// Default code language is markup
$element_values['code_language'] = 'markup';
// Hide rendered output by default
$element_values['code_render'] = FALSE;
// If tag name is markup render by default
if ($tag_name == 'markup') {
$element_values['code_render'] = TRUE;
}
// Look if a other code language is defined
if (preg_match("#^\[(.*?)\]\n#s", $tag_description, $code_language_match)) {
$element_values['code_language'] = $code_language_match[1];
$tag_description = str_replace('[' . $code_language_match[1] . ']', '', $tag_description);
}
$element_values['code'] = trim($tag_description);
break;
case 'color':
$colorsets = array();
$colorset_elements = explode("\n", $tag_description);
foreach ($colorset_elements as $colorset) {
$color_elements = explode('|', $colorset);
$colors = array();
foreach ($color_elements as $color) {
$color_arr = explode(':', $color);
if (count($color_arr) > 1) {
$colors[] = array(
'name' => trim($color_arr[0]),
'value' => trim($color_arr[1]),
);
}
else {
$colors[] = array('value' => $color_arr[0]);
}
}
$colorsets[] = $colors;
}
$element_values['color'] = $colorsets;
break;
case 'variable':
$variables = explode('|', $tag_description);
$element_values['variable'] = '- ' . implode(";\n- ", $variables) . ';';
break;
default:
$element_values[$tag_name] = $tag_description;
break;
}
}
return $element_values;
} | [
"private",
"function",
"parse_match",
"(",
"$",
"match",
")",
"{",
"$",
"match",
"=",
"trim",
"(",
"$",
"match",
")",
";",
"$",
"docblock",
"=",
"new",
"Docblock",
"(",
"$",
"match",
")",
";",
"$",
"tags",
"=",
"$",
"docblock",
"->",
"getTags",
"(",
")",
";",
"$",
"element_values",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"title",
"=",
"$",
"docblock",
"->",
"getShortDescription",
"(",
")",
")",
"{",
"// Skip text strings that start with #",
"// (e.g. source map comment)",
"if",
"(",
"strpos",
"(",
"$",
"title",
",",
"'#'",
")",
"===",
"0",
")",
"{",
"return",
"$",
"element_values",
";",
"}",
"$",
"element_values",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"}",
"if",
"(",
"$",
"description",
"=",
"$",
"docblock",
"->",
"getLongDescription",
"(",
")",
")",
"{",
"$",
"element_values",
"[",
"'description'",
"]",
"=",
"$",
"description",
";",
"}",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"$",
"tag_name",
"=",
"$",
"tag",
"->",
"getTagName",
"(",
")",
";",
"$",
"tag_description",
"=",
"$",
"this",
"->",
"clean_description",
"(",
"$",
"tag",
"->",
"getDescription",
"(",
")",
")",
";",
"switch",
"(",
"$",
"tag_name",
")",
"{",
"case",
"'code'",
":",
"case",
"'markup'",
":",
"// Default code language is markup",
"$",
"element_values",
"[",
"'code_language'",
"]",
"=",
"'markup'",
";",
"// Hide rendered output by default",
"$",
"element_values",
"[",
"'code_render'",
"]",
"=",
"FALSE",
";",
"// If tag name is markup render by default",
"if",
"(",
"$",
"tag_name",
"==",
"'markup'",
")",
"{",
"$",
"element_values",
"[",
"'code_render'",
"]",
"=",
"TRUE",
";",
"}",
"// Look if a other code language is defined",
"if",
"(",
"preg_match",
"(",
"\"#^\\[(.*?)\\]\\n#s\"",
",",
"$",
"tag_description",
",",
"$",
"code_language_match",
")",
")",
"{",
"$",
"element_values",
"[",
"'code_language'",
"]",
"=",
"$",
"code_language_match",
"[",
"1",
"]",
";",
"$",
"tag_description",
"=",
"str_replace",
"(",
"'['",
".",
"$",
"code_language_match",
"[",
"1",
"]",
".",
"']'",
",",
"''",
",",
"$",
"tag_description",
")",
";",
"}",
"$",
"element_values",
"[",
"'code'",
"]",
"=",
"trim",
"(",
"$",
"tag_description",
")",
";",
"break",
";",
"case",
"'color'",
":",
"$",
"colorsets",
"=",
"array",
"(",
")",
";",
"$",
"colorset_elements",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"tag_description",
")",
";",
"foreach",
"(",
"$",
"colorset_elements",
"as",
"$",
"colorset",
")",
"{",
"$",
"color_elements",
"=",
"explode",
"(",
"'|'",
",",
"$",
"colorset",
")",
";",
"$",
"colors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"color_elements",
"as",
"$",
"color",
")",
"{",
"$",
"color_arr",
"=",
"explode",
"(",
"':'",
",",
"$",
"color",
")",
";",
"if",
"(",
"count",
"(",
"$",
"color_arr",
")",
">",
"1",
")",
"{",
"$",
"colors",
"[",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"trim",
"(",
"$",
"color_arr",
"[",
"0",
"]",
")",
",",
"'value'",
"=>",
"trim",
"(",
"$",
"color_arr",
"[",
"1",
"]",
")",
",",
")",
";",
"}",
"else",
"{",
"$",
"colors",
"[",
"]",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"color_arr",
"[",
"0",
"]",
")",
";",
"}",
"}",
"$",
"colorsets",
"[",
"]",
"=",
"$",
"colors",
";",
"}",
"$",
"element_values",
"[",
"'color'",
"]",
"=",
"$",
"colorsets",
";",
"break",
";",
"case",
"'variable'",
":",
"$",
"variables",
"=",
"explode",
"(",
"'|'",
",",
"$",
"tag_description",
")",
";",
"$",
"element_values",
"[",
"'variable'",
"]",
"=",
"'- '",
".",
"implode",
"(",
"\";\\n- \"",
",",
"$",
"variables",
")",
".",
"';'",
";",
"break",
";",
"default",
":",
"$",
"element_values",
"[",
"$",
"tag_name",
"]",
"=",
"$",
"tag_description",
";",
"break",
";",
"}",
"}",
"return",
"$",
"element_values",
";",
"}"
] | Find styleguide elements and their values in a comment section
@param string $match The contents of a matched comment section
@return array Values of the found styleguide elements | [
"Find",
"styleguide",
"elements",
"and",
"their",
"values",
"in",
"a",
"comment",
"section"
] | 60f77a9590a1dfb605b2ca630ab0ca10e023f3ff | https://github.com/maoberlehner/cultusrego/blob/60f77a9590a1dfb605b2ca630ab0ca10e023f3ff/src/cultusrego.php#L189-L265 |
11,996 | pletfix/core | src/Services/Process.php | Process.reset | private function reset()
{
// it is important that you close any pipes before calling proc_close in order to avoid a deadlock
if ($this->pipes !== null) {
foreach ($this->pipes as $pipe) {
fclose($pipe);
}
$this->pipes = null;
}
if ($this->process !== null) {
proc_close($this->process);
$this->process = null;
}
$this->exitcode = null;
} | php | private function reset()
{
// it is important that you close any pipes before calling proc_close in order to avoid a deadlock
if ($this->pipes !== null) {
foreach ($this->pipes as $pipe) {
fclose($pipe);
}
$this->pipes = null;
}
if ($this->process !== null) {
proc_close($this->process);
$this->process = null;
}
$this->exitcode = null;
} | [
"private",
"function",
"reset",
"(",
")",
"{",
"// it is important that you close any pipes before calling proc_close in order to avoid a deadlock",
"if",
"(",
"$",
"this",
"->",
"pipes",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"pipes",
"as",
"$",
"pipe",
")",
"{",
"fclose",
"(",
"$",
"pipe",
")",
";",
"}",
"$",
"this",
"->",
"pipes",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"process",
"!==",
"null",
")",
"{",
"proc_close",
"(",
"$",
"this",
"->",
"process",
")",
";",
"$",
"this",
"->",
"process",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"exitcode",
"=",
"null",
";",
"}"
] | Reset the data. | [
"Reset",
"the",
"data",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Process.php#L68-L84 |
11,997 | pletfix/core | src/Services/Process.php | Process.start | public function start()
{
if ($this->isRunning()) {
throw new LogicException('Process is already running');
}
$this->reset();
$cmd = $this->cmd;
if (substr($cmd, 0, 4) == 'php ') {
$php = PHP_BINARY ?: PHP_BINDIR . '/php';
$cmd = $php . substr($cmd, 3);
}
$descriptorspec = [
0 => ['pipe', 'r'], // STDIN
1 => ['pipe', 'w'], // STDOUT
2 => ['pipe', 'w'] // STDERR
];
$options = [
'suppress_errors' => true,
'binary_pipes' => true,
];
$this->process = proc_open($cmd, $descriptorspec, $this->pipes, base_path(), $this->env, $options);
if (!is_resource($this->process)) {
throw new RuntimeException('Unable to launch a new process.');
}
} | php | public function start()
{
if ($this->isRunning()) {
throw new LogicException('Process is already running');
}
$this->reset();
$cmd = $this->cmd;
if (substr($cmd, 0, 4) == 'php ') {
$php = PHP_BINARY ?: PHP_BINDIR . '/php';
$cmd = $php . substr($cmd, 3);
}
$descriptorspec = [
0 => ['pipe', 'r'], // STDIN
1 => ['pipe', 'w'], // STDOUT
2 => ['pipe', 'w'] // STDERR
];
$options = [
'suppress_errors' => true,
'binary_pipes' => true,
];
$this->process = proc_open($cmd, $descriptorspec, $this->pipes, base_path(), $this->env, $options);
if (!is_resource($this->process)) {
throw new RuntimeException('Unable to launch a new process.');
}
} | [
"public",
"function",
"start",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isRunning",
"(",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Process is already running'",
")",
";",
"}",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"$",
"cmd",
"=",
"$",
"this",
"->",
"cmd",
";",
"if",
"(",
"substr",
"(",
"$",
"cmd",
",",
"0",
",",
"4",
")",
"==",
"'php '",
")",
"{",
"$",
"php",
"=",
"PHP_BINARY",
"?",
":",
"PHP_BINDIR",
".",
"'/php'",
";",
"$",
"cmd",
"=",
"$",
"php",
".",
"substr",
"(",
"$",
"cmd",
",",
"3",
")",
";",
"}",
"$",
"descriptorspec",
"=",
"[",
"0",
"=>",
"[",
"'pipe'",
",",
"'r'",
"]",
",",
"// STDIN",
"1",
"=>",
"[",
"'pipe'",
",",
"'w'",
"]",
",",
"// STDOUT",
"2",
"=>",
"[",
"'pipe'",
",",
"'w'",
"]",
"// STDERR",
"]",
";",
"$",
"options",
"=",
"[",
"'suppress_errors'",
"=>",
"true",
",",
"'binary_pipes'",
"=>",
"true",
",",
"]",
";",
"$",
"this",
"->",
"process",
"=",
"proc_open",
"(",
"$",
"cmd",
",",
"$",
"descriptorspec",
",",
"$",
"this",
"->",
"pipes",
",",
"base_path",
"(",
")",
",",
"$",
"this",
"->",
"env",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"process",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Unable to launch a new process.'",
")",
";",
"}",
"}"
] | Starts a background process.
@throws LogicException When process is already running
@throws RuntimeException When process can't be launched | [
"Starts",
"a",
"background",
"process",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Process.php#L109-L139 |
11,998 | pletfix/core | src/Services/Process.php | Process.terminate | public function terminate($signal = 15)
{
if ($this->process === null) {
return false;
}
return proc_terminate($this->process, $signal);
} | php | public function terminate($signal = 15)
{
if ($this->process === null) {
return false;
}
return proc_terminate($this->process, $signal);
} | [
"public",
"function",
"terminate",
"(",
"$",
"signal",
"=",
"15",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"process",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"proc_terminate",
"(",
"$",
"this",
"->",
"process",
",",
"$",
"signal",
")",
";",
"}"
] | Terminate the process.
This optional parameter is only useful on POSIX operating systems; you may specify a signal to send to the
process using the kill(2) system call. The default is SIGTERM (15).
SIGTERM (15) is the termination signal. The default behavior is to terminate the process, but it also can be
caught or ignored. The intention is to kill the process, but to first allow it a chance to cleanup.
SIGKILL (9) is the kill signal. The only behavior is to kill the process, immediately. As the process cannot
catch the signal, it cannot cleanup, and thus this is a signal of last resort.
@param int $signal
@return bool The termination status of the process that was run. | [
"Terminate",
"the",
"process",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Process.php#L175-L182 |
11,999 | pletfix/core | src/Services/Process.php | Process.write | public function write($line)
{
return $this->pipes !== null ? fwrite($this->pipes[0], $line . PHP_EOL) : false;
} | php | public function write($line)
{
return $this->pipes !== null ? fwrite($this->pipes[0], $line . PHP_EOL) : false;
} | [
"public",
"function",
"write",
"(",
"$",
"line",
")",
"{",
"return",
"$",
"this",
"->",
"pipes",
"!==",
"null",
"?",
"fwrite",
"(",
"$",
"this",
"->",
"pipes",
"[",
"0",
"]",
",",
"$",
"line",
".",
"PHP_EOL",
")",
":",
"false",
";",
"}"
] | Write a line to STDIN.
Returns the number of bytes written, or FALSE on error.
@param string $line
@return int|false | [
"Write",
"a",
"line",
"to",
"STDIN",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Process.php#L214-L217 |
Subsets and Splits