repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
protobuf-php/google-protobuf-proto | src/google/protobuf/FieldOptions.php | FieldOptions.setJstype | public function setJstype(\google\protobuf\FieldOptions\JSType $value = null)
{
$this->jstype = $value;
} | php | public function setJstype(\google\protobuf\FieldOptions\JSType $value = null)
{
$this->jstype = $value;
} | [
"public",
"function",
"setJstype",
"(",
"\\",
"google",
"\\",
"protobuf",
"\\",
"FieldOptions",
"\\",
"JSType",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"jstype",
"=",
"$",
"value",
";",
"}"
] | Set 'jstype' value
@param \google\protobuf\FieldOptions\JSType $value | [
"Set",
"jstype",
"value"
] | da1827b4a23fccd4eb998a8d4bcd972f2330bc29 | https://github.com/protobuf-php/google-protobuf-proto/blob/da1827b4a23fccd4eb998a8d4bcd972f2330bc29/src/google/protobuf/FieldOptions.php#L175-L178 | train |
globalis-ms/puppet-skilled-framework | src/Database/Query/Grammar.php | Grammar.whereNotIn | protected function whereNotIn(Builder $query, $where)
{
if (empty($where['values'])) {
return '1 = 1';
}
$values = $this->parameterize($where['values']);
return $this->wrap($where['column']).' not in ('.$values.')';
} | php | protected function whereNotIn(Builder $query, $where)
{
if (empty($where['values'])) {
return '1 = 1';
}
$values = $this->parameterize($where['values']);
return $this->wrap($where['column']).' not in ('.$values.')';
} | [
"protected",
"function",
"whereNotIn",
"(",
"Builder",
"$",
"query",
",",
"$",
"where",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"where",
"[",
"'values'",
"]",
")",
")",
"{",
"return",
"'1 = 1'",
";",
"}",
"$",
"values",
"=",
"$",
"this",
"->",
"par... | Compile a "where not in" clause.
@param \Globalis\PuppetSkilled\Database\Query\Builder $query
@param array $where
@return string | [
"Compile",
"a",
"where",
"not",
"in",
"clause",
"."
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/Database/Query/Grammar.php#L321-L330 | train |
globalis-ms/puppet-skilled-framework | src/Database/Query/Grammar.php | Grammar.compileReplace | public function compileReplace(Builder $query, array $values)
{
// Essentially we will force every insert to be treated as a batch insert which
// simply makes creating the SQL easier for us since we can utilize the same
// basic routine regardless of an amount of records given to us to insert.
$table = $this->wrapTable($query->from);
if (! is_array(reset($values))) {
$values = [$values];
}
$columns = $this->columnize(array_keys(reset($values)));
// We need to build a list of parameter place-holders of values that are bound
// to the query. Each insert should have the exact same amount of parameter
// bindings so we will loop through the record and parameterize them all.
$parameters = [];
foreach ($values as $record) {
$parameters[] = '('.$this->parameterize($record).')';
}
$parameters = implode(', ', $parameters);
return "replace into $table ($columns) values $parameters";
} | php | public function compileReplace(Builder $query, array $values)
{
// Essentially we will force every insert to be treated as a batch insert which
// simply makes creating the SQL easier for us since we can utilize the same
// basic routine regardless of an amount of records given to us to insert.
$table = $this->wrapTable($query->from);
if (! is_array(reset($values))) {
$values = [$values];
}
$columns = $this->columnize(array_keys(reset($values)));
// We need to build a list of parameter place-holders of values that are bound
// to the query. Each insert should have the exact same amount of parameter
// bindings so we will loop through the record and parameterize them all.
$parameters = [];
foreach ($values as $record) {
$parameters[] = '('.$this->parameterize($record).')';
}
$parameters = implode(', ', $parameters);
return "replace into $table ($columns) values $parameters";
} | [
"public",
"function",
"compileReplace",
"(",
"Builder",
"$",
"query",
",",
"array",
"$",
"values",
")",
"{",
"// Essentially we will force every insert to be treated as a batch insert which",
"// simply makes creating the SQL easier for us since we can utilize the same",
"// basic rout... | Compile an replace statement into SQL.
@param \Globalis\PuppetSkilled\Database\Query\Builder $query
@param array $values
@return string | [
"Compile",
"an",
"replace",
"statement",
"into",
"SQL",
"."
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/Database/Query/Grammar.php#L649-L674 | train |
canax/textfilter | src/TextFilter/Filter/Variable.php | Variable.getVariableValue | protected function getVariableValue(array $matches)
{
$res = $matches[0];
$variable = substr($matches[0], 1, -1);
if (isset($this->frontmatter[$variable])) {
$res = $this->frontmatter[$variable];
}
return $res;
} | php | protected function getVariableValue(array $matches)
{
$res = $matches[0];
$variable = substr($matches[0], 1, -1);
if (isset($this->frontmatter[$variable])) {
$res = $this->frontmatter[$variable];
}
return $res;
} | [
"protected",
"function",
"getVariableValue",
"(",
"array",
"$",
"matches",
")",
"{",
"$",
"res",
"=",
"$",
"matches",
"[",
"0",
"]",
";",
"$",
"variable",
"=",
"substr",
"(",
"$",
"matches",
"[",
"0",
"]",
",",
"1",
",",
"-",
"1",
")",
";",
"if",... | Detect and extract inline variables.
@param string $text to parse.
@return boolean|void true when block is found and parsed, else void.
@SuppressWarnings(PHPMD.CyclomaticComplexity) | [
"Detect",
"and",
"extract",
"inline",
"variables",
"."
] | a90177cd404b093541222fd0d6cf71907ac2ce25 | https://github.com/canax/textfilter/blob/a90177cd404b093541222fd0d6cf71907ac2ce25/src/TextFilter/Filter/Variable.php#L75-L85 | train |
CatsSystem/swoole-etcd | etcd/ClusterClient.php | ClusterClient.MemberAdd | public function MemberAdd(MemberAddRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Cluster/MemberAdd',
$argument,
['\Etcdserverpb\MemberAddResponse', 'decode'],
$metadata,
$options
);
} | php | public function MemberAdd(MemberAddRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Cluster/MemberAdd',
$argument,
['\Etcdserverpb\MemberAddResponse', 'decode'],
$metadata,
$options
);
} | [
"public",
"function",
"MemberAdd",
"(",
"MemberAddRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Cluster/MemberAdd'",
",",
"$",... | MemberAdd adds a member into the cluster.
@param MemberAddRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"MemberAdd",
"adds",
"a",
"member",
"into",
"the",
"cluster",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/ClusterClient.php#L37-L46 | train |
CatsSystem/swoole-etcd | etcd/ClusterClient.php | ClusterClient.MemberRemove | public function MemberRemove(MemberRemoveRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Cluster/MemberRemove',
$argument,
['\Etcdserverpb\MemberRemoveResponse', 'decode'],
$metadata,
$options
);
} | php | public function MemberRemove(MemberRemoveRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Cluster/MemberRemove',
$argument,
['\Etcdserverpb\MemberRemoveResponse', 'decode'],
$metadata,
$options
);
} | [
"public",
"function",
"MemberRemove",
"(",
"MemberRemoveRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Cluster/MemberRemove'",
",... | MemberRemove removes an existing member from the cluster.
@param MemberRemoveRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"MemberRemove",
"removes",
"an",
"existing",
"member",
"from",
"the",
"cluster",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/ClusterClient.php#L55-L64 | train |
CatsSystem/swoole-etcd | etcd/ClusterClient.php | ClusterClient.MemberUpdate | public function MemberUpdate(MemberUpdateRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Cluster/MemberUpdate',
$argument,
['\Etcdserverpb\MemberUpdateResponse', 'decode'],
$metadata,
$options
);
} | php | public function MemberUpdate(MemberUpdateRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Cluster/MemberUpdate',
$argument,
['\Etcdserverpb\MemberUpdateResponse', 'decode'],
$metadata,
$options
);
} | [
"public",
"function",
"MemberUpdate",
"(",
"MemberUpdateRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Cluster/MemberUpdate'",
",... | MemberUpdate updates the member configuration.
@param MemberUpdateRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"MemberUpdate",
"updates",
"the",
"member",
"configuration",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/ClusterClient.php#L73-L82 | train |
CatsSystem/swoole-etcd | etcd/ClusterClient.php | ClusterClient.MemberList | public function MemberList(MemberListRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Cluster/MemberList',
$argument,
['\Etcdserverpb\MemberListResponse', 'decode'],
$metadata,
$options
);
} | php | public function MemberList(MemberListRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Cluster/MemberList',
$argument,
['\Etcdserverpb\MemberListResponse', 'decode'],
$metadata,
$options
);
} | [
"public",
"function",
"MemberList",
"(",
"MemberListRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Cluster/MemberList'",
",",
"... | MemberList lists all the members in the cluster.
@param MemberListRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"MemberList",
"lists",
"all",
"the",
"members",
"in",
"the",
"cluster",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/ClusterClient.php#L91-L100 | train |
arkphp/database | src/Util.php | Util.checkReconnectError | public static function checkReconnectError($errorCode, $errorInfo, $exception) {
if ($exception) {
if (stripos($exception->getMessage(), self::MYSQL_GONE_AWAY) !== false || stripos($exception->getMessage(), self::MYSQL_REFUSED) !== false) {
return true;
}
} elseif ($errorInfo) {
if (stripos($errorInfo[2], self::MYSQL_GONE_AWAY) !== false || stripos($errorInfo[2], self::MYSQL_REFUSED) !== false) {
return true;
}
}
return false;
} | php | public static function checkReconnectError($errorCode, $errorInfo, $exception) {
if ($exception) {
if (stripos($exception->getMessage(), self::MYSQL_GONE_AWAY) !== false || stripos($exception->getMessage(), self::MYSQL_REFUSED) !== false) {
return true;
}
} elseif ($errorInfo) {
if (stripos($errorInfo[2], self::MYSQL_GONE_AWAY) !== false || stripos($errorInfo[2], self::MYSQL_REFUSED) !== false) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"checkReconnectError",
"(",
"$",
"errorCode",
",",
"$",
"errorInfo",
",",
"$",
"exception",
")",
"{",
"if",
"(",
"$",
"exception",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
... | Check whether we need to reconnect database
@param string|null $errorCode
@param array|null $errorInfo
@param \Exception|null $exception
@return boolean | [
"Check",
"whether",
"we",
"need",
"to",
"reconnect",
"database"
] | 5b332d0b0b683bb4211fa12687e7c89a3ab158df | https://github.com/arkphp/database/blob/5b332d0b0b683bb4211fa12687e7c89a3ab158df/src/Util.php#L20-L32 | train |
rchouinard/rych-otp | src/TOTP.php | TOTP.setTimeStep | public function setTimeStep($timeStep)
{
$timeStep = abs(intval($timeStep));
$this->timeStep = $timeStep;
return $this;
} | php | public function setTimeStep($timeStep)
{
$timeStep = abs(intval($timeStep));
$this->timeStep = $timeStep;
return $this;
} | [
"public",
"function",
"setTimeStep",
"(",
"$",
"timeStep",
")",
"{",
"$",
"timeStep",
"=",
"abs",
"(",
"intval",
"(",
"$",
"timeStep",
")",
")",
";",
"$",
"this",
"->",
"timeStep",
"=",
"$",
"timeStep",
";",
"return",
"$",
"this",
";",
"}"
] | Set the timestep value
@param integer $timeStep The timestep value.
@return self Returns an instance of self for method chaining. | [
"Set",
"the",
"timestep",
"value"
] | b3c7fc11284c546cd291f14fb383a7d49ab23832 | https://github.com/rchouinard/rych-otp/blob/b3c7fc11284c546cd291f14fb383a7d49ab23832/src/TOTP.php#L70-L76 | train |
rchouinard/rych-otp | src/TOTP.php | TOTP.timestampToCounter | private static function timestampToCounter($timestamp, $timeStep)
{
$timestamp = abs(intval($timestamp));
$counter = intval(($timestamp * 1000) / ($timeStep * 1000));
return $counter;
} | php | private static function timestampToCounter($timestamp, $timeStep)
{
$timestamp = abs(intval($timestamp));
$counter = intval(($timestamp * 1000) / ($timeStep * 1000));
return $counter;
} | [
"private",
"static",
"function",
"timestampToCounter",
"(",
"$",
"timestamp",
",",
"$",
"timeStep",
")",
"{",
"$",
"timestamp",
"=",
"abs",
"(",
"intval",
"(",
"$",
"timestamp",
")",
")",
";",
"$",
"counter",
"=",
"intval",
"(",
"(",
"$",
"timestamp",
... | Convert a timestamp into a usable counter value
@param integer $timestamp A UNIX timestamp.
@param integer $timeStep The timestep value.
@return integer Returns the calculated counter value. | [
"Convert",
"a",
"timestamp",
"into",
"a",
"usable",
"counter",
"value"
] | b3c7fc11284c546cd291f14fb383a7d49ab23832 | https://github.com/rchouinard/rych-otp/blob/b3c7fc11284c546cd291f14fb383a7d49ab23832/src/TOTP.php#L112-L118 | train |
TypiCMS/Galleries | src/Presenters/ModulePresenter.php | ModulePresenter.countFiles | public function countFiles()
{
$nbFiles = $this->entity->files->count();
$label = $nbFiles ? 'label-success' : 'label-default';
$html = [];
$html[] = '<span class="label '.$label.'">';
$html[] = $nbFiles;
$html[] = '</span>';
return implode("\r\n", $html);
} | php | public function countFiles()
{
$nbFiles = $this->entity->files->count();
$label = $nbFiles ? 'label-success' : 'label-default';
$html = [];
$html[] = '<span class="label '.$label.'">';
$html[] = $nbFiles;
$html[] = '</span>';
return implode("\r\n", $html);
} | [
"public",
"function",
"countFiles",
"(",
")",
"{",
"$",
"nbFiles",
"=",
"$",
"this",
"->",
"entity",
"->",
"files",
"->",
"count",
"(",
")",
";",
"$",
"label",
"=",
"$",
"nbFiles",
"?",
"'label-success'",
":",
"'label-default'",
";",
"$",
"html",
"=",
... | Files in list.
@return string | [
"Files",
"in",
"list",
"."
] | 3160eb90ea5ca08439818b3eb23b0ea080eb3c10 | https://github.com/TypiCMS/Galleries/blob/3160eb90ea5ca08439818b3eb23b0ea080eb3c10/src/Presenters/ModulePresenter.php#L14-L24 | train |
jbouzekri/FileUploaderBundle | DependencyInjection/MainConfiguration.php | MainConfiguration.addResolversSection | protected function addResolversSection(ArrayNodeDefinition $node, array $factories)
{
$resolverNodeBuilder = $node
->fixXmlConfig('resolver')
->children()
->arrayNode('resolvers')
->useAttributeAsKey('name')
->prototype('array')
->performNoDeepMerging()
->children()
;
foreach ($factories as $name => $factory) {
$factoryNode = $resolverNodeBuilder->arrayNode($name)->canBeUnset();
$factory->addConfiguration($factoryNode);
}
} | php | protected function addResolversSection(ArrayNodeDefinition $node, array $factories)
{
$resolverNodeBuilder = $node
->fixXmlConfig('resolver')
->children()
->arrayNode('resolvers')
->useAttributeAsKey('name')
->prototype('array')
->performNoDeepMerging()
->children()
;
foreach ($factories as $name => $factory) {
$factoryNode = $resolverNodeBuilder->arrayNode($name)->canBeUnset();
$factory->addConfiguration($factoryNode);
}
} | [
"protected",
"function",
"addResolversSection",
"(",
"ArrayNodeDefinition",
"$",
"node",
",",
"array",
"$",
"factories",
")",
"{",
"$",
"resolverNodeBuilder",
"=",
"$",
"node",
"->",
"fixXmlConfig",
"(",
"'resolver'",
")",
"->",
"children",
"(",
")",
"->",
"ar... | Add resolvers section
@param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node
@param array $factories | [
"Add",
"resolvers",
"section"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/DependencyInjection/MainConfiguration.php#L80-L97 | train |
jbouzekri/FileUploaderBundle | DependencyInjection/MainConfiguration.php | MainConfiguration.getValidators | protected function getValidators($key)
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root($key);
$rootNode
->defaultValue(array())
->prototype('variable')
->end()
->beforeNormalization()
->always()
->then(function ($values) {
// Normalize null as array
foreach ($values as $key => $value) {
if ($value === null) {
$values[$key] = array();
}
}
return $values;
})
->end();
$this->addValidatorValidation($rootNode);
return $rootNode;
} | php | protected function getValidators($key)
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root($key);
$rootNode
->defaultValue(array())
->prototype('variable')
->end()
->beforeNormalization()
->always()
->then(function ($values) {
// Normalize null as array
foreach ($values as $key => $value) {
if ($value === null) {
$values[$key] = array();
}
}
return $values;
})
->end();
$this->addValidatorValidation($rootNode);
return $rootNode;
} | [
"protected",
"function",
"getValidators",
"(",
"$",
"key",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"$",
"key",
")",
";",
"$",
"rootNode",
"->",
"defaultValue",
... | Add a custom validator key to configuration
@param $key
@param string $key
@return TreeBuilder | [
"Add",
"a",
"custom",
"validator",
"key",
"to",
"configuration"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/DependencyInjection/MainConfiguration.php#L108-L133 | train |
jbouzekri/FileUploaderBundle | DependencyInjection/MainConfiguration.php | MainConfiguration.addValidatorValidation | protected function addValidatorValidation(ArrayNodeDefinition $node)
{
$node->validate()
->ifTrue(function ($value) {
if (!is_array($value)) {
return true;
}
// All key must be string. Used as alias for the validator service
if (count(array_filter(array_keys($value), 'is_string')) != count($value)) {
return true;
}
// All value must be array. Used as configuration for validator
if (count(array_filter(array_values($value), 'is_array')) != count($value)) {
return true;
}
return false;
})
->thenInvalid('Invalid validators configuration')
->end();
} | php | protected function addValidatorValidation(ArrayNodeDefinition $node)
{
$node->validate()
->ifTrue(function ($value) {
if (!is_array($value)) {
return true;
}
// All key must be string. Used as alias for the validator service
if (count(array_filter(array_keys($value), 'is_string')) != count($value)) {
return true;
}
// All value must be array. Used as configuration for validator
if (count(array_filter(array_values($value), 'is_array')) != count($value)) {
return true;
}
return false;
})
->thenInvalid('Invalid validators configuration')
->end();
} | [
"protected",
"function",
"addValidatorValidation",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"validate",
"(",
")",
"->",
"ifTrue",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")... | Add validation to a validator key
@param ArrayNodeDefinition $node | [
"Add",
"validation",
"to",
"a",
"validator",
"key"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/DependencyInjection/MainConfiguration.php#L140-L162 | train |
VincentChalnot/SidusFilterBundle | Filter/Type/Doctrine/AdvancedTextFilterType.php | AdvancedTextFilterType.applyDQL | protected function applyDQL(QueryBuilder $qb, string $column, $data): string
{
$input = $data['input'];
$uid = uniqid('text', false); // Generate random parameter names to prevent collisions
switch ($data['option']) {
case 'exact':
$qb->setParameter($uid, $input);
return "{$column} = :{$uid}";
case 'like_':
$qb->setParameter($uid, trim($input, '%').'%');
return "{$column} LIKE :{$uid}";
case '_like':
$qb->setParameter($uid, '%'.trim($input, '%'));
return "{$column} LIKE :{$uid}";
case '_like_':
$qb->setParameter($uid, '%'.trim($input, '%').'%');
return "{$column} LIKE :{$uid}";
case 'notlike_':
$qb->setParameter($uid, trim($input, '%').'%');
return "{$column} NOT LIKE :{$uid}";
case '_notlike':
$qb->setParameter($uid, '%'.trim($input, '%'));
return "{$column} NOT LIKE :{$uid}";
case '_notlike_':
$qb->setParameter($uid, '%'.trim($input, '%').'%');
return "{$column} NOT LIKE :{$uid}";
case 'empty':
return "{$column} = ''";
case 'notempty':
return "{$column} != ''";
case 'null':
return "{$column} IS NULL";
case 'notnull':
return "{$column} IS NOT NULL";
}
throw new \UnexpectedValueException("Unknown option '{$data['option']}'");
} | php | protected function applyDQL(QueryBuilder $qb, string $column, $data): string
{
$input = $data['input'];
$uid = uniqid('text', false); // Generate random parameter names to prevent collisions
switch ($data['option']) {
case 'exact':
$qb->setParameter($uid, $input);
return "{$column} = :{$uid}";
case 'like_':
$qb->setParameter($uid, trim($input, '%').'%');
return "{$column} LIKE :{$uid}";
case '_like':
$qb->setParameter($uid, '%'.trim($input, '%'));
return "{$column} LIKE :{$uid}";
case '_like_':
$qb->setParameter($uid, '%'.trim($input, '%').'%');
return "{$column} LIKE :{$uid}";
case 'notlike_':
$qb->setParameter($uid, trim($input, '%').'%');
return "{$column} NOT LIKE :{$uid}";
case '_notlike':
$qb->setParameter($uid, '%'.trim($input, '%'));
return "{$column} NOT LIKE :{$uid}";
case '_notlike_':
$qb->setParameter($uid, '%'.trim($input, '%').'%');
return "{$column} NOT LIKE :{$uid}";
case 'empty':
return "{$column} = ''";
case 'notempty':
return "{$column} != ''";
case 'null':
return "{$column} IS NULL";
case 'notnull':
return "{$column} IS NOT NULL";
}
throw new \UnexpectedValueException("Unknown option '{$data['option']}'");
} | [
"protected",
"function",
"applyDQL",
"(",
"QueryBuilder",
"$",
"qb",
",",
"string",
"$",
"column",
",",
"$",
"data",
")",
":",
"string",
"{",
"$",
"input",
"=",
"$",
"data",
"[",
"'input'",
"]",
";",
"$",
"uid",
"=",
"uniqid",
"(",
"'text'",
",",
"... | Must return the DQL statement and set the proper parameters in the QueryBuilder
@param QueryBuilder $qb
@param string $column
@param mixed $data
@return string | [
"Must",
"return",
"the",
"DQL",
"statement",
"and",
"set",
"the",
"proper",
"parameters",
"in",
"the",
"QueryBuilder"
] | c11a60fe29d1410b8092617d8ffd58f3bdd1fd40 | https://github.com/VincentChalnot/SidusFilterBundle/blob/c11a60fe29d1410b8092617d8ffd58f3bdd1fd40/Filter/Type/Doctrine/AdvancedTextFilterType.php#L25-L68 | train |
fadion/ValidatorAssistant | src/Subrules.php | Subrules.fixMessages | private function fixMessages($messages, $name, $realName, $subName)
{
$toRemove = null;
foreach ($messages as $messageRule => $message) {
if (strpos($messageRule, $name.'.') !== false) {
$toRemove = $messageRule;
$messageRule = substr($messageRule, strpos($messageRule, '.') + 1);
$messages[$realName.'_'.$subName.'.'.$messageRule] = $message;
}
}
if (isset($toRemove)) {
$this->messageKey = $toRemove;
}
return $messages;
} | php | private function fixMessages($messages, $name, $realName, $subName)
{
$toRemove = null;
foreach ($messages as $messageRule => $message) {
if (strpos($messageRule, $name.'.') !== false) {
$toRemove = $messageRule;
$messageRule = substr($messageRule, strpos($messageRule, '.') + 1);
$messages[$realName.'_'.$subName.'.'.$messageRule] = $message;
}
}
if (isset($toRemove)) {
$this->messageKey = $toRemove;
}
return $messages;
} | [
"private",
"function",
"fixMessages",
"(",
"$",
"messages",
",",
"$",
"name",
",",
"$",
"realName",
",",
"$",
"subName",
")",
"{",
"$",
"toRemove",
"=",
"null",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"messageRule",
"=>",
"$",
"message",
")",
... | Fixes error messages to reflect subrules
names.
@param array $messages
@param string $name
@param string $realName
@param string $subName
@return array | [
"Fixes",
"error",
"messages",
"to",
"reflect",
"subrules",
"names",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/Subrules.php#L225-L243 | train |
fadion/ValidatorAssistant | src/Subrules.php | Subrules.removeMessage | private function removeMessage($messages)
{
if (! is_null($this->messageKey)) {
unset($messages[$this->messageKey]);
$this->messageKey = null;
}
return $messages;
} | php | private function removeMessage($messages)
{
if (! is_null($this->messageKey)) {
unset($messages[$this->messageKey]);
$this->messageKey = null;
}
return $messages;
} | [
"private",
"function",
"removeMessage",
"(",
"$",
"messages",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"messageKey",
")",
")",
"{",
"unset",
"(",
"$",
"messages",
"[",
"$",
"this",
"->",
"messageKey",
"]",
")",
";",
"$",
"this",
... | Removes a set message key.
@param array $messages
@return array | [
"Removes",
"a",
"set",
"message",
"key",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/Subrules.php#L251-L259 | train |
fadion/ValidatorAssistant | src/Subrules.php | Subrules.fixRules | private function fixRules($rules, $rule, $name, $realName, $subName)
{
if (isset($rules[$name])) {
$key = array_search($name, array_keys($rules));
$rules = array_slice($rules, 0, $key, true) +
array($realName.'_'.$subName => $rule) +
array_slice($rules, $key, count($rules) - $key, true);
}
return $rules;
} | php | private function fixRules($rules, $rule, $name, $realName, $subName)
{
if (isset($rules[$name])) {
$key = array_search($name, array_keys($rules));
$rules = array_slice($rules, 0, $key, true) +
array($realName.'_'.$subName => $rule) +
array_slice($rules, $key, count($rules) - $key, true);
}
return $rules;
} | [
"private",
"function",
"fixRules",
"(",
"$",
"rules",
",",
"$",
"rule",
",",
"$",
"name",
",",
"$",
"realName",
",",
"$",
"subName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"rules",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"key",
"=",
"array_... | Modifies the ruleset so that dynamically created
subrules are added to their original position.
@param array $rules
@param string $rule
@param string $name
@param string $realName
@param string $subName
@return array | [
"Modifies",
"the",
"ruleset",
"so",
"that",
"dynamically",
"created",
"subrules",
"are",
"added",
"to",
"their",
"original",
"position",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/Subrules.php#L272-L283 | train |
CatsSystem/swoole-etcd | etcd/KVClient.php | KVClient.Range | public function Range(RangeRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/Range',
$argument,
['\Etcdserverpb\RangeResponse', 'decode'],
$metadata,
$options
);
} | php | public function Range(RangeRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/Range',
$argument,
['\Etcdserverpb\RangeResponse', 'decode'],
$metadata,
$options
);
} | [
"public",
"function",
"Range",
"(",
"RangeRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.KV/Range'",
",",
"$",
"argument",
... | Range gets the keys in the range from the key-value store.
@param RangeRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"Range",
"gets",
"the",
"keys",
"in",
"the",
"range",
"from",
"the",
"key",
"-",
"value",
"store",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/KVClient.php#L39-L48 | train |
CatsSystem/swoole-etcd | etcd/KVClient.php | KVClient.Put | public function Put(PutRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/Put',
$argument,
['\Etcdserverpb\PutResponse', 'decode'],
$metadata,
$options
);
} | php | public function Put(PutRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/Put',
$argument,
['\Etcdserverpb\PutResponse', 'decode'],
$metadata,
$options
);
} | [
"public",
"function",
"Put",
"(",
"PutRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.KV/Put'",
",",
"$",
"argument",
",",
... | Put puts the given key into the key-value store.
A put request increments the revision of the key-value store
and generates one event in the event history.
@param PutRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"Put",
"puts",
"the",
"given",
"key",
"into",
"the",
"key",
"-",
"value",
"store",
".",
"A",
"put",
"request",
"increments",
"the",
"revision",
"of",
"the",
"key",
"-",
"value",
"store",
"and",
"generates",
"one",
"event",
"in",
"the",
"event",
"history"... | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/KVClient.php#L59-L68 | train |
CatsSystem/swoole-etcd | etcd/KVClient.php | KVClient.DeleteRange | public function DeleteRange(DeleteRangeRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/DeleteRange',
$argument,
['\Etcdserverpb\DeleteRangeResponse', 'decode'],
$metadata,
$options
);
} | php | public function DeleteRange(DeleteRangeRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/DeleteRange',
$argument,
['\Etcdserverpb\DeleteRangeResponse', 'decode'],
$metadata,
$options
);
} | [
"public",
"function",
"DeleteRange",
"(",
"DeleteRangeRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.KV/DeleteRange'",
",",
"$"... | DeleteRange deletes the given range from the key-value store.
A delete request increments the revision of the key-value store
and generates a delete event in the event history for every deleted key.
@param DeleteRangeRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"DeleteRange",
"deletes",
"the",
"given",
"range",
"from",
"the",
"key",
"-",
"value",
"store",
".",
"A",
"delete",
"request",
"increments",
"the",
"revision",
"of",
"the",
"key",
"-",
"value",
"store",
"and",
"generates",
"a",
"delete",
"event",
"in",
"th... | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/KVClient.php#L79-L88 | train |
CatsSystem/swoole-etcd | etcd/KVClient.php | KVClient.Txn | public function Txn(TxnRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/Txn',
$argument,
['\Etcdserverpb\TxnResponse', 'decode'],
$metadata,
$options
);
} | php | public function Txn(TxnRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/Txn',
$argument,
['\Etcdserverpb\TxnResponse', 'decode'],
$metadata,
$options
);
} | [
"public",
"function",
"Txn",
"(",
"TxnRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.KV/Txn'",
",",
"$",
"argument",
",",
... | Txn processes multiple requests in a single transaction.
A txn request increments the revision of the key-value store
and generates events with the same revision for every completed request.
It is not allowed to modify the same key several times within one txn.
@param TxnRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"Txn",
"processes",
"multiple",
"requests",
"in",
"a",
"single",
"transaction",
".",
"A",
"txn",
"request",
"increments",
"the",
"revision",
"of",
"the",
"key",
"-",
"value",
"store",
"and",
"generates",
"events",
"with",
"the",
"same",
"revision",
"for",
"e... | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/KVClient.php#L100-L109 | train |
CatsSystem/swoole-etcd | etcd/KVClient.php | KVClient.Compact | public function Compact(CompactionRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/Compact',
$argument,
['\Etcdserverpb\CompactionResponse', 'decode'],
$metadata,
$options
);
} | php | public function Compact(CompactionRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.KV/Compact',
$argument,
['\Etcdserverpb\CompactionResponse', 'decode'],
$metadata,
$options
);
} | [
"public",
"function",
"Compact",
"(",
"CompactionRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.KV/Compact'",
",",
"$",
"argu... | Compact compacts the event history in the etcd key-value store. The key-value
store should be periodically compacted or the event history will continue to grow
indefinitely.
@param CompactionRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"Compact",
"compacts",
"the",
"event",
"history",
"in",
"the",
"etcd",
"key",
"-",
"value",
"store",
".",
"The",
"key",
"-",
"value",
"store",
"should",
"be",
"periodically",
"compacted",
"or",
"the",
"event",
"history",
"will",
"continue",
"to",
"grow",
"... | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/KVClient.php#L120-L129 | train |
jasny/validation-result | src/ValidationResult.php | ValidationResult.add | public function add(ValidationResult $validation, $prefix = null)
{
$prefix = $this->translate($prefix);
foreach ($validation->getErrors() as $err) {
$this->errors[] = ($prefix ? trim($prefix) . ' ' : '') . $err;
}
} | php | public function add(ValidationResult $validation, $prefix = null)
{
$prefix = $this->translate($prefix);
foreach ($validation->getErrors() as $err) {
$this->errors[] = ($prefix ? trim($prefix) . ' ' : '') . $err;
}
} | [
"public",
"function",
"add",
"(",
"ValidationResult",
"$",
"validation",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",
"translate",
"(",
"$",
"prefix",
")",
";",
"foreach",
"(",
"$",
"validation",
"->",
"getErrors",
... | Add errors from a validation object
@param ValidationResult $validation
@param string $prefix | [
"Add",
"errors",
"from",
"a",
"validation",
"object"
] | fbce54837c8414cf5af22981ac33b26eb13b2a51 | https://github.com/jasny/validation-result/blob/fbce54837c8414cf5af22981ac33b26eb13b2a51/src/ValidationResult.php#L55-L62 | train |
nanbando/core | src/Core/Presets/PresetStore.php | PresetStore.getPreset | public function getPreset($application, $version, array $options = null)
{
$presets = [];
foreach ($this->presets as $preset) {
if ($preset['application'] === $application
&& $this->matchVersion($version, $preset)
&& $this->matchOptions($options, $preset)
) {
$presets[] = $preset['backup'];
}
}
if (0 === count($presets)) {
return [];
}
if (1 === count($presets)) {
return $presets[0];
}
return call_user_func_array('array_merge', $presets);
} | php | public function getPreset($application, $version, array $options = null)
{
$presets = [];
foreach ($this->presets as $preset) {
if ($preset['application'] === $application
&& $this->matchVersion($version, $preset)
&& $this->matchOptions($options, $preset)
) {
$presets[] = $preset['backup'];
}
}
if (0 === count($presets)) {
return [];
}
if (1 === count($presets)) {
return $presets[0];
}
return call_user_func_array('array_merge', $presets);
} | [
"public",
"function",
"getPreset",
"(",
"$",
"application",
",",
"$",
"version",
",",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"presets",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"presets",
"as",
"$",
"preset",
")",
"{",
"... | Returns preset for given application and version.
@param $application
@param $version
@param array $options
@return array | [
"Returns",
"preset",
"for",
"given",
"application",
"and",
"version",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/Presets/PresetStore.php#L34-L54 | train |
nanbando/core | src/Core/Presets/PresetStore.php | PresetStore.matchVersion | private function matchVersion($actual, array $preset)
{
if (!$actual || !array_key_exists('version', $preset)) {
return false;
}
return Semver::satisfies($actual, $preset['version']);
} | php | private function matchVersion($actual, array $preset)
{
if (!$actual || !array_key_exists('version', $preset)) {
return false;
}
return Semver::satisfies($actual, $preset['version']);
} | [
"private",
"function",
"matchVersion",
"(",
"$",
"actual",
",",
"array",
"$",
"preset",
")",
"{",
"if",
"(",
"!",
"$",
"actual",
"||",
"!",
"array_key_exists",
"(",
"'version'",
",",
"$",
"preset",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
... | Matches actual version with preset version.
@param string $actual
@param array $preset
@return bool | [
"Matches",
"actual",
"version",
"with",
"preset",
"version",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/Presets/PresetStore.php#L64-L71 | train |
nanbando/core | src/Core/Presets/PresetStore.php | PresetStore.matchOptions | private function matchOptions($actual, array $preset)
{
if (!$actual || !array_key_exists('options', $preset)) {
return true;
}
foreach ($actual as $key => $value) {
if (array_key_exists($key, $preset['options']) && $value !== $preset['options'][$key]) {
return false;
}
}
return true;
} | php | private function matchOptions($actual, array $preset)
{
if (!$actual || !array_key_exists('options', $preset)) {
return true;
}
foreach ($actual as $key => $value) {
if (array_key_exists($key, $preset['options']) && $value !== $preset['options'][$key]) {
return false;
}
}
return true;
} | [
"private",
"function",
"matchOptions",
"(",
"$",
"actual",
",",
"array",
"$",
"preset",
")",
"{",
"if",
"(",
"!",
"$",
"actual",
"||",
"!",
"array_key_exists",
"(",
"'options'",
",",
"$",
"preset",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
... | Matches actual options with preset options.
@param array $actual
@param array $preset
@return bool | [
"Matches",
"actual",
"options",
"with",
"preset",
"options",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/Presets/PresetStore.php#L81-L94 | train |
brightnucleus/shortcodes | src/Exception/FailedToInstantiateObject.php | FailedToInstantiateObject.fromFactory | public static function fromFactory( $factory, $interface, $exception = null ) {
$reason = $exception instanceof Exception
? " Reason: {$exception->getMessage()}"
: '';
if ( is_callable( $factory ) ) {
$message = sprintf(
'Could not instantiate object of type "%1$s" from factory of type: "%2$s".%3$s',
$interface,
gettype( $factory ),
$reason
);
} elseif ( is_string( $factory ) ) {
$message = sprintf(
'Could not instantiate object of type "%1$s" from class name: "%2$s".%3$s',
$interface,
$factory,
$reason
);
} else {
$message = sprintf(
'Could not instantiate object of type "%1$s" from invalid argument of type: "%2$s".%3$s',
$interface,
$factory,
$reason
);
}
return new static( $message, 0, $exception );
} | php | public static function fromFactory( $factory, $interface, $exception = null ) {
$reason = $exception instanceof Exception
? " Reason: {$exception->getMessage()}"
: '';
if ( is_callable( $factory ) ) {
$message = sprintf(
'Could not instantiate object of type "%1$s" from factory of type: "%2$s".%3$s',
$interface,
gettype( $factory ),
$reason
);
} elseif ( is_string( $factory ) ) {
$message = sprintf(
'Could not instantiate object of type "%1$s" from class name: "%2$s".%3$s',
$interface,
$factory,
$reason
);
} else {
$message = sprintf(
'Could not instantiate object of type "%1$s" from invalid argument of type: "%2$s".%3$s',
$interface,
$factory,
$reason
);
}
return new static( $message, 0, $exception );
} | [
"public",
"static",
"function",
"fromFactory",
"(",
"$",
"factory",
",",
"$",
"interface",
",",
"$",
"exception",
"=",
"null",
")",
"{",
"$",
"reason",
"=",
"$",
"exception",
"instanceof",
"Exception",
"?",
"\" Reason: {$exception->getMessage()}\"",
":",
"''",
... | Create a new instance from a passed-in class name or factory callable.
@since 0.3.0
@param mixed $factory Class name or factory callable.
@param string $interface Interface name that the object should have
implemented.
@param Exception $exception Exception that was caught.
@return static Instance of an exception. | [
"Create",
"a",
"new",
"instance",
"from",
"a",
"passed",
"-",
"in",
"class",
"name",
"or",
"factory",
"callable",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/Exception/FailedToInstantiateObject.php#L38-L67 | train |
nanbando/core | src/Core/EventListener/RestoreListener.php | RestoreListener.onRestore | public function onRestore(RestoreEvent $event)
{
$plugin = $this->pluginRegistry->getPlugin($event->getOption('plugin'));
$optionsResolver = new OptionsResolver();
$plugin->configureOptionsResolver($optionsResolver);
$parameter = $optionsResolver->resolve($event->getOption('parameter'));
try {
$plugin->restore($event->getSource(), $event->getDestination(), $event->getDatabase(), $parameter);
$event->setStatus(BackupStatus::STATE_SUCCESS);
} catch (\Exception $exception) {
$event->setStatus(BackupStatus::STATE_FAILED);
$event->setException($exception);
}
} | php | public function onRestore(RestoreEvent $event)
{
$plugin = $this->pluginRegistry->getPlugin($event->getOption('plugin'));
$optionsResolver = new OptionsResolver();
$plugin->configureOptionsResolver($optionsResolver);
$parameter = $optionsResolver->resolve($event->getOption('parameter'));
try {
$plugin->restore($event->getSource(), $event->getDestination(), $event->getDatabase(), $parameter);
$event->setStatus(BackupStatus::STATE_SUCCESS);
} catch (\Exception $exception) {
$event->setStatus(BackupStatus::STATE_FAILED);
$event->setException($exception);
}
} | [
"public",
"function",
"onRestore",
"(",
"RestoreEvent",
"$",
"event",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"pluginRegistry",
"->",
"getPlugin",
"(",
"$",
"event",
"->",
"getOption",
"(",
"'plugin'",
")",
")",
";",
"$",
"optionsResolver",
"=",
... | Executes restore for given event.
@param RestoreEvent $event | [
"Executes",
"restore",
"for",
"given",
"event",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/EventListener/RestoreListener.php#L33-L48 | train |
jbouzekri/FileUploaderBundle | Service/Validator/AbstractValidator.php | AbstractValidator.applyValidator | public function applyValidator($value, array $configuration)
{
// Validate configuration
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$configuration = $resolver->resolve($configuration);
$this->validate($value, $configuration);
} | php | public function applyValidator($value, array $configuration)
{
// Validate configuration
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$configuration = $resolver->resolve($configuration);
$this->validate($value, $configuration);
} | [
"public",
"function",
"applyValidator",
"(",
"$",
"value",
",",
"array",
"$",
"configuration",
")",
"{",
"// Validate configuration",
"$",
"resolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"this",
"->",
"configureOptions",
"(",
"$",
"resolver",
")... | Apply the validator
@param mixed $value
@param array $configuration
@throws \Jb\Bundle\FileUploaderBundle\Exception\ValidationException | [
"Apply",
"the",
"validator"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/Service/Validator/AbstractValidator.php#L39-L47 | train |
i-lateral/silverstripe-trumbowyg-htmleditor | code/forms/TrumbowygHTMLEditorField.php | TrumbowygHTMLEditorField.getButtons | public function getButtons()
{
if ($this->buttons && is_array($this->buttons)) {
return $this->buttons;
} else {
return $this->config()->default_buttons;
}
} | php | public function getButtons()
{
if ($this->buttons && is_array($this->buttons)) {
return $this->buttons;
} else {
return $this->config()->default_buttons;
}
} | [
"public",
"function",
"getButtons",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"buttons",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"buttons",
")",
")",
"{",
"return",
"$",
"this",
"->",
"buttons",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"-... | Get all the current buttons
@return array | [
"Get",
"all",
"the",
"current",
"buttons"
] | 4e4facbde21e15c9f2b348aee8e2dcba5a6490fc | https://github.com/i-lateral/silverstripe-trumbowyg-htmleditor/blob/4e4facbde21e15c9f2b348aee8e2dcba5a6490fc/code/forms/TrumbowygHTMLEditorField.php#L45-L52 | train |
i-lateral/silverstripe-trumbowyg-htmleditor | code/forms/TrumbowygHTMLEditorField.php | TrumbowygHTMLEditorField.addButton | public function addButton($button)
{
$buttons = $this->buttons;
// If buttons isn't an array, set it
if (!is_array($buttons)) {
$buttons = array();
}
$buttons[] = $button;
$this->buttons = $buttons;
return $this;
} | php | public function addButton($button)
{
$buttons = $this->buttons;
// If buttons isn't an array, set it
if (!is_array($buttons)) {
$buttons = array();
}
$buttons[] = $button;
$this->buttons = $buttons;
return $this;
} | [
"public",
"function",
"addButton",
"(",
"$",
"button",
")",
"{",
"$",
"buttons",
"=",
"$",
"this",
"->",
"buttons",
";",
"// If buttons isn't an array, set it",
"if",
"(",
"!",
"is_array",
"(",
"$",
"buttons",
")",
")",
"{",
"$",
"buttons",
"=",
"array",
... | Set our array of buttons
@param
@return Object | [
"Set",
"our",
"array",
"of",
"buttons"
] | 4e4facbde21e15c9f2b348aee8e2dcba5a6490fc | https://github.com/i-lateral/silverstripe-trumbowyg-htmleditor/blob/4e4facbde21e15c9f2b348aee8e2dcba5a6490fc/code/forms/TrumbowygHTMLEditorField.php#L72-L86 | train |
i-lateral/silverstripe-trumbowyg-htmleditor | code/forms/TrumbowygHTMLEditorField.php | TrumbowygHTMLEditorField.getButtonsJS | public function getButtonsJS()
{
$buttons = $this->getButtons();
$str = "";
for ($x = 0; $x < count($buttons); $x++) {
$str .= "'" . $buttons[$x] . "'";
if ($x < (count($buttons) - 1)) {
$str .= ",";
}
}
return $str;
} | php | public function getButtonsJS()
{
$buttons = $this->getButtons();
$str = "";
for ($x = 0; $x < count($buttons); $x++) {
$str .= "'" . $buttons[$x] . "'";
if ($x < (count($buttons) - 1)) {
$str .= ",";
}
}
return $str;
} | [
"public",
"function",
"getButtonsJS",
"(",
")",
"{",
"$",
"buttons",
"=",
"$",
"this",
"->",
"getButtons",
"(",
")",
";",
"$",
"str",
"=",
"\"\"",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"count",
"(",
"$",
"buttons",
")",
";",
... | Get all the current buttons rendered as a string for JS
@return array | [
"Get",
"all",
"the",
"current",
"buttons",
"rendered",
"as",
"a",
"string",
"for",
"JS"
] | 4e4facbde21e15c9f2b348aee8e2dcba5a6490fc | https://github.com/i-lateral/silverstripe-trumbowyg-htmleditor/blob/4e4facbde21e15c9f2b348aee8e2dcba5a6490fc/code/forms/TrumbowygHTMLEditorField.php#L93-L107 | train |
graze/console-diff-renderer | src/Terminal/TerminalDimensions.php | TerminalDimensions.refreshDimensions | public function refreshDimensions()
{
if ('\\' === DIRECTORY_SEPARATOR) {
if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) {
// extract [w, H] from "wxh (WxH)"
// or [w, h] from "wxh"
$this->width = (int) $matches[1];
$this->height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
} elseif (null !== $dimensions = $this->getConsoleMode()) {
// extract [w, h] from "wxh"
$this->width = (int) $dimensions[0];
$this->height = (int) $dimensions[1];
}
} elseif ($sttyString = $this->getSttyColumns()) {
if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
// extract [w, h] from "rows h; columns w;"
$this->width = (int) $matches[2];
$this->height = (int) $matches[1];
} elseif (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
// extract [w, h] from "; h rows; w columns"
$this->width = (int) $matches[2];
$this->height = (int) $matches[1];
}
}
$this->initialised = true;
} | php | public function refreshDimensions()
{
if ('\\' === DIRECTORY_SEPARATOR) {
if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) {
// extract [w, H] from "wxh (WxH)"
// or [w, h] from "wxh"
$this->width = (int) $matches[1];
$this->height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
} elseif (null !== $dimensions = $this->getConsoleMode()) {
// extract [w, h] from "wxh"
$this->width = (int) $dimensions[0];
$this->height = (int) $dimensions[1];
}
} elseif ($sttyString = $this->getSttyColumns()) {
if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
// extract [w, h] from "rows h; columns w;"
$this->width = (int) $matches[2];
$this->height = (int) $matches[1];
} elseif (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
// extract [w, h] from "; h rows; w columns"
$this->width = (int) $matches[2];
$this->height = (int) $matches[1];
}
}
$this->initialised = true;
} | [
"public",
"function",
"refreshDimensions",
"(",
")",
"{",
"if",
"(",
"'\\\\'",
"===",
"DIRECTORY_SEPARATOR",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^(\\d+)x(\\d+)(?: \\((\\d+)x(\\d+)\\))?$/'",
",",
"trim",
"(",
"getenv",
"(",
"'ANSICON'",
")",
")",
",",
"$",... | Refresh the current dimensions from the terminal | [
"Refresh",
"the",
"current",
"dimensions",
"from",
"the",
"terminal"
] | aafdaf504a96e6889f284bb15c75330318318df1 | https://github.com/graze/console-diff-renderer/blob/aafdaf504a96e6889f284bb15c75330318318df1/src/Terminal/TerminalDimensions.php#L64-L89 | train |
graze/console-diff-renderer | src/Terminal/TerminalDimensions.php | TerminalDimensions.getConsoleMode | private function getConsoleMode()
{
if (!function_exists('proc_open')) {
return null;
}
$spec = [
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$process = proc_open('mode CON', $spec, $pipes, null, null, ['suppress_errors' => true]);
if (is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
return [(int) $matches[2], (int) $matches[1]];
}
}
return null;
} | php | private function getConsoleMode()
{
if (!function_exists('proc_open')) {
return null;
}
$spec = [
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$process = proc_open('mode CON', $spec, $pipes, null, null, ['suppress_errors' => true]);
if (is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
return [(int) $matches[2], (int) $matches[1]];
}
}
return null;
} | [
"private",
"function",
"getConsoleMode",
"(",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'proc_open'",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"spec",
"=",
"[",
"1",
"=>",
"[",
"'pipe'",
",",
"'w'",
"]",
",",
"2",
"=>",
"[",
"'pipe'... | Runs and parses mode CON if it's available, suppressing any error output.
@return int[]|null An array composed of the width and the height or null if it could not be parsed | [
"Runs",
"and",
"parses",
"mode",
"CON",
"if",
"it",
"s",
"available",
"suppressing",
"any",
"error",
"output",
"."
] | aafdaf504a96e6889f284bb15c75330318318df1 | https://github.com/graze/console-diff-renderer/blob/aafdaf504a96e6889f284bb15c75330318318df1/src/Terminal/TerminalDimensions.php#L96-L118 | train |
graze/console-diff-renderer | src/Terminal/TerminalDimensions.php | TerminalDimensions.getSttyColumns | private function getSttyColumns()
{
if (!function_exists('proc_open')) {
return null;
}
$spec = [
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$process = proc_open('stty -a | grep columns', $spec, $pipes, null, null, ['suppress_errors' => true]);
if (is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
return $info;
}
return null;
} | php | private function getSttyColumns()
{
if (!function_exists('proc_open')) {
return null;
}
$spec = [
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$process = proc_open('stty -a | grep columns', $spec, $pipes, null, null, ['suppress_errors' => true]);
if (is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
return $info;
}
return null;
} | [
"private",
"function",
"getSttyColumns",
"(",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'proc_open'",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"spec",
"=",
"[",
"1",
"=>",
"[",
"'pipe'",
",",
"'w'",
"]",
",",
"2",
"=>",
"[",
"'pipe'... | Runs and parses stty -a if it's available, suppressing any error output.
@return string|null | [
"Runs",
"and",
"parses",
"stty",
"-",
"a",
"if",
"it",
"s",
"available",
"suppressing",
"any",
"error",
"output",
"."
] | aafdaf504a96e6889f284bb15c75330318318df1 | https://github.com/graze/console-diff-renderer/blob/aafdaf504a96e6889f284bb15c75330318318df1/src/Terminal/TerminalDimensions.php#L125-L147 | train |
nanbando/core | src/Bundle/Command/SelfUpdateCommand.php | SelfUpdateCommand.stable | private function stable(Updater $updater)
{
$updater->setStrategy(Updater::STRATEGY_GITHUB);
$updater->getStrategy()->setPackageName('nanbando/core');
$updater->getStrategy()->setPharName('nanbando.phar');
$updater->getStrategy()->setCurrentLocalVersion('@git_version@');
$updater->getStrategy()->setStability(GithubStrategy::STABLE);
} | php | private function stable(Updater $updater)
{
$updater->setStrategy(Updater::STRATEGY_GITHUB);
$updater->getStrategy()->setPackageName('nanbando/core');
$updater->getStrategy()->setPharName('nanbando.phar');
$updater->getStrategy()->setCurrentLocalVersion('@git_version@');
$updater->getStrategy()->setStability(GithubStrategy::STABLE);
} | [
"private",
"function",
"stable",
"(",
"Updater",
"$",
"updater",
")",
"{",
"$",
"updater",
"->",
"setStrategy",
"(",
"Updater",
"::",
"STRATEGY_GITHUB",
")",
";",
"$",
"updater",
"->",
"getStrategy",
"(",
")",
"->",
"setPackageName",
"(",
"'nanbando/core'",
... | Configure updater to use unstable builds.
@param Updater $updater | [
"Configure",
"updater",
"to",
"use",
"unstable",
"builds",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Bundle/Command/SelfUpdateCommand.php#L65-L72 | train |
brightnucleus/shortcodes | src/CheckNeedTrait.php | CheckNeedTrait.is_needed | protected function is_needed( $context = null ) {
$is_needed = $this->hasConfigKey( 'is_needed' )
? $this->getConfigKey( 'is_needed' )
: true;
if ( is_callable( $is_needed ) ) {
return $is_needed( $context );
}
return (bool) $is_needed;
} | php | protected function is_needed( $context = null ) {
$is_needed = $this->hasConfigKey( 'is_needed' )
? $this->getConfigKey( 'is_needed' )
: true;
if ( is_callable( $is_needed ) ) {
return $is_needed( $context );
}
return (bool) $is_needed;
} | [
"protected",
"function",
"is_needed",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"is_needed",
"=",
"$",
"this",
"->",
"hasConfigKey",
"(",
"'is_needed'",
")",
"?",
"$",
"this",
"->",
"getConfigKey",
"(",
"'is_needed'",
")",
":",
"true",
";",
"if",
... | Check whether an element is needed.
@since 0.2.0
@param mixed $context Data about the context in which the call is made.
@return boolean Whether the element is needed or not. | [
"Check",
"whether",
"an",
"element",
"is",
"needed",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/CheckNeedTrait.php#L34-L45 | train |
esmero/webform_strawberryfield | src/Tools/Ocfl/OcflHelper.php | OcflHelper.resolvetoFIDtoURI | public static function resolvetoFIDtoURI(int $fid) {
if (!is_integer($fid)) {
return null;
}
/* @var \Drupal\file\FileInterface $file */
$file = \Drupal::entityTypeManager()->getStorage('file')->load($fid);
return $file;
} | php | public static function resolvetoFIDtoURI(int $fid) {
if (!is_integer($fid)) {
return null;
}
/* @var \Drupal\file\FileInterface $file */
$file = \Drupal::entityTypeManager()->getStorage('file')->load($fid);
return $file;
} | [
"public",
"static",
"function",
"resolvetoFIDtoURI",
"(",
"int",
"$",
"fid",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"fid",
")",
")",
"{",
"return",
"null",
";",
"}",
"/* @var \\Drupal\\file\\FileInterface $file */",
"$",
"file",
"=",
"\\",
"Drupal... | Given an fid return the Drupal URI to that file..
@param int $fid
@return null | \Drupal\file\FileInterface
@throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
@throws \Drupal\Component\Plugin\Exception\PluginNotFoundException | [
"Given",
"an",
"fid",
"return",
"the",
"Drupal",
"URI",
"to",
"that",
"file",
".."
] | 7b2bd47dc01a948325a44499ff0ec3c8d9fb4efa | https://github.com/esmero/webform_strawberryfield/blob/7b2bd47dc01a948325a44499ff0ec3c8d9fb4efa/src/Tools/Ocfl/OcflHelper.php#L87-L95 | train |
jbouzekri/FileUploaderBundle | Service/CropFileManager.php | CropFileManager.transformFile | public function transformFile(array $data)
{
return $this->filterManager->apply(
$this->dataManager->find('original', $data['filename']),
array(
'filters' => array(
'crop'=> array(
'start' => array($data['x'], $data['y']),
'size' => array($data['width'], $data['height'])
)
)
)
);
} | php | public function transformFile(array $data)
{
return $this->filterManager->apply(
$this->dataManager->find('original', $data['filename']),
array(
'filters' => array(
'crop'=> array(
'start' => array($data['x'], $data['y']),
'size' => array($data['width'], $data['height'])
)
)
)
);
} | [
"public",
"function",
"transformFile",
"(",
"array",
"$",
"data",
")",
"{",
"return",
"$",
"this",
"->",
"filterManager",
"->",
"apply",
"(",
"$",
"this",
"->",
"dataManager",
"->",
"find",
"(",
"'original'",
",",
"$",
"data",
"[",
"'filename'",
"]",
")"... | Transform the file
@param array $data
@return \Liip\ImagineBundle\Binary\BinaryInterface | [
"Transform",
"the",
"file"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/Service/CropFileManager.php#L73-L86 | train |
jbouzekri/FileUploaderBundle | Service/CropFileManager.php | CropFileManager.saveTransformedFile | public function saveTransformedFile($endpoint, BinaryInterface $cropedFile, array $data)
{
$this
->filesystemMap
->get(
$this->configuration->getValue($endpoint, 'croped_fs')
)
->write(
$data['filename'],
$cropedFile->getContent()
);
} | php | public function saveTransformedFile($endpoint, BinaryInterface $cropedFile, array $data)
{
$this
->filesystemMap
->get(
$this->configuration->getValue($endpoint, 'croped_fs')
)
->write(
$data['filename'],
$cropedFile->getContent()
);
} | [
"public",
"function",
"saveTransformedFile",
"(",
"$",
"endpoint",
",",
"BinaryInterface",
"$",
"cropedFile",
",",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"filesystemMap",
"->",
"get",
"(",
"$",
"this",
"->",
"configuration",
"->",
"getValue",
"("... | Save the transformed file
@param string $endpoint
@param BinaryInterface $cropedFile
@param array $data | [
"Save",
"the",
"transformed",
"file"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/Service/CropFileManager.php#L95-L106 | train |
hostnet/entity-tracker-component | src/Provider/EntityAnnotationMetadataProvider.php | EntityAnnotationMetadataProvider.isTracked | public function isTracked(EntityManagerInterface $em, $entity)
{
$class = get_class($entity);
$annotations = $this->reader->getClassAnnotations($em->getClassMetadata($class)->getReflectionClass());
foreach ($annotations as $annotation) {
if ($annotation instanceof Tracked) {
return true;
}
}
return false;
} | php | public function isTracked(EntityManagerInterface $em, $entity)
{
$class = get_class($entity);
$annotations = $this->reader->getClassAnnotations($em->getClassMetadata($class)->getReflectionClass());
foreach ($annotations as $annotation) {
if ($annotation instanceof Tracked) {
return true;
}
}
return false;
} | [
"public",
"function",
"isTracked",
"(",
"EntityManagerInterface",
"$",
"em",
",",
"$",
"entity",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"entity",
")",
";",
"$",
"annotations",
"=",
"$",
"this",
"->",
"reader",
"->",
"getClassAnnotations",
"(",... | Get the annotation from a class or null if it doesn't exists.
@param EntityManagerInterface $em
@param mixed $entity
@return bool | [
"Get",
"the",
"annotation",
"from",
"a",
"class",
"or",
"null",
"if",
"it",
"doesn",
"t",
"exists",
"."
] | 08601d9db4faf7804f9097460e2149da3aa4fda3 | https://github.com/hostnet/entity-tracker-component/blob/08601d9db4faf7804f9097460e2149da3aa4fda3/src/Provider/EntityAnnotationMetadataProvider.php#L35-L47 | train |
globalis-ms/puppet-skilled-framework | src/View/Cell.php | Cell.render | protected function render($template, $data = [])
{
$view = new View();
$view->type(View::VIEW_TYPE_CELL);
$view->set($data);
$className = get_class($this);
$namePrefix = '\View\Cell\\';
$name = substr($className, strpos($className, $namePrefix) + strlen($namePrefix));
$view->context(str_replace('\\', DIRECTORY_SEPARATOR, $name));
return $view->render($template);
} | php | protected function render($template, $data = [])
{
$view = new View();
$view->type(View::VIEW_TYPE_CELL);
$view->set($data);
$className = get_class($this);
$namePrefix = '\View\Cell\\';
$name = substr($className, strpos($className, $namePrefix) + strlen($namePrefix));
$view->context(str_replace('\\', DIRECTORY_SEPARATOR, $name));
return $view->render($template);
} | [
"protected",
"function",
"render",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"view",
"=",
"new",
"View",
"(",
")",
";",
"$",
"view",
"->",
"type",
"(",
"View",
"::",
"VIEW_TYPE_CELL",
")",
";",
"$",
"view",
"->",
"set"... | Rendeing the cell
@param string $template
@param array $data
@return string | [
"Rendeing",
"the",
"cell"
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/View/Cell.php#L39-L49 | train |
contributte/api-docu | src/Starter.php | Starter.routeMatched | public function routeMatched(ApiRoute $route, Request $request): void
{
if (($format = $request->getParameter(self::API_DOCU_STARTER_QUERY_KEY_GENERATE)) !== null) {
$this->generator->generateAll($this->router);
exit(0);
}
if (($format = $request->getParameter(self::API_DOCU_STARTER_QUERY_KEY_TARGET)) !== null) {
$this->generator->generateTarget($route, $request);
exit(0);
}
} | php | public function routeMatched(ApiRoute $route, Request $request): void
{
if (($format = $request->getParameter(self::API_DOCU_STARTER_QUERY_KEY_GENERATE)) !== null) {
$this->generator->generateAll($this->router);
exit(0);
}
if (($format = $request->getParameter(self::API_DOCU_STARTER_QUERY_KEY_TARGET)) !== null) {
$this->generator->generateTarget($route, $request);
exit(0);
}
} | [
"public",
"function",
"routeMatched",
"(",
"ApiRoute",
"$",
"route",
",",
"Request",
"$",
"request",
")",
":",
"void",
"{",
"if",
"(",
"(",
"$",
"format",
"=",
"$",
"request",
"->",
"getParameter",
"(",
"self",
"::",
"API_DOCU_STARTER_QUERY_KEY_GENERATE",
")... | Event thatis firex when particular ApiRoute is matched | [
"Event",
"thatis",
"firex",
"when",
"particular",
"ApiRoute",
"is",
"matched"
] | 65e17dadfa0bfd1f479159fadafea8ffd67ee763 | https://github.com/contributte/api-docu/blob/65e17dadfa0bfd1f479159fadafea8ffd67ee763/src/Starter.php#L72-L85 | train |
nanbando/core | src/Core/Database/ReadonlyDatabase.php | ReadonlyDatabase.get | public function get($name)
{
if (!$this->exists($name)) {
throw new PropertyNotExistsException($name);
}
return $this->data[$name];
} | php | public function get($name)
{
if (!$this->exists($name)) {
throw new PropertyNotExistsException($name);
}
return $this->data[$name];
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"PropertyNotExistsException",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"data... | Returns value for name.
@param string $name
@return mixed
@throws PropertyNotExistsException | [
"Returns",
"value",
"for",
"name",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/Database/ReadonlyDatabase.php#L46-L53 | train |
php-kitchen/code-specs | src/Expectation/Internal/Assert.php | Assert.assertAttributeContains | public function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $key,
]);
} | php | public function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $key,
]);
} | [
"public",
"function",
"assertAttributeContains",
"(",
"$",
"needle",
",",
"$",
"haystackAttributeName",
",",
"$",
"haystackClassOrObject",
",",
"$",
"message",
"=",
"''",
",",
"$",
"ignoreCase",
"=",
"false",
",",
"$",
"checkForObjectIdentity",
"=",
"true",
",",... | Asserts that a haystack that is stored in a static attribute of a class
or an attribute of an object contains a needle.
@param mixed $needle
@param string $haystackAttributeName
@param string|object $haystackClassOrObject
@param string $message
@param bool $ignoreCase
@param bool $checkForObjectIdentity
@param bool $checkForNonObjectIdentity | [
"Asserts",
"that",
"a",
"haystack",
"that",
"is",
"stored",
"in",
"a",
"static",
"attribute",
"of",
"a",
"class",
"or",
"an",
"attribute",
"of",
"an",
"object",
"contains",
"a",
"needle",
"."
] | 6ce45183073c346787818afef922508aefc2d358 | https://github.com/php-kitchen/code-specs/blob/6ce45183073c346787818afef922508aefc2d358/src/Expectation/Internal/Assert.php#L323-L327 | train |
php-kitchen/code-specs | src/Expectation/Internal/Assert.php | Assert.assertAttributeContainsOnly | public function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $key,
]);
} | php | public function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $key,
]);
} | [
"public",
"function",
"assertAttributeContainsOnly",
"(",
"$",
"type",
",",
"$",
"haystackAttributeName",
",",
"$",
"haystackClassOrObject",
",",
"$",
"isNativeType",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"callAssertMethod",
"(",
"__FUNCTION__",
",",
"[",
"'... | Asserts that a haystack that is stored in a static attribute of a class
or an attribute of an object contains only values of a given type.
@param string $type
@param string $haystackAttributeName
@param string|object $haystackClassOrObject
@param bool $isNativeType
@param string $message | [
"Asserts",
"that",
"a",
"haystack",
"that",
"is",
"stored",
"in",
"a",
"static",
"attribute",
"of",
"a",
"class",
"or",
"an",
"attribute",
"of",
"an",
"object",
"contains",
"only",
"values",
"of",
"a",
"given",
"type",
"."
] | 6ce45183073c346787818afef922508aefc2d358 | https://github.com/php-kitchen/code-specs/blob/6ce45183073c346787818afef922508aefc2d358/src/Expectation/Internal/Assert.php#L368-L372 | train |
php-kitchen/code-specs | src/Expectation/Internal/Assert.php | Assert.assertAttributeEquals | public function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $key,
]);
} | php | public function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $key,
]);
} | [
"public",
"function",
"assertAttributeEquals",
"(",
"$",
"expected",
",",
"$",
"actualAttributeName",
",",
"$",
"actualClassOrObject",
",",
"$",
"message",
"=",
"''",
",",
"$",
"delta",
"=",
"0.0",
",",
"$",
"maxDepth",
"=",
"10",
",",
"$",
"canonicalize",
... | Asserts that a variable is equal to an attribute of an object.
@param mixed $expected
@param string $actualAttributeName
@param string|object $actualClassOrObject
@param string $message
@param float $delta
@param int $maxDepth
@param bool $canonicalize
@param bool $ignoreCase | [
"Asserts",
"that",
"a",
"variable",
"is",
"equal",
"to",
"an",
"attribute",
"of",
"an",
"object",
"."
] | 6ce45183073c346787818afef922508aefc2d358 | https://github.com/php-kitchen/code-specs/blob/6ce45183073c346787818afef922508aefc2d358/src/Expectation/Internal/Assert.php#L478-L482 | train |
php-kitchen/code-specs | src/Expectation/Internal/Assert.php | Assert.assertFileEquals | public function assertFileEquals($expected, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expected,
'additionalParams' => [
$canonicalize,
$ignoreCase,
],
]);
} | php | public function assertFileEquals($expected, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expected,
'additionalParams' => [
$canonicalize,
$ignoreCase,
],
]);
} | [
"public",
"function",
"assertFileEquals",
"(",
"$",
"expected",
",",
"$",
"canonicalize",
"=",
"false",
",",
"$",
"ignoreCase",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"callAssertMethod",
"(",
"__FUNCTION__",
",",
"[",
"'expected'",
"=>",
"$",
"expected",... | Asserts that the contents of one file is equal to the contents of another
file.
@param string $expected
@param bool $canonicalize
@param bool $ignoreCase | [
"Asserts",
"that",
"the",
"contents",
"of",
"one",
"file",
"is",
"equal",
"to",
"the",
"contents",
"of",
"another",
"file",
"."
] | 6ce45183073c346787818afef922508aefc2d358 | https://github.com/php-kitchen/code-specs/blob/6ce45183073c346787818afef922508aefc2d358/src/Expectation/Internal/Assert.php#L681-L689 | train |
php-kitchen/code-specs | src/Expectation/Internal/Assert.php | Assert.assertFileNotEquals | public function assertFileNotEquals($expected, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expected,
'additionalParams' => [
$canonicalize,
$ignoreCase,
],
]);
} | php | public function assertFileNotEquals($expected, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expected,
'additionalParams' => [
$canonicalize,
$ignoreCase,
],
]);
} | [
"public",
"function",
"assertFileNotEquals",
"(",
"$",
"expected",
",",
"$",
"canonicalize",
"=",
"false",
",",
"$",
"ignoreCase",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"callAssertMethod",
"(",
"__FUNCTION__",
",",
"[",
"'expected'",
"=>",
"$",
"expecte... | Asserts that the contents of one file is not equal to the contents of
another file.
@param string $expected
@param bool $canonicalize
@param bool $ignoreCase | [
"Asserts",
"that",
"the",
"contents",
"of",
"one",
"file",
"is",
"not",
"equal",
"to",
"the",
"contents",
"of",
"another",
"file",
"."
] | 6ce45183073c346787818afef922508aefc2d358 | https://github.com/php-kitchen/code-specs/blob/6ce45183073c346787818afef922508aefc2d358/src/Expectation/Internal/Assert.php#L699-L707 | train |
php-kitchen/code-specs | src/Expectation/Internal/Assert.php | Assert.assertStringEqualsFile | public function assertStringEqualsFile($expectedFile, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expectedFile,
'additionalParams' => [
$canonicalize,
$ignoreCase,
],
]);
} | php | public function assertStringEqualsFile($expectedFile, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expectedFile,
'additionalParams' => [
$canonicalize,
$ignoreCase,
],
]);
} | [
"public",
"function",
"assertStringEqualsFile",
"(",
"$",
"expectedFile",
",",
"$",
"canonicalize",
"=",
"false",
",",
"$",
"ignoreCase",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"callAssertMethod",
"(",
"__FUNCTION__",
",",
"[",
"'expected'",
"=>",
"$",
"... | Asserts that the contents of a string is equal
to the contents of a file.
@param string $expectedFile
@param bool $canonicalize
@param bool $ignoreCase | [
"Asserts",
"that",
"the",
"contents",
"of",
"a",
"string",
"is",
"equal",
"to",
"the",
"contents",
"of",
"a",
"file",
"."
] | 6ce45183073c346787818afef922508aefc2d358 | https://github.com/php-kitchen/code-specs/blob/6ce45183073c346787818afef922508aefc2d358/src/Expectation/Internal/Assert.php#L717-L725 | train |
php-kitchen/code-specs | src/Expectation/Internal/Assert.php | Assert.assertStringNotEqualsFile | public function assertStringNotEqualsFile($expectedFile, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expectedFile,
'additionalParams' => [
$canonicalize,
$ignoreCase,
],
]);
} | php | public function assertStringNotEqualsFile($expectedFile, $canonicalize = false, $ignoreCase = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expectedFile,
'additionalParams' => [
$canonicalize,
$ignoreCase,
],
]);
} | [
"public",
"function",
"assertStringNotEqualsFile",
"(",
"$",
"expectedFile",
",",
"$",
"canonicalize",
"=",
"false",
",",
"$",
"ignoreCase",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"callAssertMethod",
"(",
"__FUNCTION__",
",",
"[",
"'expected'",
"=>",
"$",
... | Asserts that the contents of a string is not equal
to the contents of a file.
@param string $expectedFile
@param bool $canonicalize
@param bool $ignoreCase | [
"Asserts",
"that",
"the",
"contents",
"of",
"a",
"string",
"is",
"not",
"equal",
"to",
"the",
"contents",
"of",
"a",
"file",
"."
] | 6ce45183073c346787818afef922508aefc2d358 | https://github.com/php-kitchen/code-specs/blob/6ce45183073c346787818afef922508aefc2d358/src/Expectation/Internal/Assert.php#L735-L743 | train |
php-kitchen/code-specs | src/Expectation/Internal/Assert.php | Assert.assertEqualXMLStructure | public function assertEqualXMLStructure(\DOMElement $expectedElement, $checkAttributes = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expectedElement,
'options' => [
$checkAttributes,
],
]);
} | php | public function assertEqualXMLStructure(\DOMElement $expectedElement, $checkAttributes = false) {
$this->callAssertMethod(__FUNCTION__, [
'expected' => $expectedElement,
'options' => [
$checkAttributes,
],
]);
} | [
"public",
"function",
"assertEqualXMLStructure",
"(",
"\\",
"DOMElement",
"$",
"expectedElement",
",",
"$",
"checkAttributes",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"callAssertMethod",
"(",
"__FUNCTION__",
",",
"[",
"'expected'",
"=>",
"$",
"expectedElement",... | Asserts that a hierarchy of DOMElements matches.
@param \DOMElement $expectedElement
@param bool $checkAttributes | [
"Asserts",
"that",
"a",
"hierarchy",
"of",
"DOMElements",
"matches",
"."
] | 6ce45183073c346787818afef922508aefc2d358 | https://github.com/php-kitchen/code-specs/blob/6ce45183073c346787818afef922508aefc2d358/src/Expectation/Internal/Assert.php#L1444-L1451 | train |
raftalks/Form | src/Raftalks/Form/Form.php | Form.runCallback | protected static function runCallback($method, $args)
{
$instance = static::resolveFacadeInstance();
if(empty($args))
{
throw new InvalidArgumentException("Please provide an argument to this method");
}
switch (count($args))
{
case 0:
return $instance->$method();
case 1:
return $instance->$method($args[0]);
case 2:
return $instance->$method($args[0], $args[1]);
case 3:
return $instance->$method($args[0], $args[1], $args[2]);
case 4:
return $instance->$method($args[0], $args[1], $args[2], $args[3]);
default:
return call_user_func_array(array($instance, $method), $args);
}
} | php | protected static function runCallback($method, $args)
{
$instance = static::resolveFacadeInstance();
if(empty($args))
{
throw new InvalidArgumentException("Please provide an argument to this method");
}
switch (count($args))
{
case 0:
return $instance->$method();
case 1:
return $instance->$method($args[0]);
case 2:
return $instance->$method($args[0], $args[1]);
case 3:
return $instance->$method($args[0], $args[1], $args[2]);
case 4:
return $instance->$method($args[0], $args[1], $args[2], $args[3]);
default:
return call_user_func_array(array($instance, $method), $args);
}
} | [
"protected",
"static",
"function",
"runCallback",
"(",
"$",
"method",
",",
"$",
"args",
")",
"{",
"$",
"instance",
"=",
"static",
"::",
"resolveFacadeInstance",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"Invali... | Facotory method to call the handler methods
@param string $method
@param array $args
@return mixed | [
"Facotory",
"method",
"to",
"call",
"the",
"handler",
"methods"
] | e6d116263e0ef46eb46a4741df99fd4f1414e6ad | https://github.com/raftalks/Form/blob/e6d116263e0ef46eb46a4741df99fd4f1414e6ad/src/Raftalks/Form/Form.php#L78-L108 | train |
globalis-ms/puppet-skilled-framework | src/Library/FormValidation.php | FormValidation.set_value | public function set_value($field = '', $default = '')
{
if (!isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) {
return $default;
}
return $this->_field_data[$field]['postdata'];
} | php | public function set_value($field = '', $default = '')
{
if (!isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) {
return $default;
}
return $this->_field_data[$field]['postdata'];
} | [
"public",
"function",
"set_value",
"(",
"$",
"field",
"=",
"''",
",",
"$",
"default",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_field_data",
"[",
"$",
"field",
"]",
",",
"$",
"this",
"->",
"_field_data",
"[",
"$",
"f... | Get the value from a form
Permits you to repopulate a form field with the value it was submitted
with, or, if that value doesn't exist, with the default
@param string the field name
@param string
@return string | [
"Get",
"the",
"value",
"from",
"a",
"form"
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/Library/FormValidation.php#L27-L33 | train |
globalis-ms/puppet-skilled-framework | src/Library/FormValidation.php | FormValidation.run | public function run($group = '')
{
if (!empty($this->validation_data) || $this->CI->input->method() === 'post') {
$this->ran = true;
return parent::run($group);
}
return false;
} | php | public function run($group = '')
{
if (!empty($this->validation_data) || $this->CI->input->method() === 'post') {
$this->ran = true;
return parent::run($group);
}
return false;
} | [
"public",
"function",
"run",
"(",
"$",
"group",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"validation_data",
")",
"||",
"$",
"this",
"->",
"CI",
"->",
"input",
"->",
"method",
"(",
")",
"===",
"'post'",
")",
"{",
"$",
... | Run the Validator
This function does all the work.
@param string $group
@return bool | [
"Run",
"the",
"Validator"
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/Library/FormValidation.php#L237-L244 | train |
melisplatform/melis-front | src/Listener/MelisFrontSEODispatchRouterAbstractListener.php | MelisFrontSEODispatchRouterAbstractListener.redirect404 | public function redirect404(MvcEvent $e, $idpage = null)
{
$sm = $e->getApplication()->getServiceManager();
$eventManager = $e->getApplication()->getEventManager();
$melisTree = $sm->get('MelisEngineTree');
$melisSiteDomain = $sm->get('MelisEngineTableSiteDomain');
$melisSite404 = $sm->get('MelisEngineTableSite404');
if ($idpage == null)
{
// idPage is not working, we get the site through the domain
// used to redirect to the right 404
$router = $e->getRouter();
$uri = $router->getRequestUri();
$domainTxt = $uri->getHost();
}
else
{
// We get the site using the idPage and redirect to the site's 404
$domainTxt = $melisTree->getDomainByPageId($idpage, true);
if (empty($domainTxt))
{
$router = $e->getRouter();
$uri = $router->getRequestUri();
$domainTxt = $uri->getHost();
}
$domainTxt = str_replace('http://', '', $domainTxt);
$domainTxt = str_replace('https://', '', $domainTxt);
}
// Get the siteId from the domain
if ($domainTxt)
{
$domain = $melisSiteDomain->getEntryByField('sdom_domain', $domainTxt);
$domain = $domain->current();
if ($domain)
$siteId = $domain->sdom_site_id;
else
return '';
}
else
return '';
// Get the 404 of the siteId
$site404 = $melisSite404->getEntryByField('s404_site_id', $siteId);
if ($site404)
{
$site404 = $site404->current();
if (empty($site404))
{
// No entry in DB for this siteId, let's get the general one (siteId -1)
$site404 = $melisSite404->getEntryByField('s404_site_id', -1);
$site404 = $site404->current();
}
}
if (empty($site404))
{
// No 404 found
return '';
}
else
{
// Check if the 404 defined exist also!
$melisPage = $sm->get('MelisEnginePage');
$datasPage = $melisPage->getDatasPage($site404->s404_page_id, 'published');
$pageTree = $datasPage->getMelisPageTree();
if (empty($pageTree))
return ''; // The 404 page defined doesn't exist or is not published
// Redirect to the 404 of the site
$link = $melisTree->getPageLink($site404->s404_page_id, true);
return $link;
}
} | php | public function redirect404(MvcEvent $e, $idpage = null)
{
$sm = $e->getApplication()->getServiceManager();
$eventManager = $e->getApplication()->getEventManager();
$melisTree = $sm->get('MelisEngineTree');
$melisSiteDomain = $sm->get('MelisEngineTableSiteDomain');
$melisSite404 = $sm->get('MelisEngineTableSite404');
if ($idpage == null)
{
// idPage is not working, we get the site through the domain
// used to redirect to the right 404
$router = $e->getRouter();
$uri = $router->getRequestUri();
$domainTxt = $uri->getHost();
}
else
{
// We get the site using the idPage and redirect to the site's 404
$domainTxt = $melisTree->getDomainByPageId($idpage, true);
if (empty($domainTxt))
{
$router = $e->getRouter();
$uri = $router->getRequestUri();
$domainTxt = $uri->getHost();
}
$domainTxt = str_replace('http://', '', $domainTxt);
$domainTxt = str_replace('https://', '', $domainTxt);
}
// Get the siteId from the domain
if ($domainTxt)
{
$domain = $melisSiteDomain->getEntryByField('sdom_domain', $domainTxt);
$domain = $domain->current();
if ($domain)
$siteId = $domain->sdom_site_id;
else
return '';
}
else
return '';
// Get the 404 of the siteId
$site404 = $melisSite404->getEntryByField('s404_site_id', $siteId);
if ($site404)
{
$site404 = $site404->current();
if (empty($site404))
{
// No entry in DB for this siteId, let's get the general one (siteId -1)
$site404 = $melisSite404->getEntryByField('s404_site_id', -1);
$site404 = $site404->current();
}
}
if (empty($site404))
{
// No 404 found
return '';
}
else
{
// Check if the 404 defined exist also!
$melisPage = $sm->get('MelisEnginePage');
$datasPage = $melisPage->getDatasPage($site404->s404_page_id, 'published');
$pageTree = $datasPage->getMelisPageTree();
if (empty($pageTree))
return ''; // The 404 page defined doesn't exist or is not published
// Redirect to the 404 of the site
$link = $melisTree->getPageLink($site404->s404_page_id, true);
return $link;
}
} | [
"public",
"function",
"redirect404",
"(",
"MvcEvent",
"$",
"e",
",",
"$",
"idpage",
"=",
"null",
")",
"{",
"$",
"sm",
"=",
"$",
"e",
"->",
"getApplication",
"(",
")",
"->",
"getServiceManager",
"(",
")",
";",
"$",
"eventManager",
"=",
"$",
"e",
"->",... | Get the 404 page's URL
404 can occur if page is not found or if page is not published
This function will try to find the 404 defined for the site of this page,
if not the general 404, then an empty string if nothing is defined
@param MvcEvent $e
@param int $idpage The id of the page | [
"Get",
"the",
"404",
"page",
"s",
"URL",
"404",
"can",
"occur",
"if",
"page",
"is",
"not",
"found",
"or",
"if",
"page",
"is",
"not",
"published",
"This",
"function",
"will",
"try",
"to",
"find",
"the",
"404",
"defined",
"for",
"the",
"site",
"of",
"t... | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Listener/MelisFrontSEODispatchRouterAbstractListener.php#L90-L169 | train |
melisplatform/melis-front | src/Listener/MelisFrontSEODispatchRouterAbstractListener.php | MelisFrontSEODispatchRouterAbstractListener.getQueryParameters | public function getQueryParameters($e)
{
$request = $e->getRequest();
$getString = $request->getQuery()->toString();
if ($getString != '')
$getString = '?' . $getString;
return $getString;
} | php | public function getQueryParameters($e)
{
$request = $e->getRequest();
$getString = $request->getQuery()->toString();
if ($getString != '')
$getString = '?' . $getString;
return $getString;
} | [
"public",
"function",
"getQueryParameters",
"(",
"$",
"e",
")",
"{",
"$",
"request",
"=",
"$",
"e",
"->",
"getRequest",
"(",
")",
";",
"$",
"getString",
"=",
"$",
"request",
"->",
"getQuery",
"(",
")",
"->",
"toString",
"(",
")",
";",
"if",
"(",
"$... | Gets the GET parameters
Used to add the possible parameters in a redirected URL
@param MvcEvent $e
@return string Parameters string | [
"Gets",
"the",
"GET",
"parameters",
"Used",
"to",
"add",
"the",
"possible",
"parameters",
"in",
"a",
"redirected",
"URL"
] | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Listener/MelisFrontSEODispatchRouterAbstractListener.php#L178-L187 | train |
melisplatform/melis-front | src/Listener/MelisFrontSEODispatchRouterAbstractListener.php | MelisFrontSEODispatchRouterAbstractListener.createTranslations | public function createTranslations($e, $siteFolder, $locale)
{
$sm = $e->getApplication()->getServiceManager();
$translator = $sm->get('translator');
$langFileTarget = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites/' .$siteFolder . '/language/' . $locale . '.php';
if (!file_exists($langFileTarget))
{
$langFileTarget = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites/' .$siteFolder . '/language/en_EN.php';
if (!file_exists($langFileTarget))
{
$langFileTarget = null;
}
}
else
{
$langFileTarget = null;
}
if (!is_null($langFileTarget) && !empty($siteFolder) && !empty($locale))
{
$translator->addTranslationFile(
'phparray',
$langFileTarget
);
}
} | php | public function createTranslations($e, $siteFolder, $locale)
{
$sm = $e->getApplication()->getServiceManager();
$translator = $sm->get('translator');
$langFileTarget = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites/' .$siteFolder . '/language/' . $locale . '.php';
if (!file_exists($langFileTarget))
{
$langFileTarget = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites/' .$siteFolder . '/language/en_EN.php';
if (!file_exists($langFileTarget))
{
$langFileTarget = null;
}
}
else
{
$langFileTarget = null;
}
if (!is_null($langFileTarget) && !empty($siteFolder) && !empty($locale))
{
$translator->addTranslationFile(
'phparray',
$langFileTarget
);
}
} | [
"public",
"function",
"createTranslations",
"(",
"$",
"e",
",",
"$",
"siteFolder",
",",
"$",
"locale",
")",
"{",
"$",
"sm",
"=",
"$",
"e",
"->",
"getApplication",
"(",
")",
"->",
"getServiceManager",
"(",
")",
";",
"$",
"translator",
"=",
"$",
"sm",
... | Creates translation for the appropriate site
@param MvcEvent $e
@param string $siteFolder
@param string $locale | [
"Creates",
"translation",
"for",
"the",
"appropriate",
"site"
] | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Listener/MelisFrontSEODispatchRouterAbstractListener.php#L196-L224 | train |
nanbando/core | src/Application/CompilerPass/SshServerCompilerPass.php | SshServerCompilerPass.createSshConnectionDefinition | private function createSshConnectionDefinition(
$sshId,
$serverName,
$directory,
$executable,
array $sshConfig
) {
$connectionDefinition = new Definition(
SshConnection::class, [
new Reference($sshId),
new Reference('input'),
new Reference('output'),
$serverName,
$directory,
$executable,
$sshConfig,
]
);
$connectionDefinition->setLazy(true);
return $connectionDefinition;
} | php | private function createSshConnectionDefinition(
$sshId,
$serverName,
$directory,
$executable,
array $sshConfig
) {
$connectionDefinition = new Definition(
SshConnection::class, [
new Reference($sshId),
new Reference('input'),
new Reference('output'),
$serverName,
$directory,
$executable,
$sshConfig,
]
);
$connectionDefinition->setLazy(true);
return $connectionDefinition;
} | [
"private",
"function",
"createSshConnectionDefinition",
"(",
"$",
"sshId",
",",
"$",
"serverName",
",",
"$",
"directory",
",",
"$",
"executable",
",",
"array",
"$",
"sshConfig",
")",
"{",
"$",
"connectionDefinition",
"=",
"new",
"Definition",
"(",
"SshConnection... | Create a new ssh-connection.
@param string $sshId
@param string $serverName
@param string $directory
@param string $executable
@param array $sshConfig
@return Definition | [
"Create",
"a",
"new",
"ssh",
"-",
"connection",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Application/CompilerPass/SshServerCompilerPass.php#L82-L103 | train |
nanbando/core | src/Application/CompilerPass/SshServerCompilerPass.php | SshServerCompilerPass.createCommandDefinition | private function createCommandDefinition($id, $connectionId, $class, $serverName, $command)
{
$commandDefinition = new DefinitionDecorator($id);
$commandDefinition->setClass($class);
$commandDefinition->setLazy(true);
$commandDefinition->replaceArgument(0, new Reference($connectionId));
$commandDefinition->addTag('nanbando.server_command', ['server' => $serverName, 'command' => $command]);
return $commandDefinition;
} | php | private function createCommandDefinition($id, $connectionId, $class, $serverName, $command)
{
$commandDefinition = new DefinitionDecorator($id);
$commandDefinition->setClass($class);
$commandDefinition->setLazy(true);
$commandDefinition->replaceArgument(0, new Reference($connectionId));
$commandDefinition->addTag('nanbando.server_command', ['server' => $serverName, 'command' => $command]);
return $commandDefinition;
} | [
"private",
"function",
"createCommandDefinition",
"(",
"$",
"id",
",",
"$",
"connectionId",
",",
"$",
"class",
",",
"$",
"serverName",
",",
"$",
"command",
")",
"{",
"$",
"commandDefinition",
"=",
"new",
"DefinitionDecorator",
"(",
"$",
"id",
")",
";",
"$"... | Create a new command definition.
@param string $id
@param string $connectionId
@param string $class
@param string $serverName
@param string $command
@return DefinitionDecorator | [
"Create",
"a",
"new",
"command",
"definition",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Application/CompilerPass/SshServerCompilerPass.php#L116-L125 | train |
nekudo/Angela | src/Server.php | Server.start | public function start()
{
try {
$this->createClientSocket();
$this->createWorkerJobSocket();
$this->createWorkerReplySocket();
$this->startWorkerPools();
$this->loop->addPeriodicTimer(5, [$this, 'monitorChildProcesses']);
$this->loop->addPeriodicTimer(10, [$this, 'monitorQueue']);
$this->loop->run();
} catch (ServerException $e) {
$errorMsgPattern = 'Server error: %s (%s:%d)';
$this->logger->emergency(sprintf($errorMsgPattern, $e->getMessage(), $e->getFile(), $e->getLine()));
}
} | php | public function start()
{
try {
$this->createClientSocket();
$this->createWorkerJobSocket();
$this->createWorkerReplySocket();
$this->startWorkerPools();
$this->loop->addPeriodicTimer(5, [$this, 'monitorChildProcesses']);
$this->loop->addPeriodicTimer(10, [$this, 'monitorQueue']);
$this->loop->run();
} catch (ServerException $e) {
$errorMsgPattern = 'Server error: %s (%s:%d)';
$this->logger->emergency(sprintf($errorMsgPattern, $e->getMessage(), $e->getFile(), $e->getLine()));
}
} | [
"public",
"function",
"start",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"createClientSocket",
"(",
")",
";",
"$",
"this",
"->",
"createWorkerJobSocket",
"(",
")",
";",
"$",
"this",
"->",
"createWorkerReplySocket",
"(",
")",
";",
"$",
"this",
"->",
... | Creates sockets and fires up worker processes. | [
"Creates",
"sockets",
"and",
"fires",
"up",
"worker",
"processes",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L165-L179 | train |
nekudo/Angela | src/Server.php | Server.stop | public function stop()
{
$this->stopWorkerPools();
$this->workerJobSocket->disconnect($this->config['sockets']['worker_job']);
$this->workerReplySocket->close();
$this->clientSocket->close();
$this->loop->stop();
} | php | public function stop()
{
$this->stopWorkerPools();
$this->workerJobSocket->disconnect($this->config['sockets']['worker_job']);
$this->workerReplySocket->close();
$this->clientSocket->close();
$this->loop->stop();
} | [
"public",
"function",
"stop",
"(",
")",
"{",
"$",
"this",
"->",
"stopWorkerPools",
"(",
")",
";",
"$",
"this",
"->",
"workerJobSocket",
"->",
"disconnect",
"(",
"$",
"this",
"->",
"config",
"[",
"'sockets'",
"]",
"[",
"'worker_job'",
"]",
")",
";",
"$"... | Close sockets, stop worker processes and stop main event loop. | [
"Close",
"sockets",
"stop",
"worker",
"processes",
"and",
"stop",
"main",
"event",
"loop",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L184-L191 | train |
nekudo/Angela | src/Server.php | Server.createClientSocket | protected function createClientSocket()
{
/** @var Context|\ZMQContext $clientContext */
$clientContext = new Context($this->loop);
$this->clientSocket = $clientContext->getSocket(\ZMQ::SOCKET_ROUTER);
$this->clientSocket->bind($this->config['sockets']['client']);
$this->clientSocket->on('messages', [$this, 'onClientMessage']);
} | php | protected function createClientSocket()
{
/** @var Context|\ZMQContext $clientContext */
$clientContext = new Context($this->loop);
$this->clientSocket = $clientContext->getSocket(\ZMQ::SOCKET_ROUTER);
$this->clientSocket->bind($this->config['sockets']['client']);
$this->clientSocket->on('messages', [$this, 'onClientMessage']);
} | [
"protected",
"function",
"createClientSocket",
"(",
")",
"{",
"/** @var Context|\\ZMQContext $clientContext */",
"$",
"clientContext",
"=",
"new",
"Context",
"(",
"$",
"this",
"->",
"loop",
")",
";",
"$",
"this",
"->",
"clientSocket",
"=",
"$",
"clientContext",
"-... | Creates client-socket and assigns listener. | [
"Creates",
"client",
"-",
"socket",
"and",
"assigns",
"listener",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L196-L203 | train |
nekudo/Angela | src/Server.php | Server.createWorkerJobSocket | protected function createWorkerJobSocket()
{
$workerJobContext = new \ZMQContext;
$this->workerJobSocket = $workerJobContext->getSocket(\ZMQ::SOCKET_PUB);
$this->workerJobSocket->bind($this->config['sockets']['worker_job']);
} | php | protected function createWorkerJobSocket()
{
$workerJobContext = new \ZMQContext;
$this->workerJobSocket = $workerJobContext->getSocket(\ZMQ::SOCKET_PUB);
$this->workerJobSocket->bind($this->config['sockets']['worker_job']);
} | [
"protected",
"function",
"createWorkerJobSocket",
"(",
")",
"{",
"$",
"workerJobContext",
"=",
"new",
"\\",
"ZMQContext",
";",
"$",
"this",
"->",
"workerJobSocket",
"=",
"$",
"workerJobContext",
"->",
"getSocket",
"(",
"\\",
"ZMQ",
"::",
"SOCKET_PUB",
")",
";"... | Creates worker-job-socket. | [
"Creates",
"worker",
"-",
"job",
"-",
"socket",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L208-L213 | train |
nekudo/Angela | src/Server.php | Server.createWorkerReplySocket | protected function createWorkerReplySocket()
{
/** @var Context|\ZMQContext $workerReplyContext */
$workerReplyContext = new Context($this->loop);
$this->workerReplySocket = $workerReplyContext->getSocket(\ZMQ::SOCKET_REP);
$this->workerReplySocket->bind($this->config['sockets']['worker_reply']);
$this->workerReplySocket->on('message', [$this, 'onWorkerReplyMessage']);
} | php | protected function createWorkerReplySocket()
{
/** @var Context|\ZMQContext $workerReplyContext */
$workerReplyContext = new Context($this->loop);
$this->workerReplySocket = $workerReplyContext->getSocket(\ZMQ::SOCKET_REP);
$this->workerReplySocket->bind($this->config['sockets']['worker_reply']);
$this->workerReplySocket->on('message', [$this, 'onWorkerReplyMessage']);
} | [
"protected",
"function",
"createWorkerReplySocket",
"(",
")",
"{",
"/** @var Context|\\ZMQContext $workerReplyContext */",
"$",
"workerReplyContext",
"=",
"new",
"Context",
"(",
"$",
"this",
"->",
"loop",
")",
";",
"$",
"this",
"->",
"workerReplySocket",
"=",
"$",
"... | Creates worker-reply-socket and assigns listener. | [
"Creates",
"worker",
"-",
"reply",
"-",
"socket",
"and",
"assigns",
"listener",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L218-L225 | train |
nekudo/Angela | src/Server.php | Server.onClientMessage | public function onClientMessage(array $message)
{
try {
$clientAddress = $message[0];
$data = json_decode($message[2], true);
if (empty($clientAddress) || empty($data) || !isset($data['action'])) {
throw new ServerException('Received malformed client message.');
}
switch ($data['action']) {
case 'command':
$this->handleCommand($clientAddress, $data['command']['name']);
break;
case 'job':
$this->handleJobRequest($clientAddress, $data['job']['name'], $data['job']['workload'], false);
break;
case 'background_job':
$this->handleJobRequest($clientAddress, $data['job']['name'], $data['job']['workload'], true);
break;
default:
$this->clientSocket->send('error: unknown action');
throw new ServerException('Received request for invalid action.');
}
} catch (ServerException $e) {
$errorMsgPattern = 'Client message error: %s (%s:%d)';
$this->logger->error(sprintf($errorMsgPattern, $e->getMessage(), $e->getFile(), $e->getLine()));
}
} | php | public function onClientMessage(array $message)
{
try {
$clientAddress = $message[0];
$data = json_decode($message[2], true);
if (empty($clientAddress) || empty($data) || !isset($data['action'])) {
throw new ServerException('Received malformed client message.');
}
switch ($data['action']) {
case 'command':
$this->handleCommand($clientAddress, $data['command']['name']);
break;
case 'job':
$this->handleJobRequest($clientAddress, $data['job']['name'], $data['job']['workload'], false);
break;
case 'background_job':
$this->handleJobRequest($clientAddress, $data['job']['name'], $data['job']['workload'], true);
break;
default:
$this->clientSocket->send('error: unknown action');
throw new ServerException('Received request for invalid action.');
}
} catch (ServerException $e) {
$errorMsgPattern = 'Client message error: %s (%s:%d)';
$this->logger->error(sprintf($errorMsgPattern, $e->getMessage(), $e->getFile(), $e->getLine()));
}
} | [
"public",
"function",
"onClientMessage",
"(",
"array",
"$",
"message",
")",
"{",
"try",
"{",
"$",
"clientAddress",
"=",
"$",
"message",
"[",
"0",
"]",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"message",
"[",
"2",
"]",
",",
"true",
")",
";",
... | Handles incoming client requests.
@param array $message Json-encoded data received from client. | [
"Handles",
"incoming",
"client",
"requests",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L232-L258 | train |
nekudo/Angela | src/Server.php | Server.onWorkerReplyMessage | public function onWorkerReplyMessage(string $message)
{
try {
$data = json_decode($message, true);
if (empty($data) || !isset($data['request'])) {
throw new ServerException('Invalid worker request received.');
}
$result = null;
switch ($data['request']) {
case 'register_job':
$result = $this->registerJob($data['job_name'], $data['worker_id']);
break;
case 'unregister_job':
$result = $this->unregisterJob($data['job_name'], $data['worker_id']);
break;
case 'change_state':
$result = $this->changeWorkerState($data['worker_id'], $data['state']);
break;
case 'job_completed':
$this->onJobCompleted($data['worker_id'], $data['job_id'], $data['result']);
break;
}
$response = ($result === true) ? 'ok' : 'error';
$this->workerReplySocket->send($response);
} catch (ServerException $e) {
$errorMsgPattern = 'Worker message error: %s (%s:%d)';
$this->logger->error(sprintf($errorMsgPattern, $e->getMessage(), $e->getFile(), $e->getLine()));
}
} | php | public function onWorkerReplyMessage(string $message)
{
try {
$data = json_decode($message, true);
if (empty($data) || !isset($data['request'])) {
throw new ServerException('Invalid worker request received.');
}
$result = null;
switch ($data['request']) {
case 'register_job':
$result = $this->registerJob($data['job_name'], $data['worker_id']);
break;
case 'unregister_job':
$result = $this->unregisterJob($data['job_name'], $data['worker_id']);
break;
case 'change_state':
$result = $this->changeWorkerState($data['worker_id'], $data['state']);
break;
case 'job_completed':
$this->onJobCompleted($data['worker_id'], $data['job_id'], $data['result']);
break;
}
$response = ($result === true) ? 'ok' : 'error';
$this->workerReplySocket->send($response);
} catch (ServerException $e) {
$errorMsgPattern = 'Worker message error: %s (%s:%d)';
$this->logger->error(sprintf($errorMsgPattern, $e->getMessage(), $e->getFile(), $e->getLine()));
}
} | [
"public",
"function",
"onWorkerReplyMessage",
"(",
"string",
"$",
"message",
")",
"{",
"try",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"message",
",",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
"||",
"!",
"isset",
"(",
"$",
... | Handles incoming worker requests.
@param string $message Json-encoded data received from worker.
@throws ServerException | [
"Handles",
"incoming",
"worker",
"requests",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L266-L294 | train |
nekudo/Angela | src/Server.php | Server.onChildProcessExit | public function onChildProcessExit($exitCode, $termSignal)
{
$this->logger->error(sprintf('Child process exited. (Code: %d, Signal: %d)', $exitCode, $termSignal));
$this->monitorChildProcesses();
} | php | public function onChildProcessExit($exitCode, $termSignal)
{
$this->logger->error(sprintf('Child process exited. (Code: %d, Signal: %d)', $exitCode, $termSignal));
$this->monitorChildProcesses();
} | [
"public",
"function",
"onChildProcessExit",
"(",
"$",
"exitCode",
",",
"$",
"termSignal",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"sprintf",
"(",
"'Child process exited. (Code: %d, Signal: %d)'",
",",
"$",
"exitCode",
",",
"$",
"termSignal",
"... | Handles "exit" signals of child processes.
@param int $exitCode
@param int $termSignal | [
"Handles",
"exit",
"signals",
"of",
"child",
"processes",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L312-L316 | train |
nekudo/Angela | src/Server.php | Server.respondToClient | protected function respondToClient(string $address, string $payload = '')
{
try {
$clientSocket = $this->clientSocket->getWrappedSocket();
$clientSocket->send($address, \ZMQ::MODE_SNDMORE);
$clientSocket->send('', \ZMQ::MODE_SNDMORE);
$clientSocket->send($payload);
} catch (\ZMQException $e) {
$this->logger->error('Error respoding to client: ' . $e->getMessage());
}
} | php | protected function respondToClient(string $address, string $payload = '')
{
try {
$clientSocket = $this->clientSocket->getWrappedSocket();
$clientSocket->send($address, \ZMQ::MODE_SNDMORE);
$clientSocket->send('', \ZMQ::MODE_SNDMORE);
$clientSocket->send($payload);
} catch (\ZMQException $e) {
$this->logger->error('Error respoding to client: ' . $e->getMessage());
}
} | [
"protected",
"function",
"respondToClient",
"(",
"string",
"$",
"address",
",",
"string",
"$",
"payload",
"=",
"''",
")",
"{",
"try",
"{",
"$",
"clientSocket",
"=",
"$",
"this",
"->",
"clientSocket",
"->",
"getWrappedSocket",
"(",
")",
";",
"$",
"clientSoc... | Responds to a client request.
@param string $address
@param string $payload | [
"Responds",
"to",
"a",
"client",
"request",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L324-L334 | train |
nekudo/Angela | src/Server.php | Server.registerJob | protected function registerJob(string $jobName, string $workerId) : bool
{
if (!isset($this->workerJobCapabilities[$workerId])) {
$this->workerJobCapabilities[$workerId] = [];
}
if (!in_array($jobName, $this->workerJobCapabilities[$workerId])) {
array_push($this->workerJobCapabilities[$workerId], $jobName);
}
return true;
} | php | protected function registerJob(string $jobName, string $workerId) : bool
{
if (!isset($this->workerJobCapabilities[$workerId])) {
$this->workerJobCapabilities[$workerId] = [];
}
if (!in_array($jobName, $this->workerJobCapabilities[$workerId])) {
array_push($this->workerJobCapabilities[$workerId], $jobName);
}
return true;
} | [
"protected",
"function",
"registerJob",
"(",
"string",
"$",
"jobName",
",",
"string",
"$",
"workerId",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"workerJobCapabilities",
"[",
"$",
"workerId",
"]",
")",
")",
"{",
"$",
"this... | Registers a new job-type a workers is capable of doing.
@param string $jobName
@param string $workerId
@return bool | [
"Registers",
"a",
"new",
"job",
"-",
"type",
"a",
"workers",
"is",
"capable",
"of",
"doing",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L343-L352 | train |
nekudo/Angela | src/Server.php | Server.unregisterJob | protected function unregisterJob(string $jobName, string $workerId) : bool
{
if (!isset($this->workerJobCapabilities[$jobName])) {
return true;
}
if (($key = array_search($workerId, $this->workerJobCapabilities[$jobName])) !== false) {
unset($this->workerJobCapabilities[$jobName][$key]);
}
if (empty($this->workerJobCapabilities[$jobName])) {
unset($this->workerJobCapabilities[$jobName]);
}
return true;
} | php | protected function unregisterJob(string $jobName, string $workerId) : bool
{
if (!isset($this->workerJobCapabilities[$jobName])) {
return true;
}
if (($key = array_search($workerId, $this->workerJobCapabilities[$jobName])) !== false) {
unset($this->workerJobCapabilities[$jobName][$key]);
}
if (empty($this->workerJobCapabilities[$jobName])) {
unset($this->workerJobCapabilities[$jobName]);
}
return true;
} | [
"protected",
"function",
"unregisterJob",
"(",
"string",
"$",
"jobName",
",",
"string",
"$",
"workerId",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"workerJobCapabilities",
"[",
"$",
"jobName",
"]",
")",
")",
"{",
"return",
... | Unregisters a job-type so the worker will no longer receive jobs of this type.
@param string $jobName
@param string $workerId
@return bool | [
"Unregisters",
"a",
"job",
"-",
"type",
"so",
"the",
"worker",
"will",
"no",
"longer",
"receive",
"jobs",
"of",
"this",
"type",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L361-L373 | train |
nekudo/Angela | src/Server.php | Server.changeWorkerState | protected function changeWorkerState(string $workerId, int $workerState) : bool
{
$this->workerStates[$workerId] = $workerState;
if ($workerState === Worker::WORKER_STATE_IDLE) {
$this->pushJobs();
}
return true;
} | php | protected function changeWorkerState(string $workerId, int $workerState) : bool
{
$this->workerStates[$workerId] = $workerState;
if ($workerState === Worker::WORKER_STATE_IDLE) {
$this->pushJobs();
}
return true;
} | [
"protected",
"function",
"changeWorkerState",
"(",
"string",
"$",
"workerId",
",",
"int",
"$",
"workerState",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"workerStates",
"[",
"$",
"workerId",
"]",
"=",
"$",
"workerState",
";",
"if",
"(",
"$",
"workerState",
... | Changes the state a worker currently has.
@param string $workerId
@param int $workerState
@return bool | [
"Changes",
"the",
"state",
"a",
"worker",
"currently",
"has",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L382-L389 | train |
nekudo/Angela | src/Server.php | Server.onJobCompleted | protected function onJobCompleted(string $workerId, string $jobId, string $result = '')
{
$jobType = $this->jobTypes[$jobId];
$clientAddress = $this->jobAddresses[$jobId];
if ($jobType === 'normal') {
$this->respondToClient($clientAddress, $result);
}
unset(
$this->jobTypes[$jobId],
$this->jobAddresses[$jobId],
$this->workerJobMap[$workerId]
);
} | php | protected function onJobCompleted(string $workerId, string $jobId, string $result = '')
{
$jobType = $this->jobTypes[$jobId];
$clientAddress = $this->jobAddresses[$jobId];
if ($jobType === 'normal') {
$this->respondToClient($clientAddress, $result);
}
unset(
$this->jobTypes[$jobId],
$this->jobAddresses[$jobId],
$this->workerJobMap[$workerId]
);
} | [
"protected",
"function",
"onJobCompleted",
"(",
"string",
"$",
"workerId",
",",
"string",
"$",
"jobId",
",",
"string",
"$",
"result",
"=",
"''",
")",
"{",
"$",
"jobType",
"=",
"$",
"this",
"->",
"jobTypes",
"[",
"$",
"jobId",
"]",
";",
"$",
"clientAddr... | Handles a completed job. Sends results back to client if it was not a background job.
@param string $workerId
@param string $jobId
@param string $result | [
"Handles",
"a",
"completed",
"job",
".",
"Sends",
"results",
"back",
"to",
"client",
"if",
"it",
"was",
"not",
"a",
"background",
"job",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L398-L410 | train |
nekudo/Angela | src/Server.php | Server.handleCommand | protected function handleCommand(string $clientAddress, string $command) : bool
{
switch ($command) {
case 'stop':
$this->respondToClient($clientAddress, 'ok');
$this->stop();
return true;
case 'status':
$statusData = $this->getStatusData();
$this->respondToClient($clientAddress, json_encode($statusData));
return true;
case 'flush_queue':
$result = ($this->flushQueue() === true) ? 'ok' : 'error';
$this->respondToClient($clientAddress, $result);
return true;
}
$this->respondToClient($clientAddress, 'error');
throw new ServerException('Received unknown command.');
} | php | protected function handleCommand(string $clientAddress, string $command) : bool
{
switch ($command) {
case 'stop':
$this->respondToClient($clientAddress, 'ok');
$this->stop();
return true;
case 'status':
$statusData = $this->getStatusData();
$this->respondToClient($clientAddress, json_encode($statusData));
return true;
case 'flush_queue':
$result = ($this->flushQueue() === true) ? 'ok' : 'error';
$this->respondToClient($clientAddress, $result);
return true;
}
$this->respondToClient($clientAddress, 'error');
throw new ServerException('Received unknown command.');
} | [
"protected",
"function",
"handleCommand",
"(",
"string",
"$",
"clientAddress",
",",
"string",
"$",
"command",
")",
":",
"bool",
"{",
"switch",
"(",
"$",
"command",
")",
"{",
"case",
"'stop'",
":",
"$",
"this",
"->",
"respondToClient",
"(",
"$",
"clientAddr... | Executes commands received from a client.
@param string $clientAddress
@param string $command
@throws ServerException
@return bool | [
"Executes",
"commands",
"received",
"from",
"a",
"client",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L420-L439 | train |
nekudo/Angela | src/Server.php | Server.handleJobRequest | protected function handleJobRequest(
string $clientAddress,
string $jobName,
string $payload = '',
bool $backgroundJob = false
) : string {
$jobId = $this->addJobToQueue($jobName, $payload);
$this->jobTypes[$jobId] = ($backgroundJob === true) ? 'background' : 'normal';
$this->jobAddresses[$jobId] = $clientAddress;
$this->pushJobs();
if ($backgroundJob === true) {
$this->respondToClient($clientAddress, $jobId);
}
$this->totalJobRequests++;
return $jobId;
} | php | protected function handleJobRequest(
string $clientAddress,
string $jobName,
string $payload = '',
bool $backgroundJob = false
) : string {
$jobId = $this->addJobToQueue($jobName, $payload);
$this->jobTypes[$jobId] = ($backgroundJob === true) ? 'background' : 'normal';
$this->jobAddresses[$jobId] = $clientAddress;
$this->pushJobs();
if ($backgroundJob === true) {
$this->respondToClient($clientAddress, $jobId);
}
$this->totalJobRequests++;
return $jobId;
} | [
"protected",
"function",
"handleJobRequest",
"(",
"string",
"$",
"clientAddress",
",",
"string",
"$",
"jobName",
",",
"string",
"$",
"payload",
"=",
"''",
",",
"bool",
"$",
"backgroundJob",
"=",
"false",
")",
":",
"string",
"{",
"$",
"jobId",
"=",
"$",
"... | Handles job-requests received from a client.
@param string $clientAddress
@param string $jobName
@param string $payload
@param bool $backgroundJob
@return string The id assigned to the job. | [
"Handles",
"job",
"-",
"requests",
"received",
"from",
"a",
"client",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L450-L465 | train |
nekudo/Angela | src/Server.php | Server.addJobToQueue | protected function addJobToQueue(string $jobName, string $payload = '') : string
{
if (!isset($this->jobQueues[$jobName])) {
$this->jobQueues[$jobName] = [];
}
$jobId = $this->getJobId();
array_push($this->jobQueues[$jobName], [
'job_id' => $jobId,
'payload' => $payload
]);
$this->jobsInQueue++;
return $jobId;
} | php | protected function addJobToQueue(string $jobName, string $payload = '') : string
{
if (!isset($this->jobQueues[$jobName])) {
$this->jobQueues[$jobName] = [];
}
$jobId = $this->getJobId();
array_push($this->jobQueues[$jobName], [
'job_id' => $jobId,
'payload' => $payload
]);
$this->jobsInQueue++;
return $jobId;
} | [
"protected",
"function",
"addJobToQueue",
"(",
"string",
"$",
"jobName",
",",
"string",
"$",
"payload",
"=",
"''",
")",
":",
"string",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"jobQueues",
"[",
"$",
"jobName",
"]",
")",
")",
"{",
"$",
... | Adds a new job-requests to corresponding queue.
@param string $jobName
@param string $payload
@return string The id assigned to the job. | [
"Adds",
"a",
"new",
"job",
"-",
"requests",
"to",
"corresponding",
"queue",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L474-L486 | train |
nekudo/Angela | src/Server.php | Server.pushJobs | protected function pushJobs() : bool
{
// Skip if no jobs currently in queue
if (empty($this->jobQueues)) {
return true;
}
// Run trough list of (idle) workers and check if there is a job in queue the worker can handle
foreach ($this->workerStates as $workerId => $workerState) {
if ($workerState !== Worker::WORKER_STATE_IDLE) {
continue;
}
$jobData = $this->getJobFromQueue($workerId);
if (empty($jobData)) {
continue;
}
try {
$this->workerStats[$workerId]++;
$this->workerJobMap[$workerId] = $jobData['job_id'];
$this->workerJobSocket->send($jobData['job_name'], \ZMQ::MODE_SNDMORE);
$this->workerJobSocket->send($jobData['job_id'], \ZMQ::MODE_SNDMORE);
$this->workerJobSocket->send($workerId, \ZMQ::MODE_SNDMORE);
$this->workerJobSocket->send($jobData['payload']);
} catch (\ZMQException $e) {
$this->logger->error('Error sending job to worker: ' . $e->getMessage());
}
}
return true;
} | php | protected function pushJobs() : bool
{
// Skip if no jobs currently in queue
if (empty($this->jobQueues)) {
return true;
}
// Run trough list of (idle) workers and check if there is a job in queue the worker can handle
foreach ($this->workerStates as $workerId => $workerState) {
if ($workerState !== Worker::WORKER_STATE_IDLE) {
continue;
}
$jobData = $this->getJobFromQueue($workerId);
if (empty($jobData)) {
continue;
}
try {
$this->workerStats[$workerId]++;
$this->workerJobMap[$workerId] = $jobData['job_id'];
$this->workerJobSocket->send($jobData['job_name'], \ZMQ::MODE_SNDMORE);
$this->workerJobSocket->send($jobData['job_id'], \ZMQ::MODE_SNDMORE);
$this->workerJobSocket->send($workerId, \ZMQ::MODE_SNDMORE);
$this->workerJobSocket->send($jobData['payload']);
} catch (\ZMQException $e) {
$this->logger->error('Error sending job to worker: ' . $e->getMessage());
}
}
return true;
} | [
"protected",
"function",
"pushJobs",
"(",
")",
":",
"bool",
"{",
"// Skip if no jobs currently in queue",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"jobQueues",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Run trough list of (idle) workers and check if there is a ... | Runs trough the job queue and pushes jobs to workers if an idle worker is available.
@return bool | [
"Runs",
"trough",
"the",
"job",
"queue",
"and",
"pushes",
"jobs",
"to",
"workers",
"if",
"an",
"idle",
"worker",
"is",
"available",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L493-L522 | train |
nekudo/Angela | src/Server.php | Server.startWorkerPools | protected function startWorkerPools() : bool
{
if (empty($this->config['pool'])) {
throw new ServerException('No worker pool defined. Check config file.');
}
foreach ($this->config['pool'] as $poolName => $poolConfig) {
$this->startWorkerPool($poolName, $poolConfig);
}
return true;
} | php | protected function startWorkerPools() : bool
{
if (empty($this->config['pool'])) {
throw new ServerException('No worker pool defined. Check config file.');
}
foreach ($this->config['pool'] as $poolName => $poolConfig) {
$this->startWorkerPool($poolName, $poolConfig);
}
return true;
} | [
"protected",
"function",
"startWorkerPools",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'pool'",
"]",
")",
")",
"{",
"throw",
"new",
"ServerException",
"(",
"'No worker pool defined. Check config file.'",
")",
";",
... | Starts all worker pools defined in configuration.
@return bool
@throws ServerException | [
"Starts",
"all",
"worker",
"pools",
"defined",
"in",
"configuration",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L565-L574 | train |
nekudo/Angela | src/Server.php | Server.startWorkerPool | protected function startWorkerPool(string $poolName, array $poolConfig)
{
if (!isset($poolConfig['worker_file'])) {
throw new ServerException('Path to worker file not set in pool config.');
}
$this->processes[$poolName] = [];
$processesToStart = $poolConfig['cp_start'] ?? 5;
for ($i = 0; $i < $processesToStart; $i++) {
// start child process:
try {
$process = $this->startChildProcess($poolConfig['worker_file']);
$this->registerChildProcess($process, $poolName);
} catch (\Exception $e) {
throw new ServerException('Could not start child process.');
}
}
} | php | protected function startWorkerPool(string $poolName, array $poolConfig)
{
if (!isset($poolConfig['worker_file'])) {
throw new ServerException('Path to worker file not set in pool config.');
}
$this->processes[$poolName] = [];
$processesToStart = $poolConfig['cp_start'] ?? 5;
for ($i = 0; $i < $processesToStart; $i++) {
// start child process:
try {
$process = $this->startChildProcess($poolConfig['worker_file']);
$this->registerChildProcess($process, $poolName);
} catch (\Exception $e) {
throw new ServerException('Could not start child process.');
}
}
} | [
"protected",
"function",
"startWorkerPool",
"(",
"string",
"$",
"poolName",
",",
"array",
"$",
"poolConfig",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"poolConfig",
"[",
"'worker_file'",
"]",
")",
")",
"{",
"throw",
"new",
"ServerException",
"(",
"'Path... | Starts child processes as defined in pool configuration.
@param string $poolName
@param array $poolConfig
@throws ServerException | [
"Starts",
"child",
"processes",
"as",
"defined",
"in",
"pool",
"configuration",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L583-L600 | train |
nekudo/Angela | src/Server.php | Server.stopWorkerPools | protected function stopWorkerPools() : bool
{
if (empty($this->processes)) {
return true;
}
foreach (array_keys($this->processes) as $poolName) {
$this->stopWorkerPool($poolName);
}
return true;
} | php | protected function stopWorkerPools() : bool
{
if (empty($this->processes)) {
return true;
}
foreach (array_keys($this->processes) as $poolName) {
$this->stopWorkerPool($poolName);
}
return true;
} | [
"protected",
"function",
"stopWorkerPools",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"processes",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"processes",
")",
"as",
... | Stops processes of all pools.
@return bool | [
"Stops",
"processes",
"of",
"all",
"pools",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L607-L616 | train |
nekudo/Angela | src/Server.php | Server.stopWorkerPool | protected function stopWorkerPool(string $poolName) : bool
{
if (empty($this->processes[$poolName])) {
return true;
}
foreach ($this->processes[$poolName] as $process) {
/** @var Process $process */
$process->terminate();
}
return true;
} | php | protected function stopWorkerPool(string $poolName) : bool
{
if (empty($this->processes[$poolName])) {
return true;
}
foreach ($this->processes[$poolName] as $process) {
/** @var Process $process */
$process->terminate();
}
return true;
} | [
"protected",
"function",
"stopWorkerPool",
"(",
"string",
"$",
"poolName",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"processes",
"[",
"$",
"poolName",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"thi... | Terminates all child processes of given pool.
@param string $poolName
@return bool | [
"Terminates",
"all",
"child",
"processes",
"of",
"given",
"pool",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L624-L634 | train |
nekudo/Angela | src/Server.php | Server.monitorPoolProcesses | protected function monitorPoolProcesses(string $poolName) : bool
{
if (empty($this->processes[$poolName])) {
return true;
}
/** @var Process $process */
foreach ($this->processes[$poolName] as $i => $process) {
$pid = $process->getPid();
$workerId = $this->config['server_id'] . '_' . $pid;
// check if process is still running:
if ($process->isRunning() === true) {
continue;
}
// if process is not running remove it from system:
$this->unregisterChildProcess($workerId);
unset($this->processes[$poolName][$i]);
// fire up a new process:
$workerFile = $this->config['pool'][$poolName]['worker_file'];
$process = $this->startChildProcess($workerFile);
$this->registerChildProcess($process, $poolName);
}
return true;
} | php | protected function monitorPoolProcesses(string $poolName) : bool
{
if (empty($this->processes[$poolName])) {
return true;
}
/** @var Process $process */
foreach ($this->processes[$poolName] as $i => $process) {
$pid = $process->getPid();
$workerId = $this->config['server_id'] . '_' . $pid;
// check if process is still running:
if ($process->isRunning() === true) {
continue;
}
// if process is not running remove it from system:
$this->unregisterChildProcess($workerId);
unset($this->processes[$poolName][$i]);
// fire up a new process:
$workerFile = $this->config['pool'][$poolName]['worker_file'];
$process = $this->startChildProcess($workerFile);
$this->registerChildProcess($process, $poolName);
}
return true;
} | [
"protected",
"function",
"monitorPoolProcesses",
"(",
"string",
"$",
"poolName",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"processes",
"[",
"$",
"poolName",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"/** @var Process $proces... | Checks state of every process in pool and restarts processes if necessary.
@param string $poolName
@return bool | [
"Checks",
"state",
"of",
"every",
"process",
"in",
"pool",
"and",
"restarts",
"processes",
"if",
"necessary",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L652-L677 | train |
nekudo/Angela | src/Server.php | Server.monitorQueue | public function monitorQueue() : bool
{
if ($this->jobsInQueue === 0) {
return true;
}
foreach (array_keys($this->jobQueues) as $jobName) {
if (empty($this->jobQueues[$jobName])) {
continue;
}
if ($this->jobCanBeProcessed($jobName)) {
continue;
}
$jobsCount = count($this->jobQueues[$jobName]);
$this->jobQueues[$jobName] = [];
$this->jobsInQueue -= $jobsCount;
}
return $this->pushJobs();
} | php | public function monitorQueue() : bool
{
if ($this->jobsInQueue === 0) {
return true;
}
foreach (array_keys($this->jobQueues) as $jobName) {
if (empty($this->jobQueues[$jobName])) {
continue;
}
if ($this->jobCanBeProcessed($jobName)) {
continue;
}
$jobsCount = count($this->jobQueues[$jobName]);
$this->jobQueues[$jobName] = [];
$this->jobsInQueue -= $jobsCount;
}
return $this->pushJobs();
} | [
"public",
"function",
"monitorQueue",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"jobsInQueue",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"jobQueues",
")",
"as",
"$",
"jobNa... | Cleanup jobs that are not handled correctly for some reason.
@return bool | [
"Cleanup",
"jobs",
"that",
"are",
"not",
"handled",
"correctly",
"for",
"some",
"reason",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L684-L701 | train |
nekudo/Angela | src/Server.php | Server.jobCanBeProcessed | protected function jobCanBeProcessed(string $jobName) : bool
{
foreach ($this->workerJobCapabilities as $workerId => $jobs) {
if (in_array($jobName, $jobs)) {
return true;
}
}
return false;
} | php | protected function jobCanBeProcessed(string $jobName) : bool
{
foreach ($this->workerJobCapabilities as $workerId => $jobs) {
if (in_array($jobName, $jobs)) {
return true;
}
}
return false;
} | [
"protected",
"function",
"jobCanBeProcessed",
"(",
"string",
"$",
"jobName",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"workerJobCapabilities",
"as",
"$",
"workerId",
"=>",
"$",
"jobs",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"jobName",
... | Check if there is a least one worker capable of doing requested job type.
@param string $jobName
@return bool | [
"Check",
"if",
"there",
"is",
"a",
"least",
"one",
"worker",
"capable",
"of",
"doing",
"requested",
"job",
"type",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L709-L717 | train |
nekudo/Angela | src/Server.php | Server.getStatusData | protected function getStatusData() : array
{
$statusData = [
'version' => self::VERSION,
'starttime' => '',
'uptime' => '',
'active_worker' => [],
'job_info' => [],
];
$starttime = date('Y-m-d H:i:s', $this->startTime);
$start = new \DateTime($starttime);
$now = new \DateTime('now');
$uptime = $start->diff($now)->format('%ad %Hh %Im %Ss');
$statusData['starttime'] = $starttime;
$statusData['uptime'] = $uptime;
foreach (array_keys($this->processes) as $poolName) {
if (!isset($statusData['active_worker'][$poolName])) {
$statusData['active_worker'][$poolName] = 0;
}
/** @var Process $process */
foreach ($this->processes[$poolName] as $process) {
$processIsRunning = $process->isRunning();
if ($processIsRunning === true) {
$statusData['active_worker'][$poolName]++;
}
}
}
$statusData['job_info']['job_requests_total'] = $this->totalJobRequests;
$statusData['job_info']['queue_length'] = $this->jobsInQueue;
$statusData['job_info']['worker_stats'] = $this->workerStats;
return $statusData;
} | php | protected function getStatusData() : array
{
$statusData = [
'version' => self::VERSION,
'starttime' => '',
'uptime' => '',
'active_worker' => [],
'job_info' => [],
];
$starttime = date('Y-m-d H:i:s', $this->startTime);
$start = new \DateTime($starttime);
$now = new \DateTime('now');
$uptime = $start->diff($now)->format('%ad %Hh %Im %Ss');
$statusData['starttime'] = $starttime;
$statusData['uptime'] = $uptime;
foreach (array_keys($this->processes) as $poolName) {
if (!isset($statusData['active_worker'][$poolName])) {
$statusData['active_worker'][$poolName] = 0;
}
/** @var Process $process */
foreach ($this->processes[$poolName] as $process) {
$processIsRunning = $process->isRunning();
if ($processIsRunning === true) {
$statusData['active_worker'][$poolName]++;
}
}
}
$statusData['job_info']['job_requests_total'] = $this->totalJobRequests;
$statusData['job_info']['queue_length'] = $this->jobsInQueue;
$statusData['job_info']['worker_stats'] = $this->workerStats;
return $statusData;
} | [
"protected",
"function",
"getStatusData",
"(",
")",
":",
"array",
"{",
"$",
"statusData",
"=",
"[",
"'version'",
"=>",
"self",
"::",
"VERSION",
",",
"'starttime'",
"=>",
"''",
",",
"'uptime'",
"=>",
"''",
",",
"'active_worker'",
"=>",
"[",
"]",
",",
"'jo... | Collects server and worker status information to send back to client.
@return array | [
"Collects",
"server",
"and",
"worker",
"status",
"information",
"to",
"send",
"back",
"to",
"client",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L724-L757 | train |
nekudo/Angela | src/Server.php | Server.registerChildProcess | protected function registerChildProcess(Process $process, string $poolName) : bool
{
array_push($this->processes[$poolName], $process);
$workerPid = $process->getPid();
$workerId = $this->config['server_id'] . '_' . $workerPid;
$this->workerStates[$workerId] = Worker::WORKER_STATE_IDLE;
$this->workerStats[$workerId] = 0;
return true;
} | php | protected function registerChildProcess(Process $process, string $poolName) : bool
{
array_push($this->processes[$poolName], $process);
$workerPid = $process->getPid();
$workerId = $this->config['server_id'] . '_' . $workerPid;
$this->workerStates[$workerId] = Worker::WORKER_STATE_IDLE;
$this->workerStats[$workerId] = 0;
return true;
} | [
"protected",
"function",
"registerChildProcess",
"(",
"Process",
"$",
"process",
",",
"string",
"$",
"poolName",
")",
":",
"bool",
"{",
"array_push",
"(",
"$",
"this",
"->",
"processes",
"[",
"$",
"poolName",
"]",
",",
"$",
"process",
")",
";",
"$",
"wor... | Registers new child-process at server.
@param Process $process
@param string $poolName
@return bool | [
"Registers",
"new",
"child",
"-",
"process",
"at",
"server",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L794-L802 | train |
nekudo/Angela | src/Server.php | Server.flushQueue | protected function flushQueue() : bool
{
foreach (array_keys($this->jobQueues) as $jobName) {
$this->jobQueues[$jobName] = [];
}
$this->jobsInQueue = 0;
return true;
} | php | protected function flushQueue() : bool
{
foreach (array_keys($this->jobQueues) as $jobName) {
$this->jobQueues[$jobName] = [];
}
$this->jobsInQueue = 0;
return true;
} | [
"protected",
"function",
"flushQueue",
"(",
")",
":",
"bool",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"jobQueues",
")",
"as",
"$",
"jobName",
")",
"{",
"$",
"this",
"->",
"jobQueues",
"[",
"$",
"jobName",
"]",
"=",
"[",
"]",
";",
... | Removes jobs from all queues.
@return bool | [
"Removes",
"jobs",
"from",
"all",
"queues",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Server.php#L837-L844 | train |
protobuf-php/google-protobuf-proto | src/google/protobuf/UninterpretedOption.php | UninterpretedOption.addName | public function addName(\google\protobuf\UninterpretedOption\NamePart $value)
{
if ($this->name === null) {
$this->name = new \Protobuf\MessageCollection();
}
$this->name->add($value);
} | php | public function addName(\google\protobuf\UninterpretedOption\NamePart $value)
{
if ($this->name === null) {
$this->name = new \Protobuf\MessageCollection();
}
$this->name->add($value);
} | [
"public",
"function",
"addName",
"(",
"\\",
"google",
"\\",
"protobuf",
"\\",
"UninterpretedOption",
"\\",
"NamePart",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"new",
"\\",
... | Add a new element to 'name'
@param \google\protobuf\UninterpretedOption\NamePart $value | [
"Add",
"a",
"new",
"element",
"to",
"name"
] | da1827b4a23fccd4eb998a8d4bcd972f2330bc29 | https://github.com/protobuf-php/google-protobuf-proto/blob/da1827b4a23fccd4eb998a8d4bcd972f2330bc29/src/google/protobuf/UninterpretedOption.php#L111-L118 | train |
protobuf-php/google-protobuf-proto | src/google/protobuf/UninterpretedOption.php | UninterpretedOption.setStringValue | public function setStringValue($value = null)
{
if ($value !== null && ! $value instanceof \Protobuf\Stream) {
$value = \Protobuf\Stream::wrap($value);
}
$this->string_value = $value;
} | php | public function setStringValue($value = null)
{
if ($value !== null && ! $value instanceof \Protobuf\Stream) {
$value = \Protobuf\Stream::wrap($value);
}
$this->string_value = $value;
} | [
"public",
"function",
"setStringValue",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"!==",
"null",
"&&",
"!",
"$",
"value",
"instanceof",
"\\",
"Protobuf",
"\\",
"Stream",
")",
"{",
"$",
"value",
"=",
"\\",
"Protobuf",
"\\",
"S... | Set 'string_value' value
@param \Protobuf\Stream $value | [
"Set",
"string_value",
"value"
] | da1827b4a23fccd4eb998a8d4bcd972f2330bc29 | https://github.com/protobuf-php/google-protobuf-proto/blob/da1827b4a23fccd4eb998a8d4bcd972f2330bc29/src/google/protobuf/UninterpretedOption.php#L265-L272 | train |
techdivision/import-product-media | src/Observers/MediaGalleryValueObserver.php | MediaGalleryValueObserver.prepareAttributes | protected function prepareAttributes()
{
try {
// try to load the product SKU and map it the entity ID
$parentId= $this->getValue(ColumnKeys::IMAGE_PARENT_SKU, null, array($this, 'mapParentSku'));
} catch (\Exception $e) {
throw $this->wrapException(array(ColumnKeys::IMAGE_PARENT_SKU), $e);
}
// load the store ID
$storeId = $this->getRowStoreId(StoreViewCodes::ADMIN);
// load the value ID and the position counter
$valueId = $this->getParentValueId();
$position = $this->raisePositionCounter();
// load the image label
$imageLabel = $this->getValue(ColumnKeys::IMAGE_LABEL);
// prepare the media gallery value
return $this->initializeEntity(
array(
MemberNames::VALUE_ID => $valueId,
MemberNames::STORE_ID => $storeId,
MemberNames::ENTITY_ID => $parentId,
MemberNames::LABEL => $imageLabel,
MemberNames::POSITION => $position,
MemberNames::DISABLED => 0
)
);
} | php | protected function prepareAttributes()
{
try {
// try to load the product SKU and map it the entity ID
$parentId= $this->getValue(ColumnKeys::IMAGE_PARENT_SKU, null, array($this, 'mapParentSku'));
} catch (\Exception $e) {
throw $this->wrapException(array(ColumnKeys::IMAGE_PARENT_SKU), $e);
}
// load the store ID
$storeId = $this->getRowStoreId(StoreViewCodes::ADMIN);
// load the value ID and the position counter
$valueId = $this->getParentValueId();
$position = $this->raisePositionCounter();
// load the image label
$imageLabel = $this->getValue(ColumnKeys::IMAGE_LABEL);
// prepare the media gallery value
return $this->initializeEntity(
array(
MemberNames::VALUE_ID => $valueId,
MemberNames::STORE_ID => $storeId,
MemberNames::ENTITY_ID => $parentId,
MemberNames::LABEL => $imageLabel,
MemberNames::POSITION => $position,
MemberNames::DISABLED => 0
)
);
} | [
"protected",
"function",
"prepareAttributes",
"(",
")",
"{",
"try",
"{",
"// try to load the product SKU and map it the entity ID",
"$",
"parentId",
"=",
"$",
"this",
"->",
"getValue",
"(",
"ColumnKeys",
"::",
"IMAGE_PARENT_SKU",
",",
"null",
",",
"array",
"(",
"$",... | Prepare the product media gallery value that has to be persisted.
@return array The prepared product media gallery value attributes | [
"Prepare",
"the",
"product",
"media",
"gallery",
"value",
"that",
"has",
"to",
"be",
"persisted",
"."
] | 124f4ed08d96f61fdb1eeb5aafde1c5afbd93a06 | https://github.com/techdivision/import-product-media/blob/124f4ed08d96f61fdb1eeb5aafde1c5afbd93a06/src/Observers/MediaGalleryValueObserver.php#L94-L125 | train |
undera/pwe | PWE/Modules/AbstractRESTCall.php | AbstractRESTCall.getRequestData | protected function getRequestData()
{
if ($this->PWE->getHeader('content-type') != 'application/json') {
throw new HTTP4xxException("API requires 'application/json' as type for request body", HTTP4xxException::UNSUPPORTED_MEDIA_TYPE);
}
return json_decode(file_get_contents("php://input"), true);
} | php | protected function getRequestData()
{
if ($this->PWE->getHeader('content-type') != 'application/json') {
throw new HTTP4xxException("API requires 'application/json' as type for request body", HTTP4xxException::UNSUPPORTED_MEDIA_TYPE);
}
return json_decode(file_get_contents("php://input"), true);
} | [
"protected",
"function",
"getRequestData",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"PWE",
"->",
"getHeader",
"(",
"'content-type'",
")",
"!=",
"'application/json'",
")",
"{",
"throw",
"new",
"HTTP4xxException",
"(",
"\"API requires 'application/json' as type fo... | Reads request body as JSON
@return mixed | [
"Reads",
"request",
"body",
"as",
"JSON"
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/AbstractRESTCall.php#L118-L125 | train |
undera/pwe | PWE/Modules/AbstractRESTCall.php | AbstractRESTCall.handleGet | protected function handleGet($item = null)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s", $item);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | php | protected function handleGet($item = null)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s", $item);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | [
"protected",
"function",
"handleGet",
"(",
"$",
"item",
"=",
"null",
")",
"{",
"PWELogger",
"::",
"debug",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
".",
"\": %s\"",
",",
"$",
"item",
")",
";",
"throw",
"new",
"HTTP5xxException",
"(",
"'Not suppor... | Should implement get collection or single item
@param string|int|null $item | [
"Should",
"implement",
"get",
"collection",
"or",
"single",
"item"
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/AbstractRESTCall.php#L131-L135 | train |
undera/pwe | PWE/Modules/AbstractRESTCall.php | AbstractRESTCall.handlePut | protected function handlePut($item, $data)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s %s", $item, $data);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | php | protected function handlePut($item, $data)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s %s", $item, $data);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | [
"protected",
"function",
"handlePut",
"(",
"$",
"item",
",",
"$",
"data",
")",
"{",
"PWELogger",
"::",
"debug",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
".",
"\": %s %s\"",
",",
"$",
"item",
",",
"$",
"data",
")",
";",
"throw",
"new",
"HTTP5x... | Should implement update
@param string|int $item
@param mixed $data | [
"Should",
"implement",
"update"
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/AbstractRESTCall.php#L142-L146 | train |
undera/pwe | PWE/Modules/AbstractRESTCall.php | AbstractRESTCall.handlePost | protected function handlePost($data)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s", $data);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | php | protected function handlePost($data)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s", $data);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | [
"protected",
"function",
"handlePost",
"(",
"$",
"data",
")",
"{",
"PWELogger",
"::",
"debug",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
".",
"\": %s\"",
",",
"$",
"data",
")",
";",
"throw",
"new",
"HTTP5xxException",
"(",
"'Not supported method for t... | Should implement create and return code 201 on success
@param mixed $data | [
"Should",
"implement",
"create",
"and",
"return",
"code",
"201",
"on",
"success"
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/AbstractRESTCall.php#L152-L156 | train |
undera/pwe | PWE/Modules/AbstractRESTCall.php | AbstractRESTCall.handleDelete | protected function handleDelete($item)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s", $item);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | php | protected function handleDelete($item)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s", $item);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | [
"protected",
"function",
"handleDelete",
"(",
"$",
"item",
")",
"{",
"PWELogger",
"::",
"debug",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
".",
"\": %s\"",
",",
"$",
"item",
")",
";",
"throw",
"new",
"HTTP5xxException",
"(",
"'Not supported method for... | Should implement deleting item
@param string|int $item
@throws HTTP2xxException with code 204 | [
"Should",
"implement",
"deleting",
"item"
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/AbstractRESTCall.php#L163-L167 | train |
undera/pwe | PWE/Modules/AbstractRESTCall.php | AbstractRESTCall.handlePatch | protected function handlePatch($item, $data)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s %s", $item, $data);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | php | protected function handlePatch($item, $data)
{
PWELogger::debug($_SERVER['REQUEST_METHOD'] . ": %s %s", $item, $data);
throw new HTTP5xxException('Not supported method for this call: ' . $_SERVER['REQUEST_METHOD'], HTTP5xxException::UNIMPLEMENTED);
} | [
"protected",
"function",
"handlePatch",
"(",
"$",
"item",
",",
"$",
"data",
")",
"{",
"PWELogger",
"::",
"debug",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
".",
"\": %s %s\"",
",",
"$",
"item",
",",
"$",
"data",
")",
";",
"throw",
"new",
"HTTP... | Should implement partial update
@param string|int $item
@param mixed $data | [
"Should",
"implement",
"partial",
"update"
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/AbstractRESTCall.php#L174-L178 | train |
brightnucleus/shortcodes | src/ShortcodeManager.php | ShortcodeManager.init_shortcode | protected function init_shortcode( $tag ) {
$shortcode_class = $this->get_shortcode_class( $tag );
$shortcode_atts_parser = $this->get_shortcode_atts_parser_class( $tag );
$atts_parser = $this->instantiate(
ShortcodeAttsParserInterface::class,
$shortcode_atts_parser,
[ 'config' => $this->config->getSubConfig( $tag ) ]
);
$this->shortcodes[] = $this->instantiate(
ShortcodeInterface::class,
$shortcode_class,
[
'shortcode_tag' => $tag,
'config' => $this->config->getSubConfig( $tag ),
'atts_parser' => $atts_parser,
'dependencies' => $this->dependencies,
'view_builder' => $this->view_builder,
]
);
if ( $this->hasConfigKey( $tag, self::KEY_UI ) ) {
$this->init_shortcode_ui( $tag );
}
} | php | protected function init_shortcode( $tag ) {
$shortcode_class = $this->get_shortcode_class( $tag );
$shortcode_atts_parser = $this->get_shortcode_atts_parser_class( $tag );
$atts_parser = $this->instantiate(
ShortcodeAttsParserInterface::class,
$shortcode_atts_parser,
[ 'config' => $this->config->getSubConfig( $tag ) ]
);
$this->shortcodes[] = $this->instantiate(
ShortcodeInterface::class,
$shortcode_class,
[
'shortcode_tag' => $tag,
'config' => $this->config->getSubConfig( $tag ),
'atts_parser' => $atts_parser,
'dependencies' => $this->dependencies,
'view_builder' => $this->view_builder,
]
);
if ( $this->hasConfigKey( $tag, self::KEY_UI ) ) {
$this->init_shortcode_ui( $tag );
}
} | [
"protected",
"function",
"init_shortcode",
"(",
"$",
"tag",
")",
"{",
"$",
"shortcode_class",
"=",
"$",
"this",
"->",
"get_shortcode_class",
"(",
"$",
"tag",
")",
";",
"$",
"shortcode_atts_parser",
"=",
"$",
"this",
"->",
"get_shortcode_atts_parser_class",
"(",
... | Initialize a single shortcode.
@since 0.1.0
@param string $tag The tag of the shortcode to register.
@throws FailedToInstantiateObject If the Shortcode Atts Parser object
could not be instantiated.
@throws FailedToInstantiateObject If the Shortcode object could not be
instantiated. | [
"Initialize",
"a",
"single",
"shortcode",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/ShortcodeManager.php#L167-L192 | train |
brightnucleus/shortcodes | src/ShortcodeManager.php | ShortcodeManager.get_shortcode_class | protected function get_shortcode_class( $tag ) {
$shortcode_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_CLASS )
? $this->getConfigKey( $tag, self::KEY_CUSTOM_CLASS )
: self::DEFAULT_SHORTCODE;
return $shortcode_class;
} | php | protected function get_shortcode_class( $tag ) {
$shortcode_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_CLASS )
? $this->getConfigKey( $tag, self::KEY_CUSTOM_CLASS )
: self::DEFAULT_SHORTCODE;
return $shortcode_class;
} | [
"protected",
"function",
"get_shortcode_class",
"(",
"$",
"tag",
")",
"{",
"$",
"shortcode_class",
"=",
"$",
"this",
"->",
"hasConfigKey",
"(",
"$",
"tag",
",",
"self",
"::",
"KEY_CUSTOM_CLASS",
")",
"?",
"$",
"this",
"->",
"getConfigKey",
"(",
"$",
"tag",... | Get the class name of an implementation of the ShortcodeInterface.
@since 0.1.0
@param string $tag Shortcode tag to get the class for.
@return string Class name of the Shortcode. | [
"Get",
"the",
"class",
"name",
"of",
"an",
"implementation",
"of",
"the",
"ShortcodeInterface",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/ShortcodeManager.php#L203-L209 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.