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 |
|---|---|---|---|---|---|---|---|---|---|---|
railt/railt | src/Component/Container/SimpleContainer.php | SimpleContainer.get | public function get($id)
{
\assert(\is_scalar($id), 'Invalid format of the entry identifier.');
if (\array_key_exists($id, $this->values)) {
return $this->values[$id];
}
if ($this->hasInProxy($id)) {
return $this->container->get((string)$id);
}
throw new ContainerResolutionException(\sprintf('Entry with id %s not found', $id));
} | php | public function get($id)
{
\assert(\is_scalar($id), 'Invalid format of the entry identifier.');
if (\array_key_exists($id, $this->values)) {
return $this->values[$id];
}
if ($this->hasInProxy($id)) {
return $this->container->get((string)$id);
}
throw new ContainerResolutionException(\sprintf('Entry with id %s not found', $id));
} | [
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"\\",
"assert",
"(",
"\\",
"is_scalar",
"(",
"$",
"id",
")",
",",
"'Invalid format of the entry identifier.'",
")",
";",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"this",
"->",
... | Finds an entry of the container by its identifier and returns it.
@param int|float|string|bool $id Identifier of the entry to look for.
@return mixed Desired entry.
@throws ContainerResolutionException No entry was found for **this** identifier. | [
"Finds",
"an",
"entry",
"of",
"the",
"container",
"by",
"its",
"identifier",
"and",
"returns",
"it",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Container/SimpleContainer.php#L84-L97 |
railt/railt | src/Component/Json/JsonEncoder.php | JsonEncoder.write | public function write(string $pathname, array $data): Readable
{
$json = $this->encode($data);
$dirname = \dirname($pathname);
if (! @\mkdir($dirname, 0777, true) && ! \is_dir($dirname)) {
$error = 'Could not write json file, because directory %s not accessible for writing';
throw new NotAccessibleException(\sprintf($error, $dirname));
}
if (@\file_put_contents($pathname, $this->encode($data), \LOCK_EX) === false) {
$error = 'Error while writing json into %s file';
throw new NotAccessibleException(\sprintf($error, $pathname));
}
return new Virtual($json, $pathname);
} | php | public function write(string $pathname, array $data): Readable
{
$json = $this->encode($data);
$dirname = \dirname($pathname);
if (! @\mkdir($dirname, 0777, true) && ! \is_dir($dirname)) {
$error = 'Could not write json file, because directory %s not accessible for writing';
throw new NotAccessibleException(\sprintf($error, $dirname));
}
if (@\file_put_contents($pathname, $this->encode($data), \LOCK_EX) === false) {
$error = 'Error while writing json into %s file';
throw new NotAccessibleException(\sprintf($error, $pathname));
}
return new Virtual($json, $pathname);
} | [
"public",
"function",
"write",
"(",
"string",
"$",
"pathname",
",",
"array",
"$",
"data",
")",
":",
"Readable",
"{",
"$",
"json",
"=",
"$",
"this",
"->",
"encode",
"(",
"$",
"data",
")",
";",
"$",
"dirname",
"=",
"\\",
"dirname",
"(",
"$",
"pathnam... | Writes transferred data to the specified stream (pathname).
@param string $pathname
@param array $data
@return Readable
@throws NotAccessibleException | [
"Writes",
"transferred",
"data",
"to",
"the",
"specified",
"stream",
"(",
"pathname",
")",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Json/JsonEncoder.php#L39-L56 |
railt/railt | src/Component/Parser/Ast/Builder.php | Builder.buildTree | protected function buildTree(int $i = 0, array &$children = [])
{
$max = \count($this->trace);
while ($i < $max) {
$trace = $this->trace[$i];
if ($trace instanceof Entry) {
$ruleName = $trace->getRule();
$rule = $this->grammar->fetch($ruleName);
$isRule = $trace->isTransitional() === false;
$nextTrace = $this->trace[$i + 1];
$id = $rule->getNodeId();
// Optimization: Skip empty trace sequence.
if ($nextTrace instanceof Escape && $ruleName === $nextTrace->getRule()) {
$i += 2;
continue;
}
if ($isRule === true) {
$children[] = $ruleName;
}
if ($id !== null) {
$children[] = [$id];
}
$i = $this->buildTree($i + 1, $children);
if ($isRule === false) {
continue;
}
$handle = [];
$childId = null;
do {
$pop = \array_pop($children);
if (\is_object($pop) === true) {
$handle[] = $pop;
} elseif (\is_array($pop) && $childId === null) {
$childId = \reset($pop);
} elseif ($ruleName === $pop) {
break;
}
} while ($pop !== null);
if ($childId === null) {
$childId = $rule->getDefaultId();
}
if ($childId === null) {
for ($j = \count($handle) - 1; $j >= 0; --$j) {
$children[] = $handle[$j];
}
continue;
}
$children[] = $this->getRule(
(string)($id ?: $childId),
\array_reverse($handle),
$trace->getOffset()
);
} elseif ($trace instanceof Escape) {
return $i + 1;
} else {
if (! $trace->isKept()) {
++$i;
continue;
}
$children[] = new Leaf($trace->getToken());
++$i;
}
}
return $children[0];
} | php | protected function buildTree(int $i = 0, array &$children = [])
{
$max = \count($this->trace);
while ($i < $max) {
$trace = $this->trace[$i];
if ($trace instanceof Entry) {
$ruleName = $trace->getRule();
$rule = $this->grammar->fetch($ruleName);
$isRule = $trace->isTransitional() === false;
$nextTrace = $this->trace[$i + 1];
$id = $rule->getNodeId();
// Optimization: Skip empty trace sequence.
if ($nextTrace instanceof Escape && $ruleName === $nextTrace->getRule()) {
$i += 2;
continue;
}
if ($isRule === true) {
$children[] = $ruleName;
}
if ($id !== null) {
$children[] = [$id];
}
$i = $this->buildTree($i + 1, $children);
if ($isRule === false) {
continue;
}
$handle = [];
$childId = null;
do {
$pop = \array_pop($children);
if (\is_object($pop) === true) {
$handle[] = $pop;
} elseif (\is_array($pop) && $childId === null) {
$childId = \reset($pop);
} elseif ($ruleName === $pop) {
break;
}
} while ($pop !== null);
if ($childId === null) {
$childId = $rule->getDefaultId();
}
if ($childId === null) {
for ($j = \count($handle) - 1; $j >= 0; --$j) {
$children[] = $handle[$j];
}
continue;
}
$children[] = $this->getRule(
(string)($id ?: $childId),
\array_reverse($handle),
$trace->getOffset()
);
} elseif ($trace instanceof Escape) {
return $i + 1;
} else {
if (! $trace->isKept()) {
++$i;
continue;
}
$children[] = new Leaf($trace->getToken());
++$i;
}
}
return $children[0];
} | [
"protected",
"function",
"buildTree",
"(",
"int",
"$",
"i",
"=",
"0",
",",
"array",
"&",
"$",
"children",
"=",
"[",
"]",
")",
"{",
"$",
"max",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"trace",
")",
";",
"while",
"(",
"$",
"i",
"<",
"$",
"m... | Build AST from trace.
Walk through the trace iteratively and recursively.
@param int $i Current trace index.
@param array &$children Collected children.
@return Node|int
@throws \LogicException | [
"Build",
"AST",
"from",
"trace",
".",
"Walk",
"through",
"the",
"trace",
"iteratively",
"and",
"recursively",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Parser/Ast/Builder.php#L62-L143 |
railt/railt | src/Component/SDL/Reflection/Validation/Definitions/ObjectValidator.php | ObjectValidator.validateFieldsExistence | private function validateFieldsExistence(ObjectDefinition $object, InterfaceDefinition $interface): void
{
foreach ($interface->getFields() as $field) {
$this->getCallStack()->push($field);
$exists = $object->hasField($field->getName());
if (! $exists) {
$this->throwFieldNotDefined($interface, $object, $field);
}
$this->validateFieldCompatibility($field, $object->getField($field->getName()));
$this->getCallStack()->pop();
}
} | php | private function validateFieldsExistence(ObjectDefinition $object, InterfaceDefinition $interface): void
{
foreach ($interface->getFields() as $field) {
$this->getCallStack()->push($field);
$exists = $object->hasField($field->getName());
if (! $exists) {
$this->throwFieldNotDefined($interface, $object, $field);
}
$this->validateFieldCompatibility($field, $object->getField($field->getName()));
$this->getCallStack()->pop();
}
} | [
"private",
"function",
"validateFieldsExistence",
"(",
"ObjectDefinition",
"$",
"object",
",",
"InterfaceDefinition",
"$",
"interface",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"interface",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"... | Make sure that all the interface fields are implemented.
@param InterfaceDefinition $interface
@param ObjectDefinition $object
@return void
@throws \OutOfBoundsException
@throws \Railt\Component\SDL\Exceptions\TypeConflictException | [
"Make",
"sure",
"that",
"all",
"the",
"interface",
"fields",
"are",
"implemented",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/SDL/Reflection/Validation/Definitions/ObjectValidator.php#L78-L93 |
railt/railt | src/Component/SDL/Reflection/Validation/Definitions/ObjectValidator.php | ObjectValidator.validateFieldCompatibility | private function validateFieldCompatibility(FieldDefinition $interface, FieldDefinition $object): void
{
$this->getValidator(Inheritance::class)->validate($object, $interface);
$this->validateArgumentExistence($interface, $object);
} | php | private function validateFieldCompatibility(FieldDefinition $interface, FieldDefinition $object): void
{
$this->getValidator(Inheritance::class)->validate($object, $interface);
$this->validateArgumentExistence($interface, $object);
} | [
"private",
"function",
"validateFieldCompatibility",
"(",
"FieldDefinition",
"$",
"interface",
",",
"FieldDefinition",
"$",
"object",
")",
":",
"void",
"{",
"$",
"this",
"->",
"getValidator",
"(",
"Inheritance",
"::",
"class",
")",
"->",
"validate",
"(",
"$",
... | We are convinced that the fields have a comparable signature of the type.
@param FieldDefinition $interface
@param FieldDefinition $object
@return void
@throws \Railt\Component\SDL\Exceptions\TypeConflictException
@throws \OutOfBoundsException | [
"We",
"are",
"convinced",
"that",
"the",
"fields",
"have",
"a",
"comparable",
"signature",
"of",
"the",
"type",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/SDL/Reflection/Validation/Definitions/ObjectValidator.php#L118-L123 |
railt/railt | src/Component/SDL/Reflection/Validation/Definitions/ObjectValidator.php | ObjectValidator.validateArgumentExistence | private function validateArgumentExistence(FieldDefinition $interface, FieldDefinition $object): void
{
foreach ($interface->getArguments() as $argument) {
$this->getCallStack()->push($argument);
$exists = $object->hasArgument($argument->getName());
if (! $exists) {
$this->throwArgumentNotDefined($interface, $object, $argument);
}
$this->validateArgumentCompatibility($argument, $object->getArgument($argument->getName()));
$this->getCallStack()->pop();
}
} | php | private function validateArgumentExistence(FieldDefinition $interface, FieldDefinition $object): void
{
foreach ($interface->getArguments() as $argument) {
$this->getCallStack()->push($argument);
$exists = $object->hasArgument($argument->getName());
if (! $exists) {
$this->throwArgumentNotDefined($interface, $object, $argument);
}
$this->validateArgumentCompatibility($argument, $object->getArgument($argument->getName()));
$this->getCallStack()->pop();
}
} | [
"private",
"function",
"validateArgumentExistence",
"(",
"FieldDefinition",
"$",
"interface",
",",
"FieldDefinition",
"$",
"object",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"interface",
"->",
"getArguments",
"(",
")",
"as",
"$",
"argument",
")",
"{",
"$",
... | We are convinced that all the arguments of the parent fields were implemented in the child.
@param FieldDefinition $interface
@param FieldDefinition $object
@return void
@throws TypeConflictException
@throws \OutOfBoundsException | [
"We",
"are",
"convinced",
"that",
"all",
"the",
"arguments",
"of",
"the",
"parent",
"fields",
"were",
"implemented",
"in",
"the",
"child",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/SDL/Reflection/Validation/Definitions/ObjectValidator.php#L134-L148 |
railt/railt | src/Component/SDL/Reflection/Validation/Definitions/ObjectValidator.php | ObjectValidator.validateArgumentCompatibility | private function validateArgumentCompatibility(ArgumentDefinition $interface, ArgumentDefinition $object): void
{
$this->getValidator(Inheritance::class)->validate($object, $interface);
} | php | private function validateArgumentCompatibility(ArgumentDefinition $interface, ArgumentDefinition $object): void
{
$this->getValidator(Inheritance::class)->validate($object, $interface);
} | [
"private",
"function",
"validateArgumentCompatibility",
"(",
"ArgumentDefinition",
"$",
"interface",
",",
"ArgumentDefinition",
"$",
"object",
")",
":",
"void",
"{",
"$",
"this",
"->",
"getValidator",
"(",
"Inheritance",
"::",
"class",
")",
"->",
"validate",
"(",
... | We are convinced that the arguments have a comparable signature of the type.
@param ArgumentDefinition $interface
@param ArgumentDefinition $object
@return void
@throws \OutOfBoundsException | [
"We",
"are",
"convinced",
"that",
"the",
"arguments",
"have",
"a",
"comparable",
"signature",
"of",
"the",
"type",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/SDL/Reflection/Validation/Definitions/ObjectValidator.php#L173-L176 |
railt/railt | src/Component/Parser/Parser.php | Parser.unfold | private function unfold(): bool
{
while (0 < \count($this->todo)) {
$rule = \array_pop($this->todo);
if ($rule instanceof Escape) {
$this->addTrace($rule);
} else {
$out = $this->reduce($this->grammar->fetch($rule->getRule()), $rule->getData());
if ($out === false && $this->backtrack() === false) {
return false;
}
}
}
return true;
} | php | private function unfold(): bool
{
while (0 < \count($this->todo)) {
$rule = \array_pop($this->todo);
if ($rule instanceof Escape) {
$this->addTrace($rule);
} else {
$out = $this->reduce($this->grammar->fetch($rule->getRule()), $rule->getData());
if ($out === false && $this->backtrack() === false) {
return false;
}
}
}
return true;
} | [
"private",
"function",
"unfold",
"(",
")",
":",
"bool",
"{",
"while",
"(",
"0",
"<",
"\\",
"count",
"(",
"$",
"this",
"->",
"todo",
")",
")",
"{",
"$",
"rule",
"=",
"\\",
"array_pop",
"(",
"$",
"this",
"->",
"todo",
")",
";",
"if",
"(",
"$",
... | Unfold trace.
@return bool | [
"Unfold",
"trace",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Parser/Parser.php#L253-L270 |
railt/railt | src/Component/Parser/Parser.php | Parser.backtrack | private function backtrack(): bool
{
$found = false;
do {
$last = \array_pop($this->trace);
if ($last instanceof Entry) {
$found = $this->grammar->fetch($last->getRule()) instanceof Alternation;
} elseif ($last instanceof Escape) {
$found = $this->grammar->fetch($last->getRule()) instanceof Repetition;
} elseif ($last instanceof Token) {
if (! $this->stream->prev()) {
return false;
}
}
} while (0 < \count($this->trace) && $found === false);
if ($found === false) {
return false;
}
$this->todo = $last->getTodo();
$this->todo[] = new Entry($last->getRule(), $last->getData() + 1);
return true;
} | php | private function backtrack(): bool
{
$found = false;
do {
$last = \array_pop($this->trace);
if ($last instanceof Entry) {
$found = $this->grammar->fetch($last->getRule()) instanceof Alternation;
} elseif ($last instanceof Escape) {
$found = $this->grammar->fetch($last->getRule()) instanceof Repetition;
} elseif ($last instanceof Token) {
if (! $this->stream->prev()) {
return false;
}
}
} while (0 < \count($this->trace) && $found === false);
if ($found === false) {
return false;
}
$this->todo = $last->getTodo();
$this->todo[] = new Entry($last->getRule(), $last->getData() + 1);
return true;
} | [
"private",
"function",
"backtrack",
"(",
")",
":",
"bool",
"{",
"$",
"found",
"=",
"false",
";",
"do",
"{",
"$",
"last",
"=",
"\\",
"array_pop",
"(",
"$",
"this",
"->",
"trace",
")",
";",
"if",
"(",
"$",
"last",
"instanceof",
"Entry",
")",
"{",
"... | Backtrack the trace.
@return bool | [
"Backtrack",
"the",
"trace",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Parser/Parser.php#L422-L448 |
railt/railt | src/Component/Compiler/Grammar/Analyzer.php | Analyzer.analyze | public function analyze(): iterable
{
if (\count($this->rules) === 0) {
throw new GrammarException('No rules specified');
}
$this->parsedRules = [];
foreach ($this->rules as $delegate) {
$this->ruleName = $delegate->getRuleName();
$nodeId = $delegate->isKept()
? $delegate->getRuleName()
: null;
$pNodeId = $nodeId;
$rule = $this->rule($delegate->getInnerTokens(), $pNodeId);
if ($rule === null) {
$error = \sprintf('Error while parsing rule %s.', $delegate->getRuleName());
throw new GrammarException($error, 1);
}
$zeRule = $this->parsedRules[$rule];
$zeRule->setName($delegate->getRuleName());
if ($nodeId !== null) {
$zeRule->setDefaultId($nodeId);
}
unset($this->parsedRules[$rule]);
$this->parsedRules[$delegate->getRuleName()] = $zeRule;
}
foreach ($this->parsedRules as $builder) {
yield $builder->build();
}
} | php | public function analyze(): iterable
{
if (\count($this->rules) === 0) {
throw new GrammarException('No rules specified');
}
$this->parsedRules = [];
foreach ($this->rules as $delegate) {
$this->ruleName = $delegate->getRuleName();
$nodeId = $delegate->isKept()
? $delegate->getRuleName()
: null;
$pNodeId = $nodeId;
$rule = $this->rule($delegate->getInnerTokens(), $pNodeId);
if ($rule === null) {
$error = \sprintf('Error while parsing rule %s.', $delegate->getRuleName());
throw new GrammarException($error, 1);
}
$zeRule = $this->parsedRules[$rule];
$zeRule->setName($delegate->getRuleName());
if ($nodeId !== null) {
$zeRule->setDefaultId($nodeId);
}
unset($this->parsedRules[$rule]);
$this->parsedRules[$delegate->getRuleName()] = $zeRule;
}
foreach ($this->parsedRules as $builder) {
yield $builder->build();
}
} | [
"public",
"function",
"analyze",
"(",
")",
":",
"iterable",
"{",
"if",
"(",
"\\",
"count",
"(",
"$",
"this",
"->",
"rules",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"GrammarException",
"(",
"'No rules specified'",
")",
";",
"}",
"$",
"this",
"->",
... | Build the analyzer of the rules (does not analyze the rules).
@return Rule[]|\Traversable
@throws GrammarException | [
"Build",
"the",
"analyzer",
"of",
"the",
"rules",
"(",
"does",
"not",
"analyze",
"the",
"rules",
")",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Compiler/Grammar/Analyzer.php#L67-L103 |
railt/railt | src/Component/Compiler/Grammar/Analyzer.php | Analyzer.choice | protected function choice(LookaheadIterator $tokens, &$pNodeId)
{
$children = [];
// concatenation() …
$nNodeId = $pNodeId;
$rule = $this->concatenation($tokens, $nNodeId);
if ($rule === null) {
return null;
}
if ($nNodeId !== null) {
$this->parsedRules[$rule]->setNodeId($nNodeId);
}
$children[] = $rule;
$others = false;
// … ( ::or:: concatenation() )*
while ($tokens->current()->getName() === Parser::T_OR) {
$tokens->next();
$others = true;
$nNodeId = $pNodeId;
$rule = $this->concatenation($tokens, $nNodeId);
if ($rule === null) {
return null;
}
if ($nNodeId !== null) {
$this->parsedRules[$rule]->setNodeId($nNodeId);
}
$children[] = $rule;
}
$pNodeId = null;
if ($others === false) {
return $rule;
}
$name = $this->transitionalRuleCounter++;
$this->parsedRules[$name] = new Alternation($name, $children);
return $name;
} | php | protected function choice(LookaheadIterator $tokens, &$pNodeId)
{
$children = [];
// concatenation() …
$nNodeId = $pNodeId;
$rule = $this->concatenation($tokens, $nNodeId);
if ($rule === null) {
return null;
}
if ($nNodeId !== null) {
$this->parsedRules[$rule]->setNodeId($nNodeId);
}
$children[] = $rule;
$others = false;
// … ( ::or:: concatenation() )*
while ($tokens->current()->getName() === Parser::T_OR) {
$tokens->next();
$others = true;
$nNodeId = $pNodeId;
$rule = $this->concatenation($tokens, $nNodeId);
if ($rule === null) {
return null;
}
if ($nNodeId !== null) {
$this->parsedRules[$rule]->setNodeId($nNodeId);
}
$children[] = $rule;
}
$pNodeId = null;
if ($others === false) {
return $rule;
}
$name = $this->transitionalRuleCounter++;
$this->parsedRules[$name] = new Alternation($name, $children);
return $name;
} | [
"protected",
"function",
"choice",
"(",
"LookaheadIterator",
"$",
"tokens",
",",
"&",
"$",
"pNodeId",
")",
"{",
"$",
"children",
"=",
"[",
"]",
";",
"// concatenation() …",
"$",
"nNodeId",
"=",
"$",
"pNodeId",
";",
"$",
"rule",
"=",
"$",
"this",
"->",
... | Implementation of “choice”.
@param LookaheadIterator $tokens
@param string|null $pNodeId
@return string|int|null
@throws GrammarException | [
"Implementation",
"of",
"“choice”",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Compiler/Grammar/Analyzer.php#L126-L174 |
railt/railt | src/Component/Compiler/Grammar/Analyzer.php | Analyzer.concatenation | protected function concatenation(LookaheadIterator $tokens, &$pNodeId)
{
$children = [];
// repetition() …
$rule = $this->repetition($tokens, $pNodeId);
if ($rule === null) {
return null;
}
$children[] = $rule;
$others = false;
// … repetition()*
while (null !== $r1 = $this->repetition($tokens, $pNodeId)) {
$children[] = $r1;
$others = true;
}
if ($others === false && $pNodeId === null) {
return $rule;
}
$name = $this->transitionalRuleCounter++;
$this->parsedRules[$name] = new Concatenation($name, $children);
return $name;
} | php | protected function concatenation(LookaheadIterator $tokens, &$pNodeId)
{
$children = [];
// repetition() …
$rule = $this->repetition($tokens, $pNodeId);
if ($rule === null) {
return null;
}
$children[] = $rule;
$others = false;
// … repetition()*
while (null !== $r1 = $this->repetition($tokens, $pNodeId)) {
$children[] = $r1;
$others = true;
}
if ($others === false && $pNodeId === null) {
return $rule;
}
$name = $this->transitionalRuleCounter++;
$this->parsedRules[$name] = new Concatenation($name, $children);
return $name;
} | [
"protected",
"function",
"concatenation",
"(",
"LookaheadIterator",
"$",
"tokens",
",",
"&",
"$",
"pNodeId",
")",
"{",
"$",
"children",
"=",
"[",
"]",
";",
"// repetition() …",
"$",
"rule",
"=",
"$",
"this",
"->",
"repetition",
"(",
"$",
"tokens",
",",
"... | Implementation of “concatenation”.
@param LookaheadIterator $tokens
@param string|null $pNodeId
@return string|int|null
@throws GrammarException | [
"Implementation",
"of",
"“concatenation”",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Compiler/Grammar/Analyzer.php#L184-L213 |
railt/railt | src/Component/Compiler/Grammar/Analyzer.php | Analyzer.repetition | protected function repetition(LookaheadIterator $tokens, &$pNodeId)
{
[$min, $max] = [null, null];
// simple() …
$children = $this->simple($tokens, $pNodeId);
if ($children === null) {
return null;
}
// … quantifier()?
switch ($tokens->current()->getName()) {
case Parser::T_REPEAT_ZERO_OR_ONE:
[$min, $max] = [0, 1];
$tokens->next();
break;
case Parser::T_REPEAT_ONE_OR_MORE:
[$min, $max] = [1, -1];
$tokens->next();
break;
case Parser::T_REPEAT_ZERO_OR_MORE:
[$min, $max] = [0, -1];
$tokens->next();
break;
case Parser::T_REPEAT_N_TO_M:
$min = (int)$tokens->current()->getValue(1);
$max = (int)$tokens->current()->getValue(2);
$tokens->next();
break;
case Parser::T_REPEAT_ZERO_TO_M:
[$min, $max] = [0, (int)$tokens->current()->getValue(1)];
$tokens->next();
break;
case Parser::T_REPEAT_N_OR_MORE:
[$min, $max] = [(int)$tokens->current()->getValue(1), -1];
$tokens->next();
break;
case Parser::T_REPEAT_EXACTLY_N:
$min = $max = (int)$tokens->current()->getValue(1);
$tokens->next();
break;
}
// … <node>?
if ($tokens->current()->getName() === Parser::T_KEPT_NAME) {
$tokens->next();
$pNodeId = $tokens->current()->getValue();
$tokens->next();
}
if ($min === null) {
return $children;
}
if ($max !== -1 && $max < $min) {
$error = 'Upper bound %d must be greater or equal to lower bound %d in rule %s.';
$error = \sprintf($error, $max, $min, $this->ruleName);
throw new GrammarException($error, 2);
}
$name = $this->transitionalRuleCounter++;
$this->parsedRules[$name] = new Repetition($name, $min, $max, $children);
return $name;
} | php | protected function repetition(LookaheadIterator $tokens, &$pNodeId)
{
[$min, $max] = [null, null];
// simple() …
$children = $this->simple($tokens, $pNodeId);
if ($children === null) {
return null;
}
// … quantifier()?
switch ($tokens->current()->getName()) {
case Parser::T_REPEAT_ZERO_OR_ONE:
[$min, $max] = [0, 1];
$tokens->next();
break;
case Parser::T_REPEAT_ONE_OR_MORE:
[$min, $max] = [1, -1];
$tokens->next();
break;
case Parser::T_REPEAT_ZERO_OR_MORE:
[$min, $max] = [0, -1];
$tokens->next();
break;
case Parser::T_REPEAT_N_TO_M:
$min = (int)$tokens->current()->getValue(1);
$max = (int)$tokens->current()->getValue(2);
$tokens->next();
break;
case Parser::T_REPEAT_ZERO_TO_M:
[$min, $max] = [0, (int)$tokens->current()->getValue(1)];
$tokens->next();
break;
case Parser::T_REPEAT_N_OR_MORE:
[$min, $max] = [(int)$tokens->current()->getValue(1), -1];
$tokens->next();
break;
case Parser::T_REPEAT_EXACTLY_N:
$min = $max = (int)$tokens->current()->getValue(1);
$tokens->next();
break;
}
// … <node>?
if ($tokens->current()->getName() === Parser::T_KEPT_NAME) {
$tokens->next();
$pNodeId = $tokens->current()->getValue();
$tokens->next();
}
if ($min === null) {
return $children;
}
if ($max !== -1 && $max < $min) {
$error = 'Upper bound %d must be greater or equal to lower bound %d in rule %s.';
$error = \sprintf($error, $max, $min, $this->ruleName);
throw new GrammarException($error, 2);
}
$name = $this->transitionalRuleCounter++;
$this->parsedRules[$name] = new Repetition($name, $min, $max, $children);
return $name;
} | [
"protected",
"function",
"repetition",
"(",
"LookaheadIterator",
"$",
"tokens",
",",
"&",
"$",
"pNodeId",
")",
"{",
"[",
"$",
"min",
",",
"$",
"max",
"]",
"=",
"[",
"null",
",",
"null",
"]",
";",
"// simple() …",
"$",
"children",
"=",
"$",
"this",
"-... | Implementation of “repetition”.
@param LookaheadIterator $tokens
@param string|null $pNodeId
@return string|int|null
@throws GrammarException | [
"Implementation",
"of",
"“repetition”",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Compiler/Grammar/Analyzer.php#L223-L295 |
railt/railt | src/Component/Compiler/Grammar/Analyzer.php | Analyzer.simple | protected function simple(LookaheadIterator $tokens, &$pNodeId)
{
switch ($tokens->current()->getName()) {
case Parser::T_GROUP_OPEN:
return $this->group($tokens, $pNodeId);
case Parser::T_TOKEN_SKIPPED:
return $this->token($tokens, false);
case Parser::T_TOKEN_KEPT:
return $this->token($tokens, true);
case Parser::T_INVOKE:
return $this->invoke($tokens);
default:
return null;
}
} | php | protected function simple(LookaheadIterator $tokens, &$pNodeId)
{
switch ($tokens->current()->getName()) {
case Parser::T_GROUP_OPEN:
return $this->group($tokens, $pNodeId);
case Parser::T_TOKEN_SKIPPED:
return $this->token($tokens, false);
case Parser::T_TOKEN_KEPT:
return $this->token($tokens, true);
case Parser::T_INVOKE:
return $this->invoke($tokens);
default:
return null;
}
} | [
"protected",
"function",
"simple",
"(",
"LookaheadIterator",
"$",
"tokens",
",",
"&",
"$",
"pNodeId",
")",
"{",
"switch",
"(",
"$",
"tokens",
"->",
"current",
"(",
")",
"->",
"getName",
"(",
")",
")",
"{",
"case",
"Parser",
"::",
"T_GROUP_OPEN",
":",
"... | Implementation of “simple”.
@param LookaheadIterator $tokens
@param int|string|null $pNodeId
@return string|int|null
@throws GrammarException | [
"Implementation",
"of",
"“simple”",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Compiler/Grammar/Analyzer.php#L305-L323 |
railt/railt | src/Component/SDL/Standard/GraphQLDocument.php | GraphQLDocument.createStandardTypes | private function createStandardTypes(): void
{
foreach ($this->getStandardTypes() as $type) {
/** @var Definition|mixed $instance */
$instance = new $type($this);
if ($instance instanceof TypeDefinition) {
$this->types[$instance->getName()] = $instance;
} else {
$this->definitions[] = $instance;
}
}
} | php | private function createStandardTypes(): void
{
foreach ($this->getStandardTypes() as $type) {
/** @var Definition|mixed $instance */
$instance = new $type($this);
if ($instance instanceof TypeDefinition) {
$this->types[$instance->getName()] = $instance;
} else {
$this->definitions[] = $instance;
}
}
} | [
"private",
"function",
"createStandardTypes",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getStandardTypes",
"(",
")",
"as",
"$",
"type",
")",
"{",
"/** @var Definition|mixed $instance */",
"$",
"instance",
"=",
"new",
"$",
"type",
"(",
"... | Creation and registration of types.
@return void | [
"Creation",
"and",
"registration",
"of",
"types",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/SDL/Standard/GraphQLDocument.php#L75-L87 |
railt/railt | src/Component/SDL/Standard/GraphQLDocument.php | GraphQLDocument.getStandardTypes | private function getStandardTypes(): array
{
$standard = [
// Scalars
BooleanType::class,
FloatType::class,
IDType::class,
IntType::class,
StringType::class,
AnyType::class,
DateTimeType::class,
// Directives
Deprecation::class,
];
return \array_merge($standard, $this->additionalTypes);
} | php | private function getStandardTypes(): array
{
$standard = [
// Scalars
BooleanType::class,
FloatType::class,
IDType::class,
IntType::class,
StringType::class,
AnyType::class,
DateTimeType::class,
// Directives
Deprecation::class,
];
return \array_merge($standard, $this->additionalTypes);
} | [
"private",
"function",
"getStandardTypes",
"(",
")",
":",
"array",
"{",
"$",
"standard",
"=",
"[",
"// Scalars",
"BooleanType",
"::",
"class",
",",
"FloatType",
"::",
"class",
",",
"IDType",
"::",
"class",
",",
"IntType",
"::",
"class",
",",
"StringType",
... | Returns should return a list of all predefined GraphQL types.
@return array|StandardType[] | [
"Returns",
"should",
"return",
"a",
"list",
"of",
"all",
"predefined",
"GraphQL",
"types",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/SDL/Standard/GraphQLDocument.php#L94-L111 |
railt/railt | src/Component/SDL/Reflection/Validation/Inheritance/WrapperValidator.php | WrapperValidator.validateListDirectRedefinition | private function validateListDirectRedefinition(AllowsTypeIndication $child, AllowsTypeIndication $parent): void
{
$isBrokenDirectRedefinition = $parent->isList() && ! $child->isList();
if ($isBrokenDirectRedefinition) {
$error = \sprintf('The %s cannot be overridden by non-list, but %s given', $parent, $child);
throw new TypeConflictException($error, $this->getCallStack());
}
} | php | private function validateListDirectRedefinition(AllowsTypeIndication $child, AllowsTypeIndication $parent): void
{
$isBrokenDirectRedefinition = $parent->isList() && ! $child->isList();
if ($isBrokenDirectRedefinition) {
$error = \sprintf('The %s cannot be overridden by non-list, but %s given', $parent, $child);
throw new TypeConflictException($error, $this->getCallStack());
}
} | [
"private",
"function",
"validateListDirectRedefinition",
"(",
"AllowsTypeIndication",
"$",
"child",
",",
"AllowsTypeIndication",
"$",
"parent",
")",
":",
"void",
"{",
"$",
"isBrokenDirectRedefinition",
"=",
"$",
"parent",
"->",
"isList",
"(",
")",
"&&",
"!",
"$",
... | Checks the following situations:
<code>
- [Type] overriden by Type
- [Type] overriden by Type!
- [Type]! overriden by Type
- [Type]! overriden by Type!
- [Type!] overriden by Type
- [Type!] overriden by Type!
- [Type!]! overriden by Type
- [Type!]! overriden by Type!
</code>
@param AllowsTypeIndication $child
@param AllowsTypeIndication $parent
@return void
@throws TypeConflictException | [
"Checks",
"the",
"following",
"situations",
":",
"<code",
">",
"-",
"[",
"Type",
"]",
"overriden",
"by",
"Type",
"-",
"[",
"Type",
"]",
"overriden",
"by",
"Type!",
"-",
"[",
"Type",
"]",
"!",
"overriden",
"by",
"Type",
"-",
"[",
"Type",
"]",
"!",
"... | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/SDL/Reflection/Validation/Inheritance/WrapperValidator.php#L88-L96 |
railt/railt | src/Component/SDL/Reflection/Validation/Inheritance/WrapperValidator.php | WrapperValidator.validateListInverseRedefinition | private function validateListInverseRedefinition(AllowsTypeIndication $child, AllowsTypeIndication $parent): void
{
$isBrokenInverseRedefinition = ! $parent->isList() && $child->isList();
if ($isBrokenInverseRedefinition) {
$error = \sprintf('The %s cannot be overridden by list, but %s given', $parent, $child);
throw new TypeConflictException($error, $this->getCallStack());
}
} | php | private function validateListInverseRedefinition(AllowsTypeIndication $child, AllowsTypeIndication $parent): void
{
$isBrokenInverseRedefinition = ! $parent->isList() && $child->isList();
if ($isBrokenInverseRedefinition) {
$error = \sprintf('The %s cannot be overridden by list, but %s given', $parent, $child);
throw new TypeConflictException($error, $this->getCallStack());
}
} | [
"private",
"function",
"validateListInverseRedefinition",
"(",
"AllowsTypeIndication",
"$",
"child",
",",
"AllowsTypeIndication",
"$",
"parent",
")",
":",
"void",
"{",
"$",
"isBrokenInverseRedefinition",
"=",
"!",
"$",
"parent",
"->",
"isList",
"(",
")",
"&&",
"$"... | Checks the following situations:
<code>
- Type overriden by [Type]
- Type! overriden by [Type]
- Type overriden by [Type]!
- Type! overriden by [Type]!
- Type overriden by [Type!]
- Type! overriden by [Type!]
- Type overriden by [Type!]!
- Type! overriden by [Type!]!
</code>
@param AllowsTypeIndication $child
@param AllowsTypeIndication $parent
@return void
@throws TypeConflictException | [
"Checks",
"the",
"following",
"situations",
":",
"<code",
">",
"-",
"Type",
"overriden",
"by",
"[",
"Type",
"]",
"-",
"Type!",
"overriden",
"by",
"[",
"Type",
"]",
"-",
"Type",
"overriden",
"by",
"[",
"Type",
"]",
"!",
"-",
"Type!",
"overriden",
"by",
... | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/SDL/Reflection/Validation/Inheritance/WrapperValidator.php#L116-L124 |
railt/railt | src/Component/Json/JsonRuntime.php | JsonRuntime.getOptions | public function getOptions(): int
{
$options = $this->traitGetOptions();
if (! (bool)($options & \JSON_THROW_ON_ERROR)) {
$options |= \JSON_THROW_ON_ERROR;
}
return $options;
} | php | public function getOptions(): int
{
$options = $this->traitGetOptions();
if (! (bool)($options & \JSON_THROW_ON_ERROR)) {
$options |= \JSON_THROW_ON_ERROR;
}
return $options;
} | [
"public",
"function",
"getOptions",
"(",
")",
":",
"int",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"traitGetOptions",
"(",
")",
";",
"if",
"(",
"!",
"(",
"bool",
")",
"(",
"$",
"options",
"&",
"\\",
"JSON_THROW_ON_ERROR",
")",
")",
"{",
"$",
"o... | Returns options used while encoding and decoding JSON sources.
@return int | [
"Returns",
"options",
"used",
"while",
"encoding",
"and",
"decoding",
"JSON",
"sources",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Json/JsonRuntime.php#L54-L63 |
railt/railt | src/Component/Container/Container/AliasesTrait.php | AliasesTrait.alias | public function alias(string $locator, string ...$aliases): Aliased
{
if (\count($aliases) === 0) {
$error = 'The number of aliases should be greater than zero';
throw new InvalidArgumentException($error);
}
if (! $this->has($locator)) {
$error = 'Could not to define an alias, because service %s is not defined in the container';
throw new ContainerResolutionException(\sprintf($error, $locator));
}
foreach ($aliases as $alias) {
$this->aliases[$alias] = $locator;
}
return $this;
} | php | public function alias(string $locator, string ...$aliases): Aliased
{
if (\count($aliases) === 0) {
$error = 'The number of aliases should be greater than zero';
throw new InvalidArgumentException($error);
}
if (! $this->has($locator)) {
$error = 'Could not to define an alias, because service %s is not defined in the container';
throw new ContainerResolutionException(\sprintf($error, $locator));
}
foreach ($aliases as $alias) {
$this->aliases[$alias] = $locator;
}
return $this;
} | [
"public",
"function",
"alias",
"(",
"string",
"$",
"locator",
",",
"string",
"...",
"$",
"aliases",
")",
":",
"Aliased",
"{",
"if",
"(",
"\\",
"count",
"(",
"$",
"aliases",
")",
"===",
"0",
")",
"{",
"$",
"error",
"=",
"'The number of aliases should be g... | Alias a type to a different name.
@param string $locator
@param string ...$aliases
@return Aliased|$this
@throws ContainerResolutionException
@throws InvalidArgumentException | [
"Alias",
"a",
"type",
"to",
"a",
"different",
"name",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Container/Container/AliasesTrait.php#L44-L61 |
railt/railt | src/Component/Json/Rfc7159/NativeJsonEncoder.php | NativeJsonEncoder.encode | public function encode($data, int $options = null): string
{
if ($options !== null) {
return (clone $this)->encode($data);
}
return $this->wrap(function () use ($data) {
return @\json_encode($data, $this->getOptions(), $this->getRecursionDepth());
});
} | php | public function encode($data, int $options = null): string
{
if ($options !== null) {
return (clone $this)->encode($data);
}
return $this->wrap(function () use ($data) {
return @\json_encode($data, $this->getOptions(), $this->getRecursionDepth());
});
} | [
"public",
"function",
"encode",
"(",
"$",
"data",
",",
"int",
"$",
"options",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"$",
"options",
"!==",
"null",
")",
"{",
"return",
"(",
"clone",
"$",
"this",
")",
"->",
"encode",
"(",
"$",
"data",
")... | Wrapper for JSON encoding logic with predefined options that
throws a Railt\Component\Json\Exception\JsonException when an error occurs.
@see http://www.php.net/manual/en/function.json-encode.php
@see http://php.net/manual/en/class.jsonexception.php
@param mixed $data
@param int|null $options
@return string
@throws JsonException | [
"Wrapper",
"for",
"JSON",
"encoding",
"logic",
"with",
"predefined",
"options",
"that",
"throws",
"a",
"Railt",
"\\",
"Component",
"\\",
"Json",
"\\",
"Exception",
"\\",
"JsonException",
"when",
"an",
"error",
"occurs",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Json/Rfc7159/NativeJsonEncoder.php#L41-L50 |
railt/railt | src/Component/Json/Json5/Json5Decoder.php | Json5Decoder.tryFallback | private function tryFallback(string $json, \Closure $otherwise)
{
if ($this->hasOption(Json5::FORCE_JSON5_DECODER)) {
return $otherwise($json);
}
try {
$decoder = new NativeJsonDecoder();
$decoder->setOptions($this->getOptions());
return $decoder->decode($json);
} catch (JsonStackOverflowException | JsonEncodingException $e) {
throw $e;
} catch (\Throwable $e) {
return $otherwise($json);
}
} | php | private function tryFallback(string $json, \Closure $otherwise)
{
if ($this->hasOption(Json5::FORCE_JSON5_DECODER)) {
return $otherwise($json);
}
try {
$decoder = new NativeJsonDecoder();
$decoder->setOptions($this->getOptions());
return $decoder->decode($json);
} catch (JsonStackOverflowException | JsonEncodingException $e) {
throw $e;
} catch (\Throwable $e) {
return $otherwise($json);
}
} | [
"private",
"function",
"tryFallback",
"(",
"string",
"$",
"json",
",",
"\\",
"Closure",
"$",
"otherwise",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"Json5",
"::",
"FORCE_JSON5_DECODER",
")",
")",
"{",
"return",
"$",
"otherwise",
"(",
"$",... | Try parsing with native JSON extension first, since that's much faster.
@param string $json
@param \Closure $otherwise
@return mixed
@throws JsonException | [
"Try",
"parsing",
"with",
"native",
"JSON",
"extension",
"first",
"since",
"that",
"s",
"much",
"faster",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Component/Json/Json5/Json5Decoder.php#L83-L99 |
railt/railt | src/Extension/Debug/Formatter/PrettyResponseSubscriber.php | PrettyResponseSubscriber.shareExceptionTrace | private function shareExceptionTrace(ResponseInterface $response): void
{
foreach ($response->getExceptions() as $exception) {
if ($exception instanceof GraphQLExceptionInterface) {
$exception->withExtension(new ExceptionTraceExtension($exception));
}
$exception->publish();
}
} | php | private function shareExceptionTrace(ResponseInterface $response): void
{
foreach ($response->getExceptions() as $exception) {
if ($exception instanceof GraphQLExceptionInterface) {
$exception->withExtension(new ExceptionTraceExtension($exception));
}
$exception->publish();
}
} | [
"private",
"function",
"shareExceptionTrace",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"response",
"->",
"getExceptions",
"(",
")",
"as",
"$",
"exception",
")",
"{",
"if",
"(",
"$",
"exception",
"instanceof",
"Gr... | Toggles all exceptions in response to debug mode.
@param ResponseInterface $response | [
"Toggles",
"all",
"exceptions",
"in",
"response",
"to",
"debug",
"mode",
"."
] | train | https://github.com/railt/railt/blob/8f17cd620fd0eecb9aa9a09fda87fa6f7afbc7dd/src/Extension/Debug/Formatter/PrettyResponseSubscriber.php#L58-L67 |
ingrammicro/connect-php-sdk | src/Logger.php | Logger.setLogFile | public function setLogFile($filePath)
{
if ($this->logFile != $filePath && $this->fp) {
@fclose($this->fp);
$this->fp = null;
}
$logDir = dirname($filePath);
if (!file_exists($logDir)) {
@mkdir($logDir, 0755, true);
}
if (!file_exists($logDir)) {
throw new Exception(sprintf('Can\'t create log directory "%s".', $logDir), 'logger');
}
if (!$this->fp = @fopen($filePath, 'a+')) {
throw new Exception(sprintf('Can\'t create log file "%s".', $filePath), 'logger');
}
$this->logFile = $filePath;
return $this;
} | php | public function setLogFile($filePath)
{
if ($this->logFile != $filePath && $this->fp) {
@fclose($this->fp);
$this->fp = null;
}
$logDir = dirname($filePath);
if (!file_exists($logDir)) {
@mkdir($logDir, 0755, true);
}
if (!file_exists($logDir)) {
throw new Exception(sprintf('Can\'t create log directory "%s".', $logDir), 'logger');
}
if (!$this->fp = @fopen($filePath, 'a+')) {
throw new Exception(sprintf('Can\'t create log file "%s".', $filePath), 'logger');
}
$this->logFile = $filePath;
return $this;
} | [
"public",
"function",
"setLogFile",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logFile",
"!=",
"$",
"filePath",
"&&",
"$",
"this",
"->",
"fp",
")",
"{",
"@",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"$",
"this",
"->",... | Set the log file path
@param $filePath
@throws Exception
@return $this | [
"Set",
"the",
"log",
"file",
"path"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Logger.php#L59-L80 |
ingrammicro/connect-php-sdk | src/Logger.php | Logger.log | public function log($level, $message, array $context = [])
{
$record = new LogRecord($level, $message);
// add all messages to session log
$this->session->addRecord($record);
// write record into log only if it is enough by level
if ($this->logLevel >= $level) {
$this->write($record);
}
} | php | public function log($level, $message, array $context = [])
{
$record = new LogRecord($level, $message);
// add all messages to session log
$this->session->addRecord($record);
// write record into log only if it is enough by level
if ($this->logLevel >= $level) {
$this->write($record);
}
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"record",
"=",
"new",
"LogRecord",
"(",
"$",
"level",
",",
"$",
"message",
")",
";",
"// add all messages to session log",
... | Log message of any level
@param int $level
@param string $message
@param array $context | [
"Log",
"message",
"of",
"any",
"level"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Logger.php#L195-L206 |
ingrammicro/connect-php-sdk | src/Logger.php | Logger.write | public function write(LogRecord $record)
{
$logLine = array();
if ($record->time) {
$timestr = ($this->logLevel >= self::LEVEL_DEBUG) ?
$this->udate('Y-m-d H:i:s.u T', $record->time) :
date('Y/m/d h:i:s', $record->time);
$logLine[] = "[ $timestr ]";
}
if ($record->level != null) {
$logLine[] = self::LEVELS[$record->level];
}
$logLine[] = $record->message;
$message = implode(' ', $logLine) . PHP_EOL;
if ($this->fp) {
fwrite($this->fp, $message);
} else {
if (isset($GLOBALS['useErrorLog'])) {
error_log($message);
} else {
file_put_contents('php://stderr', $message, FILE_APPEND);
}
}
return $message;
} | php | public function write(LogRecord $record)
{
$logLine = array();
if ($record->time) {
$timestr = ($this->logLevel >= self::LEVEL_DEBUG) ?
$this->udate('Y-m-d H:i:s.u T', $record->time) :
date('Y/m/d h:i:s', $record->time);
$logLine[] = "[ $timestr ]";
}
if ($record->level != null) {
$logLine[] = self::LEVELS[$record->level];
}
$logLine[] = $record->message;
$message = implode(' ', $logLine) . PHP_EOL;
if ($this->fp) {
fwrite($this->fp, $message);
} else {
if (isset($GLOBALS['useErrorLog'])) {
error_log($message);
} else {
file_put_contents('php://stderr', $message, FILE_APPEND);
}
}
return $message;
} | [
"public",
"function",
"write",
"(",
"LogRecord",
"$",
"record",
")",
"{",
"$",
"logLine",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"record",
"->",
"time",
")",
"{",
"$",
"timestr",
"=",
"(",
"$",
"this",
"->",
"logLevel",
">=",
"self",
"::",
... | Write log record into log
@param LogRecord $record
@return string | [
"Write",
"log",
"record",
"into",
"log"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Logger.php#L214-L244 |
ingrammicro/connect-php-sdk | src/Logger.php | Logger.udate | private function udate($format = 'u', $utimestamp = null)
{
$utimestamp = is_null($utimestamp) ? microtime(true) : $utimestamp;
$timestamp = floor($utimestamp);
$milliseconds = round(($utimestamp - $timestamp) * 1000000);
return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp);
} | php | private function udate($format = 'u', $utimestamp = null)
{
$utimestamp = is_null($utimestamp) ? microtime(true) : $utimestamp;
$timestamp = floor($utimestamp);
$milliseconds = round(($utimestamp - $timestamp) * 1000000);
return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp);
} | [
"private",
"function",
"udate",
"(",
"$",
"format",
"=",
"'u'",
",",
"$",
"utimestamp",
"=",
"null",
")",
"{",
"$",
"utimestamp",
"=",
"is_null",
"(",
"$",
"utimestamp",
")",
"?",
"microtime",
"(",
"true",
")",
":",
"$",
"utimestamp",
";",
"$",
"time... | @param string $format
@param null $utimestamp
@return bool|string | [
"@param",
"string",
"$format",
"@param",
"null",
"$utimestamp"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Logger.php#L252-L259 |
ingrammicro/connect-php-sdk | src/Modules/Fulfillment.php | Fulfillment.updateParameters | public function updateParameters(Request $request, array $params)
{
$body = new Request(['asset' => ['params' => $params]]);
$this->sendRequest('PUT', '/requests/' . $request->id, $body);
} | php | public function updateParameters(Request $request, array $params)
{
$body = new Request(['asset' => ['params' => $params]]);
$this->sendRequest('PUT', '/requests/' . $request->id, $body);
} | [
"public",
"function",
"updateParameters",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"params",
")",
"{",
"$",
"body",
"=",
"new",
"Request",
"(",
"[",
"'asset'",
"=>",
"[",
"'params'",
"=>",
"$",
"params",
"]",
"]",
")",
";",
"$",
"this",
"->... | Update request parameters
@param Request $request - request being updated
@param Param[] $params - array of parameters
Example:
[
$request->asset->params['param_a']->error('Unknown activation ID was provided'),
$request->asset->params['param_b']->value('true'),
new \Connect\Param(['id' => 'param_c', 'newValue'])
]
@throws GuzzleException | [
"Update",
"request",
"parameters"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Modules/Fulfillment.php#L87-L91 |
ingrammicro/connect-php-sdk | src/Modules/Fulfillment.php | Fulfillment.renderTemplate | public function renderTemplate($templateId, $request)
{
$query = ($request instanceof Request) ? $request->id : $request;
return $this->sendRequest('GET', '/templates/' . $templateId . '/render?request_id=' . $query);
} | php | public function renderTemplate($templateId, $request)
{
$query = ($request instanceof Request) ? $request->id : $request;
return $this->sendRequest('GET', '/templates/' . $templateId . '/render?request_id=' . $query);
} | [
"public",
"function",
"renderTemplate",
"(",
"$",
"templateId",
",",
"$",
"request",
")",
"{",
"$",
"query",
"=",
"(",
"$",
"request",
"instanceof",
"Request",
")",
"?",
"$",
"request",
"->",
"id",
":",
"$",
"request",
";",
"return",
"$",
"this",
"->",... | Gets Activation template for a given request
@param $templateId - ID of template requested
@param $request - ID of request or Request object
@return string - Rendered template
@throws GuzzleException | [
"Gets",
"Activation",
"template",
"for",
"a",
"given",
"request"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Modules/Fulfillment.php#L100-L104 |
ingrammicro/connect-php-sdk | src/Request.php | Request.getNewItems | public function getNewItems()
{
$ret = array();
foreach ($this->asset->items as $item) {
if (($item->quantity > 0) && ($item->old_quantity == 0)) {
$ret[] = $item;
}
}
return $ret;
} | php | public function getNewItems()
{
$ret = array();
foreach ($this->asset->items as $item) {
if (($item->quantity > 0) && ($item->old_quantity == 0)) {
$ret[] = $item;
}
}
return $ret;
} | [
"public",
"function",
"getNewItems",
"(",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"asset",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"(",
"$",
"item",
"->",
"quantity",
">",
"0",
")",
"... | Get new SKUs purchased in the request
@return Item[] | [
"Get",
"new",
"SKUs",
"purchased",
"in",
"the",
"request"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Request.php#L55-L64 |
ingrammicro/connect-php-sdk | src/Logger/LogSession.php | LogSession.dumpTo | public function dumpTo(LoggerInterface $logger)
{
if (empty($this->sessionLog)) {
return $this;
}
$logger->write(new LogRecord(null, "=== Detailed session log dump begin ==================", null));
foreach ($this->sessionLog as $record) {
$logger->write($record); // historical log dumped with actual event times
}
$logger->write(new LogRecord(null, "=== Detailed session log dump end ====================", null));
return $this;
} | php | public function dumpTo(LoggerInterface $logger)
{
if (empty($this->sessionLog)) {
return $this;
}
$logger->write(new LogRecord(null, "=== Detailed session log dump begin ==================", null));
foreach ($this->sessionLog as $record) {
$logger->write($record); // historical log dumped with actual event times
}
$logger->write(new LogRecord(null, "=== Detailed session log dump end ====================", null));
return $this;
} | [
"public",
"function",
"dumpTo",
"(",
"LoggerInterface",
"$",
"logger",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"sessionLog",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"logger",
"->",
"write",
"(",
"new",
"LogRecord",
"(",
"nu... | Dump session log to specified logger
@param LoggerInterface $logger
@return $this | [
"Dump",
"session",
"log",
"to",
"specified",
"logger"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Logger/LogSession.php#L50-L63 |
ingrammicro/connect-php-sdk | src/Config.php | Config.setRuntimeServices | public function setRuntimeServices($runtimeServices)
{
if (!in_array(gettype($runtimeServices), ['array', 'object'])) {
throw new \InvalidArgumentException("The service provider list must be an array or an object, given " . gettype($runtimeServices));
}
$this->runtimeServices = array_merge($this->runtimeServices, (new Model($runtimeServices))->toArray());
} | php | public function setRuntimeServices($runtimeServices)
{
if (!in_array(gettype($runtimeServices), ['array', 'object'])) {
throw new \InvalidArgumentException("The service provider list must be an array or an object, given " . gettype($runtimeServices));
}
$this->runtimeServices = array_merge($this->runtimeServices, (new Model($runtimeServices))->toArray());
} | [
"public",
"function",
"setRuntimeServices",
"(",
"$",
"runtimeServices",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"gettype",
"(",
"$",
"runtimeServices",
")",
",",
"[",
"'array'",
",",
"'object'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumen... | Reconfigure the service builder list
@param array $runtimeServices | [
"Reconfigure",
"the",
"service",
"builder",
"list"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Config.php#L142-L149 |
ingrammicro/connect-php-sdk | src/Config.php | Config.setProducts | public function setProducts($product)
{
if (is_string($product)) {
$product = [$product];
}
if (!is_array($product)) {
throw new \InvalidArgumentException("The product list must be an string or an array, given " . gettype($product));
}
$this->products = $product;
} | php | public function setProducts($product)
{
if (is_string($product)) {
$product = [$product];
}
if (!is_array($product)) {
throw new \InvalidArgumentException("The product list must be an string or an array, given " . gettype($product));
}
$this->products = $product;
} | [
"public",
"function",
"setProducts",
"(",
"$",
"product",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"product",
")",
")",
"{",
"$",
"product",
"=",
"[",
"$",
"product",
"]",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"product",
")",
")",
"{... | Set the product list
@param string|array $product | [
"Set",
"the",
"product",
"list"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Config.php#L156-L167 |
ingrammicro/connect-php-sdk | src/Modules/Usage.php | Usage.listListings | public function listListings(array $filters = [])
{
$query = '';
if ($this->config->products) {
$filters['product__id'] = $this->config->products;
}
if ($filters) {
$query = '?' . preg_replace('/%5B[0-9]+%5D/simU', '', http_build_query($filters));
}
$body = $this->sendRequest('GET', '/listings' . $query);
/** @var Listing[] $models */
$models = Model::modelize('listings', json_decode($body));
foreach ($models as $index => $model) {
$models[$index]->requestProcessor = $this;
}
return $models;
} | php | public function listListings(array $filters = [])
{
$query = '';
if ($this->config->products) {
$filters['product__id'] = $this->config->products;
}
if ($filters) {
$query = '?' . preg_replace('/%5B[0-9]+%5D/simU', '', http_build_query($filters));
}
$body = $this->sendRequest('GET', '/listings' . $query);
/** @var Listing[] $models */
$models = Model::modelize('listings', json_decode($body));
foreach ($models as $index => $model) {
$models[$index]->requestProcessor = $this;
}
return $models;
} | [
"public",
"function",
"listListings",
"(",
"array",
"$",
"filters",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"products",
")",
"{",
"$",
"filters",
"[",
"'product__id'",
"]",
"=",
"$",
"thi... | Lists the product listings
@param array $filters Filter for listing key->value or key->array(value1, value2)
@return Listing[]
@throws GuzzleException | [
"Lists",
"the",
"product",
"listings"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Modules/Usage.php#L65-L86 |
ingrammicro/connect-php-sdk | src/Asset.php | Asset.getParameterByID | public function getParameterByID($id)
{
$param = current(array_filter($this->params, function (Param $param) use ($id) {
return ($param->id === $id);
}));
return ($param) ? $param : null;
} | php | public function getParameterByID($id)
{
$param = current(array_filter($this->params, function (Param $param) use ($id) {
return ($param->id === $id);
}));
return ($param) ? $param : null;
} | [
"public",
"function",
"getParameterByID",
"(",
"$",
"id",
")",
"{",
"$",
"param",
"=",
"current",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"params",
",",
"function",
"(",
"Param",
"$",
"param",
")",
"use",
"(",
"$",
"id",
")",
"{",
"return",
"(",... | Return a Param by ID
@param $id
@return Param | [
"Return",
"a",
"Param",
"by",
"ID"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Asset.php#L51-L58 |
ingrammicro/connect-php-sdk | src/Asset.php | Asset.getItemByID | public function getItemByID($id)
{
$item = current(array_filter($this->items, function (Item $item) use ($id) {
return ($item->id === $id);
}));
return ($item) ? $item : null;
} | php | public function getItemByID($id)
{
$item = current(array_filter($this->items, function (Item $item) use ($id) {
return ($item->id === $id);
}));
return ($item) ? $item : null;
} | [
"public",
"function",
"getItemByID",
"(",
"$",
"id",
")",
"{",
"$",
"item",
"=",
"current",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"items",
",",
"function",
"(",
"Item",
"$",
"item",
")",
"use",
"(",
"$",
"id",
")",
"{",
"return",
"(",
"$",
... | Return a Item by ID
@param $id
@return Item | [
"Return",
"a",
"Item",
"by",
"ID"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Asset.php#L67-L74 |
ingrammicro/connect-php-sdk | src/Asset.php | Asset.getItemByMPN | public function getItemByMPN($mpn)
{
$item = current(array_filter($this->items, function (Item $item) use ($mpn) {
return ($item->mpn === $mpn);
}));
return ($item) ? $item : null;
} | php | public function getItemByMPN($mpn)
{
$item = current(array_filter($this->items, function (Item $item) use ($mpn) {
return ($item->mpn === $mpn);
}));
return ($item) ? $item : null;
} | [
"public",
"function",
"getItemByMPN",
"(",
"$",
"mpn",
")",
"{",
"$",
"item",
"=",
"current",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"items",
",",
"function",
"(",
"Item",
"$",
"item",
")",
"use",
"(",
"$",
"mpn",
")",
"{",
"return",
"(",
"$"... | Return a Item by MPN
@param $id
@return Item | [
"Return",
"a",
"Item",
"by",
"MPN"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Asset.php#L81-L88 |
ingrammicro/connect-php-sdk | src/Runtime/Providers/TierConfigurationServiceProvider.php | TierConfigurationServiceProvider.register | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
/** @var LoggerInterface $logger */
$logger = $container['logger'];
/** @var Client $http */
$http = $container['http'];
return new TierConfiguration($configuration, $logger, $http, $container);
} | php | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
/** @var LoggerInterface $logger */
$logger = $container['logger'];
/** @var Client $http */
$http = $container['http'];
return new TierConfiguration($configuration, $logger, $http, $container);
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"container",
")",
"{",
"/** @var Config $configuration */",
"$",
"configuration",
"=",
"$",
"container",
"[",
"'config'",
"]",
";",
"/** @var LoggerInterface $logger */",
"$",
"logger",
"=",
"$",
"container",
... | Create the TierConfiguration Service
@param Container $container
@return TierConfiguration | [
"Create",
"the",
"TierConfiguration",
"Service"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Runtime/Providers/TierConfigurationServiceProvider.php#L29-L41 |
ingrammicro/connect-php-sdk | src/Runtime/Providers/HttpServiceProvider.php | HttpServiceProvider.register | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
$client = new Client([
'timeout' => $configuration->timeout,
'verify' => $configuration->sslVerifyHost,
]);
return $client;
} | php | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
$client = new Client([
'timeout' => $configuration->timeout,
'verify' => $configuration->sslVerifyHost,
]);
return $client;
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"container",
")",
"{",
"/** @var Config $configuration */",
"$",
"configuration",
"=",
"$",
"container",
"[",
"'config'",
"]",
";",
"$",
"client",
"=",
"new",
"Client",
"(",
"[",
"'timeout'",
"=>",
"$",
... | Create the Curl Service
@param Container $container
@return Client | [
"Create",
"the",
"Curl",
"Service"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Runtime/Providers/HttpServiceProvider.php#L27-L38 |
ingrammicro/connect-php-sdk | src/Modules/TierConfiguration.php | TierConfiguration.updateTierConfigRequestParameters | public function updateTierConfigRequestParameters(TierConfigRequest $tierConfigRequest, array $params)
{
$body = new TierConfigRequest(['params' => $params]);
$this->sendRequest('PUT', '/tier/config-requests/' . $tierConfigRequest->id, $body);
} | php | public function updateTierConfigRequestParameters(TierConfigRequest $tierConfigRequest, array $params)
{
$body = new TierConfigRequest(['params' => $params]);
$this->sendRequest('PUT', '/tier/config-requests/' . $tierConfigRequest->id, $body);
} | [
"public",
"function",
"updateTierConfigRequestParameters",
"(",
"TierConfigRequest",
"$",
"tierConfigRequest",
",",
"array",
"$",
"params",
")",
"{",
"$",
"body",
"=",
"new",
"TierConfigRequest",
"(",
"[",
"'params'",
"=>",
"$",
"params",
"]",
")",
";",
"$",
"... | Update tierConfig parameters
@param TierConfigRequest $tierConfigRequest - TierConfigRequest being updated
@param Param[] $params - array of parameters
@throws GuzzleException | [
"Update",
"tierConfig",
"parameters"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Modules/TierConfiguration.php#L54-L58 |
ingrammicro/connect-php-sdk | src/Runtime/Providers/UsageServiceProvider.php | UsageServiceProvider.register | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
/** @var LoggerInterface $logger */
$logger = $container['logger'];
/** @var Client $http */
$http = $container['http'];
/** @var TierConfiguration $tierConfiguration */
$tierConfiguration = $container['tierConfiguration'];
/** @var Fulfillment $fulfillment */
$fulfillment = $container['fulfillment'];
return new Usage($configuration, $logger, $http, $tierConfiguration, $fulfillment);
} | php | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
/** @var LoggerInterface $logger */
$logger = $container['logger'];
/** @var Client $http */
$http = $container['http'];
/** @var TierConfiguration $tierConfiguration */
$tierConfiguration = $container['tierConfiguration'];
/** @var Fulfillment $fulfillment */
$fulfillment = $container['fulfillment'];
return new Usage($configuration, $logger, $http, $tierConfiguration, $fulfillment);
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"container",
")",
"{",
"/** @var Config $configuration */",
"$",
"configuration",
"=",
"$",
"container",
"[",
"'config'",
"]",
";",
"/** @var LoggerInterface $logger */",
"$",
"logger",
"=",
"$",
"container",
... | Create the Usage Service
@param Container $container
@return Usage | [
"Create",
"the",
"Usage",
"Service"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Runtime/Providers/UsageServiceProvider.php#L31-L49 |
ingrammicro/connect-php-sdk | src/Model.php | Model.hydrate | public function hydrate($source)
{
/**
* foreach element of the "source" try to find programmatically
* the correct data model base in the property type and name.
*/
foreach ($source as $key => $value) {
$this->set($key, $value);
}
return $this;
} | php | public function hydrate($source)
{
/**
* foreach element of the "source" try to find programmatically
* the correct data model base in the property type and name.
*/
foreach ($source as $key => $value) {
$this->set($key, $value);
}
return $this;
} | [
"public",
"function",
"hydrate",
"(",
"$",
"source",
")",
"{",
"/**\n * foreach element of the \"source\" try to find programmatically\n * the correct data model base in the property type and name.\n */",
"foreach",
"(",
"$",
"source",
"as",
"$",
"key",
"=>",
... | Populate the object recursively
@param array|object $source
@return $this | [
"Populate",
"the",
"object",
"recursively"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Model.php#L89-L100 |
ingrammicro/connect-php-sdk | src/Model.php | Model.set | public function set($key, $value)
{
$allowed = array_diff(array_keys(get_class_vars(get_class($this))), $this->_hidden);
if (empty($allowed) || !empty($allowed) && in_array($key, $allowed)) {
if (method_exists($this, 'set' . ucfirst($key))) {
call_user_func_array([$this, 'set' . ucfirst($key)], [$value]);
} else {
$this->{$key} = self::modelize($key, $value);
}
}
return $this;
} | php | public function set($key, $value)
{
$allowed = array_diff(array_keys(get_class_vars(get_class($this))), $this->_hidden);
if (empty($allowed) || !empty($allowed) && in_array($key, $allowed)) {
if (method_exists($this, 'set' . ucfirst($key))) {
call_user_func_array([$this, 'set' . ucfirst($key)], [$value]);
} else {
$this->{$key} = self::modelize($key, $value);
}
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"allowed",
"=",
"array_diff",
"(",
"array_keys",
"(",
"get_class_vars",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
")",
",",
"$",
"this",
"->",
"_hidden",
")",
";",
... | Set the given value into the model
@param string $key
@param mixed $value
@return $this | [
"Set",
"the",
"given",
"value",
"into",
"the",
"model"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Model.php#L108-L120 |
ingrammicro/connect-php-sdk | src/Model.php | Model.get | public function get($key)
{
$allowed = array_diff(array_keys(get_class_vars(get_class($this))), $this->_hidden);
if (empty($allowed) || !empty($allowed) && in_array($key, $allowed)) {
if (method_exists($this, 'get' . ucfirst($key))) {
return call_user_func_array([$this, 'get' . ucfirst($key)], [$key]);
}
return $this->{$key};
}
return null;
} | php | public function get($key)
{
$allowed = array_diff(array_keys(get_class_vars(get_class($this))), $this->_hidden);
if (empty($allowed) || !empty($allowed) && in_array($key, $allowed)) {
if (method_exists($this, 'get' . ucfirst($key))) {
return call_user_func_array([$this, 'get' . ucfirst($key)], [$key]);
}
return $this->{$key};
}
return null;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"allowed",
"=",
"array_diff",
"(",
"array_keys",
"(",
"get_class_vars",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
")",
",",
"$",
"this",
"->",
"_hidden",
")",
";",
"if",
"(",
"empty",
... | Get the requested value from the model
@param string $key
@return null|mixed | [
"Get",
"the",
"requested",
"value",
"from",
"the",
"model"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Model.php#L138-L150 |
ingrammicro/connect-php-sdk | src/Model.php | Model.modelize | public static function modelize($key, $value)
{
switch (gettype($value)) {
case 'object':
$namespaces = ['\Connect\\', '\Connect\Usage\\'];
/**
* if the item is an object search if there are any model that match with it:
*
* foreach tracked namespace do:
*
* 1. fqcn = base namespace + capitalized property name.
*
* 2. fqcn = base namespace + capitalized + singularized property name.
*
* 3. if '_' is found in name then
* fqcn = base namespace + split property name by '_', for each section
* capitalize, singularize and merge sections.
*
* 4. fqcn = base namespace + capitalized + singularized property name with trimmed nums.
*
* if any of the user cases from above match, create a single Connect\Model object.
*/
foreach ($namespaces as $namespace) {
$fqcn = $namespace . ucfirst($key);
if (class_exists($fqcn, true)) {
return new $fqcn($value);
}
$fqcn = $namespace . ucfirst(Inflector::singularize($key));
if (strpos($key, '_') !== false) {
$fqcn = $namespace . implode('', array_map(function ($word) {
return ucfirst(Inflector::singularize($word));
}, explode('_', $key)));
}
if (class_exists($fqcn, true)) {
return new $fqcn($value);
}
$fqcn = trim($fqcn, '0123456789');
if (class_exists($fqcn, true)) {
return new $fqcn($value);
}
}
return new Model($value);
case 'array':
$array = [];
/**
* if the item is an array, call again the modelize method for each item
* of the array using the key as seed of the model and keeping the index
* of original array.
*/
foreach ($value as $index => $item) {
$array[$index] = self::modelize(is_int($index) ? $key : $index, $item);
}
return $array;
break;
default:
/**
* if the data is an scalar directly assign it. the data type
* should be correctly from the source: int as int instead
* of string etc...
*/
return $value;
}
} | php | public static function modelize($key, $value)
{
switch (gettype($value)) {
case 'object':
$namespaces = ['\Connect\\', '\Connect\Usage\\'];
/**
* if the item is an object search if there are any model that match with it:
*
* foreach tracked namespace do:
*
* 1. fqcn = base namespace + capitalized property name.
*
* 2. fqcn = base namespace + capitalized + singularized property name.
*
* 3. if '_' is found in name then
* fqcn = base namespace + split property name by '_', for each section
* capitalize, singularize and merge sections.
*
* 4. fqcn = base namespace + capitalized + singularized property name with trimmed nums.
*
* if any of the user cases from above match, create a single Connect\Model object.
*/
foreach ($namespaces as $namespace) {
$fqcn = $namespace . ucfirst($key);
if (class_exists($fqcn, true)) {
return new $fqcn($value);
}
$fqcn = $namespace . ucfirst(Inflector::singularize($key));
if (strpos($key, '_') !== false) {
$fqcn = $namespace . implode('', array_map(function ($word) {
return ucfirst(Inflector::singularize($word));
}, explode('_', $key)));
}
if (class_exists($fqcn, true)) {
return new $fqcn($value);
}
$fqcn = trim($fqcn, '0123456789');
if (class_exists($fqcn, true)) {
return new $fqcn($value);
}
}
return new Model($value);
case 'array':
$array = [];
/**
* if the item is an array, call again the modelize method for each item
* of the array using the key as seed of the model and keeping the index
* of original array.
*/
foreach ($value as $index => $item) {
$array[$index] = self::modelize(is_int($index) ? $key : $index, $item);
}
return $array;
break;
default:
/**
* if the data is an scalar directly assign it. the data type
* should be correctly from the source: int as int instead
* of string etc...
*/
return $value;
}
} | [
"public",
"static",
"function",
"modelize",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"gettype",
"(",
"$",
"value",
")",
")",
"{",
"case",
"'object'",
":",
"$",
"namespaces",
"=",
"[",
"'\\Connect\\\\'",
",",
"'\\Connect\\Usage\\\\'",
... | Modelize the given value into \Connect\Model
@param string $key
@param mixed $value
@return array|Model | [
"Modelize",
"the",
"given",
"value",
"into",
"\\",
"Connect",
"\\",
"Model"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Model.php#L168-L241 |
ingrammicro/connect-php-sdk | src/Model.php | Model.arrayize | public static function arrayize($value)
{
$forbidden = [];
if ($value instanceof Model) {
$forbidden = $value->getHidden();
}
$array = [];
foreach ($value as $key => $item) {
if (!in_array(trim($key), $forbidden)) {
switch (gettype($item)) {
case 'object':
case 'array':
$buffer = self::arrayize($item);
if (!empty($buffer)) {
$array[trim($key)] = $buffer;
}
break;
default:
if (isset($item)) {
$array[trim($key)] = $item;
}
}
}
}
return $array;
} | php | public static function arrayize($value)
{
$forbidden = [];
if ($value instanceof Model) {
$forbidden = $value->getHidden();
}
$array = [];
foreach ($value as $key => $item) {
if (!in_array(trim($key), $forbidden)) {
switch (gettype($item)) {
case 'object':
case 'array':
$buffer = self::arrayize($item);
if (!empty($buffer)) {
$array[trim($key)] = $buffer;
}
break;
default:
if (isset($item)) {
$array[trim($key)] = $item;
}
}
}
}
return $array;
} | [
"public",
"static",
"function",
"arrayize",
"(",
"$",
"value",
")",
"{",
"$",
"forbidden",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"value",
"instanceof",
"Model",
")",
"{",
"$",
"forbidden",
"=",
"$",
"value",
"->",
"getHidden",
"(",
")",
";",
"}",
"$"... | Transform the given structure into array
@param mixed $value
@return array | [
"Transform",
"the",
"given",
"structure",
"into",
"array"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Model.php#L248-L276 |
ingrammicro/connect-php-sdk | src/Runtime/Providers/FulfillmentServiceProvider.php | FulfillmentServiceProvider.register | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
/** @var LoggerInterface $logger */
$logger = $container['logger'];
/** @var Client $http */
$http = $container['http'];
/** @var TierConfiguration $tierConfiguration */
$tierConfiguration = $container['tierConfiguration'];
return new Fulfillment($configuration, $logger, $http, $tierConfiguration);
} | php | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
/** @var LoggerInterface $logger */
$logger = $container['logger'];
/** @var Client $http */
$http = $container['http'];
/** @var TierConfiguration $tierConfiguration */
$tierConfiguration = $container['tierConfiguration'];
return new Fulfillment($configuration, $logger, $http, $tierConfiguration);
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"container",
")",
"{",
"/** @var Config $configuration */",
"$",
"configuration",
"=",
"$",
"container",
"[",
"'config'",
"]",
";",
"/** @var LoggerInterface $logger */",
"$",
"logger",
"=",
"$",
"container",
... | Create the Fulfillment Service
@param Container $container
@return Fulfillment | [
"Create",
"the",
"Fulfillment",
"Service"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Runtime/Providers/FulfillmentServiceProvider.php#L30-L45 |
ingrammicro/connect-php-sdk | src/Runtime/Providers/LoggerServiceProvider.php | LoggerServiceProvider.register | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
$logger = Logger::get();
$logger->setLogLevel($configuration->logLevel);
return $logger;
} | php | public function register(Container $container)
{
/** @var Config $configuration */
$configuration = $container['config'];
$logger = Logger::get();
$logger->setLogLevel($configuration->logLevel);
return $logger;
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"container",
")",
"{",
"/** @var Config $configuration */",
"$",
"configuration",
"=",
"$",
"container",
"[",
"'config'",
"]",
";",
"$",
"logger",
"=",
"Logger",
"::",
"get",
"(",
")",
";",
"$",
"logge... | Create the Logger Service
@param Container $container
@return \Psr\Log\LoggerInterface | [
"Create",
"the",
"Logger",
"Service"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Runtime/Providers/LoggerServiceProvider.php#L27-L36 |
ingrammicro/connect-php-sdk | src/FulfillmentAutomation.php | FulfillmentAutomation.process | public function process()
{
foreach ($this->tierConfiguration->listTierConfigs(['status' => 'pending']) as $tierConfig) {
$this->dispatchTierConfig($tierConfig);
}
foreach ($this->fulfillment->listRequests(['status' => 'pending']) as $request) {
$this->dispatch($request);
}
} | php | public function process()
{
foreach ($this->tierConfiguration->listTierConfigs(['status' => 'pending']) as $tierConfig) {
$this->dispatchTierConfig($tierConfig);
}
foreach ($this->fulfillment->listRequests(['status' => 'pending']) as $request) {
$this->dispatch($request);
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"tierConfiguration",
"->",
"listTierConfigs",
"(",
"[",
"'status'",
"=>",
"'pending'",
"]",
")",
"as",
"$",
"tierConfig",
")",
"{",
"$",
"this",
"->",
"dispatchTierConfig",
... | Process all requests
@throws GuzzleException | [
"Process",
"all",
"requests"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/FulfillmentAutomation.php#L24-L33 |
ingrammicro/connect-php-sdk | src/Modules/Core.php | Core.sendRequest | public function sendRequest($verb, $path, $body = null)
{
$this->logger->info('Module: ' . __CLASS__);
if ($body instanceof Model) {
$body = $body->toJSON(true);
}
$headers = [
'Authorization' => 'ApiKey ' . $this->config->apiKey,
'Request-ID' => uniqid('api-request-'),
'Content-Type' => 'application/json',
];
$this->logger->info('HTTP Request: ' . strtoupper($verb) . ' ' . $this->config->apiEndpoint . $path);
$this->logger->debug("Request Headers:\n" . print_r($headers, true));
if (isset($body)) {
$this->logger->debug("Request Body:\n" . $body);
}
$response = $this->http->request(strtoupper($verb), trim($this->config->apiEndpoint . $path), [
'body' => $body,
'headers' => $headers
]);
$this->logger->info('HTTP Code: ' . $response->getStatusCode());
return $response->getBody()->getContents();
} | php | public function sendRequest($verb, $path, $body = null)
{
$this->logger->info('Module: ' . __CLASS__);
if ($body instanceof Model) {
$body = $body->toJSON(true);
}
$headers = [
'Authorization' => 'ApiKey ' . $this->config->apiKey,
'Request-ID' => uniqid('api-request-'),
'Content-Type' => 'application/json',
];
$this->logger->info('HTTP Request: ' . strtoupper($verb) . ' ' . $this->config->apiEndpoint . $path);
$this->logger->debug("Request Headers:\n" . print_r($headers, true));
if (isset($body)) {
$this->logger->debug("Request Body:\n" . $body);
}
$response = $this->http->request(strtoupper($verb), trim($this->config->apiEndpoint . $path), [
'body' => $body,
'headers' => $headers
]);
$this->logger->info('HTTP Code: ' . $response->getStatusCode());
return $response->getBody()->getContents();
} | [
"public",
"function",
"sendRequest",
"(",
"$",
"verb",
",",
"$",
"path",
",",
"$",
"body",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'Module: '",
".",
"__CLASS__",
")",
";",
"if",
"(",
"$",
"body",
"instanceof",
"Model",... | Send the actual request to the connect endpoint
@param string $verb
@param string $path
@param null|Model|string $body
@return string
@throws GuzzleException | [
"Send",
"the",
"actual",
"request",
"to",
"the",
"connect",
"endpoint"
] | train | https://github.com/ingrammicro/connect-php-sdk/blob/a9e0d824b1118afb7408b808f588dd3e624e357b/src/Modules/Core.php#L119-L148 |
sitkoru/yandex-direct-api | src/services/bids/BidsService.php | BidsService.get | public function get(BidsSelectionCriteria $SelectionCriteria, array $FieldNames): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
return $this->doGet($params, 'Bids', BidGetItem::class);
} | php | public function get(BidsSelectionCriteria $SelectionCriteria, array $FieldNames): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
return $this->doGet($params, 'Bids', BidGetItem::class);
} | [
"public",
"function",
"get",
"(",
"BidsSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"SelectionCriteria",
",",
"'FieldNames'",
"=>",
"$",
"FieldNa... | @param BidsSelectionCriteria $SelectionCriteria
@param BidFieldEnum[] $FieldNames
@return BidGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"BidsSelectionCriteria",
"$SelectionCriteria",
"@param",
"BidFieldEnum",
"[]",
"$FieldNames"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/bids/BidsService.php#L28-L35 |
sitkoru/yandex-direct-api | src/services/bids/BidsService.php | BidsService.setAuto | public function setAuto(array $Bids): array
{
$params = [
'Bids' => $Bids
];
$result = $this->call('setAuto', $params);
return $this->mapArray($result->SetAutoResults, BidActionResult::class);
} | php | public function setAuto(array $Bids): array
{
$params = [
'Bids' => $Bids
];
$result = $this->call('setAuto', $params);
return $this->mapArray($result->SetAutoResults, BidActionResult::class);
} | [
"public",
"function",
"setAuto",
"(",
"array",
"$",
"Bids",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'Bids'",
"=>",
"$",
"Bids",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"call",
"(",
"'setAuto'",
",",
"$",
"params",
")",
";",
"re... | @param BidSetAutoItem[] $Bids
@return BidActionResult[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"BidSetAutoItem",
"[]",
"$Bids"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/bids/BidsService.php#L66-L73 |
sitkoru/yandex-direct-api | src/services/campaigns/CampaignsService.php | CampaignsService.get | public function get(
CampaignsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $TextCampaignFieldNames = [],
array $MobileAppCampaignFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames,
];
if ($TextCampaignFieldNames) {
$params['TextCampaignFieldNames'] = $TextCampaignFieldNames;
}
if ($MobileAppCampaignFieldNames) {
$params['MobileAppCampaignFieldNames'] = $MobileAppCampaignFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'Campaigns', CampaignGetItem::class);
} | php | public function get(
CampaignsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $TextCampaignFieldNames = [],
array $MobileAppCampaignFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames,
];
if ($TextCampaignFieldNames) {
$params['TextCampaignFieldNames'] = $TextCampaignFieldNames;
}
if ($MobileAppCampaignFieldNames) {
$params['MobileAppCampaignFieldNames'] = $MobileAppCampaignFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'Campaigns', CampaignGetItem::class);
} | [
"public",
"function",
"get",
"(",
"CampaignsSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"array",
"$",
"TextCampaignFieldNames",
"=",
"[",
"]",
",",
"array",
"$",
"MobileAppCampaignFieldNames",
"=",
"[",
"]",
",",
"LimitOffse... | @param CampaignsSelectionCriteria $SelectionCriteria
@param CampaignFieldEnum[] $FieldNames
@param TextCampaignFieldEnum[] $TextCampaignFieldNames
@param MobileAppCampaignFieldEnum[] $MobileAppCampaignFieldNames
@param LimitOffset|null $Page
@return CampaignGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"CampaignsSelectionCriteria",
"$SelectionCriteria",
"@param",
"CampaignFieldEnum",
"[]",
"$FieldNames",
"@param",
"TextCampaignFieldEnum",
"[]",
"$TextCampaignFieldNames",
"@param",
"MobileAppCampaignFieldEnum",
"[]",
"$MobileAppCampaignFieldNames",
"@param",
"LimitOffset|n... | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/campaigns/CampaignsService.php#L79-L100 |
sitkoru/yandex-direct-api | src/services/adextensions/AdExtensionsService.php | AdExtensionsService.get | public function get(
AdExtensionsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $CalloutFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($CalloutFieldNames) {
$params['CalloutFieldNames'] = $CalloutFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'AdExtensions', AdExtensionGetItem::class);
} | php | public function get(
AdExtensionsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $CalloutFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($CalloutFieldNames) {
$params['CalloutFieldNames'] = $CalloutFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'AdExtensions', AdExtensionGetItem::class);
} | [
"public",
"function",
"get",
"(",
"AdExtensionsSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"array",
"$",
"CalloutFieldNames",
"=",
"[",
"]",
",",
"LimitOffset",
"$",
"Page",
"=",
"null",
")",
":",
"array",
"{",
"$",
"p... | @param AdExtensionsSelectionCriteria $SelectionCriteria
@param AdExtensionFieldEnum[] $FieldNames
@param CalloutFieldEnum[] $CalloutFieldNames
@param LimitOffset $Page
@return AdExtensionGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"AdExtensionsSelectionCriteria",
"$SelectionCriteria"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/adextensions/AdExtensionsService.php#L75-L95 |
sitkoru/yandex-direct-api | src/components/constraints/ContainsEnumValidator.php | ContainsEnumValidator.validate | public function validate($array, Constraint $constraint): void
{
if (\is_array($array)) {
$type = $constraint->type;
$values = $type::getValues();
$badValues = [];
foreach ($array as $v) {
if (!\in_array($v, $values, true)) {
$badValues[] = $v;
}
}
if ($badValues) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ type }}', $constraint->type)
->setParameter('{{ value }}', implode(', ', $badValues))
->addViolation();
}
}
} | php | public function validate($array, Constraint $constraint): void
{
if (\is_array($array)) {
$type = $constraint->type;
$values = $type::getValues();
$badValues = [];
foreach ($array as $v) {
if (!\in_array($v, $values, true)) {
$badValues[] = $v;
}
}
if ($badValues) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ type }}', $constraint->type)
->setParameter('{{ value }}', implode(', ', $badValues))
->addViolation();
}
}
} | [
"public",
"function",
"validate",
"(",
"$",
"array",
",",
"Constraint",
"$",
"constraint",
")",
":",
"void",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"$",
"type",
"=",
"$",
"constraint",
"->",
"type",
";",
"$",
"values",
... | Checks if the passed value is valid.
@param mixed $array The value that should be validated
@param ContainsEnum|Constraint $constraint The constraint for the validation | [
"Checks",
"if",
"the",
"passed",
"value",
"is",
"valid",
"."
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/components/constraints/ContainsEnumValidator.php#L18-L36 |
sitkoru/yandex-direct-api | src/components/constraints/ArrayOfValidator.php | ArrayOfValidator.validate | public function validate($array, Constraint $constraint): void
{
if ($array !== null) {
if (!\is_array($array)) {
$this->context->buildViolation('Должно быть массивом')
->addViolation();
} else {
$type = $constraint->type;
$badValues = [];
foreach ($array as $i => $v) {
$valueType = \is_object($v) ? \get_class($v) : \gettype($v);
if ($valueType !== $type) {
$badValues[] = $i . ' => ' . $valueType;
}
}
if ($badValues) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ type }}', $constraint->type)
->setParameter('{{ value }}', implode(', ', $badValues))
->addViolation();
}
}
}
} | php | public function validate($array, Constraint $constraint): void
{
if ($array !== null) {
if (!\is_array($array)) {
$this->context->buildViolation('Должно быть массивом')
->addViolation();
} else {
$type = $constraint->type;
$badValues = [];
foreach ($array as $i => $v) {
$valueType = \is_object($v) ? \get_class($v) : \gettype($v);
if ($valueType !== $type) {
$badValues[] = $i . ' => ' . $valueType;
}
}
if ($badValues) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ type }}', $constraint->type)
->setParameter('{{ value }}', implode(', ', $badValues))
->addViolation();
}
}
}
} | [
"public",
"function",
"validate",
"(",
"$",
"array",
",",
"Constraint",
"$",
"constraint",
")",
":",
"void",
"{",
"if",
"(",
"$",
"array",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"$",
"this",
"... | Checks if the passed value is valid.
@param mixed $array The value that should be validated
@param ContainsEnum|Constraint $constraint The constraint for the validation | [
"Checks",
"if",
"the",
"passed",
"value",
"is",
"valid",
"."
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/components/constraints/ArrayOfValidator.php#L18-L41 |
sitkoru/yandex-direct-api | src/components/constraints/ArrayOfEnumValidator.php | ArrayOfEnumValidator.validate | public function validate($array, Constraint $constraint): void
{
if ($array !== null) {
if (!\is_array($array)) {
$this->context->buildViolation('Должно быть массивом')
->addViolation();
} else {
/**
* @var Enum $type
*/
$type = $constraint->type;
$badValues = [];
foreach ($array as $i => $v) {
if (\call_user_func($type . '::check', [$v]) === false) {
$badValues[] = $i . ' => ' . $v;
}
}
if (\count($badValues) > 0) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ type }}', $constraint->type)
->setParameter('{{ value }}', implode(', ', $badValues))
->addViolation();
}
}
}
} | php | public function validate($array, Constraint $constraint): void
{
if ($array !== null) {
if (!\is_array($array)) {
$this->context->buildViolation('Должно быть массивом')
->addViolation();
} else {
/**
* @var Enum $type
*/
$type = $constraint->type;
$badValues = [];
foreach ($array as $i => $v) {
if (\call_user_func($type . '::check', [$v]) === false) {
$badValues[] = $i . ' => ' . $v;
}
}
if (\count($badValues) > 0) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ type }}', $constraint->type)
->setParameter('{{ value }}', implode(', ', $badValues))
->addViolation();
}
}
}
} | [
"public",
"function",
"validate",
"(",
"$",
"array",
",",
"Constraint",
"$",
"constraint",
")",
":",
"void",
"{",
"if",
"(",
"$",
"array",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"$",
"this",
"... | Checks if the passed value is valid.
@param mixed $array The value that should be validated
@param ContainsEnum|Constraint $constraint The constraint for the validation | [
"Checks",
"if",
"the",
"passed",
"value",
"is",
"valid",
"."
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/components/constraints/ArrayOfEnumValidator.php#L19-L45 |
sitkoru/yandex-direct-api | src/services/bidmodifiers/BidModifiersService.php | BidModifiersService.get | public function get(
BidModifiersSelectionCriteria $SelectionCriteria,
$FieldNames,
array $MobileAdjustmentFieldNames = [],
array $DemographicsAdjustmentFieldNames = [],
array $RetargetingAdjustmentFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames,
];
if ($MobileAdjustmentFieldNames) {
$params['MobileAdjustmentFieldNames'] = $MobileAdjustmentFieldNames;
}
if ($DemographicsAdjustmentFieldNames) {
$params['DemographicsAdjustmentFieldNames'] = $DemographicsAdjustmentFieldNames;
}
if ($RetargetingAdjustmentFieldNames) {
$params['RetargetingAdjustmentFieldNames'] = $RetargetingAdjustmentFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'BidModifiers', BidModifierGetItem::class);
} | php | public function get(
BidModifiersSelectionCriteria $SelectionCriteria,
$FieldNames,
array $MobileAdjustmentFieldNames = [],
array $DemographicsAdjustmentFieldNames = [],
array $RetargetingAdjustmentFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames,
];
if ($MobileAdjustmentFieldNames) {
$params['MobileAdjustmentFieldNames'] = $MobileAdjustmentFieldNames;
}
if ($DemographicsAdjustmentFieldNames) {
$params['DemographicsAdjustmentFieldNames'] = $DemographicsAdjustmentFieldNames;
}
if ($RetargetingAdjustmentFieldNames) {
$params['RetargetingAdjustmentFieldNames'] = $RetargetingAdjustmentFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'BidModifiers', BidModifierGetItem::class);
} | [
"public",
"function",
"get",
"(",
"BidModifiersSelectionCriteria",
"$",
"SelectionCriteria",
",",
"$",
"FieldNames",
",",
"array",
"$",
"MobileAdjustmentFieldNames",
"=",
"[",
"]",
",",
"array",
"$",
"DemographicsAdjustmentFieldNames",
"=",
"[",
"]",
",",
"array",
... | @param BidModifiersSelectionCriteria $SelectionCriteria
@param BidModifierFieldEnum $FieldNames
@param MobileAdjustmentFieldEnum[] $MobileAdjustmentFieldNames
@param DemographicsAdjustmentFieldEnum[] $DemographicsAdjustmentFieldNames
@param RetargetingAdjustmentFieldEnum[] $RetargetingAdjustmentFieldNames
@param LimitOffset|null $Page
@return BidModifierGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"BidModifiersSelectionCriteria",
"$SelectionCriteria",
"@param",
"BidModifierFieldEnum",
"$FieldNames",
"@param",
"MobileAdjustmentFieldEnum",
"[]",
"$MobileAdjustmentFieldNames",
"@param",
"DemographicsAdjustmentFieldEnum",
"[]",
"$DemographicsAdjustmentFieldNames",
"@param",
... | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/bidmodifiers/BidModifiersService.php#L71-L96 |
sitkoru/yandex-direct-api | src/services/bidmodifiers/BidModifiersService.php | BidModifiersService.set | public function set(array $BidModifiers): array
{
$params = [
'BidModifiers' => $BidModifiers
];
$result = $this->call('set', $params);
return $this->mapArray($result->SetResults, ActionResult::class);
} | php | public function set(array $BidModifiers): array
{
$params = [
'BidModifiers' => $BidModifiers
];
$result = $this->call('set', $params);
return $this->mapArray($result->SetResults, ActionResult::class);
} | [
"public",
"function",
"set",
"(",
"array",
"$",
"BidModifiers",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'BidModifiers'",
"=>",
"$",
"BidModifiers",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"call",
"(",
"'set'",
",",
"$",
"params",
"... | @param BidModifierSetItem[] $BidModifiers
@return ActionResult[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"BidModifierSetItem",
"[]",
"$BidModifiers"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/bidmodifiers/BidModifiersService.php#L108-L115 |
sitkoru/yandex-direct-api | src/services/bidmodifiers/BidModifiersService.php | BidModifiersService.toggle | public function toggle(array $BidModifierToggleItems): array
{
$params = [
'BidModifierToggleItems' => $BidModifierToggleItems
];
$result = $this->call('toggle', $params);
return $this->mapArray($result->SetResults, ToggleResult::class);
} | php | public function toggle(array $BidModifierToggleItems): array
{
$params = [
'BidModifierToggleItems' => $BidModifierToggleItems
];
$result = $this->call('toggle', $params);
return $this->mapArray($result->SetResults, ToggleResult::class);
} | [
"public",
"function",
"toggle",
"(",
"array",
"$",
"BidModifierToggleItems",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'BidModifierToggleItems'",
"=>",
"$",
"BidModifierToggleItems",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"call",
"(",
"'tog... | @param BidModifierToggleItem[] $BidModifierToggleItems
@return ToggleResult[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"BidModifierToggleItem",
"[]",
"$BidModifierToggleItems"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/bidmodifiers/BidModifiersService.php#L127-L134 |
sitkoru/yandex-direct-api | src/services/ads/AdsService.php | AdsService.get | public function get(
AdsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $TextAdFieldNames = [],
array $MobileAppAdFieldNames = [],
array $DynamicTextAdFieldNames = [],
array $TextImageAdFieldNames = [],
array $MobileAppImageAdFieldNames = [],
array $TextAdBuilderAdFieldNames = [],
array $MobileAppAdBuilderAdFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($TextAdFieldNames) {
$params['TextAdFieldNames'] = $TextAdFieldNames;
}
if ($MobileAppAdFieldNames) {
$params['MobileAppAdFieldNames'] = $MobileAppAdFieldNames;
}
if ($DynamicTextAdFieldNames) {
$params['DynamicTextAdFieldNames'] = $DynamicTextAdFieldNames;
}
if ($TextImageAdFieldNames) {
$params['TextImageAdFieldNames'] = $TextImageAdFieldNames;
}
if ($MobileAppImageAdFieldNames) {
$params['MobileAppImageAdFieldNames'] = $MobileAppImageAdFieldNames;
}
if ($TextAdBuilderAdFieldNames) {
$params['TextAdBuilderAdFieldNames'] = $TextAdBuilderAdFieldNames;
}
if ($MobileAppAdBuilderAdFieldNames) {
$params['MobileAppAdBuilderAdFieldNames'] = $MobileAppAdBuilderAdFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'Ads', AdGetItem::class);
} | php | public function get(
AdsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $TextAdFieldNames = [],
array $MobileAppAdFieldNames = [],
array $DynamicTextAdFieldNames = [],
array $TextImageAdFieldNames = [],
array $MobileAppImageAdFieldNames = [],
array $TextAdBuilderAdFieldNames = [],
array $MobileAppAdBuilderAdFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($TextAdFieldNames) {
$params['TextAdFieldNames'] = $TextAdFieldNames;
}
if ($MobileAppAdFieldNames) {
$params['MobileAppAdFieldNames'] = $MobileAppAdFieldNames;
}
if ($DynamicTextAdFieldNames) {
$params['DynamicTextAdFieldNames'] = $DynamicTextAdFieldNames;
}
if ($TextImageAdFieldNames) {
$params['TextImageAdFieldNames'] = $TextImageAdFieldNames;
}
if ($MobileAppImageAdFieldNames) {
$params['MobileAppImageAdFieldNames'] = $MobileAppImageAdFieldNames;
}
if ($TextAdBuilderAdFieldNames) {
$params['TextAdBuilderAdFieldNames'] = $TextAdBuilderAdFieldNames;
}
if ($MobileAppAdBuilderAdFieldNames) {
$params['MobileAppAdBuilderAdFieldNames'] = $MobileAppAdBuilderAdFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'Ads', AdGetItem::class);
} | [
"public",
"function",
"get",
"(",
"AdsSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"array",
"$",
"TextAdFieldNames",
"=",
"[",
"]",
",",
"array",
"$",
"MobileAppAdFieldNames",
"=",
"[",
"]",
",",
"array",
"$",
"DynamicTex... | @param AdsSelectionCriteria $SelectionCriteria
@param AdFieldEnum[] $FieldNames
@param TextAdFieldEnum[] $TextAdFieldNames
@param MobileAppAdFieldEnum[] $MobileAppAdFieldNames
@param DynamicTextAdFieldEnum[] $DynamicTextAdFieldNames
@param TextImageAdFieldEnum[] $TextImageAdFieldNames
@param MobileAppImageAdFieldEnum[] $MobileAppImageAdFieldNames
@param TextAdBuilderAdFieldEnum[] $TextAdBuilderAdFieldNames
@param MobileAppAdBuilderAdFieldEnum[] $MobileAppAdBuilderAdFieldNames
@param LimitOffset $Page
@return models\AdGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"AdsSelectionCriteria",
"$SelectionCriteria"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/ads/AdsService.php#L83-L133 |
sitkoru/yandex-direct-api | src/services/ads/AdsService.php | AdsService.moderate | public function moderate(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('moderate', $params);
return $this->mapArray($response->ModerateResults, ActionResult::class);
} | php | public function moderate(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('moderate', $params);
return $this->mapArray($response->ModerateResults, ActionResult::class);
} | [
"public",
"function",
"moderate",
"(",
"IdsCriteria",
"$",
"SelectionCriteria",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"SelectionCriteria",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"call",
"(",
"'moderate... | @param IdsCriteria $SelectionCriteria
@return ActionResult[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"IdsCriteria",
"$SelectionCriteria"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/ads/AdsService.php#L145-L152 |
sitkoru/yandex-direct-api | src/services/BaseService.php | BaseService.suspend | protected function suspend(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('suspend', $params);
return $this->mapArray($response->SuspendResults, ActionResult::class);
} | php | protected function suspend(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('suspend', $params);
return $this->mapArray($response->SuspendResults, ActionResult::class);
} | [
"protected",
"function",
"suspend",
"(",
"IdsCriteria",
"$",
"SelectionCriteria",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"SelectionCriteria",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"call",
"(",
"'suspen... | @param IdsCriteria $SelectionCriteria
@return ActionResult[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"IdsCriteria",
"$SelectionCriteria"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/BaseService.php#L289-L296 |
sitkoru/yandex-direct-api | src/services/BaseService.php | BaseService.resume | protected function resume(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('resume', $params);
return $this->mapArray($response->ResumeResults, ActionResult::class);
} | php | protected function resume(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('resume', $params);
return $this->mapArray($response->ResumeResults, ActionResult::class);
} | [
"protected",
"function",
"resume",
"(",
"IdsCriteria",
"$",
"SelectionCriteria",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"SelectionCriteria",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"call",
"(",
"'resume'... | @param IdsCriteria $SelectionCriteria
@return ActionResult[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"IdsCriteria",
"$SelectionCriteria"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/BaseService.php#L308-L315 |
sitkoru/yandex-direct-api | src/services/BaseService.php | BaseService.archive | protected function archive(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('archive', $params);
return $this->mapArray($response->ArchiveResults, ActionResult::class);
} | php | protected function archive(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('archive', $params);
return $this->mapArray($response->ArchiveResults, ActionResult::class);
} | [
"protected",
"function",
"archive",
"(",
"IdsCriteria",
"$",
"SelectionCriteria",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"SelectionCriteria",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"call",
"(",
"'archiv... | @param IdsCriteria $SelectionCriteria
@return ActionResult[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"IdsCriteria",
"$SelectionCriteria"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/BaseService.php#L327-L334 |
sitkoru/yandex-direct-api | src/services/BaseService.php | BaseService.unarchive | protected function unarchive(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('unarchive', $params);
return $this->mapArray($response->UnarchiveResults, ActionResult::class);
} | php | protected function unarchive(IdsCriteria $SelectionCriteria): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria
];
$response = $this->call('unarchive', $params);
return $this->mapArray($response->UnarchiveResults, ActionResult::class);
} | [
"protected",
"function",
"unarchive",
"(",
"IdsCriteria",
"$",
"SelectionCriteria",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"SelectionCriteria",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"call",
"(",
"'unar... | @param IdsCriteria $SelectionCriteria
@return ActionResult[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"IdsCriteria",
"$SelectionCriteria"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/BaseService.php#L346-L353 |
sitkoru/yandex-direct-api | src/services/adimages/AdImagesService.php | AdImagesService.get | public function get(AdImageSelectionCriteria $SelectionCriteria, array $FieldNames, LimitOffset $Page = null): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'IdImage', AdImageGetItem::class);
} | php | public function get(AdImageSelectionCriteria $SelectionCriteria, array $FieldNames, LimitOffset $Page = null): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'IdImage', AdImageGetItem::class);
} | [
"public",
"function",
"get",
"(",
"AdImageSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"LimitOffset",
"$",
"Page",
"=",
"null",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"Selection... | @param AdImageSelectionCriteria $SelectionCriteria
@param AdImageFieldEnum[] $FieldNames
@param LimitOffset $Page
@return AdImageGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"AdImageSelectionCriteria",
"$SelectionCriteria",
"@param",
"AdImageFieldEnum",
"[]",
"$FieldNames",
"@param",
"LimitOffset",
"$Page"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/adimages/AdImagesService.php#L61-L72 |
sitkoru/yandex-direct-api | src/services/keywords/KeywordsService.php | KeywordsService.get | public function get(
KeywordsSelectionCriteria $SelectionCriteria,
array $FieldNames,
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'Keywords', KeywordGetItem::class);
} | php | public function get(
KeywordsSelectionCriteria $SelectionCriteria,
array $FieldNames,
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'Keywords', KeywordGetItem::class);
} | [
"public",
"function",
"get",
"(",
"KeywordsSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"LimitOffset",
"$",
"Page",
"=",
"null",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"Selectio... | @param KeywordsSelectionCriteria $SelectionCriteria
@param KeywordFieldEnum[] $FieldNames
@param LimitOffset|null $Page
@return KeywordGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"KeywordsSelectionCriteria",
"$SelectionCriteria",
"@param",
"KeywordFieldEnum",
"[]",
"$FieldNames",
"@param",
"LimitOffset|null",
"$Page"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/keywords/KeywordsService.php#L62-L76 |
sitkoru/yandex-direct-api | src/services/adgroups/AdGroupsService.php | AdGroupsService.get | public function get(
AdGroupsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $MobileAppAdGroupFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames,
];
if ($MobileAppAdGroupFieldNames) {
$params['MobileAppAdGroupFieldNames'] = $MobileAppAdGroupFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'AdGroups', AdGroupGetItem::class);
} | php | public function get(
AdGroupsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $MobileAppAdGroupFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames,
];
if ($MobileAppAdGroupFieldNames) {
$params['MobileAppAdGroupFieldNames'] = $MobileAppAdGroupFieldNames;
}
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'AdGroups', AdGroupGetItem::class);
} | [
"public",
"function",
"get",
"(",
"AdGroupsSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"array",
"$",
"MobileAppAdGroupFieldNames",
"=",
"[",
"]",
",",
"LimitOffset",
"$",
"Page",
"=",
"null",
")",
":",
"array",
"{",
"$",... | @param AdGroupsSelectionCriteria $SelectionCriteria
@param AdGroupFieldEnum[] $FieldNames
@param MobileAppAdGroupFieldEnum[] $MobileAppAdGroupFieldNames
@param LimitOffset $Page
@return AdGroupGetItem[]
@throws \Exception
@throws \GuzzleHttp\Exception\GuzzleException | [
"@param",
"AdGroupsSelectionCriteria",
"$SelectionCriteria",
"@param",
"AdGroupFieldEnum",
"[]",
"$FieldNames",
"@param",
"MobileAppAdGroupFieldEnum",
"[]",
"$MobileAppAdGroupFieldNames",
"@param",
"LimitOffset",
"$Page"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/adgroups/AdGroupsService.php#L57-L75 |
sitkoru/yandex-direct-api | src/services/audiencetargets/AudienceTargetsService.php | AudienceTargetsService.get | public function get(
AudienceTargetSelectionCriteria $SelectionCriteria,
array $FieldNames,
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'AudienceTargets', AudienceTargetGetItem::class);
} | php | public function get(
AudienceTargetSelectionCriteria $SelectionCriteria,
array $FieldNames,
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'AudienceTargets', AudienceTargetGetItem::class);
} | [
"public",
"function",
"get",
"(",
"AudienceTargetSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"LimitOffset",
"$",
"Page",
"=",
"null",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"Se... | @param AudienceTargetSelectionCriteria $SelectionCriteria
@param AudienceTargetFieldEnum[] $FieldNames
@param LimitOffset $Page
@return AudienceTargetGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"AudienceTargetSelectionCriteria",
"$SelectionCriteria"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/audiencetargets/AudienceTargetsService.php#L94-L109 |
sitkoru/yandex-direct-api | src/services/changes/ChangesService.php | ChangesService.checkDictionaries | public function checkDictionaries($Timestamp): CheckDictionariesResponse
{
$params = [
'Timestamp' => $Timestamp
];
$result = $this->call('checkDictionaries', $params);
return $this->map($result, CheckDictionariesResponse::class);
} | php | public function checkDictionaries($Timestamp): CheckDictionariesResponse
{
$params = [
'Timestamp' => $Timestamp
];
$result = $this->call('checkDictionaries', $params);
return $this->map($result, CheckDictionariesResponse::class);
} | [
"public",
"function",
"checkDictionaries",
"(",
"$",
"Timestamp",
")",
":",
"CheckDictionariesResponse",
"{",
"$",
"params",
"=",
"[",
"'Timestamp'",
"=>",
"$",
"Timestamp",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"call",
"(",
"'checkDictionaries'",
... | @param string $Timestamp
@return CheckDictionariesResponse
@throws \GuzzleHttp\Exception\GuzzleException
@throws \JsonMapper_Exception
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"string",
"$Timestamp"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/changes/ChangesService.php#L26-L33 |
sitkoru/yandex-direct-api | src/services/changes/ChangesService.php | ChangesService.checkCampaigns | public function checkCampaigns($Timestamp): CheckCampaignsResponse
{
$params = [
'Timestamp' => $Timestamp
];
$result = $this->call('checkCampaigns', $params);
return $this->map($result, CheckCampaignsResponse::class);
} | php | public function checkCampaigns($Timestamp): CheckCampaignsResponse
{
$params = [
'Timestamp' => $Timestamp
];
$result = $this->call('checkCampaigns', $params);
return $this->map($result, CheckCampaignsResponse::class);
} | [
"public",
"function",
"checkCampaigns",
"(",
"$",
"Timestamp",
")",
":",
"CheckCampaignsResponse",
"{",
"$",
"params",
"=",
"[",
"'Timestamp'",
"=>",
"$",
"Timestamp",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"call",
"(",
"'checkCampaigns'",
",",
"... | @param string $Timestamp
@return CheckCampaignsResponse
@throws \GuzzleHttp\Exception\GuzzleException
@throws \JsonMapper_Exception
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"string",
"$Timestamp"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/changes/ChangesService.php#L46-L53 |
sitkoru/yandex-direct-api | src/services/retargetinglists/RetargetingListsService.php | RetargetingListsService.get | public function get(
RetargetingListSelectionCriteria $SelectionCriteria,
array $FieldNames,
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'RetargetingLists', RetargetingListGetItem::class);
} | php | public function get(
RetargetingListSelectionCriteria $SelectionCriteria,
array $FieldNames,
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'RetargetingLists', RetargetingListGetItem::class);
} | [
"public",
"function",
"get",
"(",
"RetargetingListSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"LimitOffset",
"$",
"Page",
"=",
"null",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"S... | @param RetargetingListSelectionCriteria $SelectionCriteria
@param RetargetingListFieldEnum[] $FieldNames
@param LimitOffset $Page
@return RetargetingListGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"RetargetingListSelectionCriteria",
"$SelectionCriteria"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/retargetinglists/RetargetingListsService.php#L89-L104 |
sitkoru/yandex-direct-api | src/services/sitelinks/SitelinksService.php | SitelinksService.get | public function get(IdsCriteria $SelectionCriteria, array $FieldNames, LimitOffset $Page = null): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'SitelinksSets', SitelinksSetGetItem::class);
} | php | public function get(IdsCriteria $SelectionCriteria, array $FieldNames, LimitOffset $Page = null): array
{
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($Page) {
$params['Page'] = $Page;
}
return parent::doGet($params, 'SitelinksSets', SitelinksSetGetItem::class);
} | [
"public",
"function",
"get",
"(",
"IdsCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"LimitOffset",
"$",
"Page",
"=",
"null",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'SelectionCriteria'",
"=>",
"$",
"SelectionCriteria",
... | @param IdsCriteria $SelectionCriteria
@param SitelinksSetFieldEnum[] $FieldNames
@param LimitOffset $Page
@return SitelinksSetGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"IdsCriteria",
"$SelectionCriteria",
"@param",
"SitelinksSetFieldEnum",
"[]",
"$FieldNames",
"@param",
"LimitOffset",
"$Page"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/sitelinks/SitelinksService.php#L60-L71 |
sitkoru/yandex-direct-api | src/components/constraints/IsEnumValidator.php | IsEnumValidator.validate | public function validate($value, Constraint $constraint): void
{
if ($value !== null) {
$type = $constraint->type;
$values = $type::getValues();
if (!\in_array($value, $values, true)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ type }}', $constraint->type)
->setParameter('{{ value }}', $value)
->addViolation();
}
}
} | php | public function validate($value, Constraint $constraint): void
{
if ($value !== null) {
$type = $constraint->type;
$values = $type::getValues();
if (!\in_array($value, $values, true)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ type }}', $constraint->type)
->setParameter('{{ value }}', $value)
->addViolation();
}
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
":",
"void",
"{",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"type",
"=",
"$",
"constraint",
"->",
"type",
";",
"$",
"values",
"=",
"$",
"ty... | Checks if the passed value is valid.
@param mixed $value The value that should be validated
@param ContainsEnum|Constraint $constraint The constraint for the validation | [
"Checks",
"if",
"the",
"passed",
"value",
"is",
"valid",
"."
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/components/constraints/IsEnumValidator.php#L18-L30 |
sitkoru/yandex-direct-api | src/services/keywordbids/KeywordBidsService.php | KeywordBidsService.get | public function get(
KeywordBidsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $SearchFieldNames = [],
array $NetworkFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($SearchFieldNames) {
$params['SearchFieldNames'] = $Page;
}
if ($NetworkFieldNames) {
$params['NetworkFieldNames'] = $Page;
}
if ($Page) {
$params['Page'] = $Page;
}
return $this->doGet($params, 'KeywordBids', KeywordBidGetItem::class);
} | php | public function get(
KeywordBidsSelectionCriteria $SelectionCriteria,
array $FieldNames,
array $SearchFieldNames = [],
array $NetworkFieldNames = [],
LimitOffset $Page = null
): array {
$params = [
'SelectionCriteria' => $SelectionCriteria,
'FieldNames' => $FieldNames
];
if ($SearchFieldNames) {
$params['SearchFieldNames'] = $Page;
}
if ($NetworkFieldNames) {
$params['NetworkFieldNames'] = $Page;
}
if ($Page) {
$params['Page'] = $Page;
}
return $this->doGet($params, 'KeywordBids', KeywordBidGetItem::class);
} | [
"public",
"function",
"get",
"(",
"KeywordBidsSelectionCriteria",
"$",
"SelectionCriteria",
",",
"array",
"$",
"FieldNames",
",",
"array",
"$",
"SearchFieldNames",
"=",
"[",
"]",
",",
"array",
"$",
"NetworkFieldNames",
"=",
"[",
"]",
",",
"LimitOffset",
"$",
"... | @param KeywordBidsSelectionCriteria $SelectionCriteria
@param KeywordBidFieldEnum[] $FieldNames
@param string[] $SearchFieldNames
@param string[] $NetworkFieldNames
@param LimitOffset $Page
@return KeywordBidGetItem[]
@throws \GuzzleHttp\Exception\GuzzleException
@throws \directapi\exceptions\DirectAccountNotExistException
@throws \directapi\exceptions\DirectApiException
@throws \directapi\exceptions\DirectApiNotEnoughUnitsException
@throws \directapi\exceptions\RequestValidationException | [
"@param",
"KeywordBidsSelectionCriteria",
"$SelectionCriteria",
"@param",
"KeywordBidFieldEnum",
"[]",
"$FieldNames"
] | train | https://github.com/sitkoru/yandex-direct-api/blob/6d90bb2dddc6b01ab60168e6bbc98e2d8c24e252/src/services/keywordbids/KeywordBidsService.php#L31-L52 |
HelgeSverre/Domain-Availability | src/Service/DomainAvailability.php | DomainAvailability.parse | private function parse($domain)
{
$pslManager = new PublicSuffixListManager();
$parser = new Parser($pslManager->getList());
// First check if the suffix is actually valid
if (!$parser->isSuffixValid($domain)) {
throw new \InvalidArgumentException("Invalid TLD");
}
$components = [];
$components["tld"] = $parser->getPublicSuffix($domain);
$components["domain"] = $parser->getRegisterableDomain($domain);
return $components;
} | php | private function parse($domain)
{
$pslManager = new PublicSuffixListManager();
$parser = new Parser($pslManager->getList());
// First check if the suffix is actually valid
if (!$parser->isSuffixValid($domain)) {
throw new \InvalidArgumentException("Invalid TLD");
}
$components = [];
$components["tld"] = $parser->getPublicSuffix($domain);
$components["domain"] = $parser->getRegisterableDomain($domain);
return $components;
} | [
"private",
"function",
"parse",
"(",
"$",
"domain",
")",
"{",
"$",
"pslManager",
"=",
"new",
"PublicSuffixListManager",
"(",
")",
";",
"$",
"parser",
"=",
"new",
"Parser",
"(",
"$",
"pslManager",
"->",
"getList",
"(",
")",
")",
";",
"// First check if the ... | Wrapper around Jeremy Kendall's PHP Domain Parser that parses the
domain/url passed to the function and returns the Tld and Valid domain
@param $domain
@throws \InvalidArgumentException when the tld is not valid
@return array returns an associative array with the domain and tld | [
"Wrapper",
"around",
"Jeremy",
"Kendall",
"s",
"PHP",
"Domain",
"Parser",
"that",
"parses",
"the",
"domain",
"/",
"url",
"passed",
"to",
"the",
"function",
"and",
"returns",
"the",
"Tld",
"and",
"Valid",
"domain"
] | train | https://github.com/HelgeSverre/Domain-Availability/blob/a2a6632c99c5688eccb9e00bffa388331883895e/src/Service/DomainAvailability.php#L104-L119 |
chrisguitarguy/RequestIdBundle | src/DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder() : TreeBuilder
{
// compat: symfony < 4.1
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$tree = new TreeBuilder('chrisguitarguy_request_id');
$root = $tree->getRootNode();
} else {
$tree = new TreeBuilder();
$root = $tree->root('chrisguitarguy_request_id');
}
$root
->children()
->scalarNode('request_header')
->cannotBeEmpty()
->defaultValue('Request-Id')
->info('The header in which the bundle will look for and set request IDs')
->end()
->booleanNode('trust_request_header')
->defaultValue(true)
->info("Whether or not to trust the incoming request's `Request-Id` header as a real ID")
->end()
->scalarNode('response_header')
->cannotBeEmpty()
->defaultValue('Request-Id')
->info('The header the bundle will set the request ID at in the response')
->end()
->scalarNode('storage_service')
->info('The service name for request ID storage. Defaults to `SimpleIdStorage`')
->end()
->scalarNode('generator_service')
->info('The service name for the request ID generator. Defaults to `Uuid4IdGenerator`')
->end()
->booleanNode('enable_monolog')
->info('Whether or not to turn on the request ID processor for monolog')
->defaultTrue()
->end()
->booleanNode('enable_twig')
->info('Whether or not to enable the twig `request_id()` function. Only works if TwigBundle is present.')
->defaultTrue()
->end()
;
return $tree;
} | php | public function getConfigTreeBuilder() : TreeBuilder
{
// compat: symfony < 4.1
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$tree = new TreeBuilder('chrisguitarguy_request_id');
$root = $tree->getRootNode();
} else {
$tree = new TreeBuilder();
$root = $tree->root('chrisguitarguy_request_id');
}
$root
->children()
->scalarNode('request_header')
->cannotBeEmpty()
->defaultValue('Request-Id')
->info('The header in which the bundle will look for and set request IDs')
->end()
->booleanNode('trust_request_header')
->defaultValue(true)
->info("Whether or not to trust the incoming request's `Request-Id` header as a real ID")
->end()
->scalarNode('response_header')
->cannotBeEmpty()
->defaultValue('Request-Id')
->info('The header the bundle will set the request ID at in the response')
->end()
->scalarNode('storage_service')
->info('The service name for request ID storage. Defaults to `SimpleIdStorage`')
->end()
->scalarNode('generator_service')
->info('The service name for the request ID generator. Defaults to `Uuid4IdGenerator`')
->end()
->booleanNode('enable_monolog')
->info('Whether or not to turn on the request ID processor for monolog')
->defaultTrue()
->end()
->booleanNode('enable_twig')
->info('Whether or not to enable the twig `request_id()` function. Only works if TwigBundle is present.')
->defaultTrue()
->end()
;
return $tree;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
":",
"TreeBuilder",
"{",
"// compat: symfony < 4.1",
"if",
"(",
"method_exists",
"(",
"TreeBuilder",
"::",
"class",
",",
"'getRootNode'",
")",
")",
"{",
"$",
"tree",
"=",
"new",
"TreeBuilder",
"(",
"'chrisg... | {@inheritdoc} | [
"{"
] | train | https://github.com/chrisguitarguy/RequestIdBundle/blob/73743e4dd1beb4d1d1d579dfe8c1d187a5e444ba/src/DependencyInjection/Configuration.php#L24-L68 |
jobbyphp/jobby | src/Jobby.php | Jobby.getExecutableCommand | protected function getExecutableCommand($job, array $config)
{
if (isset($config['closure'])) {
$config['closure'] = $this->getSerializer()->serialize($config['closure']);
}
if (strpos(__DIR__, 'phar://') === 0) {
$script = __DIR__ . DIRECTORY_SEPARATOR . 'BackgroundJob.php';
return sprintf(' -r \'define("JOBBY_RUN_JOB",1);include("%s");\' "%s" "%s"', $script, $job, http_build_query($config));
}
return sprintf('"%s" "%s" "%s"', $this->script, $job, http_build_query($config));
} | php | protected function getExecutableCommand($job, array $config)
{
if (isset($config['closure'])) {
$config['closure'] = $this->getSerializer()->serialize($config['closure']);
}
if (strpos(__DIR__, 'phar://') === 0) {
$script = __DIR__ . DIRECTORY_SEPARATOR . 'BackgroundJob.php';
return sprintf(' -r \'define("JOBBY_RUN_JOB",1);include("%s");\' "%s" "%s"', $script, $job, http_build_query($config));
}
return sprintf('"%s" "%s" "%s"', $this->script, $job, http_build_query($config));
} | [
"protected",
"function",
"getExecutableCommand",
"(",
"$",
"job",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'closure'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'closure'",
"]",
"=",
"$",
"this",
"->",
"getS... | @param string $job
@param array $config
@return string | [
"@param",
"string",
"$job",
"@param",
"array",
"$config"
] | train | https://github.com/jobbyphp/jobby/blob/2daeb4f797459c418a78d94b81f686c935ae1620/src/Jobby.php#L207-L219 |
jobbyphp/jobby | src/Helper.php | Helper.sendMail | public function sendMail($job, array $config, $message)
{
$host = $this->getHost();
$body = <<<EOF
$message
You can find its output in {$config['output']} on $host.
Best,
jobby@$host
EOF;
$mail = new \Swift_Message();
$mail->setTo(explode(',', $config['recipients']));
$mail->setSubject("[$host] '{$job}' needs some attention!");
$mail->setBody($body);
$mail->setFrom([$config['smtpSender'] => $config['smtpSenderName']]);
$mail->setSender($config['smtpSender']);
$mailer = $this->getCurrentMailer($config);
$mailer->send($mail);
return $mail;
} | php | public function sendMail($job, array $config, $message)
{
$host = $this->getHost();
$body = <<<EOF
$message
You can find its output in {$config['output']} on $host.
Best,
jobby@$host
EOF;
$mail = new \Swift_Message();
$mail->setTo(explode(',', $config['recipients']));
$mail->setSubject("[$host] '{$job}' needs some attention!");
$mail->setBody($body);
$mail->setFrom([$config['smtpSender'] => $config['smtpSenderName']]);
$mail->setSender($config['smtpSender']);
$mailer = $this->getCurrentMailer($config);
$mailer->send($mail);
return $mail;
} | [
"public",
"function",
"sendMail",
"(",
"$",
"job",
",",
"array",
"$",
"config",
",",
"$",
"message",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"getHost",
"(",
")",
";",
"$",
"body",
"=",
" <<<EOF\n$message\n\nYou can find its output in {$config['output']}... | @param string $job
@param array $config
@param string $message
@return \Swift_Message | [
"@param",
"string",
"$job",
"@param",
"array",
"$config",
"@param",
"string",
"$message"
] | train | https://github.com/jobbyphp/jobby/blob/2daeb4f797459c418a78d94b81f686c935ae1620/src/Helper.php#L41-L63 |
jobbyphp/jobby | src/Helper.php | Helper.getCurrentMailer | private function getCurrentMailer(array $config)
{
if ($this->mailer !== null) {
return $this->mailer;
}
$swiftVersion = (int) explode('.', \Swift::VERSION)[0];
if ($config['mailer'] === 'smtp') {
$transport = new \Swift_SmtpTransport(
$config['smtpHost'],
$config['smtpPort'],
$config['smtpSecurity']
);
$transport->setUsername($config['smtpUsername']);
$transport->setPassword($config['smtpPassword']);
} elseif ($swiftVersion < 6 && $config['mailer'] === 'mail') {
$transport = \Swift_MailTransport::newInstance();
} else {
$transport = new \Swift_SendmailTransport();
}
return new \Swift_Mailer($transport);
} | php | private function getCurrentMailer(array $config)
{
if ($this->mailer !== null) {
return $this->mailer;
}
$swiftVersion = (int) explode('.', \Swift::VERSION)[0];
if ($config['mailer'] === 'smtp') {
$transport = new \Swift_SmtpTransport(
$config['smtpHost'],
$config['smtpPort'],
$config['smtpSecurity']
);
$transport->setUsername($config['smtpUsername']);
$transport->setPassword($config['smtpPassword']);
} elseif ($swiftVersion < 6 && $config['mailer'] === 'mail') {
$transport = \Swift_MailTransport::newInstance();
} else {
$transport = new \Swift_SendmailTransport();
}
return new \Swift_Mailer($transport);
} | [
"private",
"function",
"getCurrentMailer",
"(",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mailer",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"mailer",
";",
"}",
"$",
"swiftVersion",
"=",
"(",
"int",
")",
"explode",
... | @param array $config
@return \Swift_Mailer | [
"@param",
"array",
"$config"
] | train | https://github.com/jobbyphp/jobby/blob/2daeb4f797459c418a78d94b81f686c935ae1620/src/Helper.php#L70-L93 |
jobbyphp/jobby | src/Helper.php | Helper.acquireLock | public function acquireLock($lockFile)
{
if (array_key_exists($lockFile, $this->lockHandles)) {
throw new Exception("Lock already acquired (Lockfile: $lockFile).");
}
if (!file_exists($lockFile) && !touch($lockFile)) {
throw new Exception("Unable to create file (File: $lockFile).");
}
$fh = fopen($lockFile, 'rb+');
if ($fh === false) {
throw new Exception("Unable to open file (File: $lockFile).");
}
$attempts = 5;
while ($attempts > 0) {
if (flock($fh, LOCK_EX | LOCK_NB)) {
$this->lockHandles[$lockFile] = $fh;
ftruncate($fh, 0);
fwrite($fh, getmypid());
return;
}
usleep(250);
--$attempts;
}
throw new InfoException("Job is still locked (Lockfile: $lockFile)!");
} | php | public function acquireLock($lockFile)
{
if (array_key_exists($lockFile, $this->lockHandles)) {
throw new Exception("Lock already acquired (Lockfile: $lockFile).");
}
if (!file_exists($lockFile) && !touch($lockFile)) {
throw new Exception("Unable to create file (File: $lockFile).");
}
$fh = fopen($lockFile, 'rb+');
if ($fh === false) {
throw new Exception("Unable to open file (File: $lockFile).");
}
$attempts = 5;
while ($attempts > 0) {
if (flock($fh, LOCK_EX | LOCK_NB)) {
$this->lockHandles[$lockFile] = $fh;
ftruncate($fh, 0);
fwrite($fh, getmypid());
return;
}
usleep(250);
--$attempts;
}
throw new InfoException("Job is still locked (Lockfile: $lockFile)!");
} | [
"public",
"function",
"acquireLock",
"(",
"$",
"lockFile",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"lockFile",
",",
"$",
"this",
"->",
"lockHandles",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Lock already acquired (Lockfile: $lockFile).\"",
... | @param string $lockFile
@throws Exception
@throws InfoException | [
"@param",
"string",
"$lockFile"
] | train | https://github.com/jobbyphp/jobby/blob/2daeb4f797459c418a78d94b81f686c935ae1620/src/Helper.php#L101-L130 |
jobbyphp/jobby | src/Helper.php | Helper.releaseLock | public function releaseLock($lockFile)
{
if (!array_key_exists($lockFile, $this->lockHandles)) {
throw new Exception("Lock NOT held - bug? Lockfile: $lockFile");
}
if ($this->lockHandles[$lockFile]) {
ftruncate($this->lockHandles[$lockFile], 0);
flock($this->lockHandles[$lockFile], LOCK_UN);
}
unset($this->lockHandles[$lockFile]);
} | php | public function releaseLock($lockFile)
{
if (!array_key_exists($lockFile, $this->lockHandles)) {
throw new Exception("Lock NOT held - bug? Lockfile: $lockFile");
}
if ($this->lockHandles[$lockFile]) {
ftruncate($this->lockHandles[$lockFile], 0);
flock($this->lockHandles[$lockFile], LOCK_UN);
}
unset($this->lockHandles[$lockFile]);
} | [
"public",
"function",
"releaseLock",
"(",
"$",
"lockFile",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"lockFile",
",",
"$",
"this",
"->",
"lockHandles",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Lock NOT held - bug? Lockfile: $lockFile\"",... | @param string $lockFile
@throws Exception | [
"@param",
"string",
"$lockFile"
] | train | https://github.com/jobbyphp/jobby/blob/2daeb4f797459c418a78d94b81f686c935ae1620/src/Helper.php#L137-L149 |
jobbyphp/jobby | src/Helper.php | Helper.escape | public function escape($input)
{
$input = strtolower($input);
$input = preg_replace('/[^a-z0-9_. -]+/', '', $input);
$input = trim($input);
$input = str_replace(' ', '_', $input);
$input = preg_replace('/_{2,}/', '_', $input);
return $input;
} | php | public function escape($input)
{
$input = strtolower($input);
$input = preg_replace('/[^a-z0-9_. -]+/', '', $input);
$input = trim($input);
$input = str_replace(' ', '_', $input);
$input = preg_replace('/_{2,}/', '_', $input);
return $input;
} | [
"public",
"function",
"escape",
"(",
"$",
"input",
")",
"{",
"$",
"input",
"=",
"strtolower",
"(",
"$",
"input",
")",
";",
"$",
"input",
"=",
"preg_replace",
"(",
"'/[^a-z0-9_. -]+/'",
",",
"''",
",",
"$",
"input",
")",
";",
"$",
"input",
"=",
"trim"... | @param string $input
@return string | [
"@param",
"string",
"$input"
] | train | https://github.com/jobbyphp/jobby/blob/2daeb4f797459c418a78d94b81f686c935ae1620/src/Helper.php#L233-L242 |
jobbyphp/jobby | src/BackgroundJob.php | BackgroundJob.checkMaxRuntime | protected function checkMaxRuntime($lockFile)
{
$maxRuntime = $this->config['maxRuntime'];
if ($maxRuntime === null) {
return;
}
if ($this->helper->getPlatform() === Helper::WINDOWS) {
throw new Exception('"maxRuntime" is not supported on Windows');
}
$runtime = $this->helper->getLockLifetime($lockFile);
if ($runtime < $maxRuntime) {
return;
}
throw new Exception("MaxRuntime of $maxRuntime secs exceeded! Current runtime: $runtime secs");
} | php | protected function checkMaxRuntime($lockFile)
{
$maxRuntime = $this->config['maxRuntime'];
if ($maxRuntime === null) {
return;
}
if ($this->helper->getPlatform() === Helper::WINDOWS) {
throw new Exception('"maxRuntime" is not supported on Windows');
}
$runtime = $this->helper->getLockLifetime($lockFile);
if ($runtime < $maxRuntime) {
return;
}
throw new Exception("MaxRuntime of $maxRuntime secs exceeded! Current runtime: $runtime secs");
} | [
"protected",
"function",
"checkMaxRuntime",
"(",
"$",
"lockFile",
")",
"{",
"$",
"maxRuntime",
"=",
"$",
"this",
"->",
"config",
"[",
"'maxRuntime'",
"]",
";",
"if",
"(",
"$",
"maxRuntime",
"===",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
... | @param string $lockFile
@throws Exception | [
"@param",
"string",
"$lockFile"
] | train | https://github.com/jobbyphp/jobby/blob/2daeb4f797459c418a78d94b81f686c935ae1620/src/BackgroundJob.php#L126-L143 |
Sylius/SyliusMailerBundle | src/Component/Sender/Sender.php | Sender.send | public function send(string $code, array $recipients, array $data = [], array $attachments = [], array $replyTo = []): void
{
$email = $this->provider->getEmail($code);
if (!$email->isEnabled()) {
return;
}
$senderAddress = $email->getSenderAddress() ?: $this->defaultSettingsProvider->getSenderAddress();
$senderName = $email->getSenderName() ?: $this->defaultSettingsProvider->getSenderName();
$renderedEmail = $this->rendererAdapter->render($email, $data);
$this->senderAdapter->send(
$recipients,
$senderAddress,
$senderName,
$renderedEmail,
$email,
$data,
$attachments,
$replyTo
);
} | php | public function send(string $code, array $recipients, array $data = [], array $attachments = [], array $replyTo = []): void
{
$email = $this->provider->getEmail($code);
if (!$email->isEnabled()) {
return;
}
$senderAddress = $email->getSenderAddress() ?: $this->defaultSettingsProvider->getSenderAddress();
$senderName = $email->getSenderName() ?: $this->defaultSettingsProvider->getSenderName();
$renderedEmail = $this->rendererAdapter->render($email, $data);
$this->senderAdapter->send(
$recipients,
$senderAddress,
$senderName,
$renderedEmail,
$email,
$data,
$attachments,
$replyTo
);
} | [
"public",
"function",
"send",
"(",
"string",
"$",
"code",
",",
"array",
"$",
"recipients",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"attachments",
"=",
"[",
"]",
",",
"array",
"$",
"replyTo",
"=",
"[",
"]",
")",
":",
"void",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/Sylius/SyliusMailerBundle/blob/8efd82dee6a7ab22877d88122b7037ce637fcc55/src/Component/Sender/Sender.php#L50-L73 |
Sylius/SyliusMailerBundle | src/Bundle/Sender/Adapter/SwiftMailerAdapter.php | SwiftMailerAdapter.send | public function send(
array $recipients,
string $senderAddress,
string $senderName,
RenderedEmail $renderedEmail,
EmailInterface $email,
array $data,
array $attachments = [],
array $replyTo = []
): void {
$message = (new \Swift_Message())
->setSubject($renderedEmail->getSubject())
->setFrom([$senderAddress => $senderName])
->setTo($recipients)
->setReplyTo($replyTo);
$message->setBody($renderedEmail->getBody(), 'text/html');
foreach ($attachments as $attachment) {
$file = \Swift_Attachment::fromPath($attachment);
$message->attach($file);
}
$emailSendEvent = new EmailSendEvent($message, $email, $data, $recipients, $replyTo);
$this->dispatcher->dispatch(SyliusMailerEvents::EMAIL_PRE_SEND, $emailSendEvent);
$this->mailer->send($message);
$this->dispatcher->dispatch(SyliusMailerEvents::EMAIL_POST_SEND, $emailSendEvent);
} | php | public function send(
array $recipients,
string $senderAddress,
string $senderName,
RenderedEmail $renderedEmail,
EmailInterface $email,
array $data,
array $attachments = [],
array $replyTo = []
): void {
$message = (new \Swift_Message())
->setSubject($renderedEmail->getSubject())
->setFrom([$senderAddress => $senderName])
->setTo($recipients)
->setReplyTo($replyTo);
$message->setBody($renderedEmail->getBody(), 'text/html');
foreach ($attachments as $attachment) {
$file = \Swift_Attachment::fromPath($attachment);
$message->attach($file);
}
$emailSendEvent = new EmailSendEvent($message, $email, $data, $recipients, $replyTo);
$this->dispatcher->dispatch(SyliusMailerEvents::EMAIL_PRE_SEND, $emailSendEvent);
$this->mailer->send($message);
$this->dispatcher->dispatch(SyliusMailerEvents::EMAIL_POST_SEND, $emailSendEvent);
} | [
"public",
"function",
"send",
"(",
"array",
"$",
"recipients",
",",
"string",
"$",
"senderAddress",
",",
"string",
"$",
"senderName",
",",
"RenderedEmail",
"$",
"renderedEmail",
",",
"EmailInterface",
"$",
"email",
",",
"array",
"$",
"data",
",",
"array",
"$... | {@inheritdoc} | [
"{"
] | train | https://github.com/Sylius/SyliusMailerBundle/blob/8efd82dee6a7ab22877d88122b7037ce637fcc55/src/Bundle/Sender/Adapter/SwiftMailerAdapter.php#L35-L66 |
Sylius/SyliusMailerBundle | src/Bundle/DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder(): TreeBuilder
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('sylius_mailer');
$rootNode = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sylius_mailer');
}
$rootNode
->children()
->scalarNode('sender_adapter')->defaultValue('sylius.email_sender.adapter.swiftmailer')->end()
->scalarNode('renderer_adapter')->defaultValue('sylius.email_renderer.adapter.twig')->end()
->end()
;
$this->addEmailsSection($rootNode);
return $treeBuilder;
} | php | public function getConfigTreeBuilder(): TreeBuilder
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('sylius_mailer');
$rootNode = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sylius_mailer');
}
$rootNode
->children()
->scalarNode('sender_adapter')->defaultValue('sylius.email_sender.adapter.swiftmailer')->end()
->scalarNode('renderer_adapter')->defaultValue('sylius.email_renderer.adapter.twig')->end()
->end()
;
$this->addEmailsSection($rootNode);
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
":",
"TreeBuilder",
"{",
"if",
"(",
"method_exists",
"(",
"TreeBuilder",
"::",
"class",
",",
"'getRootNode'",
")",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
"'sylius_mailer'",
")",
";"... | {@inheritdoc} | [
"{"
] | train | https://github.com/Sylius/SyliusMailerBundle/blob/8efd82dee6a7ab22877d88122b7037ce637fcc55/src/Bundle/DependencyInjection/Configuration.php#L25-L46 |
Sylius/SyliusMailerBundle | src/Bundle/DependencyInjection/SyliusMailerExtension.php | SyliusMailerExtension.load | public function load(array $config, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $config);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$configFiles = [
'services.xml',
];
foreach ($configFiles as $configFile) {
$loader->load($configFile);
}
$container->setAlias('sylius.email_sender.adapter', $config['sender_adapter']);
$container->setAlias('sylius.email_renderer.adapter', $config['renderer_adapter']);
$container->setParameter('sylius.mailer.sender_name', $config['sender']['name']);
$container->setParameter('sylius.mailer.sender_address', $config['sender']['address']);
$templates = $config['templates'] ?? ['Default' => '@SyliusMailer/default.html.twig'];
$container->setParameter('sylius.mailer.emails', $config['emails']);
$container->setParameter('sylius.mailer.templates', $templates);
} | php | public function load(array $config, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $config);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$configFiles = [
'services.xml',
];
foreach ($configFiles as $configFile) {
$loader->load($configFile);
}
$container->setAlias('sylius.email_sender.adapter', $config['sender_adapter']);
$container->setAlias('sylius.email_renderer.adapter', $config['renderer_adapter']);
$container->setParameter('sylius.mailer.sender_name', $config['sender']['name']);
$container->setParameter('sylius.mailer.sender_address', $config['sender']['address']);
$templates = $config['templates'] ?? ['Default' => '@SyliusMailer/default.html.twig'];
$container->setParameter('sylius.mailer.emails', $config['emails']);
$container->setParameter('sylius.mailer.templates', $templates);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"$",
"this",
"->",
"getConfiguration",
"(",
"[",
"]",
",",
"$... | {@inheritdoc} | [
"{"
] | train | https://github.com/Sylius/SyliusMailerBundle/blob/8efd82dee6a7ab22877d88122b7037ce637fcc55/src/Bundle/DependencyInjection/SyliusMailerExtension.php#L26-L49 |
Sylius/SyliusMailerBundle | src/Bundle/DependencyInjection/SyliusMailerExtension.php | SyliusMailerExtension.getConfiguration | public function getConfiguration(array $config, ContainerBuilder $container): Configuration
{
$configuration = new Configuration();
$container->addObjectResource($configuration);
return $configuration;
} | php | public function getConfiguration(array $config, ContainerBuilder $container): Configuration
{
$configuration = new Configuration();
$container->addObjectResource($configuration);
return $configuration;
} | [
"public",
"function",
"getConfiguration",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
":",
"Configuration",
"{",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"container",
"->",
"addObjectResource",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/Sylius/SyliusMailerBundle/blob/8efd82dee6a7ab22877d88122b7037ce637fcc55/src/Bundle/DependencyInjection/SyliusMailerExtension.php#L54-L61 |
Sylius/SyliusMailerBundle | src/Bundle/Renderer/Adapter/EmailTwigAdapter.php | EmailTwigAdapter.render | public function render(EmailInterface $email, array $data = []): RenderedEmail
{
$renderedEmail = $this->getRenderedEmail($email, $data);
/** @var EmailRenderEvent $event */
$event = $this->dispatcher->dispatch(
SyliusMailerEvents::EMAIL_PRE_RENDER,
new EmailRenderEvent($renderedEmail)
);
return $event->getRenderedEmail();
} | php | public function render(EmailInterface $email, array $data = []): RenderedEmail
{
$renderedEmail = $this->getRenderedEmail($email, $data);
/** @var EmailRenderEvent $event */
$event = $this->dispatcher->dispatch(
SyliusMailerEvents::EMAIL_PRE_RENDER,
new EmailRenderEvent($renderedEmail)
);
return $event->getRenderedEmail();
} | [
"public",
"function",
"render",
"(",
"EmailInterface",
"$",
"email",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
":",
"RenderedEmail",
"{",
"$",
"renderedEmail",
"=",
"$",
"this",
"->",
"getRenderedEmail",
"(",
"$",
"email",
",",
"$",
"data",
")",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/Sylius/SyliusMailerBundle/blob/8efd82dee6a7ab22877d88122b7037ce637fcc55/src/Bundle/Renderer/Adapter/EmailTwigAdapter.php#L35-L46 |
toplan/laravel-sms | src/Toplan/LaravelSms/SmsManager.php | SmsManager.reset | protected function reset()
{
$fields = self::getFields();
$this->state = [
'sent' => false,
'to' => null,
'code' => null,
'deadline' => 0,
'usedRule' => array_fill_keys($fields, null),
'attempts' => 0,
];
} | php | protected function reset()
{
$fields = self::getFields();
$this->state = [
'sent' => false,
'to' => null,
'code' => null,
'deadline' => 0,
'usedRule' => array_fill_keys($fields, null),
'attempts' => 0,
];
} | [
"protected",
"function",
"reset",
"(",
")",
"{",
"$",
"fields",
"=",
"self",
"::",
"getFields",
"(",
")",
";",
"$",
"this",
"->",
"state",
"=",
"[",
"'sent'",
"=>",
"false",
",",
"'to'",
"=>",
"null",
",",
"'code'",
"=>",
"null",
",",
"'deadline'",
... | 重置发送状态 | [
"重置发送状态"
] | train | https://github.com/toplan/laravel-sms/blob/9c8427493c768c07a15fb993436267b81f31bae5/src/Toplan/LaravelSms/SmsManager.php#L75-L86 |
toplan/laravel-sms | src/Toplan/LaravelSms/SmsManager.php | SmsManager.validateSendable | public function validateSendable()
{
$time = $this->getCanResendTime();
if ($time <= time()) {
return self::generateResult(true, 'can_send');
}
return self::generateResult(false, 'request_invalid', [self::getInterval()]);
} | php | public function validateSendable()
{
$time = $this->getCanResendTime();
if ($time <= time()) {
return self::generateResult(true, 'can_send');
}
return self::generateResult(false, 'request_invalid', [self::getInterval()]);
} | [
"public",
"function",
"validateSendable",
"(",
")",
"{",
"$",
"time",
"=",
"$",
"this",
"->",
"getCanResendTime",
"(",
")",
";",
"if",
"(",
"$",
"time",
"<=",
"time",
"(",
")",
")",
"{",
"return",
"self",
"::",
"generateResult",
"(",
"true",
",",
"'c... | 验证是否可发送
@return array | [
"验证是否可发送"
] | train | https://github.com/toplan/laravel-sms/blob/9c8427493c768c07a15fb993436267b81f31bae5/src/Toplan/LaravelSms/SmsManager.php#L93-L101 |
toplan/laravel-sms | src/Toplan/LaravelSms/SmsManager.php | SmsManager.validateFields | public function validateFields($input = null, \Closure $validation = null)
{
if (is_callable($input)) {
$validation = $input;
$input = null;
}
if (is_array($input)) {
$this->input = array_merge($this->input, $input);
}
$rules = [];
$fields = self::getFields();
foreach ($fields as $field) {
if (self::whetherValidateFiled($field)) {
$ruleName = $this->input($field . '_rule');
$rules[$field] = $this->getRealRuleByName($field, $ruleName);
}
}
if ($validation) {
return call_user_func_array($validation, [$this->input(), $rules]);
}
if (empty($this->input())) {
return self::generateResult(false, 'empty_data');
}
$validator = Validator::make($this->input(), $rules);
if ($validator->fails()) {
$messages = $validator->errors();
foreach ($fields as $field) {
if ($messages->has($field)) {
$rule = $this->usedRule($field);
$msg = $messages->first($field);
return self::generateResult(false, $rule, $msg);
}
}
}
return self::generateResult(true, 'success');
} | php | public function validateFields($input = null, \Closure $validation = null)
{
if (is_callable($input)) {
$validation = $input;
$input = null;
}
if (is_array($input)) {
$this->input = array_merge($this->input, $input);
}
$rules = [];
$fields = self::getFields();
foreach ($fields as $field) {
if (self::whetherValidateFiled($field)) {
$ruleName = $this->input($field . '_rule');
$rules[$field] = $this->getRealRuleByName($field, $ruleName);
}
}
if ($validation) {
return call_user_func_array($validation, [$this->input(), $rules]);
}
if (empty($this->input())) {
return self::generateResult(false, 'empty_data');
}
$validator = Validator::make($this->input(), $rules);
if ($validator->fails()) {
$messages = $validator->errors();
foreach ($fields as $field) {
if ($messages->has($field)) {
$rule = $this->usedRule($field);
$msg = $messages->first($field);
return self::generateResult(false, $rule, $msg);
}
}
}
return self::generateResult(true, 'success');
} | [
"public",
"function",
"validateFields",
"(",
"$",
"input",
"=",
"null",
",",
"\\",
"Closure",
"$",
"validation",
"=",
"null",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"input",
")",
")",
"{",
"$",
"validation",
"=",
"$",
"input",
";",
"$",
"input... | 验证数据
@param mixed $input
@param \Closure|null $validation
@return array | [
"验证数据"
] | train | https://github.com/toplan/laravel-sms/blob/9c8427493c768c07a15fb993436267b81f31bae5/src/Toplan/LaravelSms/SmsManager.php#L111-L152 |
toplan/laravel-sms | src/Toplan/LaravelSms/SmsManager.php | SmsManager.getRealRuleByName | protected function getRealRuleByName($field, $ruleName)
{
if (empty($ruleName) || !is_string($ruleName)) {
$ruleName = Util::pathOfUrl(URL::previous());
}
if ($staticRule = $this->getStaticRule($field, $ruleName)) {
$this->useRule($field, $ruleName);
return $staticRule;
}
if ($dynamicRule = $this->retrieveRule($field, $ruleName)) {
$this->useRule($field, $ruleName);
return $dynamicRule;
}
$default = self::getNameOfDefaultStaticRule($field);
if ($staticRule = $this->getStaticRule($field, $default)) {
$this->useRule($field, $default);
return $staticRule;
}
return '';
} | php | protected function getRealRuleByName($field, $ruleName)
{
if (empty($ruleName) || !is_string($ruleName)) {
$ruleName = Util::pathOfUrl(URL::previous());
}
if ($staticRule = $this->getStaticRule($field, $ruleName)) {
$this->useRule($field, $ruleName);
return $staticRule;
}
if ($dynamicRule = $this->retrieveRule($field, $ruleName)) {
$this->useRule($field, $ruleName);
return $dynamicRule;
}
$default = self::getNameOfDefaultStaticRule($field);
if ($staticRule = $this->getStaticRule($field, $default)) {
$this->useRule($field, $default);
return $staticRule;
}
return '';
} | [
"protected",
"function",
"getRealRuleByName",
"(",
"$",
"field",
",",
"$",
"ruleName",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"ruleName",
")",
"||",
"!",
"is_string",
"(",
"$",
"ruleName",
")",
")",
"{",
"$",
"ruleName",
"=",
"Util",
"::",
"pathOfUrl"... | 根据规则名获取真实的验证规则
- 首先尝试使用指定名称的静态验证规则
- 其次尝试使用指定名称的动态验证规则
- 最后尝试使用配置文件中的默认静态验证规则
@param string $field
@param string $ruleName
@return string | [
"根据规则名获取真实的验证规则"
] | train | https://github.com/toplan/laravel-sms/blob/9c8427493c768c07a15fb993436267b81f31bae5/src/Toplan/LaravelSms/SmsManager.php#L166-L189 |
toplan/laravel-sms | src/Toplan/LaravelSms/SmsManager.php | SmsManager.verifyCode | protected function verifyCode()
{
$repeatIfValid = config('laravel-sms.verifyCode.repeatIfValid',
config('laravel-sms.code.repeatIfValid', false));
if ($repeatIfValid) {
$state = $this->retrieveState();
if (!(empty($state)) && $state['deadline'] >= time() + 60) {
return $state['code'];
}
}
return self::generateCode();
} | php | protected function verifyCode()
{
$repeatIfValid = config('laravel-sms.verifyCode.repeatIfValid',
config('laravel-sms.code.repeatIfValid', false));
if ($repeatIfValid) {
$state = $this->retrieveState();
if (!(empty($state)) && $state['deadline'] >= time() + 60) {
return $state['code'];
}
}
return self::generateCode();
} | [
"protected",
"function",
"verifyCode",
"(",
")",
"{",
"$",
"repeatIfValid",
"=",
"config",
"(",
"'laravel-sms.verifyCode.repeatIfValid'",
",",
"config",
"(",
"'laravel-sms.code.repeatIfValid'",
",",
"false",
")",
")",
";",
"if",
"(",
"$",
"repeatIfValid",
")",
"{"... | 生成待发生的验证码
@return string | [
"生成待发生的验证码"
] | train | https://github.com/toplan/laravel-sms/blob/9c8427493c768c07a15fb993436267b81f31bae5/src/Toplan/LaravelSms/SmsManager.php#L219-L231 |
toplan/laravel-sms | src/Toplan/LaravelSms/SmsManager.php | SmsManager.requestVerifySms | public function requestVerifySms()
{
$minutes = self::getCodeValidMinutes();
$code = $this->verifyCode();
$for = $this->input(self::getMobileField());
$content = $this->generateSmsContent($code, $minutes);
$templates = $this->generateTemplates(self::VERIFY_SMS);
$tplData = $this->generateTemplateData($code, $minutes, self::VERIFY_SMS);
$result = PhpSms::make($templates)->to($for)->data($tplData)->content($content)->send();
if ($result === null || $result === true || (isset($result['success']) && $result['success'])) {
$this->state['sent'] = true;
$this->state['to'] = $for;
$this->state['code'] = $code;
$this->state['deadline'] = time() + ($minutes * 60);
$this->storeState();
$this->setCanResendAfter(self::getInterval());
return self::generateResult(true, 'sms_sent_success');
}
return self::generateResult(false, 'sms_sent_failure');
} | php | public function requestVerifySms()
{
$minutes = self::getCodeValidMinutes();
$code = $this->verifyCode();
$for = $this->input(self::getMobileField());
$content = $this->generateSmsContent($code, $minutes);
$templates = $this->generateTemplates(self::VERIFY_SMS);
$tplData = $this->generateTemplateData($code, $minutes, self::VERIFY_SMS);
$result = PhpSms::make($templates)->to($for)->data($tplData)->content($content)->send();
if ($result === null || $result === true || (isset($result['success']) && $result['success'])) {
$this->state['sent'] = true;
$this->state['to'] = $for;
$this->state['code'] = $code;
$this->state['deadline'] = time() + ($minutes * 60);
$this->storeState();
$this->setCanResendAfter(self::getInterval());
return self::generateResult(true, 'sms_sent_success');
}
return self::generateResult(false, 'sms_sent_failure');
} | [
"public",
"function",
"requestVerifySms",
"(",
")",
"{",
"$",
"minutes",
"=",
"self",
"::",
"getCodeValidMinutes",
"(",
")",
";",
"$",
"code",
"=",
"$",
"this",
"->",
"verifyCode",
"(",
")",
";",
"$",
"for",
"=",
"$",
"this",
"->",
"input",
"(",
"sel... | 请求验证码短信
@return array | [
"请求验证码短信"
] | train | https://github.com/toplan/laravel-sms/blob/9c8427493c768c07a15fb993436267b81f31bae5/src/Toplan/LaravelSms/SmsManager.php#L238-L261 |
toplan/laravel-sms | src/Toplan/LaravelSms/SmsManager.php | SmsManager.requestVoiceVerify | public function requestVoiceVerify()
{
$minutes = self::getCodeValidMinutes();
$code = $this->verifyCode();
$for = $this->input(self::getMobileField());
$templates = $this->generateTemplates(self::VOICE_VERIFY);
$tplData = $this->generateTemplateData($code, $minutes, self::VOICE_VERIFY);
$result = PhpSms::voice($code)->template($templates)->data($tplData)->to($for)->send();
if ($result === null || $result === true || (isset($result['success']) && $result['success'])) {
$this->state['sent'] = true;
$this->state['to'] = $for;
$this->state['code'] = $code;
$this->state['deadline'] = time() + ($minutes * 60);
$this->storeState();
$this->setCanResendAfter(self::getInterval());
return self::generateResult(true, 'voice_sent_success');
}
return self::generateResult(false, 'voice_sent_failure');
} | php | public function requestVoiceVerify()
{
$minutes = self::getCodeValidMinutes();
$code = $this->verifyCode();
$for = $this->input(self::getMobileField());
$templates = $this->generateTemplates(self::VOICE_VERIFY);
$tplData = $this->generateTemplateData($code, $minutes, self::VOICE_VERIFY);
$result = PhpSms::voice($code)->template($templates)->data($tplData)->to($for)->send();
if ($result === null || $result === true || (isset($result['success']) && $result['success'])) {
$this->state['sent'] = true;
$this->state['to'] = $for;
$this->state['code'] = $code;
$this->state['deadline'] = time() + ($minutes * 60);
$this->storeState();
$this->setCanResendAfter(self::getInterval());
return self::generateResult(true, 'voice_sent_success');
}
return self::generateResult(false, 'voice_sent_failure');
} | [
"public",
"function",
"requestVoiceVerify",
"(",
")",
"{",
"$",
"minutes",
"=",
"self",
"::",
"getCodeValidMinutes",
"(",
")",
";",
"$",
"code",
"=",
"$",
"this",
"->",
"verifyCode",
"(",
")",
";",
"$",
"for",
"=",
"$",
"this",
"->",
"input",
"(",
"s... | 请求语音验证码
@return array | [
"请求语音验证码"
] | train | https://github.com/toplan/laravel-sms/blob/9c8427493c768c07a15fb993436267b81f31bae5/src/Toplan/LaravelSms/SmsManager.php#L268-L290 |
toplan/laravel-sms | src/Toplan/LaravelSms/SmsManager.php | SmsManager.state | public function state($key = null, $default = null)
{
if ($key !== null) {
return isset($this->state[$key]) ? $this->state[$key] : $default;
}
return $this->state;
} | php | public function state($key = null, $default = null)
{
if ($key !== null) {
return isset($this->state[$key]) ? $this->state[$key] : $default;
}
return $this->state;
} | [
"public",
"function",
"state",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"state",
"[",
"$",
"key",
"]",
")",
"?",
"$",
... | 获取当前的发送状态(非持久化的)
@param string|int|null $key
@param mixed $default
@return mixed | [
"获取当前的发送状态",
"(",
"非持久化的",
")"
] | train | https://github.com/toplan/laravel-sms/blob/9c8427493c768c07a15fb993436267b81f31bae5/src/Toplan/LaravelSms/SmsManager.php#L300-L307 |
toplan/laravel-sms | src/Toplan/LaravelSms/SmsManager.php | SmsManager.input | public function input($key = null, $default = null)
{
if ($key !== null) {
return isset($this->input[$key]) ? $this->input[$key] : $default;
}
return $this->input;
} | php | public function input($key = null, $default = null)
{
if ($key !== null) {
return isset($this->input[$key]) ? $this->input[$key] : $default;
}
return $this->input;
} | [
"public",
"function",
"input",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"input",
"[",
"$",
"key",
"]",
")",
"?",
"$",
... | 获取客户端数据
@param string|int|null $key
@param mixed $default
@return mixed | [
"获取客户端数据"
] | train | https://github.com/toplan/laravel-sms/blob/9c8427493c768c07a15fb993436267b81f31bae5/src/Toplan/LaravelSms/SmsManager.php#L317-L324 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.