repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
fubhy/graphql-php | src/Executor/Executor.php | Executor.collectFields | protected static function collectFields(ExecutionContext $context, ObjectType $type, SelectionSet $set, $fields, $visited)
{
$count = count($set->get('selections'));
for ($i = 0; $i < $count; $i++) {
$selection = $set->get('selections')[$i];
switch ($selection::KIND) {
case Node::KIND_FIELD:
if (!self::shouldIncludeNode($context, $selection->get('directives'))) {
continue;
}
$name = self::getFieldEntryKey($selection);
if (!isset($fields[$name])) {
$fields[$name] = new \ArrayObject();
}
$fields[$name][] = $selection;
break;
case Node::KIND_INLINE_FRAGMENT:
if (!self::shouldIncludeNode($context, $selection->get('directives')) || !self::doesFragmentConditionMatch($context, $selection, $type)) {
continue;
}
self::collectFields(
$context,
$type,
$selection->get('selectionSet'),
$fields,
$visited
);
break;
case Node::KIND_FRAGMENT_SPREAD:
$fragName = $selection->get('name')->get('value');
if (!empty($visited[$fragName]) || !self::shouldIncludeNode($context, $selection->get('directives'))) {
continue;
}
$visited[$fragName] = TRUE;
$fragment = isset($context->fragments[$fragName]) ? $context->fragments[$fragName] : NULL;
if (!$fragment || !self::shouldIncludeNode($context, $fragment->get('directives')) || !self::doesFragmentConditionMatch($context, $fragment, $type)) {
continue;
}
self::collectFields($context, $type, $fragment->get('selectionSet'), $fields, $visited);
break;
}
}
return $fields;
} | php | protected static function collectFields(ExecutionContext $context, ObjectType $type, SelectionSet $set, $fields, $visited)
{
$count = count($set->get('selections'));
for ($i = 0; $i < $count; $i++) {
$selection = $set->get('selections')[$i];
switch ($selection::KIND) {
case Node::KIND_FIELD:
if (!self::shouldIncludeNode($context, $selection->get('directives'))) {
continue;
}
$name = self::getFieldEntryKey($selection);
if (!isset($fields[$name])) {
$fields[$name] = new \ArrayObject();
}
$fields[$name][] = $selection;
break;
case Node::KIND_INLINE_FRAGMENT:
if (!self::shouldIncludeNode($context, $selection->get('directives')) || !self::doesFragmentConditionMatch($context, $selection, $type)) {
continue;
}
self::collectFields(
$context,
$type,
$selection->get('selectionSet'),
$fields,
$visited
);
break;
case Node::KIND_FRAGMENT_SPREAD:
$fragName = $selection->get('name')->get('value');
if (!empty($visited[$fragName]) || !self::shouldIncludeNode($context, $selection->get('directives'))) {
continue;
}
$visited[$fragName] = TRUE;
$fragment = isset($context->fragments[$fragName]) ? $context->fragments[$fragName] : NULL;
if (!$fragment || !self::shouldIncludeNode($context, $fragment->get('directives')) || !self::doesFragmentConditionMatch($context, $fragment, $type)) {
continue;
}
self::collectFields($context, $type, $fragment->get('selectionSet'), $fields, $visited);
break;
}
}
return $fields;
} | [
"protected",
"static",
"function",
"collectFields",
"(",
"ExecutionContext",
"$",
"context",
",",
"ObjectType",
"$",
"type",
",",
"SelectionSet",
"$",
"set",
",",
"$",
"fields",
",",
"$",
"visited",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"set",
"->",
"get",
"(",
"'selections'",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"selection",
"=",
"$",
"set",
"->",
"get",
"(",
"'selections'",
")",
"[",
"$",
"i",
"]",
";",
"switch",
"(",
"$",
"selection",
"::",
"KIND",
")",
"{",
"case",
"Node",
"::",
"KIND_FIELD",
":",
"if",
"(",
"!",
"self",
"::",
"shouldIncludeNode",
"(",
"$",
"context",
",",
"$",
"selection",
"->",
"get",
"(",
"'directives'",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"name",
"=",
"self",
"::",
"getFieldEntryKey",
"(",
"$",
"selection",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"fields",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"fields",
"[",
"$",
"name",
"]",
"=",
"new",
"\\",
"ArrayObject",
"(",
")",
";",
"}",
"$",
"fields",
"[",
"$",
"name",
"]",
"[",
"]",
"=",
"$",
"selection",
";",
"break",
";",
"case",
"Node",
"::",
"KIND_INLINE_FRAGMENT",
":",
"if",
"(",
"!",
"self",
"::",
"shouldIncludeNode",
"(",
"$",
"context",
",",
"$",
"selection",
"->",
"get",
"(",
"'directives'",
")",
")",
"||",
"!",
"self",
"::",
"doesFragmentConditionMatch",
"(",
"$",
"context",
",",
"$",
"selection",
",",
"$",
"type",
")",
")",
"{",
"continue",
";",
"}",
"self",
"::",
"collectFields",
"(",
"$",
"context",
",",
"$",
"type",
",",
"$",
"selection",
"->",
"get",
"(",
"'selectionSet'",
")",
",",
"$",
"fields",
",",
"$",
"visited",
")",
";",
"break",
";",
"case",
"Node",
"::",
"KIND_FRAGMENT_SPREAD",
":",
"$",
"fragName",
"=",
"$",
"selection",
"->",
"get",
"(",
"'name'",
")",
"->",
"get",
"(",
"'value'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"visited",
"[",
"$",
"fragName",
"]",
")",
"||",
"!",
"self",
"::",
"shouldIncludeNode",
"(",
"$",
"context",
",",
"$",
"selection",
"->",
"get",
"(",
"'directives'",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"visited",
"[",
"$",
"fragName",
"]",
"=",
"TRUE",
";",
"$",
"fragment",
"=",
"isset",
"(",
"$",
"context",
"->",
"fragments",
"[",
"$",
"fragName",
"]",
")",
"?",
"$",
"context",
"->",
"fragments",
"[",
"$",
"fragName",
"]",
":",
"NULL",
";",
"if",
"(",
"!",
"$",
"fragment",
"||",
"!",
"self",
"::",
"shouldIncludeNode",
"(",
"$",
"context",
",",
"$",
"fragment",
"->",
"get",
"(",
"'directives'",
")",
")",
"||",
"!",
"self",
"::",
"doesFragmentConditionMatch",
"(",
"$",
"context",
",",
"$",
"fragment",
",",
"$",
"type",
")",
")",
"{",
"continue",
";",
"}",
"self",
"::",
"collectFields",
"(",
"$",
"context",
",",
"$",
"type",
",",
"$",
"fragment",
"->",
"get",
"(",
"'selectionSet'",
")",
",",
"$",
"fields",
",",
"$",
"visited",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"fields",
";",
"}"
]
| Given a selectionSet, adds all of the fields in that selection to
the passed in map of fields, and returns it at the end.
@param ExecutionContext $context
@param ObjectType $type
@param SelectionSet $set
@param $fields
@param $visited
@return \ArrayObject | [
"Given",
"a",
"selectionSet",
"adds",
"all",
"of",
"the",
"fields",
"in",
"that",
"selection",
"to",
"the",
"passed",
"in",
"map",
"of",
"fields",
"and",
"returns",
"it",
"at",
"the",
"end",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L214-L267 |
fubhy/graphql-php | src/Executor/Executor.php | Executor.shouldIncludeNode | protected static function shouldIncludeNode(ExecutionContext $exeContext, $directives)
{
$skip = Directive::skipDirective();
$include = Directive::includeDirective();
foreach ($directives as $directive) {
if ($directive->get('name')->get('value') === $skip->getName()) {
$values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables);
return empty($values['if']);
}
if ($directive->get('name')->get('value') === $include->getName()) {
$values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables);
return !empty($values['if']);
}
}
return TRUE;
} | php | protected static function shouldIncludeNode(ExecutionContext $exeContext, $directives)
{
$skip = Directive::skipDirective();
$include = Directive::includeDirective();
foreach ($directives as $directive) {
if ($directive->get('name')->get('value') === $skip->getName()) {
$values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables);
return empty($values['if']);
}
if ($directive->get('name')->get('value') === $include->getName()) {
$values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables);
return !empty($values['if']);
}
}
return TRUE;
} | [
"protected",
"static",
"function",
"shouldIncludeNode",
"(",
"ExecutionContext",
"$",
"exeContext",
",",
"$",
"directives",
")",
"{",
"$",
"skip",
"=",
"Directive",
"::",
"skipDirective",
"(",
")",
";",
"$",
"include",
"=",
"Directive",
"::",
"includeDirective",
"(",
")",
";",
"foreach",
"(",
"$",
"directives",
"as",
"$",
"directive",
")",
"{",
"if",
"(",
"$",
"directive",
"->",
"get",
"(",
"'name'",
")",
"->",
"get",
"(",
"'value'",
")",
"===",
"$",
"skip",
"->",
"getName",
"(",
")",
")",
"{",
"$",
"values",
"=",
"Values",
"::",
"getArgumentValues",
"(",
"$",
"skip",
"->",
"getArguments",
"(",
")",
",",
"$",
"directive",
"->",
"get",
"(",
"'arguments'",
")",
",",
"$",
"exeContext",
"->",
"variables",
")",
";",
"return",
"empty",
"(",
"$",
"values",
"[",
"'if'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"directive",
"->",
"get",
"(",
"'name'",
")",
"->",
"get",
"(",
"'value'",
")",
"===",
"$",
"include",
"->",
"getName",
"(",
")",
")",
"{",
"$",
"values",
"=",
"Values",
"::",
"getArgumentValues",
"(",
"$",
"skip",
"->",
"getArguments",
"(",
")",
",",
"$",
"directive",
"->",
"get",
"(",
"'arguments'",
")",
",",
"$",
"exeContext",
"->",
"variables",
")",
";",
"return",
"!",
"empty",
"(",
"$",
"values",
"[",
"'if'",
"]",
")",
";",
"}",
"}",
"return",
"TRUE",
";",
"}"
]
| Determines if a field should be included based on @if and @unless directives. | [
"Determines",
"if",
"a",
"field",
"should",
"be",
"included",
"based",
"on"
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L272-L290 |
fubhy/graphql-php | src/Executor/Executor.php | Executor.doesFragmentConditionMatch | protected static function doesFragmentConditionMatch(ExecutionContext $context, $fragment, ObjectType $type)
{
$typeCondition = $fragment->get('typeCondition');
if (!$typeCondition) {
return TRUE;
}
$conditionalType = TypeInfo::typeFromAST($context->schema, $typeCondition);
if ($conditionalType->getName() === $type->getName()) {
return TRUE;
}
if ($conditionalType instanceof InterfaceType || $conditionalType instanceof UnionType) {
return $conditionalType->isPossibleType($type);
}
return FALSE;
} | php | protected static function doesFragmentConditionMatch(ExecutionContext $context, $fragment, ObjectType $type)
{
$typeCondition = $fragment->get('typeCondition');
if (!$typeCondition) {
return TRUE;
}
$conditionalType = TypeInfo::typeFromAST($context->schema, $typeCondition);
if ($conditionalType->getName() === $type->getName()) {
return TRUE;
}
if ($conditionalType instanceof InterfaceType || $conditionalType instanceof UnionType) {
return $conditionalType->isPossibleType($type);
}
return FALSE;
} | [
"protected",
"static",
"function",
"doesFragmentConditionMatch",
"(",
"ExecutionContext",
"$",
"context",
",",
"$",
"fragment",
",",
"ObjectType",
"$",
"type",
")",
"{",
"$",
"typeCondition",
"=",
"$",
"fragment",
"->",
"get",
"(",
"'typeCondition'",
")",
";",
"if",
"(",
"!",
"$",
"typeCondition",
")",
"{",
"return",
"TRUE",
";",
"}",
"$",
"conditionalType",
"=",
"TypeInfo",
"::",
"typeFromAST",
"(",
"$",
"context",
"->",
"schema",
",",
"$",
"typeCondition",
")",
";",
"if",
"(",
"$",
"conditionalType",
"->",
"getName",
"(",
")",
"===",
"$",
"type",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"TRUE",
";",
"}",
"if",
"(",
"$",
"conditionalType",
"instanceof",
"InterfaceType",
"||",
"$",
"conditionalType",
"instanceof",
"UnionType",
")",
"{",
"return",
"$",
"conditionalType",
"->",
"isPossibleType",
"(",
"$",
"type",
")",
";",
"}",
"return",
"FALSE",
";",
"}"
]
| Determines if a fragment is applicable to the given type.
@param ExecutionContext $context
@param $fragment
@param ObjectType $type
@return bool | [
"Determines",
"if",
"a",
"fragment",
"is",
"applicable",
"to",
"the",
"given",
"type",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L301-L318 |
fubhy/graphql-php | src/Executor/Executor.php | Executor.getFieldEntryKey | protected static function getFieldEntryKey(Field $node)
{
return $node->get('alias') ? $node->get('alias')->get('value') : $node->get('name')->get('value');
} | php | protected static function getFieldEntryKey(Field $node)
{
return $node->get('alias') ? $node->get('alias')->get('value') : $node->get('name')->get('value');
} | [
"protected",
"static",
"function",
"getFieldEntryKey",
"(",
"Field",
"$",
"node",
")",
"{",
"return",
"$",
"node",
"->",
"get",
"(",
"'alias'",
")",
"?",
"$",
"node",
"->",
"get",
"(",
"'alias'",
")",
"->",
"get",
"(",
"'value'",
")",
":",
"$",
"node",
"->",
"get",
"(",
"'name'",
")",
"->",
"get",
"(",
"'value'",
")",
";",
"}"
]
| Implements the logic to compute the key of a given field's entry
@param Field $node
@return string | [
"Implements",
"the",
"logic",
"to",
"compute",
"the",
"key",
"of",
"a",
"given",
"field",
"s",
"entry"
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L327-L330 |
fubhy/graphql-php | src/Executor/Executor.php | Executor.resolveField | protected static function resolveField(ExecutionContext $context, ObjectType $parent, $source, $asts)
{
$definition = self::getFieldDefinition($context->schema, $parent, $asts[0]);
if (!$definition) {
return self::$UNDEFINED;
}
// If the field type is non-nullable, then it is resolved without any
// protection from errors.
if ($definition->getType() instanceof NonNullModifier) {
return self::resolveFieldOrError($context, $parent, $source, $asts, $definition);
}
// Otherwise, error protection is applied, logging the error and
// resolving a null value for this field if one is encountered.
try {
$result = self::resolveFieldOrError($context, $parent, $source, $asts, $definition);
return $result;
} catch (\Exception $error) {
$context->errors[] = $error;
return NULL;
}
} | php | protected static function resolveField(ExecutionContext $context, ObjectType $parent, $source, $asts)
{
$definition = self::getFieldDefinition($context->schema, $parent, $asts[0]);
if (!$definition) {
return self::$UNDEFINED;
}
// If the field type is non-nullable, then it is resolved without any
// protection from errors.
if ($definition->getType() instanceof NonNullModifier) {
return self::resolveFieldOrError($context, $parent, $source, $asts, $definition);
}
// Otherwise, error protection is applied, logging the error and
// resolving a null value for this field if one is encountered.
try {
$result = self::resolveFieldOrError($context, $parent, $source, $asts, $definition);
return $result;
} catch (\Exception $error) {
$context->errors[] = $error;
return NULL;
}
} | [
"protected",
"static",
"function",
"resolveField",
"(",
"ExecutionContext",
"$",
"context",
",",
"ObjectType",
"$",
"parent",
",",
"$",
"source",
",",
"$",
"asts",
")",
"{",
"$",
"definition",
"=",
"self",
"::",
"getFieldDefinition",
"(",
"$",
"context",
"->",
"schema",
",",
"$",
"parent",
",",
"$",
"asts",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"$",
"definition",
")",
"{",
"return",
"self",
"::",
"$",
"UNDEFINED",
";",
"}",
"// If the field type is non-nullable, then it is resolved without any",
"// protection from errors.",
"if",
"(",
"$",
"definition",
"->",
"getType",
"(",
")",
"instanceof",
"NonNullModifier",
")",
"{",
"return",
"self",
"::",
"resolveFieldOrError",
"(",
"$",
"context",
",",
"$",
"parent",
",",
"$",
"source",
",",
"$",
"asts",
",",
"$",
"definition",
")",
";",
"}",
"// Otherwise, error protection is applied, logging the error and",
"// resolving a null value for this field if one is encountered.",
"try",
"{",
"$",
"result",
"=",
"self",
"::",
"resolveFieldOrError",
"(",
"$",
"context",
",",
"$",
"parent",
",",
"$",
"source",
",",
"$",
"asts",
",",
"$",
"definition",
")",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"error",
")",
"{",
"$",
"context",
"->",
"errors",
"[",
"]",
"=",
"$",
"error",
";",
"return",
"NULL",
";",
"}",
"}"
]
| A wrapper function for resolving the field, that catches the error
and adds it to the context's global if the error is not rethrowable.
@param ExecutionContext $context
@param ObjectType $parent
@param $source
@param $asts
@return array|mixed|null|string
@throws \Exception | [
"A",
"wrapper",
"function",
"for",
"resolving",
"the",
"field",
"that",
"catches",
"the",
"error",
"and",
"adds",
"it",
"to",
"the",
"context",
"s",
"global",
"if",
"the",
"error",
"is",
"not",
"rethrowable",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L345-L367 |
fubhy/graphql-php | src/Executor/Executor.php | Executor.resolveFieldOrError | protected static function resolveFieldOrError(ExecutionContext $context, ObjectType $parent, $source, $asts, FieldDefinition $definition)
{
$ast = $asts[0];
$type = $definition->getType();
$resolver = $definition->getResolveCallback() ?: [__CLASS__, 'defaultResolveFn'];
$data = $definition->getResolveData();
$args = Values::getArgumentValues($definition->getArguments(), $ast->get('arguments'), $context->variables);
try {
// @todo Change the resolver function syntax to use a value object.
$result = call_user_func($resolver, $source, $args, $context->root, $ast, $type, $parent, $context->schema, $data);
} catch (\Exception $error) {
throw $error;
}
return self::completeField($context, $type, $asts, $result);
} | php | protected static function resolveFieldOrError(ExecutionContext $context, ObjectType $parent, $source, $asts, FieldDefinition $definition)
{
$ast = $asts[0];
$type = $definition->getType();
$resolver = $definition->getResolveCallback() ?: [__CLASS__, 'defaultResolveFn'];
$data = $definition->getResolveData();
$args = Values::getArgumentValues($definition->getArguments(), $ast->get('arguments'), $context->variables);
try {
// @todo Change the resolver function syntax to use a value object.
$result = call_user_func($resolver, $source, $args, $context->root, $ast, $type, $parent, $context->schema, $data);
} catch (\Exception $error) {
throw $error;
}
return self::completeField($context, $type, $asts, $result);
} | [
"protected",
"static",
"function",
"resolveFieldOrError",
"(",
"ExecutionContext",
"$",
"context",
",",
"ObjectType",
"$",
"parent",
",",
"$",
"source",
",",
"$",
"asts",
",",
"FieldDefinition",
"$",
"definition",
")",
"{",
"$",
"ast",
"=",
"$",
"asts",
"[",
"0",
"]",
";",
"$",
"type",
"=",
"$",
"definition",
"->",
"getType",
"(",
")",
";",
"$",
"resolver",
"=",
"$",
"definition",
"->",
"getResolveCallback",
"(",
")",
"?",
":",
"[",
"__CLASS__",
",",
"'defaultResolveFn'",
"]",
";",
"$",
"data",
"=",
"$",
"definition",
"->",
"getResolveData",
"(",
")",
";",
"$",
"args",
"=",
"Values",
"::",
"getArgumentValues",
"(",
"$",
"definition",
"->",
"getArguments",
"(",
")",
",",
"$",
"ast",
"->",
"get",
"(",
"'arguments'",
")",
",",
"$",
"context",
"->",
"variables",
")",
";",
"try",
"{",
"// @todo Change the resolver function syntax to use a value object.",
"$",
"result",
"=",
"call_user_func",
"(",
"$",
"resolver",
",",
"$",
"source",
",",
"$",
"args",
",",
"$",
"context",
"->",
"root",
",",
"$",
"ast",
",",
"$",
"type",
",",
"$",
"parent",
",",
"$",
"context",
"->",
"schema",
",",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"error",
")",
"{",
"throw",
"$",
"error",
";",
"}",
"return",
"self",
"::",
"completeField",
"(",
"$",
"context",
",",
"$",
"type",
",",
"$",
"asts",
",",
"$",
"result",
")",
";",
"}"
]
| Resolves the field on the given source object.
In particular, this figures out the object that the field returns using
the resolve function, then calls completeField to coerce scalars or
execute the sub selection set for objects.
@param ExecutionContext $context
@param ObjectType $parent
@param $source
@param $asts
@param FieldDefinition $definition
@return array|mixed|null|string
@throws \Exception | [
"Resolves",
"the",
"field",
"on",
"the",
"given",
"source",
"object",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L386-L402 |
fubhy/graphql-php | src/Executor/Executor.php | Executor.completeField | protected static function completeField(ExecutionContext $context, TypeInterface $type, $asts, &$result)
{
// If field type is NonNullModifier, complete for inner type, and throw field error
// if result is null.
if ($type instanceof NonNullModifier) {
$completed = self::completeField($context, $type->getWrappedType(), $asts, $result);
if ($completed === NULL) {
throw new \Exception('Cannot return null for non-nullable type.');
}
return $completed;
}
// If result is null-like, return null.
if (!isset($result)) {
return NULL;
}
// If field type is List, complete each item in the list with the inner type
if ($type instanceof ListModifier) {
$itemType = $type->getWrappedType();
if (!(is_array($result) || $result instanceof \ArrayObject)) {
throw new \Exception('User Error: expected iterable, but did not find one.');
}
$tmp = [];
foreach ($result as $item) {
$tmp[] = self::completeField($context, $itemType, $asts, $item);
}
return $tmp;
}
// If field type is Scalar or Enum, coerce to a valid value, returning
// null if coercion is not possible.
if ($type instanceof ScalarType || $type instanceof EnumType) {
if (!method_exists($type, 'coerce')) {
throw new \Exception('Missing coerce method on type.');
}
return $type->coerce($result);
}
// Field type must be Object, Interface or Union and expect
// sub-selections.
$objectType = $type instanceof ObjectType ? $type : ($type instanceof InterfaceType || $type instanceof UnionType ? $type->resolveType($result) : NULL);
if (!$objectType) {
return NULL;
}
// Collect sub-fields to execute to complete this value.
$subFieldASTs = new \ArrayObject();
$visitedFragmentNames = new \ArrayObject();
$count = count($asts);
for ($i = 0; $i < $count; $i++) {
$selectionSet = $asts[$i]->get('selectionSet');
if ($selectionSet) {
$subFieldASTs = self::collectFields($context, $objectType, $selectionSet, $subFieldASTs, $visitedFragmentNames);
}
}
return self::executeFields($context, $objectType, $result, $subFieldASTs);
} | php | protected static function completeField(ExecutionContext $context, TypeInterface $type, $asts, &$result)
{
// If field type is NonNullModifier, complete for inner type, and throw field error
// if result is null.
if ($type instanceof NonNullModifier) {
$completed = self::completeField($context, $type->getWrappedType(), $asts, $result);
if ($completed === NULL) {
throw new \Exception('Cannot return null for non-nullable type.');
}
return $completed;
}
// If result is null-like, return null.
if (!isset($result)) {
return NULL;
}
// If field type is List, complete each item in the list with the inner type
if ($type instanceof ListModifier) {
$itemType = $type->getWrappedType();
if (!(is_array($result) || $result instanceof \ArrayObject)) {
throw new \Exception('User Error: expected iterable, but did not find one.');
}
$tmp = [];
foreach ($result as $item) {
$tmp[] = self::completeField($context, $itemType, $asts, $item);
}
return $tmp;
}
// If field type is Scalar or Enum, coerce to a valid value, returning
// null if coercion is not possible.
if ($type instanceof ScalarType || $type instanceof EnumType) {
if (!method_exists($type, 'coerce')) {
throw new \Exception('Missing coerce method on type.');
}
return $type->coerce($result);
}
// Field type must be Object, Interface or Union and expect
// sub-selections.
$objectType = $type instanceof ObjectType ? $type : ($type instanceof InterfaceType || $type instanceof UnionType ? $type->resolveType($result) : NULL);
if (!$objectType) {
return NULL;
}
// Collect sub-fields to execute to complete this value.
$subFieldASTs = new \ArrayObject();
$visitedFragmentNames = new \ArrayObject();
$count = count($asts);
for ($i = 0; $i < $count; $i++) {
$selectionSet = $asts[$i]->get('selectionSet');
if ($selectionSet) {
$subFieldASTs = self::collectFields($context, $objectType, $selectionSet, $subFieldASTs, $visitedFragmentNames);
}
}
return self::executeFields($context, $objectType, $result, $subFieldASTs);
} | [
"protected",
"static",
"function",
"completeField",
"(",
"ExecutionContext",
"$",
"context",
",",
"TypeInterface",
"$",
"type",
",",
"$",
"asts",
",",
"&",
"$",
"result",
")",
"{",
"// If field type is NonNullModifier, complete for inner type, and throw field error",
"// if result is null.",
"if",
"(",
"$",
"type",
"instanceof",
"NonNullModifier",
")",
"{",
"$",
"completed",
"=",
"self",
"::",
"completeField",
"(",
"$",
"context",
",",
"$",
"type",
"->",
"getWrappedType",
"(",
")",
",",
"$",
"asts",
",",
"$",
"result",
")",
";",
"if",
"(",
"$",
"completed",
"===",
"NULL",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cannot return null for non-nullable type.'",
")",
";",
"}",
"return",
"$",
"completed",
";",
"}",
"// If result is null-like, return null.",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"// If field type is List, complete each item in the list with the inner type",
"if",
"(",
"$",
"type",
"instanceof",
"ListModifier",
")",
"{",
"$",
"itemType",
"=",
"$",
"type",
"->",
"getWrappedType",
"(",
")",
";",
"if",
"(",
"!",
"(",
"is_array",
"(",
"$",
"result",
")",
"||",
"$",
"result",
"instanceof",
"\\",
"ArrayObject",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'User Error: expected iterable, but did not find one.'",
")",
";",
"}",
"$",
"tmp",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"item",
")",
"{",
"$",
"tmp",
"[",
"]",
"=",
"self",
"::",
"completeField",
"(",
"$",
"context",
",",
"$",
"itemType",
",",
"$",
"asts",
",",
"$",
"item",
")",
";",
"}",
"return",
"$",
"tmp",
";",
"}",
"// If field type is Scalar or Enum, coerce to a valid value, returning",
"// null if coercion is not possible.",
"if",
"(",
"$",
"type",
"instanceof",
"ScalarType",
"||",
"$",
"type",
"instanceof",
"EnumType",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"type",
",",
"'coerce'",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Missing coerce method on type.'",
")",
";",
"}",
"return",
"$",
"type",
"->",
"coerce",
"(",
"$",
"result",
")",
";",
"}",
"// Field type must be Object, Interface or Union and expect",
"// sub-selections.",
"$",
"objectType",
"=",
"$",
"type",
"instanceof",
"ObjectType",
"?",
"$",
"type",
":",
"(",
"$",
"type",
"instanceof",
"InterfaceType",
"||",
"$",
"type",
"instanceof",
"UnionType",
"?",
"$",
"type",
"->",
"resolveType",
"(",
"$",
"result",
")",
":",
"NULL",
")",
";",
"if",
"(",
"!",
"$",
"objectType",
")",
"{",
"return",
"NULL",
";",
"}",
"// Collect sub-fields to execute to complete this value.",
"$",
"subFieldASTs",
"=",
"new",
"\\",
"ArrayObject",
"(",
")",
";",
"$",
"visitedFragmentNames",
"=",
"new",
"\\",
"ArrayObject",
"(",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"asts",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"selectionSet",
"=",
"$",
"asts",
"[",
"$",
"i",
"]",
"->",
"get",
"(",
"'selectionSet'",
")",
";",
"if",
"(",
"$",
"selectionSet",
")",
"{",
"$",
"subFieldASTs",
"=",
"self",
"::",
"collectFields",
"(",
"$",
"context",
",",
"$",
"objectType",
",",
"$",
"selectionSet",
",",
"$",
"subFieldASTs",
",",
"$",
"visitedFragmentNames",
")",
";",
"}",
"}",
"return",
"self",
"::",
"executeFields",
"(",
"$",
"context",
",",
"$",
"objectType",
",",
"$",
"result",
",",
"$",
"subFieldASTs",
")",
";",
"}"
]
| Implements the instructions for completeValue as defined in the
"Field entries" section of the spec.
If the field type is Non-Null, then this recursively completes the value
for the inner type. It throws a field error if that completion returns null,
as per the "Nullability" section of the spec.
If the field type is a List, then this recursively completes the value
for the inner type on each item in the list.
If the field type is a Scalar or Enum, ensures the completed value is a legal
value of the type by calling the `coerce` method of GraphQL type definition.
Otherwise, the field type expects a sub-selection set, and will complete the
value by evaluating all sub-selections.
@param ExecutionContext $context
@param TypeInterface $type
@param $asts
@param $result
@return array|mixed|null|string
@throws \Exception | [
"Implements",
"the",
"instructions",
"for",
"completeValue",
"as",
"defined",
"in",
"the",
"Field",
"entries",
"section",
"of",
"the",
"spec",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L430-L496 |
fubhy/graphql-php | src/Executor/Executor.php | Executor.defaultResolveFn | public static function defaultResolveFn($source, $args, $root, $ast)
{
$property = NULL;
$key = $ast->get('name')->get('value');
if ((is_array($source) || $source instanceof \ArrayAccess) && isset($source[$key])) {
$property = $source[$key];
}
else if (is_object($source) && property_exists($source, $key)) {
if ($key !== 'ofType') {
$property = $source->{$key};
}
}
return is_callable($property) ? call_user_func($property, $source) : $property;
} | php | public static function defaultResolveFn($source, $args, $root, $ast)
{
$property = NULL;
$key = $ast->get('name')->get('value');
if ((is_array($source) || $source instanceof \ArrayAccess) && isset($source[$key])) {
$property = $source[$key];
}
else if (is_object($source) && property_exists($source, $key)) {
if ($key !== 'ofType') {
$property = $source->{$key};
}
}
return is_callable($property) ? call_user_func($property, $source) : $property;
} | [
"public",
"static",
"function",
"defaultResolveFn",
"(",
"$",
"source",
",",
"$",
"args",
",",
"$",
"root",
",",
"$",
"ast",
")",
"{",
"$",
"property",
"=",
"NULL",
";",
"$",
"key",
"=",
"$",
"ast",
"->",
"get",
"(",
"'name'",
")",
"->",
"get",
"(",
"'value'",
")",
";",
"if",
"(",
"(",
"is_array",
"(",
"$",
"source",
")",
"||",
"$",
"source",
"instanceof",
"\\",
"ArrayAccess",
")",
"&&",
"isset",
"(",
"$",
"source",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"property",
"=",
"$",
"source",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"if",
"(",
"is_object",
"(",
"$",
"source",
")",
"&&",
"property_exists",
"(",
"$",
"source",
",",
"$",
"key",
")",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"'ofType'",
")",
"{",
"$",
"property",
"=",
"$",
"source",
"->",
"{",
"$",
"key",
"}",
";",
"}",
"}",
"return",
"is_callable",
"(",
"$",
"property",
")",
"?",
"call_user_func",
"(",
"$",
"property",
",",
"$",
"source",
")",
":",
"$",
"property",
";",
"}"
]
| If a resolve function is not given, then a default resolve behavior is used
which takes the property of the source object of the same name as the field
and returns it as the result, or if it's a function, returns the result
of calling that function.
@param $source
@param $args
@param $root
@param $ast
@return mixed|null | [
"If",
"a",
"resolve",
"function",
"is",
"not",
"given",
"then",
"a",
"default",
"resolve",
"behavior",
"is",
"used",
"which",
"takes",
"the",
"property",
"of",
"the",
"source",
"object",
"of",
"the",
"same",
"name",
"as",
"the",
"field",
"and",
"returns",
"it",
"as",
"the",
"result",
"or",
"if",
"it",
"s",
"a",
"function",
"returns",
"the",
"result",
"of",
"calling",
"that",
"function",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L511-L526 |
fubhy/graphql-php | src/Executor/Executor.php | Executor.getFieldDefinition | protected static function getFieldDefinition(Schema $schema, ObjectType $parent, Field $ast)
{
$name = $ast->get('name')->get('value');
$schemaMeta = Introspection::schemaMetaFieldDefinition();
$typeMeta = Introspection::typeMetaFieldDefinition();
$typeNameMeta = Introspection::typeNameMetaFieldDefinition();
if ($name === $schemaMeta->getName() && $schema->getQueryType() === $parent) {
return $schemaMeta;
} else if ($name === $typeMeta->getName() && $schema->getQueryType() === $parent) {
return $typeMeta;
} else if ($name === $typeNameMeta->getName()) {
return $typeNameMeta;
}
$tmp = $parent->getFields();
return isset($tmp[$name]) ? $tmp[$name] : NULL;
} | php | protected static function getFieldDefinition(Schema $schema, ObjectType $parent, Field $ast)
{
$name = $ast->get('name')->get('value');
$schemaMeta = Introspection::schemaMetaFieldDefinition();
$typeMeta = Introspection::typeMetaFieldDefinition();
$typeNameMeta = Introspection::typeNameMetaFieldDefinition();
if ($name === $schemaMeta->getName() && $schema->getQueryType() === $parent) {
return $schemaMeta;
} else if ($name === $typeMeta->getName() && $schema->getQueryType() === $parent) {
return $typeMeta;
} else if ($name === $typeNameMeta->getName()) {
return $typeNameMeta;
}
$tmp = $parent->getFields();
return isset($tmp[$name]) ? $tmp[$name] : NULL;
} | [
"protected",
"static",
"function",
"getFieldDefinition",
"(",
"Schema",
"$",
"schema",
",",
"ObjectType",
"$",
"parent",
",",
"Field",
"$",
"ast",
")",
"{",
"$",
"name",
"=",
"$",
"ast",
"->",
"get",
"(",
"'name'",
")",
"->",
"get",
"(",
"'value'",
")",
";",
"$",
"schemaMeta",
"=",
"Introspection",
"::",
"schemaMetaFieldDefinition",
"(",
")",
";",
"$",
"typeMeta",
"=",
"Introspection",
"::",
"typeMetaFieldDefinition",
"(",
")",
";",
"$",
"typeNameMeta",
"=",
"Introspection",
"::",
"typeNameMetaFieldDefinition",
"(",
")",
";",
"if",
"(",
"$",
"name",
"===",
"$",
"schemaMeta",
"->",
"getName",
"(",
")",
"&&",
"$",
"schema",
"->",
"getQueryType",
"(",
")",
"===",
"$",
"parent",
")",
"{",
"return",
"$",
"schemaMeta",
";",
"}",
"else",
"if",
"(",
"$",
"name",
"===",
"$",
"typeMeta",
"->",
"getName",
"(",
")",
"&&",
"$",
"schema",
"->",
"getQueryType",
"(",
")",
"===",
"$",
"parent",
")",
"{",
"return",
"$",
"typeMeta",
";",
"}",
"else",
"if",
"(",
"$",
"name",
"===",
"$",
"typeNameMeta",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"$",
"typeNameMeta",
";",
"}",
"$",
"tmp",
"=",
"$",
"parent",
"->",
"getFields",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"tmp",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"tmp",
"[",
"$",
"name",
"]",
":",
"NULL",
";",
"}"
]
| This method looks up the field on the given type defintion.
It has special casing for the two introspection fields, __schema
and __typename. __typename is special because it can always be
queried as a field, even in situations where no other fields
are allowed, like on a Union. __schema could get automatically
added to the query type, but that would require mutating type
definitions, which would cause issues.
@param Schema $schema
@param ObjectType $parent
@param Field $ast
@return FieldDefinition | [
"This",
"method",
"looks",
"up",
"the",
"field",
"on",
"the",
"given",
"type",
"defintion",
".",
"It",
"has",
"special",
"casing",
"for",
"the",
"two",
"introspection",
"fields",
"__schema",
"and",
"__typename",
".",
"__typename",
"is",
"special",
"because",
"it",
"can",
"always",
"be",
"queried",
"as",
"a",
"field",
"even",
"in",
"situations",
"where",
"no",
"other",
"fields",
"are",
"allowed",
"like",
"on",
"a",
"Union",
".",
"__schema",
"could",
"get",
"automatically",
"added",
"to",
"the",
"query",
"type",
"but",
"that",
"would",
"require",
"mutating",
"type",
"definitions",
"which",
"would",
"cause",
"issues",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L543-L560 |
jinexus-framework/jinexus-mvc | src/View/AbstractView.php | AbstractView.basePath | public function basePath($file = '')
{
$basePath = dirname($_SERVER['PHP_SELF']);
if ($basePath != '/') {
$basePath .= '/';
}
if (! empty($file)) {
$basePath.= ltrim($file, '/');
}
return $basePath;
} | php | public function basePath($file = '')
{
$basePath = dirname($_SERVER['PHP_SELF']);
if ($basePath != '/') {
$basePath .= '/';
}
if (! empty($file)) {
$basePath.= ltrim($file, '/');
}
return $basePath;
} | [
"public",
"function",
"basePath",
"(",
"$",
"file",
"=",
"''",
")",
"{",
"$",
"basePath",
"=",
"dirname",
"(",
"$",
"_SERVER",
"[",
"'PHP_SELF'",
"]",
")",
";",
"if",
"(",
"$",
"basePath",
"!=",
"'/'",
")",
"{",
"$",
"basePath",
".=",
"'/'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"$",
"basePath",
".=",
"ltrim",
"(",
"$",
"file",
",",
"'/'",
")",
";",
"}",
"return",
"$",
"basePath",
";",
"}"
]
| Base Path
@param string $file
@return string | [
"Base",
"Path"
]
| train | https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L89-L101 |
jinexus-framework/jinexus-mvc | src/View/AbstractView.php | AbstractView.baseUrl | public function baseUrl($uri = '')
{
return sprintf(
"%s://%s%s%s%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$_SERVER['SERVER_NAME'],
($_SERVER['SERVER_PORT'] == 80) ?: ':' . $_SERVER['SERVER_PORT'],
$_SERVER['REQUEST_URI'],
ltrim($uri, '/')
);
} | php | public function baseUrl($uri = '')
{
return sprintf(
"%s://%s%s%s%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$_SERVER['SERVER_NAME'],
($_SERVER['SERVER_PORT'] == 80) ?: ':' . $_SERVER['SERVER_PORT'],
$_SERVER['REQUEST_URI'],
ltrim($uri, '/')
);
} | [
"public",
"function",
"baseUrl",
"(",
"$",
"uri",
"=",
"''",
")",
"{",
"return",
"sprintf",
"(",
"\"%s://%s%s%s%s\"",
",",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
"!=",
"'off'",
"?",
"'https'",
":",
"'http'",
",",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
",",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
"==",
"80",
")",
"?",
":",
"':'",
".",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
",",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"ltrim",
"(",
"$",
"uri",
",",
"'/'",
")",
")",
";",
"}"
]
| Base URL
@param string $uri
@return string | [
"Base",
"URL"
]
| train | https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L109-L119 |
jinexus-framework/jinexus-mvc | src/View/AbstractView.php | AbstractView.content | public function content()
{
if ($this->app->getMatchRoute()) {
$actionName = strtolower(preg_replace('/(?<=\d)(?=[A-Za-z])|(?<=[A-Za-z])(?=\d)|(?<=[a-z])(?=[A-Z])/', '-', $this->app->getActionName()));
$fileArray = [
strtolower($this->app->getModuleName()),
str_replace('controller', '', strtolower($this->app->getControllerName())),
$actionName . '.phtml'
];
$file = implode('/', $fileArray);
} else {
$viewManager = $this->config->get('view_manager');
$file = $viewManager['template_map']['error/404'];
}
$this->render($file);
} | php | public function content()
{
if ($this->app->getMatchRoute()) {
$actionName = strtolower(preg_replace('/(?<=\d)(?=[A-Za-z])|(?<=[A-Za-z])(?=\d)|(?<=[a-z])(?=[A-Z])/', '-', $this->app->getActionName()));
$fileArray = [
strtolower($this->app->getModuleName()),
str_replace('controller', '', strtolower($this->app->getControllerName())),
$actionName . '.phtml'
];
$file = implode('/', $fileArray);
} else {
$viewManager = $this->config->get('view_manager');
$file = $viewManager['template_map']['error/404'];
}
$this->render($file);
} | [
"public",
"function",
"content",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"getMatchRoute",
"(",
")",
")",
"{",
"$",
"actionName",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"'/(?<=\\d)(?=[A-Za-z])|(?<=[A-Za-z])(?=\\d)|(?<=[a-z])(?=[A-Z])/'",
",",
"'-'",
",",
"$",
"this",
"->",
"app",
"->",
"getActionName",
"(",
")",
")",
")",
";",
"$",
"fileArray",
"=",
"[",
"strtolower",
"(",
"$",
"this",
"->",
"app",
"->",
"getModuleName",
"(",
")",
")",
",",
"str_replace",
"(",
"'controller'",
",",
"''",
",",
"strtolower",
"(",
"$",
"this",
"->",
"app",
"->",
"getControllerName",
"(",
")",
")",
")",
",",
"$",
"actionName",
".",
"'.phtml'",
"]",
";",
"$",
"file",
"=",
"implode",
"(",
"'/'",
",",
"$",
"fileArray",
")",
";",
"}",
"else",
"{",
"$",
"viewManager",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'view_manager'",
")",
";",
"$",
"file",
"=",
"$",
"viewManager",
"[",
"'template_map'",
"]",
"[",
"'error/404'",
"]",
";",
"}",
"$",
"this",
"->",
"render",
"(",
"$",
"file",
")",
";",
"}"
]
| Render content
@throws Exception | [
"Render",
"content"
]
| train | https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L126-L144 |
jinexus-framework/jinexus-mvc | src/View/AbstractView.php | AbstractView.htmlEncode | public function htmlEncode($data)
{
switch (gettype($data)) {
case 'array':
foreach ($data as $key => $value) {
$data[$key] = $this->htmlEncode($value);
}
break;
case 'object':
$data = clone $data;
foreach ($data as $key => $value) {
$data->$key = $this->htmlEncode($value);
}
break;
case 'string':
default:
$data = htmlentities($data, ENT_QUOTES, 'UTF-8');
break;
}
return $data;
} | php | public function htmlEncode($data)
{
switch (gettype($data)) {
case 'array':
foreach ($data as $key => $value) {
$data[$key] = $this->htmlEncode($value);
}
break;
case 'object':
$data = clone $data;
foreach ($data as $key => $value) {
$data->$key = $this->htmlEncode($value);
}
break;
case 'string':
default:
$data = htmlentities($data, ENT_QUOTES, 'UTF-8');
break;
}
return $data;
} | [
"public",
"function",
"htmlEncode",
"(",
"$",
"data",
")",
"{",
"switch",
"(",
"gettype",
"(",
"$",
"data",
")",
")",
"{",
"case",
"'array'",
":",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"htmlEncode",
"(",
"$",
"value",
")",
";",
"}",
"break",
";",
"case",
"'object'",
":",
"$",
"data",
"=",
"clone",
"$",
"data",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"->",
"$",
"key",
"=",
"$",
"this",
"->",
"htmlEncode",
"(",
"$",
"value",
")",
";",
"}",
"break",
";",
"case",
"'string'",
":",
"default",
":",
"$",
"data",
"=",
"htmlentities",
"(",
"$",
"data",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
")",
";",
"break",
";",
"}",
"return",
"$",
"data",
";",
"}"
]
| Recursively make a value safe for HTML
@param mixed $data
@return mixed | [
"Recursively",
"make",
"a",
"value",
"safe",
"for",
"HTML"
]
| train | https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L152-L177 |
jinexus-framework/jinexus-mvc | src/View/AbstractView.php | AbstractView.htmlDecode | public function htmlDecode($data)
{
switch (gettype($data)) {
case 'array':
foreach ($data as $key => $value) {
$data[$key] = $this->htmlDecode($value);
}
break;
case 'object':
$data = clone $data;
foreach ($data as $key => $value) {
$data->$key = $this->htmlDecode($value);
}
break;
case 'string':
default:
$data = html_entity_decode($data, ENT_QUOTES, 'UTF-8');
break;
}
return $data;
} | php | public function htmlDecode($data)
{
switch (gettype($data)) {
case 'array':
foreach ($data as $key => $value) {
$data[$key] = $this->htmlDecode($value);
}
break;
case 'object':
$data = clone $data;
foreach ($data as $key => $value) {
$data->$key = $this->htmlDecode($value);
}
break;
case 'string':
default:
$data = html_entity_decode($data, ENT_QUOTES, 'UTF-8');
break;
}
return $data;
} | [
"public",
"function",
"htmlDecode",
"(",
"$",
"data",
")",
"{",
"switch",
"(",
"gettype",
"(",
"$",
"data",
")",
")",
"{",
"case",
"'array'",
":",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"htmlDecode",
"(",
"$",
"value",
")",
";",
"}",
"break",
";",
"case",
"'object'",
":",
"$",
"data",
"=",
"clone",
"$",
"data",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"->",
"$",
"key",
"=",
"$",
"this",
"->",
"htmlDecode",
"(",
"$",
"value",
")",
";",
"}",
"break",
";",
"case",
"'string'",
":",
"default",
":",
"$",
"data",
"=",
"html_entity_decode",
"(",
"$",
"data",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
")",
";",
"break",
";",
"}",
"return",
"$",
"data",
";",
"}"
]
| Recursively decode an HTML encoded value
@param mixed $data
@return mixed | [
"Recursively",
"decode",
"an",
"HTML",
"encoded",
"value"
]
| train | https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L185-L210 |
jinexus-framework/jinexus-mvc | src/View/AbstractView.php | AbstractView.get | public function get($variable, $htmlEncode = true)
{
$value = null;
if ( isset($this->variables[$variable]) ) {
$value = $this->variables[$variable][$htmlEncode ? 'safe' : 'unsafe'];
}
return $value;
} | php | public function get($variable, $htmlEncode = true)
{
$value = null;
if ( isset($this->variables[$variable]) ) {
$value = $this->variables[$variable][$htmlEncode ? 'safe' : 'unsafe'];
}
return $value;
} | [
"public",
"function",
"get",
"(",
"$",
"variable",
",",
"$",
"htmlEncode",
"=",
"true",
")",
"{",
"$",
"value",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"variables",
"[",
"$",
"variable",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"variables",
"[",
"$",
"variable",
"]",
"[",
"$",
"htmlEncode",
"?",
"'safe'",
":",
"'unsafe'",
"]",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Get a view variable
@param string $variable
@param bool $htmlEncode
@return mixed|null | [
"Get",
"a",
"view",
"variable"
]
| train | https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L219-L228 |
jinexus-framework/jinexus-mvc | src/View/AbstractView.php | AbstractView.set | public function set($variable, $value = null)
{
$this->variables[$variable] = array(
'safe' => $this->htmlEncode($value),
'unsafe' => $value
);
return $this;
} | php | public function set($variable, $value = null)
{
$this->variables[$variable] = array(
'safe' => $this->htmlEncode($value),
'unsafe' => $value
);
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"variable",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"variables",
"[",
"$",
"variable",
"]",
"=",
"array",
"(",
"'safe'",
"=>",
"$",
"this",
"->",
"htmlEncode",
"(",
"$",
"value",
")",
",",
"'unsafe'",
"=>",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set a view variable
@param string $variable
@param mixed $value
@return \JiNexus\Mvc\View\ViewInterface | [
"Set",
"a",
"view",
"variable"
]
| train | https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L247-L255 |
jinexus-framework/jinexus-mvc | src/View/AbstractView.php | AbstractView.setVariables | public function setVariables($variables = [])
{
foreach ($variables as $variable => $value) {
$this->set($variable, $value);
}
} | php | public function setVariables($variables = [])
{
foreach ($variables as $variable => $value) {
$this->set($variable, $value);
}
} | [
"public",
"function",
"setVariables",
"(",
"$",
"variables",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"variables",
"as",
"$",
"variable",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"variable",
",",
"$",
"value",
")",
";",
"}",
"}"
]
| Set all variables
@param array $variables | [
"Set",
"all",
"variables"
]
| train | https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L262-L267 |
jinexus-framework/jinexus-mvc | src/View/AbstractView.php | AbstractView.render | public function render($file = '')
{
$viewManager = $this->config->get('view_manager');
if ($viewManager['template_path_stack']) {
$file = $viewManager['template_path_stack'] . '/' . $file;
}
$fileInfo = pathinfo($file);
if (! isset($fileInfo['extension']) || $fileInfo['extension'] != 'phtml') {
$file = $file . '.phtml';
}
if (is_file($file)) {
if (! headers_sent()) {
header('X-Generator: JiNexus Framework');
}
ob_start();
include $file;
ob_end_flush();
} else {
throw new Exception('View not found');
}
} | php | public function render($file = '')
{
$viewManager = $this->config->get('view_manager');
if ($viewManager['template_path_stack']) {
$file = $viewManager['template_path_stack'] . '/' . $file;
}
$fileInfo = pathinfo($file);
if (! isset($fileInfo['extension']) || $fileInfo['extension'] != 'phtml') {
$file = $file . '.phtml';
}
if (is_file($file)) {
if (! headers_sent()) {
header('X-Generator: JiNexus Framework');
}
ob_start();
include $file;
ob_end_flush();
} else {
throw new Exception('View not found');
}
} | [
"public",
"function",
"render",
"(",
"$",
"file",
"=",
"''",
")",
"{",
"$",
"viewManager",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'view_manager'",
")",
";",
"if",
"(",
"$",
"viewManager",
"[",
"'template_path_stack'",
"]",
")",
"{",
"$",
"file",
"=",
"$",
"viewManager",
"[",
"'template_path_stack'",
"]",
".",
"'/'",
".",
"$",
"file",
";",
"}",
"$",
"fileInfo",
"=",
"pathinfo",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"fileInfo",
"[",
"'extension'",
"]",
")",
"||",
"$",
"fileInfo",
"[",
"'extension'",
"]",
"!=",
"'phtml'",
")",
"{",
"$",
"file",
"=",
"$",
"file",
".",
"'.phtml'",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"if",
"(",
"!",
"headers_sent",
"(",
")",
")",
"{",
"header",
"(",
"'X-Generator: JiNexus Framework'",
")",
";",
"}",
"ob_start",
"(",
")",
";",
"include",
"$",
"file",
";",
"ob_end_flush",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'View not found'",
")",
";",
"}",
"}"
]
| Render a file
@param string $file
@throws Exception | [
"Render",
"a",
"file"
]
| train | https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L275-L299 |
controlabs/routify | src/Routify/RouteGroup.php | RouteGroup.path | public function path()
{
$clean = function($v) {
return str_replace('/', '', $v);
};
return join(
'/',
array_map($clean, $this->groups)
);
} | php | public function path()
{
$clean = function($v) {
return str_replace('/', '', $v);
};
return join(
'/',
array_map($clean, $this->groups)
);
} | [
"public",
"function",
"path",
"(",
")",
"{",
"$",
"clean",
"=",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"str_replace",
"(",
"'/'",
",",
"''",
",",
"$",
"v",
")",
";",
"}",
";",
"return",
"join",
"(",
"'/'",
",",
"array_map",
"(",
"$",
"clean",
",",
"$",
"this",
"->",
"groups",
")",
")",
";",
"}"
]
| Returns a complete path
@return string | [
"Returns",
"a",
"complete",
"path"
]
| train | https://github.com/controlabs/routify/blob/a4e92000fc61ddc7f297984ef9924b6d9df508a4/src/Routify/RouteGroup.php#L41-L51 |
webforge-labs/psc-cms | lib/Psc/DependencyManager.php | DependencyManager.enqueue | public function enqueue($alias) {
if (in_array($alias, $this->ignored)) return $this;
if (!array_key_exists($alias, $this->files)) {
$e = new DependencyException('Alias: '.$alias.' nicht gefunden. Wurde diese Datei mit register() geladen?');
$e->dependency = $alias;
throw $e;
}
if (!in_array($alias, $this->enqueued)) {
$file = $this->files[$alias];
/* as naive as I can: enqueue all dependencies, if not already */
if (!empty($file['dependencies'])) {
foreach ($file['dependencies'] as $fileAlias) {
$this->enqueue($fileAlias);
}
}
$this->enqueued[] = $alias;
}
return $this;
} | php | public function enqueue($alias) {
if (in_array($alias, $this->ignored)) return $this;
if (!array_key_exists($alias, $this->files)) {
$e = new DependencyException('Alias: '.$alias.' nicht gefunden. Wurde diese Datei mit register() geladen?');
$e->dependency = $alias;
throw $e;
}
if (!in_array($alias, $this->enqueued)) {
$file = $this->files[$alias];
/* as naive as I can: enqueue all dependencies, if not already */
if (!empty($file['dependencies'])) {
foreach ($file['dependencies'] as $fileAlias) {
$this->enqueue($fileAlias);
}
}
$this->enqueued[] = $alias;
}
return $this;
} | [
"public",
"function",
"enqueue",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"alias",
",",
"$",
"this",
"->",
"ignored",
")",
")",
"return",
"$",
"this",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"alias",
",",
"$",
"this",
"->",
"files",
")",
")",
"{",
"$",
"e",
"=",
"new",
"DependencyException",
"(",
"'Alias: '",
".",
"$",
"alias",
".",
"' nicht gefunden. Wurde diese Datei mit register() geladen?'",
")",
";",
"$",
"e",
"->",
"dependency",
"=",
"$",
"alias",
";",
"throw",
"$",
"e",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"alias",
",",
"$",
"this",
"->",
"enqueued",
")",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"files",
"[",
"$",
"alias",
"]",
";",
"/* as naive as I can: enqueue all dependencies, if not already */",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
"[",
"'dependencies'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"file",
"[",
"'dependencies'",
"]",
"as",
"$",
"fileAlias",
")",
"{",
"$",
"this",
"->",
"enqueue",
"(",
"$",
"fileAlias",
")",
";",
"}",
"}",
"$",
"this",
"->",
"enqueued",
"[",
"]",
"=",
"$",
"alias",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Lädt eine Datei
@param string $alias wie bei register() angegeben | [
"Lädt",
"eine",
"Datei"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DependencyManager.php#L43-L66 |
webforge-labs/psc-cms | lib/Psc/DependencyManager.php | DependencyManager.register | public function register($file, $alias = NULL, Array $dependencies = array()) {
if (!isset($alias)) $alias = $this->getAliasFromFile($file);
$this->files[$alias] = array('name'=>$file,
'dependencies'=>$dependencies,
'sort'=>$this->sort
);
$this->sort++;
return $this;
} | php | public function register($file, $alias = NULL, Array $dependencies = array()) {
if (!isset($alias)) $alias = $this->getAliasFromFile($file);
$this->files[$alias] = array('name'=>$file,
'dependencies'=>$dependencies,
'sort'=>$this->sort
);
$this->sort++;
return $this;
} | [
"public",
"function",
"register",
"(",
"$",
"file",
",",
"$",
"alias",
"=",
"NULL",
",",
"Array",
"$",
"dependencies",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"alias",
")",
")",
"$",
"alias",
"=",
"$",
"this",
"->",
"getAliasFromFile",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"files",
"[",
"$",
"alias",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"file",
",",
"'dependencies'",
"=>",
"$",
"dependencies",
",",
"'sort'",
"=>",
"$",
"this",
"->",
"sort",
")",
";",
"$",
"this",
"->",
"sort",
"++",
";",
"return",
"$",
"this",
";",
"}"
]
| Registriert eine Datei (unter einem Alias)
diese Datei kann dann mit enqueue() geladen werden
@param string $file
@param string $alias
@param array $dependencies ein Array mit Aliases von dem diese Datei abhängt (die mitgeladen werden, wenn diese Datei mit enqueue() geladen wird) | [
"Registriert",
"eine",
"Datei",
"(",
"unter",
"einem",
"Alias",
")"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DependencyManager.php#L91-L101 |
webforge-labs/psc-cms | lib/Psc/DependencyManager.php | DependencyManager.unregister | public function unregister($alias) {
// unregister
unset($this->files[$alias]);
// aus queued entfernen
$key = array_search($alias, $this->enqueued);
if ($key !== FALSE) {
unset($this->enqueued[$key]);
}
return $this;
} | php | public function unregister($alias) {
// unregister
unset($this->files[$alias]);
// aus queued entfernen
$key = array_search($alias, $this->enqueued);
if ($key !== FALSE) {
unset($this->enqueued[$key]);
}
return $this;
} | [
"public",
"function",
"unregister",
"(",
"$",
"alias",
")",
"{",
"// unregister",
"unset",
"(",
"$",
"this",
"->",
"files",
"[",
"$",
"alias",
"]",
")",
";",
"// aus queued entfernen",
"$",
"key",
"=",
"array_search",
"(",
"$",
"alias",
",",
"$",
"this",
"->",
"enqueued",
")",
";",
"if",
"(",
"$",
"key",
"!==",
"FALSE",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"enqueued",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Entfernt eine registrierte Datei
@param string $alias wie bei register() angegeben | [
"Entfernt",
"eine",
"registrierte",
"Datei"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DependencyManager.php#L108-L118 |
webforge-labs/psc-cms | lib/Psc/DependencyManager.php | DependencyException.setInfo | public function setInfo($string) {
$this->info = $string;
$this->message = sprintf($this->newMessage,
$this->item, $this->info, $this->dependency);
} | php | public function setInfo($string) {
$this->info = $string;
$this->message = sprintf($this->newMessage,
$this->item, $this->info, $this->dependency);
} | [
"public",
"function",
"setInfo",
"(",
"$",
"string",
")",
"{",
"$",
"this",
"->",
"info",
"=",
"$",
"string",
";",
"$",
"this",
"->",
"message",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"newMessage",
",",
"$",
"this",
"->",
"item",
",",
"$",
"this",
"->",
"info",
",",
"$",
"this",
"->",
"dependency",
")",
";",
"}"
]
| Die Information welche Abhängigkeiten das $item zu welchen Libraries hat | [
"Die",
"Information",
"welche",
"Abhängigkeiten",
"das",
"$item",
"zu",
"welchen",
"Libraries",
"hat"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DependencyManager.php#L169-L173 |
christianblos/markdown2html | src/Theme/Theme.php | Theme.createNavItems | protected function createNavItems(array $treeItems, NavItem $parent = null)
{
/** @var NavItem[] $navItems */
$navItems = [];
foreach ($treeItems as $treeItem) {
if ($treeItem->isAsset) {
continue;
}
$nav = $this->createNavItem($treeItem, $parent);
if ($nav === null) {
continue;
}
if (!isset($navItems[$nav->relUrl]) || !$navItems[$nav->relUrl]->children) {
$navItems[$nav->relUrl] = $nav;
}
}
return array_values($navItems);
} | php | protected function createNavItems(array $treeItems, NavItem $parent = null)
{
/** @var NavItem[] $navItems */
$navItems = [];
foreach ($treeItems as $treeItem) {
if ($treeItem->isAsset) {
continue;
}
$nav = $this->createNavItem($treeItem, $parent);
if ($nav === null) {
continue;
}
if (!isset($navItems[$nav->relUrl]) || !$navItems[$nav->relUrl]->children) {
$navItems[$nav->relUrl] = $nav;
}
}
return array_values($navItems);
} | [
"protected",
"function",
"createNavItems",
"(",
"array",
"$",
"treeItems",
",",
"NavItem",
"$",
"parent",
"=",
"null",
")",
"{",
"/** @var NavItem[] $navItems */",
"$",
"navItems",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"treeItems",
"as",
"$",
"treeItem",
")",
"{",
"if",
"(",
"$",
"treeItem",
"->",
"isAsset",
")",
"{",
"continue",
";",
"}",
"$",
"nav",
"=",
"$",
"this",
"->",
"createNavItem",
"(",
"$",
"treeItem",
",",
"$",
"parent",
")",
";",
"if",
"(",
"$",
"nav",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"navItems",
"[",
"$",
"nav",
"->",
"relUrl",
"]",
")",
"||",
"!",
"$",
"navItems",
"[",
"$",
"nav",
"->",
"relUrl",
"]",
"->",
"children",
")",
"{",
"$",
"navItems",
"[",
"$",
"nav",
"->",
"relUrl",
"]",
"=",
"$",
"nav",
";",
"}",
"}",
"return",
"array_values",
"(",
"$",
"navItems",
")",
";",
"}"
]
| @param TreeItem[] $treeItems
@param NavItem $parent
@return NavItem[] | [
"@param",
"TreeItem",
"[]",
"$treeItems",
"@param",
"NavItem",
"$parent"
]
| train | https://github.com/christianblos/markdown2html/blob/2ae1177d71fe313c802962dbb9226b5a90bbc65a/src/Theme/Theme.php#L158-L179 |
christianblos/markdown2html | src/Theme/Theme.php | Theme.createNavItem | protected function createNavItem(TreeItem $treeItem, NavItem $parent = null)
{
// don't create navi entry for index page
if ($parent === null && basename($treeItem->src) === 'index.md') {
return null;
}
$nav = new NavItem();
$nav->id = $treeItem->getId();
$nav->label = $treeItem->label;
$nav->relUrl = $treeItem->relUrl;
$nav->parent = $parent;
if ($treeItem->isDir) {
$nav->relUrl .= '.html';
$nav->children = $this->createNavItems($treeItem->children, $nav);
if (!$nav->children) {
return null;
}
}
return $nav;
} | php | protected function createNavItem(TreeItem $treeItem, NavItem $parent = null)
{
// don't create navi entry for index page
if ($parent === null && basename($treeItem->src) === 'index.md') {
return null;
}
$nav = new NavItem();
$nav->id = $treeItem->getId();
$nav->label = $treeItem->label;
$nav->relUrl = $treeItem->relUrl;
$nav->parent = $parent;
if ($treeItem->isDir) {
$nav->relUrl .= '.html';
$nav->children = $this->createNavItems($treeItem->children, $nav);
if (!$nav->children) {
return null;
}
}
return $nav;
} | [
"protected",
"function",
"createNavItem",
"(",
"TreeItem",
"$",
"treeItem",
",",
"NavItem",
"$",
"parent",
"=",
"null",
")",
"{",
"// don't create navi entry for index page",
"if",
"(",
"$",
"parent",
"===",
"null",
"&&",
"basename",
"(",
"$",
"treeItem",
"->",
"src",
")",
"===",
"'index.md'",
")",
"{",
"return",
"null",
";",
"}",
"$",
"nav",
"=",
"new",
"NavItem",
"(",
")",
";",
"$",
"nav",
"->",
"id",
"=",
"$",
"treeItem",
"->",
"getId",
"(",
")",
";",
"$",
"nav",
"->",
"label",
"=",
"$",
"treeItem",
"->",
"label",
";",
"$",
"nav",
"->",
"relUrl",
"=",
"$",
"treeItem",
"->",
"relUrl",
";",
"$",
"nav",
"->",
"parent",
"=",
"$",
"parent",
";",
"if",
"(",
"$",
"treeItem",
"->",
"isDir",
")",
"{",
"$",
"nav",
"->",
"relUrl",
".=",
"'.html'",
";",
"$",
"nav",
"->",
"children",
"=",
"$",
"this",
"->",
"createNavItems",
"(",
"$",
"treeItem",
"->",
"children",
",",
"$",
"nav",
")",
";",
"if",
"(",
"!",
"$",
"nav",
"->",
"children",
")",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"$",
"nav",
";",
"}"
]
| @param TreeItem $treeItem
@param NavItem $parent
@return NavItem | [
"@param",
"TreeItem",
"$treeItem",
"@param",
"NavItem",
"$parent"
]
| train | https://github.com/christianblos/markdown2html/blob/2ae1177d71fe313c802962dbb9226b5a90bbc65a/src/Theme/Theme.php#L187-L210 |
christianblos/markdown2html | src/Theme/Theme.php | Theme.getPreviousNavItemOf | protected function getPreviousNavItemOf(NavItem $current)
{
$siblings = $current->parent ? $current->parent->children : $this->navItems;
$last = $current->parent;
foreach ($siblings as $sibling) {
if ($sibling->id === $current->id) {
return $last;
}
$last = $sibling;
}
return null;
} | php | protected function getPreviousNavItemOf(NavItem $current)
{
$siblings = $current->parent ? $current->parent->children : $this->navItems;
$last = $current->parent;
foreach ($siblings as $sibling) {
if ($sibling->id === $current->id) {
return $last;
}
$last = $sibling;
}
return null;
} | [
"protected",
"function",
"getPreviousNavItemOf",
"(",
"NavItem",
"$",
"current",
")",
"{",
"$",
"siblings",
"=",
"$",
"current",
"->",
"parent",
"?",
"$",
"current",
"->",
"parent",
"->",
"children",
":",
"$",
"this",
"->",
"navItems",
";",
"$",
"last",
"=",
"$",
"current",
"->",
"parent",
";",
"foreach",
"(",
"$",
"siblings",
"as",
"$",
"sibling",
")",
"{",
"if",
"(",
"$",
"sibling",
"->",
"id",
"===",
"$",
"current",
"->",
"id",
")",
"{",
"return",
"$",
"last",
";",
"}",
"$",
"last",
"=",
"$",
"sibling",
";",
"}",
"return",
"null",
";",
"}"
]
| @param NavItem $current
@return NavItem|null | [
"@param",
"NavItem",
"$current"
]
| train | https://github.com/christianblos/markdown2html/blob/2ae1177d71fe313c802962dbb9226b5a90bbc65a/src/Theme/Theme.php#L217-L231 |
christianblos/markdown2html | src/Theme/Theme.php | Theme.getNextNavItemOf | public function getNextNavItemOf(NavItem $current)
{
$siblings = $current->parent ? $current->parent->children : $this->navItems;
$found = false;
foreach ($siblings as $sibling) {
if ($found) {
return $sibling;
}
if ($sibling->id === $current->id) {
$found = true;
}
}
return null;
} | php | public function getNextNavItemOf(NavItem $current)
{
$siblings = $current->parent ? $current->parent->children : $this->navItems;
$found = false;
foreach ($siblings as $sibling) {
if ($found) {
return $sibling;
}
if ($sibling->id === $current->id) {
$found = true;
}
}
return null;
} | [
"public",
"function",
"getNextNavItemOf",
"(",
"NavItem",
"$",
"current",
")",
"{",
"$",
"siblings",
"=",
"$",
"current",
"->",
"parent",
"?",
"$",
"current",
"->",
"parent",
"->",
"children",
":",
"$",
"this",
"->",
"navItems",
";",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"$",
"siblings",
"as",
"$",
"sibling",
")",
"{",
"if",
"(",
"$",
"found",
")",
"{",
"return",
"$",
"sibling",
";",
"}",
"if",
"(",
"$",
"sibling",
"->",
"id",
"===",
"$",
"current",
"->",
"id",
")",
"{",
"$",
"found",
"=",
"true",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| @param NavItem $current
@return NavItem|null | [
"@param",
"NavItem",
"$current"
]
| train | https://github.com/christianblos/markdown2html/blob/2ae1177d71fe313c802962dbb9226b5a90bbc65a/src/Theme/Theme.php#L238-L254 |
ClanCats/Core | src/bundles/UI/Form.php | Form.start | public static function start( $key, $attr = array() )
{
$attributes = array();
// force the form role
$attributes['role'] = 'form';
if ( !is_null( $key ) )
{
static::$id_prefix = $attributes['id'] = static::form_id( 'form', $key );
}
$attributes = array_merge( $attributes, $attr );
return '<form'.HTML::attr( $attributes ).'>';
} | php | public static function start( $key, $attr = array() )
{
$attributes = array();
// force the form role
$attributes['role'] = 'form';
if ( !is_null( $key ) )
{
static::$id_prefix = $attributes['id'] = static::form_id( 'form', $key );
}
$attributes = array_merge( $attributes, $attr );
return '<form'.HTML::attr( $attributes ).'>';
} | [
"public",
"static",
"function",
"start",
"(",
"$",
"key",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"// force the form role",
"$",
"attributes",
"[",
"'role'",
"]",
"=",
"'form'",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"static",
"::",
"$",
"id_prefix",
"=",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"static",
"::",
"form_id",
"(",
"'form'",
",",
"$",
"key",
")",
";",
"}",
"$",
"attributes",
"=",
"array_merge",
"(",
"$",
"attributes",
",",
"$",
"attr",
")",
";",
"return",
"'<form'",
".",
"HTML",
"::",
"attr",
"(",
"$",
"attributes",
")",
".",
"'>'",
";",
"}"
]
| Open a new form
This will set the current form to this one
@param string $key
@param array $attr
@return string | [
"Open",
"a",
"new",
"form",
"This",
"will",
"set",
"the",
"current",
"form",
"to",
"this",
"one"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L64-L79 |
ClanCats/Core | src/bundles/UI/Form.php | Form.capture | public static function capture( $callback = null, $key = null, $attr = null )
{
// we got some dynamics in the parameters here so in case
// of this shift stuff
if ( is_callable( $attr ) && !is_callable( $callback ) )
{
$new_attr = $key;
$key = $callback;
$callback = $attr;
$attr = $new_attr;
}
$form = new static;
if ( is_null( $callback ) )
{
throw new Exception( 'Cannot use capture without a callback or string given.' );
}
// fix no array given
if ( !is_array( $attr ) )
{
$attr = array();
}
return static::start( $key, $attr ).\CCStr::capture( $callback, array( $form ) ).static::end();
} | php | public static function capture( $callback = null, $key = null, $attr = null )
{
// we got some dynamics in the parameters here so in case
// of this shift stuff
if ( is_callable( $attr ) && !is_callable( $callback ) )
{
$new_attr = $key;
$key = $callback;
$callback = $attr;
$attr = $new_attr;
}
$form = new static;
if ( is_null( $callback ) )
{
throw new Exception( 'Cannot use capture without a callback or string given.' );
}
// fix no array given
if ( !is_array( $attr ) )
{
$attr = array();
}
return static::start( $key, $attr ).\CCStr::capture( $callback, array( $form ) ).static::end();
} | [
"public",
"static",
"function",
"capture",
"(",
"$",
"callback",
"=",
"null",
",",
"$",
"key",
"=",
"null",
",",
"$",
"attr",
"=",
"null",
")",
"{",
"// we got some dynamics in the parameters here so in case",
"// of this shift stuff",
"if",
"(",
"is_callable",
"(",
"$",
"attr",
")",
"&&",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"new_attr",
"=",
"$",
"key",
";",
"$",
"key",
"=",
"$",
"callback",
";",
"$",
"callback",
"=",
"$",
"attr",
";",
"$",
"attr",
"=",
"$",
"new_attr",
";",
"}",
"$",
"form",
"=",
"new",
"static",
";",
"if",
"(",
"is_null",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot use capture without a callback or string given.'",
")",
";",
"}",
"// fix no array given",
"if",
"(",
"!",
"is_array",
"(",
"$",
"attr",
")",
")",
"{",
"$",
"attr",
"=",
"array",
"(",
")",
";",
"}",
"return",
"static",
"::",
"start",
"(",
"$",
"key",
",",
"$",
"attr",
")",
".",
"\\",
"CCStr",
"::",
"capture",
"(",
"$",
"callback",
",",
"array",
"(",
"$",
"form",
")",
")",
".",
"static",
"::",
"end",
"(",
")",
";",
"}"
]
| Create a new from instance
@param callback $callback
@param string $key The form key used for identification.
@param array $attr The form dom attributes.
@return UI\Form | [
"Create",
"a",
"new",
"from",
"instance"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L101-L127 |
ClanCats/Core | src/bundles/UI/Form.php | Form.build_id | public static function build_id( $type, $name )
{
if ( !is_null( static::$id_prefix ) )
{
return static::$id_prefix.'-'.static::form_id( $type, $name );
}
return static::form_id( $type, $name );
} | php | public static function build_id( $type, $name )
{
if ( !is_null( static::$id_prefix ) )
{
return static::$id_prefix.'-'.static::form_id( $type, $name );
}
return static::form_id( $type, $name );
} | [
"public",
"static",
"function",
"build_id",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"static",
"::",
"$",
"id_prefix",
")",
")",
"{",
"return",
"static",
"::",
"$",
"id_prefix",
".",
"'-'",
".",
"static",
"::",
"form_id",
"(",
"$",
"type",
",",
"$",
"name",
")",
";",
"}",
"return",
"static",
"::",
"form_id",
"(",
"$",
"type",
",",
"$",
"name",
")",
";",
"}"
]
| Format an id by configartion with the current form prefix
@param string $type element, form etc..
@param strgin $name
@return string | [
"Format",
"an",
"id",
"by",
"configartion",
"with",
"the",
"current",
"form",
"prefix"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L148-L155 |
ClanCats/Core | src/bundles/UI/Form.php | Form.make_input | public static function make_input( $id, $key, $value = null, $type = 'text', $attr = array() )
{
$element = HTML::tag( 'input', array_merge( array(
'id' => $id,
'name' => $key,
'type' => $type
), $attr ));
if ( !is_null( $value ) )
{
$element->value( _e( $value ) );
}
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_input', $element );
} | php | public static function make_input( $id, $key, $value = null, $type = 'text', $attr = array() )
{
$element = HTML::tag( 'input', array_merge( array(
'id' => $id,
'name' => $key,
'type' => $type
), $attr ));
if ( !is_null( $value ) )
{
$element->value( _e( $value ) );
}
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_input', $element );
} | [
"public",
"static",
"function",
"make_input",
"(",
"$",
"id",
",",
"$",
"key",
",",
"$",
"value",
"=",
"null",
",",
"$",
"type",
"=",
"'text'",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"element",
"=",
"HTML",
"::",
"tag",
"(",
"'input'",
",",
"array_merge",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'name'",
"=>",
"$",
"key",
",",
"'type'",
"=>",
"$",
"type",
")",
",",
"$",
"attr",
")",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"element",
"->",
"value",
"(",
"_e",
"(",
"$",
"value",
")",
")",
";",
"}",
"if",
"(",
"!",
"static",
"::",
"$",
"builder_enabled",
")",
"{",
"return",
"$",
"element",
";",
"}",
"return",
"Builder",
"::",
"handle",
"(",
"'form_input'",
",",
"$",
"element",
")",
";",
"}"
]
| make an input
@param string $id The id that has been generated for us.
@param string $key This is the name
@param string $type
@param array $attr | [
"make",
"an",
"input"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L204-L223 |
ClanCats/Core | src/bundles/UI/Form.php | Form.make_label | public static function make_label( $id, $key, $text = null, $attr = array() )
{
if ( is_null( $text ) )
{
$text = $key;
}
$element = HTML::tag( 'label', $text, array_merge( array(
'id' => $id,
'for' => static::build_id( 'input', $key )
), $attr ));
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_label', $element );
} | php | public static function make_label( $id, $key, $text = null, $attr = array() )
{
if ( is_null( $text ) )
{
$text = $key;
}
$element = HTML::tag( 'label', $text, array_merge( array(
'id' => $id,
'for' => static::build_id( 'input', $key )
), $attr ));
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_label', $element );
} | [
"public",
"static",
"function",
"make_label",
"(",
"$",
"id",
",",
"$",
"key",
",",
"$",
"text",
"=",
"null",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"text",
")",
")",
"{",
"$",
"text",
"=",
"$",
"key",
";",
"}",
"$",
"element",
"=",
"HTML",
"::",
"tag",
"(",
"'label'",
",",
"$",
"text",
",",
"array_merge",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'for'",
"=>",
"static",
"::",
"build_id",
"(",
"'input'",
",",
"$",
"key",
")",
")",
",",
"$",
"attr",
")",
")",
";",
"if",
"(",
"!",
"static",
"::",
"$",
"builder_enabled",
")",
"{",
"return",
"$",
"element",
";",
"}",
"return",
"Builder",
"::",
"handle",
"(",
"'form_label'",
",",
"$",
"element",
")",
";",
"}"
]
| make a label
@param string $id The id that has been generated for us.
@param string $key This is the name
@param string $text
@param array $attr | [
"make",
"a",
"label"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L233-L251 |
ClanCats/Core | src/bundles/UI/Form.php | Form.make_checkbox | public static function make_checkbox( $id, $key, $text = '', $active = false, $attr = array() )
{
$element = HTML::tag( 'input', array_merge( array(
'id' => $id,
'name' => $key,
'type' => 'checkbox'
), $attr ));
$element->checked( (bool) $active );
$element = HTML::tag( 'label', $element->render().' '.$text );
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_checkbox', $element );
} | php | public static function make_checkbox( $id, $key, $text = '', $active = false, $attr = array() )
{
$element = HTML::tag( 'input', array_merge( array(
'id' => $id,
'name' => $key,
'type' => 'checkbox'
), $attr ));
$element->checked( (bool) $active );
$element = HTML::tag( 'label', $element->render().' '.$text );
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_checkbox', $element );
} | [
"public",
"static",
"function",
"make_checkbox",
"(",
"$",
"id",
",",
"$",
"key",
",",
"$",
"text",
"=",
"''",
",",
"$",
"active",
"=",
"false",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"element",
"=",
"HTML",
"::",
"tag",
"(",
"'input'",
",",
"array_merge",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'name'",
"=>",
"$",
"key",
",",
"'type'",
"=>",
"'checkbox'",
")",
",",
"$",
"attr",
")",
")",
";",
"$",
"element",
"->",
"checked",
"(",
"(",
"bool",
")",
"$",
"active",
")",
";",
"$",
"element",
"=",
"HTML",
"::",
"tag",
"(",
"'label'",
",",
"$",
"element",
"->",
"render",
"(",
")",
".",
"' '",
".",
"$",
"text",
")",
";",
"if",
"(",
"!",
"static",
"::",
"$",
"builder_enabled",
")",
"{",
"return",
"$",
"element",
";",
"}",
"return",
"Builder",
"::",
"handle",
"(",
"'form_checkbox'",
",",
"$",
"element",
")",
";",
"}"
]
| make a checkbox
@param string $id The id that has been generated for us.
@param string $key This is the name
@param string $text
@param bool $active Is the checkbox cheked
@param array $attr
@return string | [
"make",
"a",
"checkbox"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L263-L281 |
ClanCats/Core | src/bundles/UI/Form.php | Form.make_textarea | public static function make_textarea( $id, $key, $value = '', $attr = array() )
{
$element = HTML::tag( 'textarea', _e( $value ), array_merge( array(
'id' => $id,
'name' => $key,
), $attr ));
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_textarea', $element );
} | php | public static function make_textarea( $id, $key, $value = '', $attr = array() )
{
$element = HTML::tag( 'textarea', _e( $value ), array_merge( array(
'id' => $id,
'name' => $key,
), $attr ));
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_textarea', $element );
} | [
"public",
"static",
"function",
"make_textarea",
"(",
"$",
"id",
",",
"$",
"key",
",",
"$",
"value",
"=",
"''",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"element",
"=",
"HTML",
"::",
"tag",
"(",
"'textarea'",
",",
"_e",
"(",
"$",
"value",
")",
",",
"array_merge",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'name'",
"=>",
"$",
"key",
",",
")",
",",
"$",
"attr",
")",
")",
";",
"if",
"(",
"!",
"static",
"::",
"$",
"builder_enabled",
")",
"{",
"return",
"$",
"element",
";",
"}",
"return",
"Builder",
"::",
"handle",
"(",
"'form_textarea'",
",",
"$",
"element",
")",
";",
"}"
]
| generate a textarea
@param string $id The id that has been generated for us.
@param string $key This is the name
@param string $value
@param array $attr
@return string | [
"generate",
"a",
"textarea"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L292-L305 |
ClanCats/Core | src/bundles/UI/Form.php | Form.make_select | public static function make_select( $id, $name, array $options, $selected = array(), $size = 1 )
{
if ( !is_array( $selected ) )
{
$selected = array( $selected );
}
$buffer = "";
foreach( $options as $key => $option )
{
if ( ! ( $option instanceof HTML ) )
{
$option = HTML::tag( 'option', $option )
->value( $key );
}
if ( in_array( $key, $selected ) )
{
$option->selected( true );
}
$buffer .= $option->render();
}
$element = HTML::tag( 'select', $buffer, array(
'id' => $id,
'name' => $name,
'size' => $size,
) );
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_select', $element );
} | php | public static function make_select( $id, $name, array $options, $selected = array(), $size = 1 )
{
if ( !is_array( $selected ) )
{
$selected = array( $selected );
}
$buffer = "";
foreach( $options as $key => $option )
{
if ( ! ( $option instanceof HTML ) )
{
$option = HTML::tag( 'option', $option )
->value( $key );
}
if ( in_array( $key, $selected ) )
{
$option->selected( true );
}
$buffer .= $option->render();
}
$element = HTML::tag( 'select', $buffer, array(
'id' => $id,
'name' => $name,
'size' => $size,
) );
if ( !static::$builder_enabled )
{
return $element;
}
return Builder::handle( 'form_select', $element );
} | [
"public",
"static",
"function",
"make_select",
"(",
"$",
"id",
",",
"$",
"name",
",",
"array",
"$",
"options",
",",
"$",
"selected",
"=",
"array",
"(",
")",
",",
"$",
"size",
"=",
"1",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"selected",
")",
")",
"{",
"$",
"selected",
"=",
"array",
"(",
"$",
"selected",
")",
";",
"}",
"$",
"buffer",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"option",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"option",
"instanceof",
"HTML",
")",
")",
"{",
"$",
"option",
"=",
"HTML",
"::",
"tag",
"(",
"'option'",
",",
"$",
"option",
")",
"->",
"value",
"(",
"$",
"key",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"selected",
")",
")",
"{",
"$",
"option",
"->",
"selected",
"(",
"true",
")",
";",
"}",
"$",
"buffer",
".=",
"$",
"option",
"->",
"render",
"(",
")",
";",
"}",
"$",
"element",
"=",
"HTML",
"::",
"tag",
"(",
"'select'",
",",
"$",
"buffer",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'name'",
"=>",
"$",
"name",
",",
"'size'",
"=>",
"$",
"size",
",",
")",
")",
";",
"if",
"(",
"!",
"static",
"::",
"$",
"builder_enabled",
")",
"{",
"return",
"$",
"element",
";",
"}",
"return",
"Builder",
"::",
"handle",
"(",
"'form_select'",
",",
"$",
"element",
")",
";",
"}"
]
| generate an select
Form::select( 'gender', array( 'F', 'M' ), 0 );
Form::select( 'gender', array( '1' => 'A', '2' => 'B' ), array( 1,2 ), 2 );
@param string $id The id that has been generated for us.
@param string $name This is the name
@param array $options
@param array $selected
@param int $size
@return string | [
"generate",
"an",
"select"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L334-L371 |
iocaste/microservice-foundation | src/Command/Command.php | Command.logOutput | protected function logOutput($output, $type = 'info', $context = [], $toConsole = true, $toLog = true)
{
if ($toConsole) {
$this->{$type}(' ' . $output);
}
$type = ($type === 'line') ? 'info' : $type;
if ($toLog) {
app('log')->$type($output, $context);
}
} | php | protected function logOutput($output, $type = 'info', $context = [], $toConsole = true, $toLog = true)
{
if ($toConsole) {
$this->{$type}(' ' . $output);
}
$type = ($type === 'line') ? 'info' : $type;
if ($toLog) {
app('log')->$type($output, $context);
}
} | [
"protected",
"function",
"logOutput",
"(",
"$",
"output",
",",
"$",
"type",
"=",
"'info'",
",",
"$",
"context",
"=",
"[",
"]",
",",
"$",
"toConsole",
"=",
"true",
",",
"$",
"toLog",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"toConsole",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
"(",
"' '",
".",
"$",
"output",
")",
";",
"}",
"$",
"type",
"=",
"(",
"$",
"type",
"===",
"'line'",
")",
"?",
"'info'",
":",
"$",
"type",
";",
"if",
"(",
"$",
"toLog",
")",
"{",
"app",
"(",
"'log'",
")",
"->",
"$",
"type",
"(",
"$",
"output",
",",
"$",
"context",
")",
";",
"}",
"}"
]
| @param $output
@param string $type
@param array $context
@param bool $toConsole
@param bool $toLog
@return void | [
"@param",
"$output",
"@param",
"string",
"$type",
"@param",
"array",
"$context",
"@param",
"bool",
"$toConsole",
"@param",
"bool",
"$toLog"
]
| train | https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Command/Command.php#L21-L32 |
boekkooi/tactician-amqp | src/Middleware/RemoteResponseMiddleware.php | RemoteResponseMiddleware.execute | public function execute($command, callable $next)
{
// Check that the command expects a response
if (!$command instanceof Command || empty($command->getEnvelope()->getReplyTo())) {
return $next($command);
}
// Execute command
$result = $next($command);
// Transform result
$message = $this->transformer->transformCommandResponse($result);
// Publish the response message
$publisher = $this->getPublisher($command);
$publisher->publish($message);
return $result;
} | php | public function execute($command, callable $next)
{
// Check that the command expects a response
if (!$command instanceof Command || empty($command->getEnvelope()->getReplyTo())) {
return $next($command);
}
// Execute command
$result = $next($command);
// Transform result
$message = $this->transformer->transformCommandResponse($result);
// Publish the response message
$publisher = $this->getPublisher($command);
$publisher->publish($message);
return $result;
} | [
"public",
"function",
"execute",
"(",
"$",
"command",
",",
"callable",
"$",
"next",
")",
"{",
"// Check that the command expects a response",
"if",
"(",
"!",
"$",
"command",
"instanceof",
"Command",
"||",
"empty",
"(",
"$",
"command",
"->",
"getEnvelope",
"(",
")",
"->",
"getReplyTo",
"(",
")",
")",
")",
"{",
"return",
"$",
"next",
"(",
"$",
"command",
")",
";",
"}",
"// Execute command",
"$",
"result",
"=",
"$",
"next",
"(",
"$",
"command",
")",
";",
"// Transform result",
"$",
"message",
"=",
"$",
"this",
"->",
"transformer",
"->",
"transformCommandResponse",
"(",
"$",
"result",
")",
";",
"// Publish the response message",
"$",
"publisher",
"=",
"$",
"this",
"->",
"getPublisher",
"(",
"$",
"command",
")",
";",
"$",
"publisher",
"->",
"publish",
"(",
"$",
"message",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/boekkooi/tactician-amqp/blob/55cbb8b9e20aab7891e6a6090b248377c599360e/src/Middleware/RemoteResponseMiddleware.php#L28-L46 |
flipboxstudio/orm-manager | src/Flipbox/OrmManager/BothRelations/OneToOne.php | OneToOne.buildRelations | public function buildRelations()
{
$this->command->buildMethod($this->model, 'hasOne', $this->toModel, $this->options);
$this->command->buildMethod($this->toModel, 'belongsTo', $this->model, $this->options);
} | php | public function buildRelations()
{
$this->command->buildMethod($this->model, 'hasOne', $this->toModel, $this->options);
$this->command->buildMethod($this->toModel, 'belongsTo', $this->model, $this->options);
} | [
"public",
"function",
"buildRelations",
"(",
")",
"{",
"$",
"this",
"->",
"command",
"->",
"buildMethod",
"(",
"$",
"this",
"->",
"model",
",",
"'hasOne'",
",",
"$",
"this",
"->",
"toModel",
",",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"command",
"->",
"buildMethod",
"(",
"$",
"this",
"->",
"toModel",
",",
"'belongsTo'",
",",
"$",
"this",
"->",
"model",
",",
"$",
"this",
"->",
"options",
")",
";",
"}"
]
| build relations between models
@return void | [
"build",
"relations",
"between",
"models"
]
| train | https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/BothRelations/OneToOne.php#L98-L102 |
rayrutjes/domain-foundation | src/Persistence/Pdo/EventStore/PdoReadRecordEventStream.php | PdoReadRecordEventStream.translateRecordIntoEventMessage | private function translateRecordIntoEventMessage(array $record)
{
$identifier = new MessageIdentifier($record['event_id']);
$payload = $this->eventSerializer->deserializePayload(
$record['event_payload'],
Contract::createFromClassName($record['event_payload_type'])
);
$metadata = $this->eventSerializer->deserializeMetadata(
$record['event_metadata'],
Contract::createFromClassName($record['event_metadata_type'])
);
$sequenceNumber = (int) $record['aggregate_version'];
$eventMessage = new GenericEvent($this->aggregateRootIdentifier, $sequenceNumber, $identifier, $payload, $metadata);
return $eventMessage;
} | php | private function translateRecordIntoEventMessage(array $record)
{
$identifier = new MessageIdentifier($record['event_id']);
$payload = $this->eventSerializer->deserializePayload(
$record['event_payload'],
Contract::createFromClassName($record['event_payload_type'])
);
$metadata = $this->eventSerializer->deserializeMetadata(
$record['event_metadata'],
Contract::createFromClassName($record['event_metadata_type'])
);
$sequenceNumber = (int) $record['aggregate_version'];
$eventMessage = new GenericEvent($this->aggregateRootIdentifier, $sequenceNumber, $identifier, $payload, $metadata);
return $eventMessage;
} | [
"private",
"function",
"translateRecordIntoEventMessage",
"(",
"array",
"$",
"record",
")",
"{",
"$",
"identifier",
"=",
"new",
"MessageIdentifier",
"(",
"$",
"record",
"[",
"'event_id'",
"]",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"eventSerializer",
"->",
"deserializePayload",
"(",
"$",
"record",
"[",
"'event_payload'",
"]",
",",
"Contract",
"::",
"createFromClassName",
"(",
"$",
"record",
"[",
"'event_payload_type'",
"]",
")",
")",
";",
"$",
"metadata",
"=",
"$",
"this",
"->",
"eventSerializer",
"->",
"deserializeMetadata",
"(",
"$",
"record",
"[",
"'event_metadata'",
"]",
",",
"Contract",
"::",
"createFromClassName",
"(",
"$",
"record",
"[",
"'event_metadata_type'",
"]",
")",
")",
";",
"$",
"sequenceNumber",
"=",
"(",
"int",
")",
"$",
"record",
"[",
"'aggregate_version'",
"]",
";",
"$",
"eventMessage",
"=",
"new",
"GenericEvent",
"(",
"$",
"this",
"->",
"aggregateRootIdentifier",
",",
"$",
"sequenceNumber",
",",
"$",
"identifier",
",",
"$",
"payload",
",",
"$",
"metadata",
")",
";",
"return",
"$",
"eventMessage",
";",
"}"
]
| @param array $record
@return Event | [
"@param",
"array",
"$record"
]
| train | https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Persistence/Pdo/EventStore/PdoReadRecordEventStream.php#L74-L93 |
neos/doctools | Classes/Command/ReferenceCommandController.php | ReferenceCommandController.renderCollectionCommand | public function renderCollectionCommand($collection)
{
if (!isset($this->settings['collections'][$collection])) {
$this->outputLine('Collection "%s" is not configured', [$collection]);
$this->quit(1);
}
if (!isset($this->settings['collections'][$collection]['references'])) {
$this->outputLine('Collection "%s" does not have any references', [$collection]);
$this->quit(1);
}
$references = $this->settings['collections'][$collection]['references'];
$this->renderReferences($references);
} | php | public function renderCollectionCommand($collection)
{
if (!isset($this->settings['collections'][$collection])) {
$this->outputLine('Collection "%s" is not configured', [$collection]);
$this->quit(1);
}
if (!isset($this->settings['collections'][$collection]['references'])) {
$this->outputLine('Collection "%s" does not have any references', [$collection]);
$this->quit(1);
}
$references = $this->settings['collections'][$collection]['references'];
$this->renderReferences($references);
} | [
"public",
"function",
"renderCollectionCommand",
"(",
"$",
"collection",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"settings",
"[",
"'collections'",
"]",
"[",
"$",
"collection",
"]",
")",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
"'Collection \"%s\" is not configured'",
",",
"[",
"$",
"collection",
"]",
")",
";",
"$",
"this",
"->",
"quit",
"(",
"1",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"settings",
"[",
"'collections'",
"]",
"[",
"$",
"collection",
"]",
"[",
"'references'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
"'Collection \"%s\" does not have any references'",
",",
"[",
"$",
"collection",
"]",
")",
";",
"$",
"this",
"->",
"quit",
"(",
"1",
")",
";",
"}",
"$",
"references",
"=",
"$",
"this",
"->",
"settings",
"[",
"'collections'",
"]",
"[",
"$",
"collection",
"]",
"[",
"'references'",
"]",
";",
"$",
"this",
"->",
"renderReferences",
"(",
"$",
"references",
")",
";",
"}"
]
| Renders a configured collection of reference documentation from source code.
@param string $collection to render (typically the name of a package).
@return void
@throws \Neos\Flow\Mvc\Exception\StopActionException
@throws \Neos\FluidAdaptor\Exception
@throws \Neos\Flow\Reflection\Exception\ClassLoadingForReflectionFailedException | [
"Renders",
"a",
"configured",
"collection",
"of",
"reference",
"documentation",
"from",
"source",
"code",
"."
]
| train | https://github.com/neos/doctools/blob/726981245a8d59319ee594a582f80a30256df98b/Classes/Command/ReferenceCommandController.php#L71-L83 |
neos/doctools | Classes/Command/ReferenceCommandController.php | ReferenceCommandController.renderReference | protected function renderReference($reference)
{
if (!isset($this->settings['references'][$reference])) {
$this->outputLine('Reference "%s" is not configured', [$reference]);
$this->quit(1);
}
$referenceConfiguration = $this->settings['references'][$reference];
$affectedClassNames = $this->getAffectedClassNames($referenceConfiguration['affectedClasses']);
$parserClassName = $referenceConfiguration['parser']['implementationClassName'];
$parserOptions = isset($referenceConfiguration['parser']['options']) ? $referenceConfiguration['parser']['options'] : [];
/** @var $classParser \Neos\DocTools\Domain\Service\AbstractClassParser */
$classParser = new $parserClassName($parserOptions);
$classReferences = [];
foreach ($affectedClassNames as $className) {
$classReferences[$className] = $classParser->parse($className);
}
usort($classReferences, function (ClassReference $a, ClassReference $b) {
if ($a->getTitle() == $b->getTitle()) {
return 0;
}
return ($a->getTitle() < $b->getTitle()) ? -1 : 1;
});
$standaloneView = new \Neos\FluidAdaptor\View\StandaloneView();
$templatePathAndFilename = isset($referenceConfiguration['templatePathAndFilename']) ? $referenceConfiguration['templatePathAndFilename'] : 'resource://Neos.DocTools/Private/Templates/ClassReferenceTemplate.txt';
$standaloneView->setTemplatePathAndFilename($templatePathAndFilename);
$standaloneView->assign('title', isset($referenceConfiguration['title']) ? $referenceConfiguration['title'] : $reference);
$standaloneView->assign('classReferences', $classReferences);
file_put_contents($referenceConfiguration['savePathAndFilename'], $standaloneView->render());
$this->outputLine('DONE.');
} | php | protected function renderReference($reference)
{
if (!isset($this->settings['references'][$reference])) {
$this->outputLine('Reference "%s" is not configured', [$reference]);
$this->quit(1);
}
$referenceConfiguration = $this->settings['references'][$reference];
$affectedClassNames = $this->getAffectedClassNames($referenceConfiguration['affectedClasses']);
$parserClassName = $referenceConfiguration['parser']['implementationClassName'];
$parserOptions = isset($referenceConfiguration['parser']['options']) ? $referenceConfiguration['parser']['options'] : [];
/** @var $classParser \Neos\DocTools\Domain\Service\AbstractClassParser */
$classParser = new $parserClassName($parserOptions);
$classReferences = [];
foreach ($affectedClassNames as $className) {
$classReferences[$className] = $classParser->parse($className);
}
usort($classReferences, function (ClassReference $a, ClassReference $b) {
if ($a->getTitle() == $b->getTitle()) {
return 0;
}
return ($a->getTitle() < $b->getTitle()) ? -1 : 1;
});
$standaloneView = new \Neos\FluidAdaptor\View\StandaloneView();
$templatePathAndFilename = isset($referenceConfiguration['templatePathAndFilename']) ? $referenceConfiguration['templatePathAndFilename'] : 'resource://Neos.DocTools/Private/Templates/ClassReferenceTemplate.txt';
$standaloneView->setTemplatePathAndFilename($templatePathAndFilename);
$standaloneView->assign('title', isset($referenceConfiguration['title']) ? $referenceConfiguration['title'] : $reference);
$standaloneView->assign('classReferences', $classReferences);
file_put_contents($referenceConfiguration['savePathAndFilename'], $standaloneView->render());
$this->outputLine('DONE.');
} | [
"protected",
"function",
"renderReference",
"(",
"$",
"reference",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"settings",
"[",
"'references'",
"]",
"[",
"$",
"reference",
"]",
")",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
"'Reference \"%s\" is not configured'",
",",
"[",
"$",
"reference",
"]",
")",
";",
"$",
"this",
"->",
"quit",
"(",
"1",
")",
";",
"}",
"$",
"referenceConfiguration",
"=",
"$",
"this",
"->",
"settings",
"[",
"'references'",
"]",
"[",
"$",
"reference",
"]",
";",
"$",
"affectedClassNames",
"=",
"$",
"this",
"->",
"getAffectedClassNames",
"(",
"$",
"referenceConfiguration",
"[",
"'affectedClasses'",
"]",
")",
";",
"$",
"parserClassName",
"=",
"$",
"referenceConfiguration",
"[",
"'parser'",
"]",
"[",
"'implementationClassName'",
"]",
";",
"$",
"parserOptions",
"=",
"isset",
"(",
"$",
"referenceConfiguration",
"[",
"'parser'",
"]",
"[",
"'options'",
"]",
")",
"?",
"$",
"referenceConfiguration",
"[",
"'parser'",
"]",
"[",
"'options'",
"]",
":",
"[",
"]",
";",
"/** @var $classParser \\Neos\\DocTools\\Domain\\Service\\AbstractClassParser */",
"$",
"classParser",
"=",
"new",
"$",
"parserClassName",
"(",
"$",
"parserOptions",
")",
";",
"$",
"classReferences",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"affectedClassNames",
"as",
"$",
"className",
")",
"{",
"$",
"classReferences",
"[",
"$",
"className",
"]",
"=",
"$",
"classParser",
"->",
"parse",
"(",
"$",
"className",
")",
";",
"}",
"usort",
"(",
"$",
"classReferences",
",",
"function",
"(",
"ClassReference",
"$",
"a",
",",
"ClassReference",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"getTitle",
"(",
")",
"==",
"$",
"b",
"->",
"getTitle",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"(",
"$",
"a",
"->",
"getTitle",
"(",
")",
"<",
"$",
"b",
"->",
"getTitle",
"(",
")",
")",
"?",
"-",
"1",
":",
"1",
";",
"}",
")",
";",
"$",
"standaloneView",
"=",
"new",
"\\",
"Neos",
"\\",
"FluidAdaptor",
"\\",
"View",
"\\",
"StandaloneView",
"(",
")",
";",
"$",
"templatePathAndFilename",
"=",
"isset",
"(",
"$",
"referenceConfiguration",
"[",
"'templatePathAndFilename'",
"]",
")",
"?",
"$",
"referenceConfiguration",
"[",
"'templatePathAndFilename'",
"]",
":",
"'resource://Neos.DocTools/Private/Templates/ClassReferenceTemplate.txt'",
";",
"$",
"standaloneView",
"->",
"setTemplatePathAndFilename",
"(",
"$",
"templatePathAndFilename",
")",
";",
"$",
"standaloneView",
"->",
"assign",
"(",
"'title'",
",",
"isset",
"(",
"$",
"referenceConfiguration",
"[",
"'title'",
"]",
")",
"?",
"$",
"referenceConfiguration",
"[",
"'title'",
"]",
":",
"$",
"reference",
")",
";",
"$",
"standaloneView",
"->",
"assign",
"(",
"'classReferences'",
",",
"$",
"classReferences",
")",
";",
"file_put_contents",
"(",
"$",
"referenceConfiguration",
"[",
"'savePathAndFilename'",
"]",
",",
"$",
"standaloneView",
"->",
"render",
"(",
")",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"'DONE.'",
")",
";",
"}"
]
| Render a reference to reStructuredText.
@param string $reference
@return void
@throws \Neos\Flow\Mvc\Exception\StopActionException
@throws \Neos\FluidAdaptor\Exception
@throws \Neos\Flow\Reflection\Exception\ClassLoadingForReflectionFailedException | [
"Render",
"a",
"reference",
"to",
"reStructuredText",
"."
]
| train | https://github.com/neos/doctools/blob/726981245a8d59319ee594a582f80a30256df98b/Classes/Command/ReferenceCommandController.php#L111-L141 |
accgit/single-web | src/Single/Single.php | Single.flashMessage | public function flashMessage($message)
{
$sessions = $this->getSessions()->getSessionSection('flash.message');
$sessions->message = $message;
$sessions->setExpiration('5 second');
return $sessions->message;
} | php | public function flashMessage($message)
{
$sessions = $this->getSessions()->getSessionSection('flash.message');
$sessions->message = $message;
$sessions->setExpiration('5 second');
return $sessions->message;
} | [
"public",
"function",
"flashMessage",
"(",
"$",
"message",
")",
"{",
"$",
"sessions",
"=",
"$",
"this",
"->",
"getSessions",
"(",
")",
"->",
"getSessionSection",
"(",
"'flash.message'",
")",
";",
"$",
"sessions",
"->",
"message",
"=",
"$",
"message",
";",
"$",
"sessions",
"->",
"setExpiration",
"(",
"'5 second'",
")",
";",
"return",
"$",
"sessions",
"->",
"message",
";",
"}"
]
| Create flash message.
@param string $message
@return string | [
"Create",
"flash",
"message",
"."
]
| train | https://github.com/accgit/single-web/blob/5d0dce3313df9e22ab60749bcf01f1753de8c143/src/Single/Single.php#L49-L55 |
askupasoftware/amarkal | UI/Components/Slider/controller.php | Slider.validate | public function validate( $value, &$error )
{
$error = 'Invalid slider range for '.$this->get_name();
if( 'range' == $this->type )
{
return is_numeric($value[0]) && is_numeric($value[1]) && ( intval($value[0]) <= intval($value[1]) );
}
else
{
return is_numeric($value);
}
} | php | public function validate( $value, &$error )
{
$error = 'Invalid slider range for '.$this->get_name();
if( 'range' == $this->type )
{
return is_numeric($value[0]) && is_numeric($value[1]) && ( intval($value[0]) <= intval($value[1]) );
}
else
{
return is_numeric($value);
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"&",
"$",
"error",
")",
"{",
"$",
"error",
"=",
"'Invalid slider range for '",
".",
"$",
"this",
"->",
"get_name",
"(",
")",
";",
"if",
"(",
"'range'",
"==",
"$",
"this",
"->",
"type",
")",
"{",
"return",
"is_numeric",
"(",
"$",
"value",
"[",
"0",
"]",
")",
"&&",
"is_numeric",
"(",
"$",
"value",
"[",
"1",
"]",
")",
"&&",
"(",
"intval",
"(",
"$",
"value",
"[",
"0",
"]",
")",
"<=",
"intval",
"(",
"$",
"value",
"[",
"1",
"]",
")",
")",
";",
"}",
"else",
"{",
"return",
"is_numeric",
"(",
"$",
"value",
")",
";",
"}",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/UI/Components/Slider/controller.php#L106-L117 |
kattsoftware/phassets | src/Phassets/Factory.php | Factory.buildLogger | public function buildLogger($class, Configurator $configurator)
{
if (!class_exists($class) || !is_subclass_of($class, Logger::class)) {
$class = "\\Phassets\\Loggers\\$class";
}
if (class_exists($class) && is_subclass_of($class, Logger::class)) {
return new $class($configurator);
}
return false;
} | php | public function buildLogger($class, Configurator $configurator)
{
if (!class_exists($class) || !is_subclass_of($class, Logger::class)) {
$class = "\\Phassets\\Loggers\\$class";
}
if (class_exists($class) && is_subclass_of($class, Logger::class)) {
return new $class($configurator);
}
return false;
} | [
"public",
"function",
"buildLogger",
"(",
"$",
"class",
",",
"Configurator",
"$",
"configurator",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
"||",
"!",
"is_subclass_of",
"(",
"$",
"class",
",",
"Logger",
"::",
"class",
")",
")",
"{",
"$",
"class",
"=",
"\"\\\\Phassets\\\\Loggers\\\\$class\"",
";",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"&&",
"is_subclass_of",
"(",
"$",
"class",
",",
"Logger",
"::",
"class",
")",
")",
"{",
"return",
"new",
"$",
"class",
"(",
"$",
"configurator",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Creates a Logger instance.
@param string $class Fully qualified class name of a Logger class
@param Configurator $configurator Currently used Configurator of Phassets
@return bool|Logger Created instance of the provided Logger; false on failure | [
"Creates",
"a",
"Logger",
"instance",
"."
]
| train | https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L50-L61 |
kattsoftware/phassets | src/Phassets/Factory.php | Factory.buildCacheAdapter | public function buildCacheAdapter($class, Configurator $configurator)
{
if (!class_exists($class) || !is_subclass_of($class, CacheAdapter::class)) {
$class = "\\Phassets\\CacheAdapters\\$class";
}
if (class_exists($class) && is_subclass_of($class, CacheAdapter::class)) {
return new $class($configurator);
}
return false;
} | php | public function buildCacheAdapter($class, Configurator $configurator)
{
if (!class_exists($class) || !is_subclass_of($class, CacheAdapter::class)) {
$class = "\\Phassets\\CacheAdapters\\$class";
}
if (class_exists($class) && is_subclass_of($class, CacheAdapter::class)) {
return new $class($configurator);
}
return false;
} | [
"public",
"function",
"buildCacheAdapter",
"(",
"$",
"class",
",",
"Configurator",
"$",
"configurator",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
"||",
"!",
"is_subclass_of",
"(",
"$",
"class",
",",
"CacheAdapter",
"::",
"class",
")",
")",
"{",
"$",
"class",
"=",
"\"\\\\Phassets\\\\CacheAdapters\\\\$class\"",
";",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"&&",
"is_subclass_of",
"(",
"$",
"class",
",",
"CacheAdapter",
"::",
"class",
")",
")",
"{",
"return",
"new",
"$",
"class",
"(",
"$",
"configurator",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Creates a CacheAdapter instance.
@param string $class Fully qualified class name of a CacheAdapter class
@param Configurator $configurator Currently used Configurator of Phassets
@return bool|CacheAdapter Created instance of the provided CacheAdapter; false on failure | [
"Creates",
"a",
"CacheAdapter",
"instance",
"."
]
| train | https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L71-L82 |
kattsoftware/phassets | src/Phassets/Factory.php | Factory.buildDeployer | public function buildDeployer($class, Configurator $configurator, CacheAdapter $cacheAdapter)
{
if (!class_exists($class) || !is_subclass_of($class, Deployer::class)) {
$class = "\\Phassets\\Deployers\\$class";
}
if (class_exists($class) && is_subclass_of($class, Deployer::class)) {
return new $class($configurator, $cacheAdapter);
}
return false;
} | php | public function buildDeployer($class, Configurator $configurator, CacheAdapter $cacheAdapter)
{
if (!class_exists($class) || !is_subclass_of($class, Deployer::class)) {
$class = "\\Phassets\\Deployers\\$class";
}
if (class_exists($class) && is_subclass_of($class, Deployer::class)) {
return new $class($configurator, $cacheAdapter);
}
return false;
} | [
"public",
"function",
"buildDeployer",
"(",
"$",
"class",
",",
"Configurator",
"$",
"configurator",
",",
"CacheAdapter",
"$",
"cacheAdapter",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
"||",
"!",
"is_subclass_of",
"(",
"$",
"class",
",",
"Deployer",
"::",
"class",
")",
")",
"{",
"$",
"class",
"=",
"\"\\\\Phassets\\\\Deployers\\\\$class\"",
";",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"&&",
"is_subclass_of",
"(",
"$",
"class",
",",
"Deployer",
"::",
"class",
")",
")",
"{",
"return",
"new",
"$",
"class",
"(",
"$",
"configurator",
",",
"$",
"cacheAdapter",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Creates a Deployer instance.
@param string $class Fully qualified class name of a Deployer class
@param Configurator $configurator Currently used Configurator of Phassets
@param CacheAdapter $cacheAdapter Currently used CacheAdapter of Phassets
@return Deployer|bool Created instance of the provided Deployer; false on failure | [
"Creates",
"a",
"Deployer",
"instance",
"."
]
| train | https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L104-L115 |
kattsoftware/phassets | src/Phassets/Factory.php | Factory.buildFilter | public function buildFilter($class, Configurator $configurator)
{
if (!class_exists($class) || !is_subclass_of($class, Filter::class)) {
$class = "\\Phassets\\Filters\\$class";
}
if (class_exists($class) && is_subclass_of($class, Filter::class)) {
return new $class($configurator);
}
return false;
} | php | public function buildFilter($class, Configurator $configurator)
{
if (!class_exists($class) || !is_subclass_of($class, Filter::class)) {
$class = "\\Phassets\\Filters\\$class";
}
if (class_exists($class) && is_subclass_of($class, Filter::class)) {
return new $class($configurator);
}
return false;
} | [
"public",
"function",
"buildFilter",
"(",
"$",
"class",
",",
"Configurator",
"$",
"configurator",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
"||",
"!",
"is_subclass_of",
"(",
"$",
"class",
",",
"Filter",
"::",
"class",
")",
")",
"{",
"$",
"class",
"=",
"\"\\\\Phassets\\\\Filters\\\\$class\"",
";",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"&&",
"is_subclass_of",
"(",
"$",
"class",
",",
"Filter",
"::",
"class",
")",
")",
"{",
"return",
"new",
"$",
"class",
"(",
"$",
"configurator",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Creates a Filter instance.
@param string $class Fully qualified class name of a Filter class
@param Configurator $configurator Currently used Configurator of Phassets
@return Filter|bool Created instance of the provided Filter; false on failure | [
"Creates",
"a",
"Filter",
"instance",
"."
]
| train | https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L125-L136 |
kattsoftware/phassets | src/Phassets/Factory.php | Factory.buildAssetsMerger | public function buildAssetsMerger($class, Configurator $configurator)
{
if (!class_exists($class) || !is_subclass_of($class, AssetsMerger::class)) {
$class = "\\Phassets\\AssetsMergers\\$class";
}
if (class_exists($class) && is_subclass_of($class, AssetsMerger::class)) {
return new $class($configurator);
}
return false;
} | php | public function buildAssetsMerger($class, Configurator $configurator)
{
if (!class_exists($class) || !is_subclass_of($class, AssetsMerger::class)) {
$class = "\\Phassets\\AssetsMergers\\$class";
}
if (class_exists($class) && is_subclass_of($class, AssetsMerger::class)) {
return new $class($configurator);
}
return false;
} | [
"public",
"function",
"buildAssetsMerger",
"(",
"$",
"class",
",",
"Configurator",
"$",
"configurator",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
"||",
"!",
"is_subclass_of",
"(",
"$",
"class",
",",
"AssetsMerger",
"::",
"class",
")",
")",
"{",
"$",
"class",
"=",
"\"\\\\Phassets\\\\AssetsMergers\\\\$class\"",
";",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"&&",
"is_subclass_of",
"(",
"$",
"class",
",",
"AssetsMerger",
"::",
"class",
")",
")",
"{",
"return",
"new",
"$",
"class",
"(",
"$",
"configurator",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Creates an AssetsMerger instance.
@param string $class Fully qualified class name of a AssetsMerger class
@param Configurator $configurator Currently used Configurator of Phassets
@return bool|AssetsMerger Created instance of the provided AssetsMerger; false on failure | [
"Creates",
"an",
"AssetsMerger",
"instance",
"."
]
| train | https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L166-L177 |
digitalkaoz/versioneye-php | src/Output/Products.php | Products.show | public function show(OutputInterface $output, array $response)
{
$this->printList($output,
['Name', 'Description', 'Source', 'Archive', 'Key', 'Type', 'License', 'Version', 'Group', 'Updated At'],
['name', 'description', 'links', 'archives', 'prod_key', 'prod_type', 'license_info', 'version', 'group_id', 'updated_at'],
$response,
function ($heading, $value) {
if ('Source' === $heading) {
if (!empty($value)) {
return array_pop($value)['link'];
}
}
if ('Archive' === $heading) {
return array_pop($value)['link'];
}
return $value;
}
);
$this->printTable($output,
['Name', 'Current', 'Requested'],
['name', 'parsed_version', 'version'],
$response['dependencies']
);
} | php | public function show(OutputInterface $output, array $response)
{
$this->printList($output,
['Name', 'Description', 'Source', 'Archive', 'Key', 'Type', 'License', 'Version', 'Group', 'Updated At'],
['name', 'description', 'links', 'archives', 'prod_key', 'prod_type', 'license_info', 'version', 'group_id', 'updated_at'],
$response,
function ($heading, $value) {
if ('Source' === $heading) {
if (!empty($value)) {
return array_pop($value)['link'];
}
}
if ('Archive' === $heading) {
return array_pop($value)['link'];
}
return $value;
}
);
$this->printTable($output,
['Name', 'Current', 'Requested'],
['name', 'parsed_version', 'version'],
$response['dependencies']
);
} | [
"public",
"function",
"show",
"(",
"OutputInterface",
"$",
"output",
",",
"array",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"printList",
"(",
"$",
"output",
",",
"[",
"'Name'",
",",
"'Description'",
",",
"'Source'",
",",
"'Archive'",
",",
"'Key'",
",",
"'Type'",
",",
"'License'",
",",
"'Version'",
",",
"'Group'",
",",
"'Updated At'",
"]",
",",
"[",
"'name'",
",",
"'description'",
",",
"'links'",
",",
"'archives'",
",",
"'prod_key'",
",",
"'prod_type'",
",",
"'license_info'",
",",
"'version'",
",",
"'group_id'",
",",
"'updated_at'",
"]",
",",
"$",
"response",
",",
"function",
"(",
"$",
"heading",
",",
"$",
"value",
")",
"{",
"if",
"(",
"'Source'",
"===",
"$",
"heading",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"array_pop",
"(",
"$",
"value",
")",
"[",
"'link'",
"]",
";",
"}",
"}",
"if",
"(",
"'Archive'",
"===",
"$",
"heading",
")",
"{",
"return",
"array_pop",
"(",
"$",
"value",
")",
"[",
"'link'",
"]",
";",
"}",
"return",
"$",
"value",
";",
"}",
")",
";",
"$",
"this",
"->",
"printTable",
"(",
"$",
"output",
",",
"[",
"'Name'",
",",
"'Current'",
",",
"'Requested'",
"]",
",",
"[",
"'name'",
",",
"'parsed_version'",
",",
"'version'",
"]",
",",
"$",
"response",
"[",
"'dependencies'",
"]",
")",
";",
"}"
]
| output for the show API.
@param OutputInterface $output
@param array $response | [
"output",
"for",
"the",
"show",
"API",
"."
]
| train | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Products.php#L42-L68 |
digitalkaoz/versioneye-php | src/Output/Products.php | Products.versions | public function versions(OutputInterface $output, array $response)
{
$this->printList($output,
['Name', 'Language', 'Key', 'Type', 'Version'],
['name', 'language', 'prod_key', 'prod_type', 'version'],
$response
);
$this->printTable($output,
['Version', 'Released At'],
['version', 'released_at'],
$response['versions'],
function ($key, $value) {
if ('released_at' !== $key) {
return $value;
}
return date('Y-m-d H:i:s', strtotime($value));
}
);
} | php | public function versions(OutputInterface $output, array $response)
{
$this->printList($output,
['Name', 'Language', 'Key', 'Type', 'Version'],
['name', 'language', 'prod_key', 'prod_type', 'version'],
$response
);
$this->printTable($output,
['Version', 'Released At'],
['version', 'released_at'],
$response['versions'],
function ($key, $value) {
if ('released_at' !== $key) {
return $value;
}
return date('Y-m-d H:i:s', strtotime($value));
}
);
} | [
"public",
"function",
"versions",
"(",
"OutputInterface",
"$",
"output",
",",
"array",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"printList",
"(",
"$",
"output",
",",
"[",
"'Name'",
",",
"'Language'",
",",
"'Key'",
",",
"'Type'",
",",
"'Version'",
"]",
",",
"[",
"'name'",
",",
"'language'",
",",
"'prod_key'",
",",
"'prod_type'",
",",
"'version'",
"]",
",",
"$",
"response",
")",
";",
"$",
"this",
"->",
"printTable",
"(",
"$",
"output",
",",
"[",
"'Version'",
",",
"'Released At'",
"]",
",",
"[",
"'version'",
",",
"'released_at'",
"]",
",",
"$",
"response",
"[",
"'versions'",
"]",
",",
"function",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"'released_at'",
"!==",
"$",
"key",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"strtotime",
"(",
"$",
"value",
")",
")",
";",
"}",
")",
";",
"}"
]
| output for the versions API.
@param OutputInterface $output
@param array $response | [
"output",
"for",
"the",
"versions",
"API",
"."
]
| train | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Products.php#L109-L129 |
CakeCMS/Core | src/View/Helper/LessHelper.php | LessHelper.initialize | public function initialize(array $config)
{
$corePath = Plugin::path('Core') . Configure::read('App.webroot') . '/' . Configure::read('App.lessBaseUrl');
$cachePath = WWW_ROOT . Configure::read('App.cssBaseUrl') . Configure::read('App.cacheDir');
$this
->setConfig('root_path', APP_ROOT)
->setConfig('cache_path', $cachePath)
->setConfig('root_url', Router::fullBaseUrl())
->setConfig('debug', Configure::read('debug'))
->setConfig('import_paths', [realpath($corePath) => realpath($corePath)]);
parent::initialize($config);
} | php | public function initialize(array $config)
{
$corePath = Plugin::path('Core') . Configure::read('App.webroot') . '/' . Configure::read('App.lessBaseUrl');
$cachePath = WWW_ROOT . Configure::read('App.cssBaseUrl') . Configure::read('App.cacheDir');
$this
->setConfig('root_path', APP_ROOT)
->setConfig('cache_path', $cachePath)
->setConfig('root_url', Router::fullBaseUrl())
->setConfig('debug', Configure::read('debug'))
->setConfig('import_paths', [realpath($corePath) => realpath($corePath)]);
parent::initialize($config);
} | [
"public",
"function",
"initialize",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"corePath",
"=",
"Plugin",
"::",
"path",
"(",
"'Core'",
")",
".",
"Configure",
"::",
"read",
"(",
"'App.webroot'",
")",
".",
"'/'",
".",
"Configure",
"::",
"read",
"(",
"'App.lessBaseUrl'",
")",
";",
"$",
"cachePath",
"=",
"WWW_ROOT",
".",
"Configure",
"::",
"read",
"(",
"'App.cssBaseUrl'",
")",
".",
"Configure",
"::",
"read",
"(",
"'App.cacheDir'",
")",
";",
"$",
"this",
"->",
"setConfig",
"(",
"'root_path'",
",",
"APP_ROOT",
")",
"->",
"setConfig",
"(",
"'cache_path'",
",",
"$",
"cachePath",
")",
"->",
"setConfig",
"(",
"'root_url'",
",",
"Router",
"::",
"fullBaseUrl",
"(",
")",
")",
"->",
"setConfig",
"(",
"'debug'",
",",
"Configure",
"::",
"read",
"(",
"'debug'",
")",
")",
"->",
"setConfig",
"(",
"'import_paths'",
",",
"[",
"realpath",
"(",
"$",
"corePath",
")",
"=>",
"realpath",
"(",
"$",
"corePath",
")",
"]",
")",
";",
"parent",
"::",
"initialize",
"(",
"$",
"config",
")",
";",
"}"
]
| Constructor hook method.
@param array $config | [
"Constructor",
"hook",
"method",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L50-L63 |
CakeCMS/Core | src/View/Helper/LessHelper.php | LessHelper.process | public function process($source, $force = true)
{
list ($webRoot, $source) = $this->_findWebRoot($source);
$lessFile = FS::clean($webRoot . Configure::read('App.lessBaseUrl') . $source, '/');
$this->_setForce($force);
$less = new Less($this->_config);
if (!FS::isFile($lessFile)) {
return null;
}
list($source, $isExpired) = $less->compile($lessFile);
if ($isExpired) {
$cacheId = FS::firstLine($source);
$comment = '/* resource:' . str_replace(FS::clean(ROOT, '/'), '', $lessFile) . ' */' . PHP_EOL;
$fileHead = implode('', [$cacheId, Str::low($comment)]);
$css = $this->_normalizeContent($source, $fileHead);
$this->_write($source, $css);
}
$source = str_replace(FS::clean(APP_ROOT . '/' . Configure::read('App.webroot'), '/'), '', $source);
return $source;
} | php | public function process($source, $force = true)
{
list ($webRoot, $source) = $this->_findWebRoot($source);
$lessFile = FS::clean($webRoot . Configure::read('App.lessBaseUrl') . $source, '/');
$this->_setForce($force);
$less = new Less($this->_config);
if (!FS::isFile($lessFile)) {
return null;
}
list($source, $isExpired) = $less->compile($lessFile);
if ($isExpired) {
$cacheId = FS::firstLine($source);
$comment = '/* resource:' . str_replace(FS::clean(ROOT, '/'), '', $lessFile) . ' */' . PHP_EOL;
$fileHead = implode('', [$cacheId, Str::low($comment)]);
$css = $this->_normalizeContent($source, $fileHead);
$this->_write($source, $css);
}
$source = str_replace(FS::clean(APP_ROOT . '/' . Configure::read('App.webroot'), '/'), '', $source);
return $source;
} | [
"public",
"function",
"process",
"(",
"$",
"source",
",",
"$",
"force",
"=",
"true",
")",
"{",
"list",
"(",
"$",
"webRoot",
",",
"$",
"source",
")",
"=",
"$",
"this",
"->",
"_findWebRoot",
"(",
"$",
"source",
")",
";",
"$",
"lessFile",
"=",
"FS",
"::",
"clean",
"(",
"$",
"webRoot",
".",
"Configure",
"::",
"read",
"(",
"'App.lessBaseUrl'",
")",
".",
"$",
"source",
",",
"'/'",
")",
";",
"$",
"this",
"->",
"_setForce",
"(",
"$",
"force",
")",
";",
"$",
"less",
"=",
"new",
"Less",
"(",
"$",
"this",
"->",
"_config",
")",
";",
"if",
"(",
"!",
"FS",
"::",
"isFile",
"(",
"$",
"lessFile",
")",
")",
"{",
"return",
"null",
";",
"}",
"list",
"(",
"$",
"source",
",",
"$",
"isExpired",
")",
"=",
"$",
"less",
"->",
"compile",
"(",
"$",
"lessFile",
")",
";",
"if",
"(",
"$",
"isExpired",
")",
"{",
"$",
"cacheId",
"=",
"FS",
"::",
"firstLine",
"(",
"$",
"source",
")",
";",
"$",
"comment",
"=",
"'/* resource:'",
".",
"str_replace",
"(",
"FS",
"::",
"clean",
"(",
"ROOT",
",",
"'/'",
")",
",",
"''",
",",
"$",
"lessFile",
")",
".",
"' */'",
".",
"PHP_EOL",
";",
"$",
"fileHead",
"=",
"implode",
"(",
"''",
",",
"[",
"$",
"cacheId",
",",
"Str",
"::",
"low",
"(",
"$",
"comment",
")",
"]",
")",
";",
"$",
"css",
"=",
"$",
"this",
"->",
"_normalizeContent",
"(",
"$",
"source",
",",
"$",
"fileHead",
")",
";",
"$",
"this",
"->",
"_write",
"(",
"$",
"source",
",",
"$",
"css",
")",
";",
"}",
"$",
"source",
"=",
"str_replace",
"(",
"FS",
"::",
"clean",
"(",
"APP_ROOT",
".",
"'/'",
".",
"Configure",
"::",
"read",
"(",
"'App.webroot'",
")",
",",
"'/'",
")",
",",
"''",
",",
"$",
"source",
")",
";",
"return",
"$",
"source",
";",
"}"
]
| Process less file.
@param string $source
@param bool $force
@return string|null
@throws \JBZoo\Less\Exception | [
"Process",
"less",
"file",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L73-L99 |
CakeCMS/Core | src/View/Helper/LessHelper.php | LessHelper._compress | protected function _compress($code, $cacheId)
{
$code = (string) $code;
// remove comments
$code = preg_replace('#/\*[^*]*\*+([^/][^*]*\*+)*/#ius', '', $code);
$code = str_replace(
["\r\n", "\r", "\n", "\t", ' ', ' ', ' {', '{ ', ' }', '; ', ';;', ';;;', ';;;;', ';}'],
['', '', '', '', '', '', '{', '{', '}', ';', ';', ';', ';', '}'],
$code
); // remove tabs, spaces, newlines, etc.
// remove spaces after and before colons
$code = preg_replace('#([a-z\-])(:\s*|\s*:\s*|\s*:)#ius', '$1:', $code);
// spaces before "!important"
$code = preg_replace('#(\s*\!important)#ius', '!important', $code);
$code = Str::trim($code);
return implode('', [$cacheId, $code]);
} | php | protected function _compress($code, $cacheId)
{
$code = (string) $code;
// remove comments
$code = preg_replace('#/\*[^*]*\*+([^/][^*]*\*+)*/#ius', '', $code);
$code = str_replace(
["\r\n", "\r", "\n", "\t", ' ', ' ', ' {', '{ ', ' }', '; ', ';;', ';;;', ';;;;', ';}'],
['', '', '', '', '', '', '{', '{', '}', ';', ';', ';', ';', '}'],
$code
); // remove tabs, spaces, newlines, etc.
// remove spaces after and before colons
$code = preg_replace('#([a-z\-])(:\s*|\s*:\s*|\s*:)#ius', '$1:', $code);
// spaces before "!important"
$code = preg_replace('#(\s*\!important)#ius', '!important', $code);
$code = Str::trim($code);
return implode('', [$cacheId, $code]);
} | [
"protected",
"function",
"_compress",
"(",
"$",
"code",
",",
"$",
"cacheId",
")",
"{",
"$",
"code",
"=",
"(",
"string",
")",
"$",
"code",
";",
"// remove comments",
"$",
"code",
"=",
"preg_replace",
"(",
"'#/\\*[^*]*\\*+([^/][^*]*\\*+)*/#ius'",
",",
"''",
",",
"$",
"code",
")",
";",
"$",
"code",
"=",
"str_replace",
"(",
"[",
"\"\\r\\n\"",
",",
"\"\\r\"",
",",
"\"\\n\"",
",",
"\"\\t\"",
",",
"' '",
",",
"' '",
",",
"' {'",
",",
"'{ '",
",",
"' }'",
",",
"'; '",
",",
"';;'",
",",
"';;;'",
",",
"';;;;'",
",",
"';}'",
"]",
",",
"[",
"''",
",",
"''",
",",
"''",
",",
"''",
",",
"''",
",",
"''",
",",
"'{'",
",",
"'{'",
",",
"'}'",
",",
"';'",
",",
"';'",
",",
"';'",
",",
"';'",
",",
"'}'",
"]",
",",
"$",
"code",
")",
";",
"// remove tabs, spaces, newlines, etc.",
"// remove spaces after and before colons",
"$",
"code",
"=",
"preg_replace",
"(",
"'#([a-z\\-])(:\\s*|\\s*:\\s*|\\s*:)#ius'",
",",
"'$1:'",
",",
"$",
"code",
")",
";",
"// spaces before \"!important\"",
"$",
"code",
"=",
"preg_replace",
"(",
"'#(\\s*\\!important)#ius'",
",",
"'!important'",
",",
"$",
"code",
")",
";",
"$",
"code",
"=",
"Str",
"::",
"trim",
"(",
"$",
"code",
")",
";",
"return",
"implode",
"(",
"''",
",",
"[",
"$",
"cacheId",
",",
"$",
"code",
"]",
")",
";",
"}"
]
| CSS compressing.
@param string $code
@param string $cacheId
@return string | [
"CSS",
"compressing",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L108-L129 |
CakeCMS/Core | src/View/Helper/LessHelper.php | LessHelper._findWebRoot | protected function _findWebRoot($source)
{
$webRootDir = Configure::read('App.webroot');
$webRoot = APP_ROOT . DS . $webRootDir . DS;
list ($plugin, $source) = $this->_View->pluginSplit($source);
if ($plugin !== null && Plugin::loaded($plugin)) {
$webRoot = Plugin::path($plugin) . $webRootDir . DS;
}
return [FS::clean($webRoot, '/'), $source];
} | php | protected function _findWebRoot($source)
{
$webRootDir = Configure::read('App.webroot');
$webRoot = APP_ROOT . DS . $webRootDir . DS;
list ($plugin, $source) = $this->_View->pluginSplit($source);
if ($plugin !== null && Plugin::loaded($plugin)) {
$webRoot = Plugin::path($plugin) . $webRootDir . DS;
}
return [FS::clean($webRoot, '/'), $source];
} | [
"protected",
"function",
"_findWebRoot",
"(",
"$",
"source",
")",
"{",
"$",
"webRootDir",
"=",
"Configure",
"::",
"read",
"(",
"'App.webroot'",
")",
";",
"$",
"webRoot",
"=",
"APP_ROOT",
".",
"DS",
".",
"$",
"webRootDir",
".",
"DS",
";",
"list",
"(",
"$",
"plugin",
",",
"$",
"source",
")",
"=",
"$",
"this",
"->",
"_View",
"->",
"pluginSplit",
"(",
"$",
"source",
")",
";",
"if",
"(",
"$",
"plugin",
"!==",
"null",
"&&",
"Plugin",
"::",
"loaded",
"(",
"$",
"plugin",
")",
")",
"{",
"$",
"webRoot",
"=",
"Plugin",
"::",
"path",
"(",
"$",
"plugin",
")",
".",
"$",
"webRootDir",
".",
"DS",
";",
"}",
"return",
"[",
"FS",
"::",
"clean",
"(",
"$",
"webRoot",
",",
"'/'",
")",
",",
"$",
"source",
"]",
";",
"}"
]
| Find source webroot dir.
@param string $source
@return array | [
"Find",
"source",
"webroot",
"dir",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L137-L148 |
CakeCMS/Core | src/View/Helper/LessHelper.php | LessHelper._getPlgAssetUrl | protected function _getPlgAssetUrl($path)
{
$isPlugin = false;
$plgPaths = Configure::read('App.paths.plugins');
foreach ($plgPaths as $plgPath) {
$plgPath = ltrim(FS::clean($plgPath, '/'), '/');
if (preg_match('(' . quotemeta($plgPath) . ')', $path)) {
$path = str_replace($plgPath, '', $path);
return [true, $path];
}
}
foreach (Configure::read('plugins') as $name => $plgPath) {
$plgPath = FS::clean($plgPath, '/');
if (preg_match('(' . quotemeta($plgPath) . ')', $path)) {
$path = Str::low($name) . '/' . str_replace($plgPath, '', $path);
return [true, $path];
}
}
return [$isPlugin, $path];
} | php | protected function _getPlgAssetUrl($path)
{
$isPlugin = false;
$plgPaths = Configure::read('App.paths.plugins');
foreach ($plgPaths as $plgPath) {
$plgPath = ltrim(FS::clean($plgPath, '/'), '/');
if (preg_match('(' . quotemeta($plgPath) . ')', $path)) {
$path = str_replace($plgPath, '', $path);
return [true, $path];
}
}
foreach (Configure::read('plugins') as $name => $plgPath) {
$plgPath = FS::clean($plgPath, '/');
if (preg_match('(' . quotemeta($plgPath) . ')', $path)) {
$path = Str::low($name) . '/' . str_replace($plgPath, '', $path);
return [true, $path];
}
}
return [$isPlugin, $path];
} | [
"protected",
"function",
"_getPlgAssetUrl",
"(",
"$",
"path",
")",
"{",
"$",
"isPlugin",
"=",
"false",
";",
"$",
"plgPaths",
"=",
"Configure",
"::",
"read",
"(",
"'App.paths.plugins'",
")",
";",
"foreach",
"(",
"$",
"plgPaths",
"as",
"$",
"plgPath",
")",
"{",
"$",
"plgPath",
"=",
"ltrim",
"(",
"FS",
"::",
"clean",
"(",
"$",
"plgPath",
",",
"'/'",
")",
",",
"'/'",
")",
";",
"if",
"(",
"preg_match",
"(",
"'('",
".",
"quotemeta",
"(",
"$",
"plgPath",
")",
".",
"')'",
",",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"$",
"plgPath",
",",
"''",
",",
"$",
"path",
")",
";",
"return",
"[",
"true",
",",
"$",
"path",
"]",
";",
"}",
"}",
"foreach",
"(",
"Configure",
"::",
"read",
"(",
"'plugins'",
")",
"as",
"$",
"name",
"=>",
"$",
"plgPath",
")",
"{",
"$",
"plgPath",
"=",
"FS",
"::",
"clean",
"(",
"$",
"plgPath",
",",
"'/'",
")",
";",
"if",
"(",
"preg_match",
"(",
"'('",
".",
"quotemeta",
"(",
"$",
"plgPath",
")",
".",
"')'",
",",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"Str",
"::",
"low",
"(",
"$",
"name",
")",
".",
"'/'",
".",
"str_replace",
"(",
"$",
"plgPath",
",",
"''",
",",
"$",
"path",
")",
";",
"return",
"[",
"true",
",",
"$",
"path",
"]",
";",
"}",
"}",
"return",
"[",
"$",
"isPlugin",
",",
"$",
"path",
"]",
";",
"}"
]
| Get plugin asset url.
@param string $path
@return array | [
"Get",
"plugin",
"asset",
"url",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L167-L188 |
CakeCMS/Core | src/View/Helper/LessHelper.php | LessHelper._normalizeContent | protected function _normalizeContent($path, $fileHead)
{
$css = file_get_contents($path);
if (!$this->_configRead('debug')) {
$css = $this->_compress($css, $fileHead);
} else {
list ($first, $second) = explode(PHP_EOL, $css, 2);
if (preg_match('(\/* cacheid:)', $first)) {
$css = $second;
}
$css = implode('', [$fileHead, $css]);
}
return $this->_replaceUrl($css);
} | php | protected function _normalizeContent($path, $fileHead)
{
$css = file_get_contents($path);
if (!$this->_configRead('debug')) {
$css = $this->_compress($css, $fileHead);
} else {
list ($first, $second) = explode(PHP_EOL, $css, 2);
if (preg_match('(\/* cacheid:)', $first)) {
$css = $second;
}
$css = implode('', [$fileHead, $css]);
}
return $this->_replaceUrl($css);
} | [
"protected",
"function",
"_normalizeContent",
"(",
"$",
"path",
",",
"$",
"fileHead",
")",
"{",
"$",
"css",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_configRead",
"(",
"'debug'",
")",
")",
"{",
"$",
"css",
"=",
"$",
"this",
"->",
"_compress",
"(",
"$",
"css",
",",
"$",
"fileHead",
")",
";",
"}",
"else",
"{",
"list",
"(",
"$",
"first",
",",
"$",
"second",
")",
"=",
"explode",
"(",
"PHP_EOL",
",",
"$",
"css",
",",
"2",
")",
";",
"if",
"(",
"preg_match",
"(",
"'(\\/* cacheid:)'",
",",
"$",
"first",
")",
")",
"{",
"$",
"css",
"=",
"$",
"second",
";",
"}",
"$",
"css",
"=",
"implode",
"(",
"''",
",",
"[",
"$",
"fileHead",
",",
"$",
"css",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_replaceUrl",
"(",
"$",
"css",
")",
";",
"}"
]
| Normalize style file.
@param string $path
@param string $fileHead
@return mixed | [
"Normalize",
"style",
"file",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L197-L212 |
CakeCMS/Core | src/View/Helper/LessHelper.php | LessHelper._normalizePlgAssetUrl | protected function _normalizePlgAssetUrl($path)
{
$details = explode('/', $path, 3);
$pluginName = Inflector::camelize(trim($details[0], '/'));
if (Plugin::loaded($pluginName)) {
unset($details[0]);
$source = $pluginName . '.' . ltrim(implode('/', $details), '/');
return $this->_getAssetUrl($source);
}
return $this->_getAssetUrl($path);
} | php | protected function _normalizePlgAssetUrl($path)
{
$details = explode('/', $path, 3);
$pluginName = Inflector::camelize(trim($details[0], '/'));
if (Plugin::loaded($pluginName)) {
unset($details[0]);
$source = $pluginName . '.' . ltrim(implode('/', $details), '/');
return $this->_getAssetUrl($source);
}
return $this->_getAssetUrl($path);
} | [
"protected",
"function",
"_normalizePlgAssetUrl",
"(",
"$",
"path",
")",
"{",
"$",
"details",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
",",
"3",
")",
";",
"$",
"pluginName",
"=",
"Inflector",
"::",
"camelize",
"(",
"trim",
"(",
"$",
"details",
"[",
"0",
"]",
",",
"'/'",
")",
")",
";",
"if",
"(",
"Plugin",
"::",
"loaded",
"(",
"$",
"pluginName",
")",
")",
"{",
"unset",
"(",
"$",
"details",
"[",
"0",
"]",
")",
";",
"$",
"source",
"=",
"$",
"pluginName",
".",
"'.'",
".",
"ltrim",
"(",
"implode",
"(",
"'/'",
",",
"$",
"details",
")",
",",
"'/'",
")",
";",
"return",
"$",
"this",
"->",
"_getAssetUrl",
"(",
"$",
"source",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_getAssetUrl",
"(",
"$",
"path",
")",
";",
"}"
]
| Normalize plugin asset url.
@param string $path
@return string | [
"Normalize",
"plugin",
"asset",
"url",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L220-L232 |
CakeCMS/Core | src/View/Helper/LessHelper.php | LessHelper._replaceUrlCallback | protected function _replaceUrlCallback(array $match)
{
$assetPath = str_replace(Router::fullBaseUrl(), '', $match[2]);
$assetPath = trim(FS::clean($assetPath, '/'), '/');
$appDir = trim(FS::clean(APP_ROOT, '/'), '/');
list ($isPlugin, $assetPath) = $this->_getPlgAssetUrl($assetPath);
if (!$isPlugin) {
$assetPath = str_replace($appDir, '', $assetPath);
}
$assetPath = str_replace(Configure::read('App.webroot'), '', $assetPath);
$assetPath = FS::clean($assetPath, '/');
if ($isPlugin) {
return $this->_normalizePlgAssetUrl($assetPath);
}
return $this->_getAssetUrl($assetPath);
} | php | protected function _replaceUrlCallback(array $match)
{
$assetPath = str_replace(Router::fullBaseUrl(), '', $match[2]);
$assetPath = trim(FS::clean($assetPath, '/'), '/');
$appDir = trim(FS::clean(APP_ROOT, '/'), '/');
list ($isPlugin, $assetPath) = $this->_getPlgAssetUrl($assetPath);
if (!$isPlugin) {
$assetPath = str_replace($appDir, '', $assetPath);
}
$assetPath = str_replace(Configure::read('App.webroot'), '', $assetPath);
$assetPath = FS::clean($assetPath, '/');
if ($isPlugin) {
return $this->_normalizePlgAssetUrl($assetPath);
}
return $this->_getAssetUrl($assetPath);
} | [
"protected",
"function",
"_replaceUrlCallback",
"(",
"array",
"$",
"match",
")",
"{",
"$",
"assetPath",
"=",
"str_replace",
"(",
"Router",
"::",
"fullBaseUrl",
"(",
")",
",",
"''",
",",
"$",
"match",
"[",
"2",
"]",
")",
";",
"$",
"assetPath",
"=",
"trim",
"(",
"FS",
"::",
"clean",
"(",
"$",
"assetPath",
",",
"'/'",
")",
",",
"'/'",
")",
";",
"$",
"appDir",
"=",
"trim",
"(",
"FS",
"::",
"clean",
"(",
"APP_ROOT",
",",
"'/'",
")",
",",
"'/'",
")",
";",
"list",
"(",
"$",
"isPlugin",
",",
"$",
"assetPath",
")",
"=",
"$",
"this",
"->",
"_getPlgAssetUrl",
"(",
"$",
"assetPath",
")",
";",
"if",
"(",
"!",
"$",
"isPlugin",
")",
"{",
"$",
"assetPath",
"=",
"str_replace",
"(",
"$",
"appDir",
",",
"''",
",",
"$",
"assetPath",
")",
";",
"}",
"$",
"assetPath",
"=",
"str_replace",
"(",
"Configure",
"::",
"read",
"(",
"'App.webroot'",
")",
",",
"''",
",",
"$",
"assetPath",
")",
";",
"$",
"assetPath",
"=",
"FS",
"::",
"clean",
"(",
"$",
"assetPath",
",",
"'/'",
")",
";",
"if",
"(",
"$",
"isPlugin",
")",
"{",
"return",
"$",
"this",
"->",
"_normalizePlgAssetUrl",
"(",
"$",
"assetPath",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_getAssetUrl",
"(",
"$",
"assetPath",
")",
";",
"}"
]
| Replace url callback.
@param array $match
@return string | [
"Replace",
"url",
"callback",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L252-L272 |
CakeCMS/Core | src/View/Helper/LessHelper.php | LessHelper._write | protected function _write($path, $content)
{
$File = new File($path);
$File->write($content);
$File->exists();
} | php | protected function _write($path, $content)
{
$File = new File($path);
$File->write($content);
$File->exists();
} | [
"protected",
"function",
"_write",
"(",
"$",
"path",
",",
"$",
"content",
")",
"{",
"$",
"File",
"=",
"new",
"File",
"(",
"$",
"path",
")",
";",
"$",
"File",
"->",
"write",
"(",
"$",
"content",
")",
";",
"$",
"File",
"->",
"exists",
"(",
")",
";",
"}"
]
| Write content in to the file.
@param string $path
@param string $content
@return void | [
"Write",
"content",
"in",
"to",
"the",
"file",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L294-L299 |
inc2734/wp-share-buttons | src/App/Contract/Shortcode/Button.php | Button._get_requester | protected function _get_requester() {
$this_class = get_class( $this );
$this_class = explode( '\\', $this_class );
$this_class = array_pop( $this_class );
$requester_class = '\Inc2734\WP_Share_Buttons\App\Model\Requester\\' . $this_class;
if ( ! class_exists( $requester_class ) ) {
return;
}
return $requester_class;
} | php | protected function _get_requester() {
$this_class = get_class( $this );
$this_class = explode( '\\', $this_class );
$this_class = array_pop( $this_class );
$requester_class = '\Inc2734\WP_Share_Buttons\App\Model\Requester\\' . $this_class;
if ( ! class_exists( $requester_class ) ) {
return;
}
return $requester_class;
} | [
"protected",
"function",
"_get_requester",
"(",
")",
"{",
"$",
"this_class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"this_class",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this_class",
")",
";",
"$",
"this_class",
"=",
"array_pop",
"(",
"$",
"this_class",
")",
";",
"$",
"requester_class",
"=",
"'\\Inc2734\\WP_Share_Buttons\\App\\Model\\Requester\\\\'",
".",
"$",
"this_class",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"requester_class",
")",
")",
"{",
"return",
";",
"}",
"return",
"$",
"requester_class",
";",
"}"
]
| Return Requester class name
@return string | [
"Return",
"Requester",
"class",
"name"
]
| train | https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Contract/Shortcode/Button.php#L43-L54 |
inc2734/wp-share-buttons | src/App/Contract/Shortcode/Button.php | Button.render | protected function render( $filepath, $vars ) {
$filepath = __DIR__ . '/../../../view/' . $filepath . '.php';
if ( file_exists( $filepath ) ) {
ob_start();
// @todo Using getter method
// @codingStandardsIgnoreStart
extract( $vars );
// @codingStandardsIgnoreEnd
include( $filepath );
return ob_get_clean();
}
} | php | protected function render( $filepath, $vars ) {
$filepath = __DIR__ . '/../../../view/' . $filepath . '.php';
if ( file_exists( $filepath ) ) {
ob_start();
// @todo Using getter method
// @codingStandardsIgnoreStart
extract( $vars );
// @codingStandardsIgnoreEnd
include( $filepath );
return ob_get_clean();
}
} | [
"protected",
"function",
"render",
"(",
"$",
"filepath",
",",
"$",
"vars",
")",
"{",
"$",
"filepath",
"=",
"__DIR__",
".",
"'/../../../view/'",
".",
"$",
"filepath",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filepath",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"// @todo Using getter method",
"// @codingStandardsIgnoreStart",
"extract",
"(",
"$",
"vars",
")",
";",
"// @codingStandardsIgnoreEnd",
"include",
"(",
"$",
"filepath",
")",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}",
"}"
]
| Load shortcode
@param string $filepath
@param array $vars
@return string | [
"Load",
"shortcode"
]
| train | https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Contract/Shortcode/Button.php#L63-L74 |
yuncms/framework | src/notifications/models/DatabaseNotification.php | DatabaseNotification.getContent | public function getContent()
{
$params = $this->data->toArray();
$p = [];
foreach ($params as $name => $value) {
$p['{' . $name . '}'] = $value;
}
return strtr($this->template, $p);
} | php | public function getContent()
{
$params = $this->data->toArray();
$p = [];
foreach ($params as $name => $value) {
$p['{' . $name . '}'] = $value;
}
return strtr($this->template, $p);
} | [
"public",
"function",
"getContent",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"data",
"->",
"toArray",
"(",
")",
";",
"$",
"p",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"p",
"[",
"'{'",
".",
"$",
"name",
".",
"'}'",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"strtr",
"(",
"$",
"this",
"->",
"template",
",",
"$",
"p",
")",
";",
"}"
]
| 获取详细内容
@return string | [
"获取详细内容"
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/notifications/models/DatabaseNotification.php#L92-L100 |
factorio-item-browser/export-data | src/Registry/AbstractRegistry.php | AbstractRegistry.saveContent | protected function saveContent(string $hash, string $content): void
{
$this->adapter->save($this->namespace, $hash, $content);
$this->cache[$hash] = $content;
} | php | protected function saveContent(string $hash, string $content): void
{
$this->adapter->save($this->namespace, $hash, $content);
$this->cache[$hash] = $content;
} | [
"protected",
"function",
"saveContent",
"(",
"string",
"$",
"hash",
",",
"string",
"$",
"content",
")",
":",
"void",
"{",
"$",
"this",
"->",
"adapter",
"->",
"save",
"(",
"$",
"this",
"->",
"namespace",
",",
"$",
"hash",
",",
"$",
"content",
")",
";",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"]",
"=",
"$",
"content",
";",
"}"
]
| Saves the specified content into the registry.
@param string $hash
@param string $content | [
"Saves",
"the",
"specified",
"content",
"into",
"the",
"registry",
"."
]
| train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/AbstractRegistry.php#L51-L55 |
factorio-item-browser/export-data | src/Registry/AbstractRegistry.php | AbstractRegistry.loadContent | protected function loadContent(string $hash): ?string
{
if (!array_key_exists($hash, $this->cache)) {
$content = $this->adapter->load($this->namespace, $hash);
$this->cache[$hash] = is_string($content) ? $content : null;
}
return $this->cache[$hash];
} | php | protected function loadContent(string $hash): ?string
{
if (!array_key_exists($hash, $this->cache)) {
$content = $this->adapter->load($this->namespace, $hash);
$this->cache[$hash] = is_string($content) ? $content : null;
}
return $this->cache[$hash];
} | [
"protected",
"function",
"loadContent",
"(",
"string",
"$",
"hash",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"hash",
",",
"$",
"this",
"->",
"cache",
")",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"adapter",
"->",
"load",
"(",
"$",
"this",
"->",
"namespace",
",",
"$",
"hash",
")",
";",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"]",
"=",
"is_string",
"(",
"$",
"content",
")",
"?",
"$",
"content",
":",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"]",
";",
"}"
]
| Loads the content with the specified hash from the registry.
@param string $hash
@return string|null | [
"Loads",
"the",
"content",
"with",
"the",
"specified",
"hash",
"from",
"the",
"registry",
"."
]
| train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/AbstractRegistry.php#L62-L69 |
factorio-item-browser/export-data | src/Registry/AbstractRegistry.php | AbstractRegistry.deleteContent | protected function deleteContent(string $hash): void
{
$this->adapter->delete($this->namespace, $hash);
unset($this->cache[$hash]);
} | php | protected function deleteContent(string $hash): void
{
$this->adapter->delete($this->namespace, $hash);
unset($this->cache[$hash]);
} | [
"protected",
"function",
"deleteContent",
"(",
"string",
"$",
"hash",
")",
":",
"void",
"{",
"$",
"this",
"->",
"adapter",
"->",
"delete",
"(",
"$",
"this",
"->",
"namespace",
",",
"$",
"hash",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"]",
")",
";",
"}"
]
| Deletes the content with the specified hash from the registry.
@param string $hash | [
"Deletes",
"the",
"content",
"with",
"the",
"specified",
"hash",
"from",
"the",
"registry",
"."
]
| train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/AbstractRegistry.php#L75-L79 |
factorio-item-browser/export-data | src/Registry/AbstractRegistry.php | AbstractRegistry.decodeContent | protected function decodeContent(string $content): array
{
$result = json_decode($content, true);
return is_array($result) ? $result : [];
} | php | protected function decodeContent(string $content): array
{
$result = json_decode($content, true);
return is_array($result) ? $result : [];
} | [
"protected",
"function",
"decodeContent",
"(",
"string",
"$",
"content",
")",
":",
"array",
"{",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"content",
",",
"true",
")",
";",
"return",
"is_array",
"(",
"$",
"result",
")",
"?",
"$",
"result",
":",
"[",
"]",
";",
"}"
]
| Decodes the specified JSON content.
@param string $content
@return array | [
"Decodes",
"the",
"specified",
"JSON",
"content",
"."
]
| train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/AbstractRegistry.php#L96-L100 |
Ocramius/OcraDiCompiler | src/OcraDiCompiler/Definition/ClassListCompilerDefinition.php | ClassListCompilerDefinition.addClassToProcess | public function addClassToProcess($className)
{
if (!class_exists($className)) {
return false;
}
$this->classesToProcess[(string) $className] = true;
return true;
} | php | public function addClassToProcess($className)
{
if (!class_exists($className)) {
return false;
}
$this->classesToProcess[(string) $className] = true;
return true;
} | [
"public",
"function",
"addClassToProcess",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"classesToProcess",
"[",
"(",
"string",
")",
"$",
"className",
"]",
"=",
"true",
";",
"return",
"true",
";",
"}"
]
| Adds a class to the list of classes to be processed
@param string $className
@return bool true if the class was added, false if the class does not exist | [
"Adds",
"a",
"class",
"to",
"the",
"list",
"of",
"classes",
"to",
"be",
"processed"
]
| train | https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Definition/ClassListCompilerDefinition.php#L54-L62 |
amostajo/wordpress-plugin-core | src/psr4/Log.php | Log.instance | public static function instance()
{
if ( ! isset( self::$logger ) ) {
self::$logger = new Logger( self::$path );
}
return self::$logger;
} | php | public static function instance()
{
if ( ! isset( self::$logger ) ) {
self::$logger = new Logger( self::$path );
}
return self::$logger;
} | [
"public",
"static",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"logger",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"=",
"new",
"Logger",
"(",
"self",
"::",
"$",
"path",
")",
";",
"}",
"return",
"self",
"::",
"$",
"logger",
";",
"}"
]
| Returns Logger instance.
@since 1.0
@return mixed. | [
"Returns",
"Logger",
"instance",
"."
]
| train | https://github.com/amostajo/wordpress-plugin-core/blob/63aba30b07057df540c3af4dc50b92bd5501d6fd/src/psr4/Log.php#L65-L71 |
amostajo/wordpress-plugin-core | src/psr4/Log.php | Log.debug | public static function debug( $message, $values = [] )
{
$logger = self::instance();
if ( $logger ) {
$logger->debug(
$message,
is_array( $values )
? $values
: ( is_object( $values )
? (array)$values
: [ $values ]
)
);
}
} | php | public static function debug( $message, $values = [] )
{
$logger = self::instance();
if ( $logger ) {
$logger->debug(
$message,
is_array( $values )
? $values
: ( is_object( $values )
? (array)$values
: [ $values ]
)
);
}
} | [
"public",
"static",
"function",
"debug",
"(",
"$",
"message",
",",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"$",
"logger",
"=",
"self",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"$",
"message",
",",
"is_array",
"(",
"$",
"values",
")",
"?",
"$",
"values",
":",
"(",
"is_object",
"(",
"$",
"values",
")",
"?",
"(",
"array",
")",
"$",
"values",
":",
"[",
"$",
"values",
"]",
")",
")",
";",
"}",
"}"
]
| Debugs / prints value in log.
@since 1.0
@param mixed $message Message to debug.
@param array $values Value(s) to debug. | [
"Debugs",
"/",
"prints",
"value",
"in",
"log",
"."
]
| train | https://github.com/amostajo/wordpress-plugin-core/blob/63aba30b07057df540c3af4dc50b92bd5501d6fd/src/psr4/Log.php#L92-L106 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.getCriteria | public function getCriteria()
{
$gets = $this->request->get();
if (empty($this->routeData)) {
$criteria = array();
} else {
$criteria = $this->routeData;
}
foreach ($gets as $key => $value) {
if ($key[0] !== '!') {
$criteria[$key] = $value;
}
}
$criteria = array_merge($criteria,$this->getOr());
return $criteria;
} | php | public function getCriteria()
{
$gets = $this->request->get();
if (empty($this->routeData)) {
$criteria = array();
} else {
$criteria = $this->routeData;
}
foreach ($gets as $key => $value) {
if ($key[0] !== '!') {
$criteria[$key] = $value;
}
}
$criteria = array_merge($criteria,$this->getOr());
return $criteria;
} | [
"public",
"function",
"getCriteria",
"(",
")",
"{",
"$",
"gets",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"routeData",
")",
")",
"{",
"$",
"criteria",
"=",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"criteria",
"=",
"$",
"this",
"->",
"routeData",
";",
"}",
"foreach",
"(",
"$",
"gets",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"[",
"0",
"]",
"!==",
"'!'",
")",
"{",
"$",
"criteria",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"criteria",
"=",
"array_merge",
"(",
"$",
"criteria",
",",
"$",
"this",
"->",
"getOr",
"(",
")",
")",
";",
"return",
"$",
"criteria",
";",
"}"
]
| Get criteria of current request
@return array | [
"Get",
"criteria",
"of",
"current",
"request"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L63-L82 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.getOr | public function getOr()
{
$or = array();
if($this->request->get('!or')){
foreach ($this->request->get('!or') as $key => $value) {
if(is_array($value)){
foreach($value as $k => $v){
$or[] = array($key => $v);
}
}else{
$or[] = array($key => $value);
}
}
$or = array("!or" => $or);
}
return $or;
} | php | public function getOr()
{
$or = array();
if($this->request->get('!or')){
foreach ($this->request->get('!or') as $key => $value) {
if(is_array($value)){
foreach($value as $k => $v){
$or[] = array($key => $v);
}
}else{
$or[] = array($key => $value);
}
}
$or = array("!or" => $or);
}
return $or;
} | [
"public",
"function",
"getOr",
"(",
")",
"{",
"$",
"or",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'!or'",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'!or'",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"or",
"[",
"]",
"=",
"array",
"(",
"$",
"key",
"=>",
"$",
"v",
")",
";",
"}",
"}",
"else",
"{",
"$",
"or",
"[",
"]",
"=",
"array",
"(",
"$",
"key",
"=>",
"$",
"value",
")",
";",
"}",
"}",
"$",
"or",
"=",
"array",
"(",
"\"!or\"",
"=>",
"$",
"or",
")",
";",
"}",
"return",
"$",
"or",
";",
"}"
]
| Get **or** criteria of current request.
@return array | [
"Get",
"**",
"or",
"**",
"criteria",
"of",
"current",
"request",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L89-L110 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.getSort | public function getSort()
{
$sorts = $get = $this->request->get('!sort') ?: array();
foreach ($sorts as $key => &$value) {
$value = (int) $value;
}
return $sorts;
} | php | public function getSort()
{
$sorts = $get = $this->request->get('!sort') ?: array();
foreach ($sorts as $key => &$value) {
$value = (int) $value;
}
return $sorts;
} | [
"public",
"function",
"getSort",
"(",
")",
"{",
"$",
"sorts",
"=",
"$",
"get",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'!sort'",
")",
"?",
":",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"sorts",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"value",
";",
"}",
"return",
"$",
"sorts",
";",
"}"
]
| Get **sort** command of current request.
@return array | [
"Get",
"**",
"sort",
"**",
"command",
"of",
"current",
"request",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L117-L126 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.getLimit | public function getLimit()
{
$limit = $this->request->get('!limit');
if (is_null($limit) && !is_null($this->collection->option('limit'))) {
$limit = $this->collection->option('limit');
}
return $limit;
} | php | public function getLimit()
{
$limit = $this->request->get('!limit');
if (is_null($limit) && !is_null($this->collection->option('limit'))) {
$limit = $this->collection->option('limit');
}
return $limit;
} | [
"public",
"function",
"getLimit",
"(",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'!limit'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"limit",
")",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"collection",
"->",
"option",
"(",
"'limit'",
")",
")",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"collection",
"->",
"option",
"(",
"'limit'",
")",
";",
"}",
"return",
"$",
"limit",
";",
"}"
]
| Get **limit** command of current request.
@return array | [
"Get",
"**",
"limit",
"**",
"command",
"of",
"current",
"request",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L145-L154 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.search | public function search()
{
$entries = $this->collection->find($this->getCriteria())
->match($this->getMatch())
->sort($this->getSort())
->skip($this->getSkip())
->limit($this->getLimit());
$this->data['entries'] = $entries;
} | php | public function search()
{
$entries = $this->collection->find($this->getCriteria())
->match($this->getMatch())
->sort($this->getSort())
->skip($this->getSkip())
->limit($this->getLimit());
$this->data['entries'] = $entries;
} | [
"public",
"function",
"search",
"(",
")",
"{",
"$",
"entries",
"=",
"$",
"this",
"->",
"collection",
"->",
"find",
"(",
"$",
"this",
"->",
"getCriteria",
"(",
")",
")",
"->",
"match",
"(",
"$",
"this",
"->",
"getMatch",
"(",
")",
")",
"->",
"sort",
"(",
"$",
"this",
"->",
"getSort",
"(",
")",
")",
"->",
"skip",
"(",
"$",
"this",
"->",
"getSkip",
"(",
")",
")",
"->",
"limit",
"(",
"$",
"this",
"->",
"getLimit",
"(",
")",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'entries'",
"]",
"=",
"$",
"entries",
";",
"}"
]
| Handle **search / listing** request.
@return void | [
"Handle",
"**",
"search",
"/",
"listing",
"**",
"request",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L173-L182 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.create | public function create()
{
$entry = $this->collection->newInstance()->set($this->getCriteria());
$this->data['entry'] = $entry;
if ($this->request->isPost()) {
try {
$result = $entry->set($this->request->getBody())->save();
h('notification.info', $this->clazz.' created.');
h('controller.create.success', array(
'model' => $entry
));
} catch (Stop $e) {
throw $e;
} catch (Exception $e) {
// no more set notification.error since notificationmiddleware will
// write this later
// h('notification.error', $e);
h('controller.create.error', array(
'model' => $entry,
'error' => $e,
));
// rethrow error to make sure notificationmiddleware know what todo
throw $e;
}
}
} | php | public function create()
{
$entry = $this->collection->newInstance()->set($this->getCriteria());
$this->data['entry'] = $entry;
if ($this->request->isPost()) {
try {
$result = $entry->set($this->request->getBody())->save();
h('notification.info', $this->clazz.' created.');
h('controller.create.success', array(
'model' => $entry
));
} catch (Stop $e) {
throw $e;
} catch (Exception $e) {
// no more set notification.error since notificationmiddleware will
// write this later
// h('notification.error', $e);
h('controller.create.error', array(
'model' => $entry,
'error' => $e,
));
// rethrow error to make sure notificationmiddleware know what todo
throw $e;
}
}
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"entry",
"=",
"$",
"this",
"->",
"collection",
"->",
"newInstance",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"getCriteria",
"(",
")",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'entry'",
"]",
"=",
"$",
"entry",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"entry",
"->",
"set",
"(",
"$",
"this",
"->",
"request",
"->",
"getBody",
"(",
")",
")",
"->",
"save",
"(",
")",
";",
"h",
"(",
"'notification.info'",
",",
"$",
"this",
"->",
"clazz",
".",
"' created.'",
")",
";",
"h",
"(",
"'controller.create.success'",
",",
"array",
"(",
"'model'",
"=>",
"$",
"entry",
")",
")",
";",
"}",
"catch",
"(",
"Stop",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// no more set notification.error since notificationmiddleware will",
"// write this later",
"// h('notification.error', $e);",
"h",
"(",
"'controller.create.error'",
",",
"array",
"(",
"'model'",
"=>",
"$",
"entry",
",",
"'error'",
"=>",
"$",
"e",
",",
")",
")",
";",
"// rethrow error to make sure notificationmiddleware know what todo",
"throw",
"$",
"e",
";",
"}",
"}",
"}"
]
| Handle creation of new document.
@return void | [
"Handle",
"creation",
"of",
"new",
"document",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L189-L221 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.read | public function read($id)
{
$found = false;
try {
$this->data['entry'] = $entry = $this->collection->findOne($id);
} catch (Exception $e) {
// noop
}
if (isset($entry)) {
$found = true;
}
if (! $found) {
return $this->app->notFound();
}
} | php | public function read($id)
{
$found = false;
try {
$this->data['entry'] = $entry = $this->collection->findOne($id);
} catch (Exception $e) {
// noop
}
if (isset($entry)) {
$found = true;
}
if (! $found) {
return $this->app->notFound();
}
} | [
"public",
"function",
"read",
"(",
"$",
"id",
")",
"{",
"$",
"found",
"=",
"false",
";",
"try",
"{",
"$",
"this",
"->",
"data",
"[",
"'entry'",
"]",
"=",
"$",
"entry",
"=",
"$",
"this",
"->",
"collection",
"->",
"findOne",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// noop",
"}",
"if",
"(",
"isset",
"(",
"$",
"entry",
")",
")",
"{",
"$",
"found",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"->",
"notFound",
"(",
")",
";",
"}",
"}"
]
| Show a document **detail** by an ID.
@param mixed $id
@return void | [
"Show",
"a",
"document",
"**",
"detail",
"**",
"by",
"an",
"ID",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L230-L247 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.update | public function update($id)
{
try {
$entry = $this->collection->findOne($id);
} catch (Exception $e) {
// noop
}
if (is_null($entry)) {
return $this->app->notFound();
}
if ($this->request->isPost() || $this->request->isPut()) {
try {
$merged = array_merge(
isset($entry) ? $entry->dump() : array(),
$this->request->getBody() ?: array()
);
$entry->set($merged)->save();
h('notification.info', $this->clazz.' updated');
h('controller.update.success', array(
'model' => $entry,
));
} catch (Stop $e) {
throw $e;
} catch (Exception $e) {
h('notification.error', $e);
if (empty($entry)) {
$model = null;
}
h('controller.update.error', array(
'error' => $e,
'model' => $entry,
));
}
}
$this->data['entry'] = $entry;
} | php | public function update($id)
{
try {
$entry = $this->collection->findOne($id);
} catch (Exception $e) {
// noop
}
if (is_null($entry)) {
return $this->app->notFound();
}
if ($this->request->isPost() || $this->request->isPut()) {
try {
$merged = array_merge(
isset($entry) ? $entry->dump() : array(),
$this->request->getBody() ?: array()
);
$entry->set($merged)->save();
h('notification.info', $this->clazz.' updated');
h('controller.update.success', array(
'model' => $entry,
));
} catch (Stop $e) {
throw $e;
} catch (Exception $e) {
h('notification.error', $e);
if (empty($entry)) {
$model = null;
}
h('controller.update.error', array(
'error' => $e,
'model' => $entry,
));
}
}
$this->data['entry'] = $entry;
} | [
"public",
"function",
"update",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"entry",
"=",
"$",
"this",
"->",
"collection",
"->",
"findOne",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// noop",
"}",
"if",
"(",
"is_null",
"(",
"$",
"entry",
")",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"->",
"notFound",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"isPost",
"(",
")",
"||",
"$",
"this",
"->",
"request",
"->",
"isPut",
"(",
")",
")",
"{",
"try",
"{",
"$",
"merged",
"=",
"array_merge",
"(",
"isset",
"(",
"$",
"entry",
")",
"?",
"$",
"entry",
"->",
"dump",
"(",
")",
":",
"array",
"(",
")",
",",
"$",
"this",
"->",
"request",
"->",
"getBody",
"(",
")",
"?",
":",
"array",
"(",
")",
")",
";",
"$",
"entry",
"->",
"set",
"(",
"$",
"merged",
")",
"->",
"save",
"(",
")",
";",
"h",
"(",
"'notification.info'",
",",
"$",
"this",
"->",
"clazz",
".",
"' updated'",
")",
";",
"h",
"(",
"'controller.update.success'",
",",
"array",
"(",
"'model'",
"=>",
"$",
"entry",
",",
")",
")",
";",
"}",
"catch",
"(",
"Stop",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"h",
"(",
"'notification.error'",
",",
"$",
"e",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"entry",
")",
")",
"{",
"$",
"model",
"=",
"null",
";",
"}",
"h",
"(",
"'controller.update.error'",
",",
"array",
"(",
"'error'",
"=>",
"$",
"e",
",",
"'model'",
"=>",
"$",
"entry",
",",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"data",
"[",
"'entry'",
"]",
"=",
"$",
"entry",
";",
"}"
]
| Perform **updating** a document.
@param mixed $id
@return void | [
"Perform",
"**",
"updating",
"**",
"a",
"document",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L256-L299 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.delete | public function delete($id)
{
$id = explode(',', $id);
if ($this->request->isPost() || $this->request->isDelete()) {
$single = false;
if (count($id) === 1) {
$single = true;
}
try {
$this->data['entries'] = array();
foreach ($id as $value) {
$model = $this->collection->findOne($value);
if (is_null($model)) {
if ($single) {
$this->app->notFound();
}
continue;
}
$model->remove();
$this->data['entries'][] = $model;
}
h('notification.info', $this->clazz.' deleted.');
h('controller.delete.success', array(
'models' => $this->data['entries'],
));
} catch (Stop $e) {
throw $e;
} catch (Exception $e) {
h('notification.error', $e);
if (empty($model)) {
$model = null;
}
h('controller.delete.error', array(
'error' => $e,
'model' => $model,
));
}
}
} | php | public function delete($id)
{
$id = explode(',', $id);
if ($this->request->isPost() || $this->request->isDelete()) {
$single = false;
if (count($id) === 1) {
$single = true;
}
try {
$this->data['entries'] = array();
foreach ($id as $value) {
$model = $this->collection->findOne($value);
if (is_null($model)) {
if ($single) {
$this->app->notFound();
}
continue;
}
$model->remove();
$this->data['entries'][] = $model;
}
h('notification.info', $this->clazz.' deleted.');
h('controller.delete.success', array(
'models' => $this->data['entries'],
));
} catch (Stop $e) {
throw $e;
} catch (Exception $e) {
h('notification.error', $e);
if (empty($model)) {
$model = null;
}
h('controller.delete.error', array(
'error' => $e,
'model' => $model,
));
}
}
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"explode",
"(",
"','",
",",
"$",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"isPost",
"(",
")",
"||",
"$",
"this",
"->",
"request",
"->",
"isDelete",
"(",
")",
")",
"{",
"$",
"single",
"=",
"false",
";",
"if",
"(",
"count",
"(",
"$",
"id",
")",
"===",
"1",
")",
"{",
"$",
"single",
"=",
"true",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"data",
"[",
"'entries'",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"id",
"as",
"$",
"value",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"collection",
"->",
"findOne",
"(",
"$",
"value",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"model",
")",
")",
"{",
"if",
"(",
"$",
"single",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"notFound",
"(",
")",
";",
"}",
"continue",
";",
"}",
"$",
"model",
"->",
"remove",
"(",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'entries'",
"]",
"[",
"]",
"=",
"$",
"model",
";",
"}",
"h",
"(",
"'notification.info'",
",",
"$",
"this",
"->",
"clazz",
".",
"' deleted.'",
")",
";",
"h",
"(",
"'controller.delete.success'",
",",
"array",
"(",
"'models'",
"=>",
"$",
"this",
"->",
"data",
"[",
"'entries'",
"]",
",",
")",
")",
";",
"}",
"catch",
"(",
"Stop",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"h",
"(",
"'notification.error'",
",",
"$",
"e",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"model",
")",
")",
"{",
"$",
"model",
"=",
"null",
";",
"}",
"h",
"(",
"'controller.delete.error'",
",",
"array",
"(",
"'error'",
"=>",
"$",
"e",
",",
"'model'",
"=>",
"$",
"model",
",",
")",
")",
";",
"}",
"}",
"}"
]
| Perform **deletion** of a document by an ID given.
@param mixed $id
@return void | [
"Perform",
"**",
"deletion",
"**",
"of",
"a",
"document",
"by",
"an",
"ID",
"given",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L308-L359 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.schema | public function schema($schema = null)
{
if (func_num_args() === 0) {
return $this->collection->schema();
}
return $this->collection->schema($schema);
} | php | public function schema($schema = null)
{
if (func_num_args() === 0) {
return $this->collection->schema();
}
return $this->collection->schema($schema);
} | [
"public",
"function",
"schema",
"(",
"$",
"schema",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"collection",
"->",
"schema",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"collection",
"->",
"schema",
"(",
"$",
"schema",
")",
";",
"}"
]
| Get schema of collection
@param string|null $schema
@return mixed | [
"Get",
"schema",
"of",
"collection"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L368-L375 |
xinix-technology/norm | src/Norm/Controller/NormController.php | NormController.routeModel | public function routeModel($key)
{
if (! isset($this->routeModels[$key])) {
$Clazz = Inflector::classify($key);
$collection = Norm::factory($this->schema($key)->get('foreign'));
$this->routeModels[$key] = $collection->findOne($this->routeData($key));
}
return $this->routeModels[$key];
} | php | public function routeModel($key)
{
if (! isset($this->routeModels[$key])) {
$Clazz = Inflector::classify($key);
$collection = Norm::factory($this->schema($key)->get('foreign'));
$this->routeModels[$key] = $collection->findOne($this->routeData($key));
}
return $this->routeModels[$key];
} | [
"public",
"function",
"routeModel",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"routeModels",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"Clazz",
"=",
"Inflector",
"::",
"classify",
"(",
"$",
"key",
")",
";",
"$",
"collection",
"=",
"Norm",
"::",
"factory",
"(",
"$",
"this",
"->",
"schema",
"(",
"$",
"key",
")",
"->",
"get",
"(",
"'foreign'",
")",
")",
";",
"$",
"this",
"->",
"routeModels",
"[",
"$",
"key",
"]",
"=",
"$",
"collection",
"->",
"findOne",
"(",
"$",
"this",
"->",
"routeData",
"(",
"$",
"key",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"routeModels",
"[",
"$",
"key",
"]",
";",
"}"
]
| Register a route model.
@param string $key
@return mixed | [
"Register",
"a",
"route",
"model",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L396-L407 |
SachaMorard/phalcon-console | Library/Phalcon/Script.php | Script.dispatch | public function dispatch(Command $command)
{
// If beforeCommand fails abort
if ($this->_eventsManager->fire('command:beforeCommand', $command) === false) {
return false;
}
// If run the commands fails abort too
if ($command->run($command->getParameters()) === false) {
return false;
}
$this->_eventsManager->fire('command:afterCommand', $command);
return true;
} | php | public function dispatch(Command $command)
{
// If beforeCommand fails abort
if ($this->_eventsManager->fire('command:beforeCommand', $command) === false) {
return false;
}
// If run the commands fails abort too
if ($command->run($command->getParameters()) === false) {
return false;
}
$this->_eventsManager->fire('command:afterCommand', $command);
return true;
} | [
"public",
"function",
"dispatch",
"(",
"Command",
"$",
"command",
")",
"{",
"// If beforeCommand fails abort",
"if",
"(",
"$",
"this",
"->",
"_eventsManager",
"->",
"fire",
"(",
"'command:beforeCommand'",
",",
"$",
"command",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"// If run the commands fails abort too",
"if",
"(",
"$",
"command",
"->",
"run",
"(",
"$",
"command",
"->",
"getParameters",
"(",
")",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_eventsManager",
"->",
"fire",
"(",
"'command:afterCommand'",
",",
"$",
"command",
")",
";",
"return",
"true",
";",
"}"
]
| Dispatch the Command
@param Command $command
@return bool | [
"Dispatch",
"the",
"Command"
]
| train | https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Script.php#L108-L123 |
SachaMorard/phalcon-console | Library/Phalcon/Script.php | Script.run | public function run()
{
if (!isset($_SERVER['argv'][1])) {
$_SERVER['argv'][1] = 'commands';
}
$input = $_SERVER['argv'][1];
// Force `commands` command
if (in_array(strtolower(trim($input)), ['-h', '--help', 'help'], true)) {
$input = $_SERVER['argv'][1] = 'commands';
}
if (in_array(strtolower(trim($input)), ['--version', '-v', '--info'], true)) {
$input = $_SERVER['argv'][1] = 'info';
}
// Try to dispatch the command
foreach ($this->_commands as $command) {
if ($command->hasIdentifier($input)) {
return $this->dispatch($command);
}
}
// Check for alternatives
$available = [];
foreach ($this->_commands as $command) {
$providedCommands = $command->getCommands();
foreach ($providedCommands as $alias) {
$soundex = soundex($alias);
if (!isset($available[$soundex])) {
$available[$soundex] = [];
}
$available[$soundex][] = $alias;
}
}
// Show exception with/without alternatives
$soundex = soundex($input);
$message = sprintf('%s is not a recognized command.', $input);
if (isset($available[$soundex])) {
throw new ScriptException(sprintf('%s Did you mean: %s?', $message, join(' or ', $available[$soundex])));
}
throw new ScriptException($message);
} | php | public function run()
{
if (!isset($_SERVER['argv'][1])) {
$_SERVER['argv'][1] = 'commands';
}
$input = $_SERVER['argv'][1];
// Force `commands` command
if (in_array(strtolower(trim($input)), ['-h', '--help', 'help'], true)) {
$input = $_SERVER['argv'][1] = 'commands';
}
if (in_array(strtolower(trim($input)), ['--version', '-v', '--info'], true)) {
$input = $_SERVER['argv'][1] = 'info';
}
// Try to dispatch the command
foreach ($this->_commands as $command) {
if ($command->hasIdentifier($input)) {
return $this->dispatch($command);
}
}
// Check for alternatives
$available = [];
foreach ($this->_commands as $command) {
$providedCommands = $command->getCommands();
foreach ($providedCommands as $alias) {
$soundex = soundex($alias);
if (!isset($available[$soundex])) {
$available[$soundex] = [];
}
$available[$soundex][] = $alias;
}
}
// Show exception with/without alternatives
$soundex = soundex($input);
$message = sprintf('%s is not a recognized command.', $input);
if (isset($available[$soundex])) {
throw new ScriptException(sprintf('%s Did you mean: %s?', $message, join(' or ', $available[$soundex])));
}
throw new ScriptException($message);
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SERVER",
"[",
"'argv'",
"]",
"[",
"1",
"]",
")",
")",
"{",
"$",
"_SERVER",
"[",
"'argv'",
"]",
"[",
"1",
"]",
"=",
"'commands'",
";",
"}",
"$",
"input",
"=",
"$",
"_SERVER",
"[",
"'argv'",
"]",
"[",
"1",
"]",
";",
"// Force `commands` command",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"input",
")",
")",
",",
"[",
"'-h'",
",",
"'--help'",
",",
"'help'",
"]",
",",
"true",
")",
")",
"{",
"$",
"input",
"=",
"$",
"_SERVER",
"[",
"'argv'",
"]",
"[",
"1",
"]",
"=",
"'commands'",
";",
"}",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"input",
")",
")",
",",
"[",
"'--version'",
",",
"'-v'",
",",
"'--info'",
"]",
",",
"true",
")",
")",
"{",
"$",
"input",
"=",
"$",
"_SERVER",
"[",
"'argv'",
"]",
"[",
"1",
"]",
"=",
"'info'",
";",
"}",
"// Try to dispatch the command",
"foreach",
"(",
"$",
"this",
"->",
"_commands",
"as",
"$",
"command",
")",
"{",
"if",
"(",
"$",
"command",
"->",
"hasIdentifier",
"(",
"$",
"input",
")",
")",
"{",
"return",
"$",
"this",
"->",
"dispatch",
"(",
"$",
"command",
")",
";",
"}",
"}",
"// Check for alternatives",
"$",
"available",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_commands",
"as",
"$",
"command",
")",
"{",
"$",
"providedCommands",
"=",
"$",
"command",
"->",
"getCommands",
"(",
")",
";",
"foreach",
"(",
"$",
"providedCommands",
"as",
"$",
"alias",
")",
"{",
"$",
"soundex",
"=",
"soundex",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"available",
"[",
"$",
"soundex",
"]",
")",
")",
"{",
"$",
"available",
"[",
"$",
"soundex",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"available",
"[",
"$",
"soundex",
"]",
"[",
"]",
"=",
"$",
"alias",
";",
"}",
"}",
"// Show exception with/without alternatives",
"$",
"soundex",
"=",
"soundex",
"(",
"$",
"input",
")",
";",
"$",
"message",
"=",
"sprintf",
"(",
"'%s is not a recognized command.'",
",",
"$",
"input",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"available",
"[",
"$",
"soundex",
"]",
")",
")",
"{",
"throw",
"new",
"ScriptException",
"(",
"sprintf",
"(",
"'%s Did you mean: %s?'",
",",
"$",
"message",
",",
"join",
"(",
"' or '",
",",
"$",
"available",
"[",
"$",
"soundex",
"]",
")",
")",
")",
";",
"}",
"throw",
"new",
"ScriptException",
"(",
"$",
"message",
")",
";",
"}"
]
| Run the scripts
@throws ScriptException | [
"Run",
"the",
"scripts"
]
| train | https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Script.php#L130-L177 |
wucdbm/php-cs-fixers | src/Fixer/EnsureBlankLineAfterClassOpeningFixer.php | EnsureBlankLineAfterClassOpeningFixer.applyFix | protected function applyFix(\SplFileInfo $file, Tokens $tokens) {
foreach ($tokens as $index => $token) {
if (!$token->isClassy()) {
continue;
}
$startBraceIndex = $tokens->getNextTokenOfKind($index, ['{']);
$whitespace = $this->createBlankLine($tokens, $startBraceIndex);
$whiteSpaceIndex = $startBraceIndex + 1;
if (!$tokens[$whiteSpaceIndex]->isWhitespace()) {
// If there is no white space at all, we need two lines and a single indentation
// But in case the declaration is wrapped in an if statement,
// Then we need the current indentation
$closingBraceIndex = $startBraceIndex + 1;
$isClosingBrace = '}' === $tokens[$closingBraceIndex]->getContent();
if (!$isClosingBrace) {
// Plus one additional if the next token is not a closing brace
// If there is no white space after the opening brace
// And the next token is NOT a closing brace
// Then we need an additional indent
$whitespace .= $this->whitespacesConfig->getIndent();
}
$tokens->insertAt($whiteSpaceIndex, new Token([T_WHITESPACE, $whitespace]));
} else {
// If there is any white space, then we can just replace it
// What we need is two line endings, the class declaration indentation
$closingBraceIndex = $whiteSpaceIndex + 1;
$isClosingBrace = '}' === $tokens[$closingBraceIndex]->getContent();
if (!$isClosingBrace) {
// And another indent for any following NON-WHITESPACE Token (property, constant, method, etc)
// But ONLY IF the next token is NOT a closing brace
// Which would need to remain at its class declaration indentation
$whitespace .= $this->whitespacesConfig->getIndent();
}
$tokens[$whiteSpaceIndex] = new Token([T_WHITESPACE, $whitespace]);
}
}
} | php | protected function applyFix(\SplFileInfo $file, Tokens $tokens) {
foreach ($tokens as $index => $token) {
if (!$token->isClassy()) {
continue;
}
$startBraceIndex = $tokens->getNextTokenOfKind($index, ['{']);
$whitespace = $this->createBlankLine($tokens, $startBraceIndex);
$whiteSpaceIndex = $startBraceIndex + 1;
if (!$tokens[$whiteSpaceIndex]->isWhitespace()) {
// If there is no white space at all, we need two lines and a single indentation
// But in case the declaration is wrapped in an if statement,
// Then we need the current indentation
$closingBraceIndex = $startBraceIndex + 1;
$isClosingBrace = '}' === $tokens[$closingBraceIndex]->getContent();
if (!$isClosingBrace) {
// Plus one additional if the next token is not a closing brace
// If there is no white space after the opening brace
// And the next token is NOT a closing brace
// Then we need an additional indent
$whitespace .= $this->whitespacesConfig->getIndent();
}
$tokens->insertAt($whiteSpaceIndex, new Token([T_WHITESPACE, $whitespace]));
} else {
// If there is any white space, then we can just replace it
// What we need is two line endings, the class declaration indentation
$closingBraceIndex = $whiteSpaceIndex + 1;
$isClosingBrace = '}' === $tokens[$closingBraceIndex]->getContent();
if (!$isClosingBrace) {
// And another indent for any following NON-WHITESPACE Token (property, constant, method, etc)
// But ONLY IF the next token is NOT a closing brace
// Which would need to remain at its class declaration indentation
$whitespace .= $this->whitespacesConfig->getIndent();
}
$tokens[$whiteSpaceIndex] = new Token([T_WHITESPACE, $whitespace]);
}
}
} | [
"protected",
"function",
"applyFix",
"(",
"\\",
"SplFileInfo",
"$",
"file",
",",
"Tokens",
"$",
"tokens",
")",
"{",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"index",
"=>",
"$",
"token",
")",
"{",
"if",
"(",
"!",
"$",
"token",
"->",
"isClassy",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"startBraceIndex",
"=",
"$",
"tokens",
"->",
"getNextTokenOfKind",
"(",
"$",
"index",
",",
"[",
"'{'",
"]",
")",
";",
"$",
"whitespace",
"=",
"$",
"this",
"->",
"createBlankLine",
"(",
"$",
"tokens",
",",
"$",
"startBraceIndex",
")",
";",
"$",
"whiteSpaceIndex",
"=",
"$",
"startBraceIndex",
"+",
"1",
";",
"if",
"(",
"!",
"$",
"tokens",
"[",
"$",
"whiteSpaceIndex",
"]",
"->",
"isWhitespace",
"(",
")",
")",
"{",
"// If there is no white space at all, we need two lines and a single indentation",
"// But in case the declaration is wrapped in an if statement,",
"// Then we need the current indentation",
"$",
"closingBraceIndex",
"=",
"$",
"startBraceIndex",
"+",
"1",
";",
"$",
"isClosingBrace",
"=",
"'}'",
"===",
"$",
"tokens",
"[",
"$",
"closingBraceIndex",
"]",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"isClosingBrace",
")",
"{",
"// Plus one additional if the next token is not a closing brace",
"// If there is no white space after the opening brace",
"// And the next token is NOT a closing brace",
"// Then we need an additional indent",
"$",
"whitespace",
".=",
"$",
"this",
"->",
"whitespacesConfig",
"->",
"getIndent",
"(",
")",
";",
"}",
"$",
"tokens",
"->",
"insertAt",
"(",
"$",
"whiteSpaceIndex",
",",
"new",
"Token",
"(",
"[",
"T_WHITESPACE",
",",
"$",
"whitespace",
"]",
")",
")",
";",
"}",
"else",
"{",
"// If there is any white space, then we can just replace it",
"// What we need is two line endings, the class declaration indentation",
"$",
"closingBraceIndex",
"=",
"$",
"whiteSpaceIndex",
"+",
"1",
";",
"$",
"isClosingBrace",
"=",
"'}'",
"===",
"$",
"tokens",
"[",
"$",
"closingBraceIndex",
"]",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"isClosingBrace",
")",
"{",
"// And another indent for any following NON-WHITESPACE Token (property, constant, method, etc)",
"// But ONLY IF the next token is NOT a closing brace",
"// Which would need to remain at its class declaration indentation",
"$",
"whitespace",
".=",
"$",
"this",
"->",
"whitespacesConfig",
"->",
"getIndent",
"(",
")",
";",
"}",
"$",
"tokens",
"[",
"$",
"whiteSpaceIndex",
"]",
"=",
"new",
"Token",
"(",
"[",
"T_WHITESPACE",
",",
"$",
"whitespace",
"]",
")",
";",
"}",
"}",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/wucdbm/php-cs-fixers/blob/5b12529bd0f81e0c7eb2cebd61b11cd65f279f9e/src/Fixer/EnsureBlankLineAfterClassOpeningFixer.php#L59-L103 |
ClanCats/Core | src/bundles/Database/DB.php | DB.fetch | public static function fetch( $query, $params = array(), $handler = null, $arguments = array( 'obj' ) )
{
return Handler::create( $handler )->fetch( $query, $params, $arguments );
} | php | public static function fetch( $query, $params = array(), $handler = null, $arguments = array( 'obj' ) )
{
return Handler::create( $handler )->fetch( $query, $params, $arguments );
} | [
"public",
"static",
"function",
"fetch",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"handler",
"=",
"null",
",",
"$",
"arguments",
"=",
"array",
"(",
"'obj'",
")",
")",
"{",
"return",
"Handler",
"::",
"create",
"(",
"$",
"handler",
")",
"->",
"fetch",
"(",
"$",
"query",
",",
"$",
"params",
",",
"$",
"arguments",
")",
";",
"}"
]
| Fetch data from an sql query
Returns always an array of results
@param string $query
@param array $params
@return array | [
"Fetch",
"data",
"from",
"an",
"sql",
"query",
"Returns",
"always",
"an",
"array",
"of",
"results"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L86-L89 |
ClanCats/Core | src/bundles/Database/DB.php | DB.run | public static function run( $query, $params = array(), $handler = null )
{
return Handler::create( $handler )->run( $query, $params );
} | php | public static function run( $query, $params = array(), $handler = null )
{
return Handler::create( $handler )->run( $query, $params );
} | [
"public",
"static",
"function",
"run",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"return",
"Handler",
"::",
"create",
"(",
"$",
"handler",
")",
"->",
"run",
"(",
"$",
"query",
",",
"$",
"params",
")",
";",
"}"
]
| Run an sql statement will return the number of affected rows
@param string $query
@param array $params
@return mixed | [
"Run",
"an",
"sql",
"statement",
"will",
"return",
"the",
"number",
"of",
"affected",
"rows"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L98-L101 |
ClanCats/Core | src/bundles/Database/DB.php | DB.select | public static function select( $table, $fields = array(), $handler = null )
{
return Query::select( $table, $fields, $handler );
} | php | public static function select( $table, $fields = array(), $handler = null )
{
return Query::select( $table, $fields, $handler );
} | [
"public",
"static",
"function",
"select",
"(",
"$",
"table",
",",
"$",
"fields",
"=",
"array",
"(",
")",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"return",
"Query",
"::",
"select",
"(",
"$",
"table",
",",
"$",
"fields",
",",
"$",
"handler",
")",
";",
"}"
]
| Select data from the database
@param string $table
@param array $fields
@return mixed | [
"Select",
"data",
"from",
"the",
"database"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L110-L113 |
ClanCats/Core | src/bundles/Database/DB.php | DB.model | public static function model( $model, $handler = null )
{
$model_data = call_user_func( $model.'::_model' );
return Query::select( $model_data['table'], null, $model_data['handler'] )
->fetch_handler( $model.'::_fetch_handler' );
} | php | public static function model( $model, $handler = null )
{
$model_data = call_user_func( $model.'::_model' );
return Query::select( $model_data['table'], null, $model_data['handler'] )
->fetch_handler( $model.'::_fetch_handler' );
} | [
"public",
"static",
"function",
"model",
"(",
"$",
"model",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"$",
"model_data",
"=",
"call_user_func",
"(",
"$",
"model",
".",
"'::_model'",
")",
";",
"return",
"Query",
"::",
"select",
"(",
"$",
"model_data",
"[",
"'table'",
"]",
",",
"null",
",",
"$",
"model_data",
"[",
"'handler'",
"]",
")",
"->",
"fetch_handler",
"(",
"$",
"model",
".",
"'::_fetch_handler'",
")",
";",
"}"
]
| Create a select query with an model assignment
@param string $table
@param array $fields
@return mixed | [
"Create",
"a",
"select",
"query",
"with",
"an",
"model",
"assignment"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L122-L127 |
ClanCats/Core | src/bundles/Database/DB.php | DB.find | public static function find( $table, $id, $key = null, $handler = null )
{
return Query::select( $table )->find( $id, $key, $handler );
} | php | public static function find( $table, $id, $key = null, $handler = null )
{
return Query::select( $table )->find( $id, $key, $handler );
} | [
"public",
"static",
"function",
"find",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"key",
"=",
"null",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"return",
"Query",
"::",
"select",
"(",
"$",
"table",
")",
"->",
"find",
"(",
"$",
"id",
",",
"$",
"key",
",",
"$",
"handler",
")",
";",
"}"
]
| Find something, means select one record by key
@param string $table
@param int $id
@param string $key
@param string $handler
@return mixed | [
"Find",
"something",
"means",
"select",
"one",
"record",
"by",
"key"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L138-L141 |
ClanCats/Core | src/bundles/Database/DB.php | DB.first | public static function first( $table, $key = null, $handler = null )
{
return Query::select( $table )->first( $key, $handler );
} | php | public static function first( $table, $key = null, $handler = null )
{
return Query::select( $table )->first( $key, $handler );
} | [
"public",
"static",
"function",
"first",
"(",
"$",
"table",
",",
"$",
"key",
"=",
"null",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"return",
"Query",
"::",
"select",
"(",
"$",
"table",
")",
"->",
"first",
"(",
"$",
"key",
",",
"$",
"handler",
")",
";",
"}"
]
| Get the first result by key
@param string $table
@param string $key
@param string $handler
@return mixed | [
"Get",
"the",
"first",
"result",
"by",
"key"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L151-L154 |
ClanCats/Core | src/bundles/Database/DB.php | DB.last | public static function last( $table, $key = null, $handler = null )
{
return Query::select( $table )->last( $key, $handler );
} | php | public static function last( $table, $key = null, $handler = null )
{
return Query::select( $table )->last( $key, $handler );
} | [
"public",
"static",
"function",
"last",
"(",
"$",
"table",
",",
"$",
"key",
"=",
"null",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"return",
"Query",
"::",
"select",
"(",
"$",
"table",
")",
"->",
"last",
"(",
"$",
"key",
",",
"$",
"handler",
")",
";",
"}"
]
| Get the last result by key
@param string $table
@param string $key
@param string $handler
@return mixed | [
"Get",
"the",
"last",
"result",
"by",
"key"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L164-L167 |
ClanCats/Core | src/bundles/Database/DB.php | DB.insert | public static function insert( $table, $values = array(), $handler = null )
{
return Query::insert( $table, $values, $handler );
} | php | public static function insert( $table, $values = array(), $handler = null )
{
return Query::insert( $table, $values, $handler );
} | [
"public",
"static",
"function",
"insert",
"(",
"$",
"table",
",",
"$",
"values",
"=",
"array",
"(",
")",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"return",
"Query",
"::",
"insert",
"(",
"$",
"table",
",",
"$",
"values",
",",
"$",
"handler",
")",
";",
"}"
]
| Create an insert query object
@param string $table
@param array $data
@return mixed | [
"Create",
"an",
"insert",
"query",
"object"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L188-L191 |
ClanCats/Core | src/bundles/Database/DB.php | DB.update | public static function update( $table, $data = null, $handler = null )
{
return Query::update( $table, $data, $handler );
} | php | public static function update( $table, $data = null, $handler = null )
{
return Query::update( $table, $data, $handler );
} | [
"public",
"static",
"function",
"update",
"(",
"$",
"table",
",",
"$",
"data",
"=",
"null",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"return",
"Query",
"::",
"update",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"handler",
")",
";",
"}"
]
| Create an update
@param string $table
@param array $values
@param string $handler
@return DB\Query | [
"Create",
"an",
"update"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L201-L204 |
terion-name/package-installer | src/Terion/PackageInstaller/SpecialsResolver.php | SpecialsResolver.specials | public function specials($package, Version $version)
{
$specials = $this->searchProvides($package);
if ($specials) {
$this->providesJsonDetected = true;
} else {
$this->providesJsonDetected = false;
$specials = $this->searchReflect($package, $version);
}
if (count($specials['providers']) === 0 && count($specials['aliases']) === 0) {
return false;
}
return $specials;
} | php | public function specials($package, Version $version)
{
$specials = $this->searchProvides($package);
if ($specials) {
$this->providesJsonDetected = true;
} else {
$this->providesJsonDetected = false;
$specials = $this->searchReflect($package, $version);
}
if (count($specials['providers']) === 0 && count($specials['aliases']) === 0) {
return false;
}
return $specials;
} | [
"public",
"function",
"specials",
"(",
"$",
"package",
",",
"Version",
"$",
"version",
")",
"{",
"$",
"specials",
"=",
"$",
"this",
"->",
"searchProvides",
"(",
"$",
"package",
")",
";",
"if",
"(",
"$",
"specials",
")",
"{",
"$",
"this",
"->",
"providesJsonDetected",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"providesJsonDetected",
"=",
"false",
";",
"$",
"specials",
"=",
"$",
"this",
"->",
"searchReflect",
"(",
"$",
"package",
",",
"$",
"version",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"specials",
"[",
"'providers'",
"]",
")",
"===",
"0",
"&&",
"count",
"(",
"$",
"specials",
"[",
"'aliases'",
"]",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"specials",
";",
"}"
]
| @param Package|string $package
@param Version $version
@return array|bool | [
"@param",
"Package|string",
"$package",
"@param",
"Version",
"$version"
]
| train | https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/SpecialsResolver.php#L44-L57 |
terion-name/package-installer | src/Terion/PackageInstaller/SpecialsResolver.php | SpecialsResolver.searchProvides | protected function searchProvides($package)
{
$packageName = $package instanceof Package ? $package->getName() : $package;
$providesJsonLocation = base_path("vendor/{$packageName}/provides.json");
if (file_exists($providesJsonLocation)) {
$provides = json_decode(str_replace('\\', '\\\\', file_get_contents($providesJsonLocation)), true);
$return = array('providers' => array(), 'aliases' => array());
if (isset($provides['providers']) && is_array($provides['providers'])) {
$return['providers'] = $provides['providers'];
}
if (isset($provides['aliases']) && is_array($provides['aliases'])) {
$return['aliases'] = $provides['aliases'];
}
return $return;
}
return false;
} | php | protected function searchProvides($package)
{
$packageName = $package instanceof Package ? $package->getName() : $package;
$providesJsonLocation = base_path("vendor/{$packageName}/provides.json");
if (file_exists($providesJsonLocation)) {
$provides = json_decode(str_replace('\\', '\\\\', file_get_contents($providesJsonLocation)), true);
$return = array('providers' => array(), 'aliases' => array());
if (isset($provides['providers']) && is_array($provides['providers'])) {
$return['providers'] = $provides['providers'];
}
if (isset($provides['aliases']) && is_array($provides['aliases'])) {
$return['aliases'] = $provides['aliases'];
}
return $return;
}
return false;
} | [
"protected",
"function",
"searchProvides",
"(",
"$",
"package",
")",
"{",
"$",
"packageName",
"=",
"$",
"package",
"instanceof",
"Package",
"?",
"$",
"package",
"->",
"getName",
"(",
")",
":",
"$",
"package",
";",
"$",
"providesJsonLocation",
"=",
"base_path",
"(",
"\"vendor/{$packageName}/provides.json\"",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"providesJsonLocation",
")",
")",
"{",
"$",
"provides",
"=",
"json_decode",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"file_get_contents",
"(",
"$",
"providesJsonLocation",
")",
")",
",",
"true",
")",
";",
"$",
"return",
"=",
"array",
"(",
"'providers'",
"=>",
"array",
"(",
")",
",",
"'aliases'",
"=>",
"array",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"provides",
"[",
"'providers'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"provides",
"[",
"'providers'",
"]",
")",
")",
"{",
"$",
"return",
"[",
"'providers'",
"]",
"=",
"$",
"provides",
"[",
"'providers'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"provides",
"[",
"'aliases'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"provides",
"[",
"'aliases'",
"]",
")",
")",
"{",
"$",
"return",
"[",
"'aliases'",
"]",
"=",
"$",
"provides",
"[",
"'aliases'",
"]",
";",
"}",
"return",
"$",
"return",
";",
"}",
"return",
"false",
";",
"}"
]
| @param Package|string $package
@return array|bool | [
"@param",
"Package|string",
"$package"
]
| train | https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/SpecialsResolver.php#L64-L80 |
terion-name/package-installer | src/Terion/PackageInstaller/SpecialsResolver.php | SpecialsResolver.searchReflect | protected function searchReflect($package, Version $version)
{
$namespaces = $this->getNamespaces($package, $version);
$this->loadPackageClasses($package, $version);
$classes = $this->listPackageClasses($namespaces);
$providers = array();
$aliases = array();
foreach ($classes as $class) {
$reflect = new ReflectionClass($class);
if ($reflect->isInstantiable()) {
if ($reflect->isSubclassOf('Illuminate\Support\ServiceProvider')) {
$providers[] = $class;
} elseif ($reflect->isSubclassOf('Illuminate\Support\Facades\Facade')) {
$aliases[] = array(
'alias' => class_basename($class),
'facade' => $class
);
}
}
}
return array('providers' => $providers, 'aliases' => $aliases);
} | php | protected function searchReflect($package, Version $version)
{
$namespaces = $this->getNamespaces($package, $version);
$this->loadPackageClasses($package, $version);
$classes = $this->listPackageClasses($namespaces);
$providers = array();
$aliases = array();
foreach ($classes as $class) {
$reflect = new ReflectionClass($class);
if ($reflect->isInstantiable()) {
if ($reflect->isSubclassOf('Illuminate\Support\ServiceProvider')) {
$providers[] = $class;
} elseif ($reflect->isSubclassOf('Illuminate\Support\Facades\Facade')) {
$aliases[] = array(
'alias' => class_basename($class),
'facade' => $class
);
}
}
}
return array('providers' => $providers, 'aliases' => $aliases);
} | [
"protected",
"function",
"searchReflect",
"(",
"$",
"package",
",",
"Version",
"$",
"version",
")",
"{",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"getNamespaces",
"(",
"$",
"package",
",",
"$",
"version",
")",
";",
"$",
"this",
"->",
"loadPackageClasses",
"(",
"$",
"package",
",",
"$",
"version",
")",
";",
"$",
"classes",
"=",
"$",
"this",
"->",
"listPackageClasses",
"(",
"$",
"namespaces",
")",
";",
"$",
"providers",
"=",
"array",
"(",
")",
";",
"$",
"aliases",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"$",
"reflect",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"reflect",
"->",
"isInstantiable",
"(",
")",
")",
"{",
"if",
"(",
"$",
"reflect",
"->",
"isSubclassOf",
"(",
"'Illuminate\\Support\\ServiceProvider'",
")",
")",
"{",
"$",
"providers",
"[",
"]",
"=",
"$",
"class",
";",
"}",
"elseif",
"(",
"$",
"reflect",
"->",
"isSubclassOf",
"(",
"'Illuminate\\Support\\Facades\\Facade'",
")",
")",
"{",
"$",
"aliases",
"[",
"]",
"=",
"array",
"(",
"'alias'",
"=>",
"class_basename",
"(",
"$",
"class",
")",
",",
"'facade'",
"=>",
"$",
"class",
")",
";",
"}",
"}",
"}",
"return",
"array",
"(",
"'providers'",
"=>",
"$",
"providers",
",",
"'aliases'",
"=>",
"$",
"aliases",
")",
";",
"}"
]
| @param Package|string $package
@param Version $version
@return array | [
"@param",
"Package|string",
"$package",
"@param",
"Version",
"$version"
]
| train | https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/SpecialsResolver.php#L88-L110 |
terion-name/package-installer | src/Terion/PackageInstaller/SpecialsResolver.php | SpecialsResolver.getNamespaces | protected function getNamespaces($package, Version $version)
{
$autoload = $version->getAutoload();
$namespaces = array();
foreach ($autoload as $type => $map) {
if ($type === 'psr-0' or $type === 'psr-4') {
foreach ($map as $ns => $rules) {
$namespace = str_replace('\\\\', '\\', $ns);
$namespace = rtrim($namespace, '\\') . '\\';
$namespaces[] = $namespace;
}
}
}
return $namespaces;
} | php | protected function getNamespaces($package, Version $version)
{
$autoload = $version->getAutoload();
$namespaces = array();
foreach ($autoload as $type => $map) {
if ($type === 'psr-0' or $type === 'psr-4') {
foreach ($map as $ns => $rules) {
$namespace = str_replace('\\\\', '\\', $ns);
$namespace = rtrim($namespace, '\\') . '\\';
$namespaces[] = $namespace;
}
}
}
return $namespaces;
} | [
"protected",
"function",
"getNamespaces",
"(",
"$",
"package",
",",
"Version",
"$",
"version",
")",
"{",
"$",
"autoload",
"=",
"$",
"version",
"->",
"getAutoload",
"(",
")",
";",
"$",
"namespaces",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"autoload",
"as",
"$",
"type",
"=>",
"$",
"map",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"'psr-0'",
"or",
"$",
"type",
"===",
"'psr-4'",
")",
"{",
"foreach",
"(",
"$",
"map",
"as",
"$",
"ns",
"=>",
"$",
"rules",
")",
"{",
"$",
"namespace",
"=",
"str_replace",
"(",
"'\\\\\\\\'",
",",
"'\\\\'",
",",
"$",
"ns",
")",
";",
"$",
"namespace",
"=",
"rtrim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
".",
"'\\\\'",
";",
"$",
"namespaces",
"[",
"]",
"=",
"$",
"namespace",
";",
"}",
"}",
"}",
"return",
"$",
"namespaces",
";",
"}"
]
| @param Package|string $package
@param Version $version
@return array | [
"@param",
"Package|string",
"$package",
"@param",
"Version",
"$version"
]
| train | https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/SpecialsResolver.php#L118-L132 |
terion-name/package-installer | src/Terion/PackageInstaller/SpecialsResolver.php | SpecialsResolver.getLoadPackagePathes | protected function getLoadPackagePathes($package, Version $version)
{
$packageName = $package instanceof Package ? $package->getName() : $package;
$basePath = 'vendor' . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, explode('/', $packageName));
$paths = array('directories' => array(), 'files' => array());
foreach ($version->getAutoload() as $type => $map) {
switch ($type) {
case 'classmap':
$paths['directories'] = array_merge($paths['directories'], (array)$map);
break;
case 'psr-0':
foreach ($map as $ns => $src) {
$nsPath = implode(DIRECTORY_SEPARATOR, explode('\\', str_replace('\\\\', '\\', $ns)));
foreach ((array)$src as $path) {
$paths['directories'][] = rtrim($path, '/') . DIRECTORY_SEPARATOR . $nsPath;
}
}
break;
case 'psr-4':
foreach ($map as $ns => $src) {
foreach ((array)$src as $path) {
$paths['directories'][] = implode(DIRECTORY_SEPARATOR, explode('/', rtrim($path, '/')));
}
}
break;
case 'files':
$paths['files'] = array_merge($paths['files'], (array)$map);
}
}
$pathsToExclude = $this->excludeFilesInPath($basePath);
$pathsToExclude = array_map(function ($p) use ($basePath) {
return realpath($basePath . DIRECTORY_SEPARATOR . $p);
}, $pathsToExclude);
$pathsToExclude = array_filter($pathsToExclude, function ($p) {
return $p !== false;
});
foreach ($paths as &$maps) {
$maps = array_unique(array_values($maps));
$maps = array_map(function ($p) use ($basePath) {
return realpath($basePath . DIRECTORY_SEPARATOR . $p);
}, $maps);
foreach ($pathsToExclude as $p) {
foreach ($maps as $index => $map) {
if (strpos($map, $p) === 0) {
unset($maps[$index]);
}
}
}
}
return $paths;
} | php | protected function getLoadPackagePathes($package, Version $version)
{
$packageName = $package instanceof Package ? $package->getName() : $package;
$basePath = 'vendor' . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, explode('/', $packageName));
$paths = array('directories' => array(), 'files' => array());
foreach ($version->getAutoload() as $type => $map) {
switch ($type) {
case 'classmap':
$paths['directories'] = array_merge($paths['directories'], (array)$map);
break;
case 'psr-0':
foreach ($map as $ns => $src) {
$nsPath = implode(DIRECTORY_SEPARATOR, explode('\\', str_replace('\\\\', '\\', $ns)));
foreach ((array)$src as $path) {
$paths['directories'][] = rtrim($path, '/') . DIRECTORY_SEPARATOR . $nsPath;
}
}
break;
case 'psr-4':
foreach ($map as $ns => $src) {
foreach ((array)$src as $path) {
$paths['directories'][] = implode(DIRECTORY_SEPARATOR, explode('/', rtrim($path, '/')));
}
}
break;
case 'files':
$paths['files'] = array_merge($paths['files'], (array)$map);
}
}
$pathsToExclude = $this->excludeFilesInPath($basePath);
$pathsToExclude = array_map(function ($p) use ($basePath) {
return realpath($basePath . DIRECTORY_SEPARATOR . $p);
}, $pathsToExclude);
$pathsToExclude = array_filter($pathsToExclude, function ($p) {
return $p !== false;
});
foreach ($paths as &$maps) {
$maps = array_unique(array_values($maps));
$maps = array_map(function ($p) use ($basePath) {
return realpath($basePath . DIRECTORY_SEPARATOR . $p);
}, $maps);
foreach ($pathsToExclude as $p) {
foreach ($maps as $index => $map) {
if (strpos($map, $p) === 0) {
unset($maps[$index]);
}
}
}
}
return $paths;
} | [
"protected",
"function",
"getLoadPackagePathes",
"(",
"$",
"package",
",",
"Version",
"$",
"version",
")",
"{",
"$",
"packageName",
"=",
"$",
"package",
"instanceof",
"Package",
"?",
"$",
"package",
"->",
"getName",
"(",
")",
":",
"$",
"package",
";",
"$",
"basePath",
"=",
"'vendor'",
".",
"DIRECTORY_SEPARATOR",
".",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"explode",
"(",
"'/'",
",",
"$",
"packageName",
")",
")",
";",
"$",
"paths",
"=",
"array",
"(",
"'directories'",
"=>",
"array",
"(",
")",
",",
"'files'",
"=>",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"version",
"->",
"getAutoload",
"(",
")",
"as",
"$",
"type",
"=>",
"$",
"map",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'classmap'",
":",
"$",
"paths",
"[",
"'directories'",
"]",
"=",
"array_merge",
"(",
"$",
"paths",
"[",
"'directories'",
"]",
",",
"(",
"array",
")",
"$",
"map",
")",
";",
"break",
";",
"case",
"'psr-0'",
":",
"foreach",
"(",
"$",
"map",
"as",
"$",
"ns",
"=>",
"$",
"src",
")",
"{",
"$",
"nsPath",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"explode",
"(",
"'\\\\'",
",",
"str_replace",
"(",
"'\\\\\\\\'",
",",
"'\\\\'",
",",
"$",
"ns",
")",
")",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"src",
"as",
"$",
"path",
")",
"{",
"$",
"paths",
"[",
"'directories'",
"]",
"[",
"]",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"nsPath",
";",
"}",
"}",
"break",
";",
"case",
"'psr-4'",
":",
"foreach",
"(",
"$",
"map",
"as",
"$",
"ns",
"=>",
"$",
"src",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"src",
"as",
"$",
"path",
")",
"{",
"$",
"paths",
"[",
"'directories'",
"]",
"[",
"]",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"explode",
"(",
"'/'",
",",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
")",
")",
";",
"}",
"}",
"break",
";",
"case",
"'files'",
":",
"$",
"paths",
"[",
"'files'",
"]",
"=",
"array_merge",
"(",
"$",
"paths",
"[",
"'files'",
"]",
",",
"(",
"array",
")",
"$",
"map",
")",
";",
"}",
"}",
"$",
"pathsToExclude",
"=",
"$",
"this",
"->",
"excludeFilesInPath",
"(",
"$",
"basePath",
")",
";",
"$",
"pathsToExclude",
"=",
"array_map",
"(",
"function",
"(",
"$",
"p",
")",
"use",
"(",
"$",
"basePath",
")",
"{",
"return",
"realpath",
"(",
"$",
"basePath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"p",
")",
";",
"}",
",",
"$",
"pathsToExclude",
")",
";",
"$",
"pathsToExclude",
"=",
"array_filter",
"(",
"$",
"pathsToExclude",
",",
"function",
"(",
"$",
"p",
")",
"{",
"return",
"$",
"p",
"!==",
"false",
";",
"}",
")",
";",
"foreach",
"(",
"$",
"paths",
"as",
"&",
"$",
"maps",
")",
"{",
"$",
"maps",
"=",
"array_unique",
"(",
"array_values",
"(",
"$",
"maps",
")",
")",
";",
"$",
"maps",
"=",
"array_map",
"(",
"function",
"(",
"$",
"p",
")",
"use",
"(",
"$",
"basePath",
")",
"{",
"return",
"realpath",
"(",
"$",
"basePath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"p",
")",
";",
"}",
",",
"$",
"maps",
")",
";",
"foreach",
"(",
"$",
"pathsToExclude",
"as",
"$",
"p",
")",
"{",
"foreach",
"(",
"$",
"maps",
"as",
"$",
"index",
"=>",
"$",
"map",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"map",
",",
"$",
"p",
")",
"===",
"0",
")",
"{",
"unset",
"(",
"$",
"maps",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"paths",
";",
"}"
]
| @param Package|string $package
@param Version $version
@return array | [
"@param",
"Package|string",
"$package",
"@param",
"Version",
"$version"
]
| train | https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/SpecialsResolver.php#L183-L236 |
terion-name/package-installer | src/Terion/PackageInstaller/SpecialsResolver.php | SpecialsResolver.excludeFilesInPath | protected function excludeFilesInPath($basePath)
{
$paths = ['tests' . DIRECTORY_SEPARATOR, 'test' . DIRECTORY_SEPARATOR];
$phpUnit = $basePath . DIRECTORY_SEPARATOR . 'phpunit.xml';
if (!file_exists($phpUnit)) {
$phpUnit = $basePath . DIRECTORY_SEPARATOR . 'phpunit.xml.dist';
}
if (file_exists($phpUnit)) {
$xml = simplexml_load_file($phpUnit);
$suites = $xml->testsuites->testsuite;
if ($suites) {
foreach ($suites as $ts) {
$paths[] = $ts->directory;
}
}
}
return array_unique($paths);
} | php | protected function excludeFilesInPath($basePath)
{
$paths = ['tests' . DIRECTORY_SEPARATOR, 'test' . DIRECTORY_SEPARATOR];
$phpUnit = $basePath . DIRECTORY_SEPARATOR . 'phpunit.xml';
if (!file_exists($phpUnit)) {
$phpUnit = $basePath . DIRECTORY_SEPARATOR . 'phpunit.xml.dist';
}
if (file_exists($phpUnit)) {
$xml = simplexml_load_file($phpUnit);
$suites = $xml->testsuites->testsuite;
if ($suites) {
foreach ($suites as $ts) {
$paths[] = $ts->directory;
}
}
}
return array_unique($paths);
} | [
"protected",
"function",
"excludeFilesInPath",
"(",
"$",
"basePath",
")",
"{",
"$",
"paths",
"=",
"[",
"'tests'",
".",
"DIRECTORY_SEPARATOR",
",",
"'test'",
".",
"DIRECTORY_SEPARATOR",
"]",
";",
"$",
"phpUnit",
"=",
"$",
"basePath",
".",
"DIRECTORY_SEPARATOR",
".",
"'phpunit.xml'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"phpUnit",
")",
")",
"{",
"$",
"phpUnit",
"=",
"$",
"basePath",
".",
"DIRECTORY_SEPARATOR",
".",
"'phpunit.xml.dist'",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"phpUnit",
")",
")",
"{",
"$",
"xml",
"=",
"simplexml_load_file",
"(",
"$",
"phpUnit",
")",
";",
"$",
"suites",
"=",
"$",
"xml",
"->",
"testsuites",
"->",
"testsuite",
";",
"if",
"(",
"$",
"suites",
")",
"{",
"foreach",
"(",
"$",
"suites",
"as",
"$",
"ts",
")",
"{",
"$",
"paths",
"[",
"]",
"=",
"$",
"ts",
"->",
"directory",
";",
"}",
"}",
"}",
"return",
"array_unique",
"(",
"$",
"paths",
")",
";",
"}"
]
| @param $basePath
@return array | [
"@param",
"$basePath"
]
| train | https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/SpecialsResolver.php#L243-L261 |
terion-name/package-installer | src/Terion/PackageInstaller/SpecialsResolver.php | SpecialsResolver.listPackageClasses | protected function listPackageClasses(array $namespaces)
{
return array_filter(get_declared_classes(), function ($class) use ($namespaces) {
$valid = false;
foreach ($namespaces as $ns) {
$valid = (strpos($class, $ns) === 0) ? true : $valid;
}
return $valid;
});
} | php | protected function listPackageClasses(array $namespaces)
{
return array_filter(get_declared_classes(), function ($class) use ($namespaces) {
$valid = false;
foreach ($namespaces as $ns) {
$valid = (strpos($class, $ns) === 0) ? true : $valid;
}
return $valid;
});
} | [
"protected",
"function",
"listPackageClasses",
"(",
"array",
"$",
"namespaces",
")",
"{",
"return",
"array_filter",
"(",
"get_declared_classes",
"(",
")",
",",
"function",
"(",
"$",
"class",
")",
"use",
"(",
"$",
"namespaces",
")",
"{",
"$",
"valid",
"=",
"false",
";",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"ns",
")",
"{",
"$",
"valid",
"=",
"(",
"strpos",
"(",
"$",
"class",
",",
"$",
"ns",
")",
"===",
"0",
")",
"?",
"true",
":",
"$",
"valid",
";",
"}",
"return",
"$",
"valid",
";",
"}",
")",
";",
"}"
]
| @param array $namespaces
@return array | [
"@param",
"array",
"$namespaces"
]
| train | https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/SpecialsResolver.php#L268-L277 |
ufocoder/yii2-SyncSocial | src/SyncService.php | SyncService.isConnected | public function isConnected(OAuthToken $accessToken = null) {
/**
* @var $service \yii\authclient\BaseOAuth
*/
if ($accessToken === null) {
$accessToken = $this->service->getAccessToken();
}
if (is_object($accessToken) && $accessToken->getIsValid()) {
return true;
} else {
return false;
}
} | php | public function isConnected(OAuthToken $accessToken = null) {
/**
* @var $service \yii\authclient\BaseOAuth
*/
if ($accessToken === null) {
$accessToken = $this->service->getAccessToken();
}
if (is_object($accessToken) && $accessToken->getIsValid()) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"isConnected",
"(",
"OAuthToken",
"$",
"accessToken",
"=",
"null",
")",
"{",
"/**\n\t\t * @var $service \\yii\\authclient\\BaseOAuth\n\t\t */",
"if",
"(",
"$",
"accessToken",
"===",
"null",
")",
"{",
"$",
"accessToken",
"=",
"$",
"this",
"->",
"service",
"->",
"getAccessToken",
"(",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"accessToken",
")",
"&&",
"$",
"accessToken",
"->",
"getIsValid",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
]
| @param OAuthToken $accessToken
@return bool | [
"@param",
"OAuthToken",
"$accessToken"
]
| train | https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/SyncService.php#L148-L164 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.