id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
39,900
Rican7/incoming
src/Incoming/Structure/RecursiveInputStructureFactory.php
RecursiveInputStructureFactory.buildFromTraversableLike
protected static function buildFromTraversableLike($data): Structure { if (is_array($data)) { return static::buildFromArray($data); } elseif ($data instanceof Traversable) { return static::buildFromTraversable($data); } throw InvalidStructuralTypeException::withTypeInfo($data); }
php
protected static function buildFromTraversableLike($data): Structure { if (is_array($data)) { return static::buildFromArray($data); } elseif ($data instanceof Traversable) { return static::buildFromTraversable($data); } throw InvalidStructuralTypeException::withTypeInfo($data); }
[ "protected", "static", "function", "buildFromTraversableLike", "(", "$", "data", ")", ":", "Structure", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "return", "static", "::", "buildFromArray", "(", "$", "data", ")", ";", "}", "elseif", "(...
Build a structure from "Traversable-like" data. This allows to build from data that is either an array or Traversable, as PHP's array type works JUST like a Traversable instance but doesn't actually implement any interfaces. @param Traversable|array $data The input data. @throws InvalidStructuralTypeException If the data type isn't supported. @return Structure The built structure.
[ "Build", "a", "structure", "from", "Traversable", "-", "like", "data", "." ]
23d5179f994980d56dd32ae056498dc91e72c1f7
https://github.com/Rican7/incoming/blob/23d5179f994980d56dd32ae056498dc91e72c1f7/src/Incoming/Structure/RecursiveInputStructureFactory.php#L48-L57
39,901
Rican7/incoming
src/Incoming/Structure/RecursiveInputStructureFactory.php
RecursiveInputStructureFactory.buildFromTraversable
protected static function buildFromTraversable(Traversable $data): Structure { $is_map = false; // Traverse through the data, but only check the first item's key foreach ($data as $key => &$val) { $is_map = $is_map || !is_int($key); $val = self::attemptBuildTraversableLike($val); } if ($is_map) { return Map::fromTraversable($data); } return FixedList::fromTraversable($data); }
php
protected static function buildFromTraversable(Traversable $data): Structure { $is_map = false; // Traverse through the data, but only check the first item's key foreach ($data as $key => &$val) { $is_map = $is_map || !is_int($key); $val = self::attemptBuildTraversableLike($val); } if ($is_map) { return Map::fromTraversable($data); } return FixedList::fromTraversable($data); }
[ "protected", "static", "function", "buildFromTraversable", "(", "Traversable", "$", "data", ")", ":", "Structure", "{", "$", "is_map", "=", "false", ";", "// Traverse through the data, but only check the first item's key", "foreach", "(", "$", "data", "as", "$", "key"...
Build a structure from data in a Traversable instance. @param Traversable $data The input data. @return Structure The built structure.
[ "Build", "a", "structure", "from", "data", "in", "a", "Traversable", "instance", "." ]
23d5179f994980d56dd32ae056498dc91e72c1f7
https://github.com/Rican7/incoming/blob/23d5179f994980d56dd32ae056498dc91e72c1f7/src/Incoming/Structure/RecursiveInputStructureFactory.php#L78-L94
39,902
Rican7/incoming
src/Incoming/Structure/RecursiveInputStructureFactory.php
RecursiveInputStructureFactory.attemptBuildTraversableLike
private static function attemptBuildTraversableLike($data) { if (is_array($data) || $data instanceof Traversable) { $data = static::buildFromTraversableLike($data); } return $data; }
php
private static function attemptBuildTraversableLike($data) { if (is_array($data) || $data instanceof Traversable) { $data = static::buildFromTraversableLike($data); } return $data; }
[ "private", "static", "function", "attemptBuildTraversableLike", "(", "$", "data", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", "||", "$", "data", "instanceof", "Traversable", ")", "{", "$", "data", "=", "static", "::", "buildFromTraversableLike", ...
Attempt to build a structure from "Traversable-like" data. If the data type isn't supported, we simply return the original data untouched. This allows to more easily traverse deeply nested structures. @param mixed $data The input data. @return Structure|mixed The built structure or original data.
[ "Attempt", "to", "build", "a", "structure", "from", "Traversable", "-", "like", "data", "." ]
23d5179f994980d56dd32ae056498dc91e72c1f7
https://github.com/Rican7/incoming/blob/23d5179f994980d56dd32ae056498dc91e72c1f7/src/Incoming/Structure/RecursiveInputStructureFactory.php#L105-L112
39,903
Rican7/incoming
src/Incoming/Structure/Exception/ReadOnlyException.php
ReadOnlyException.forAttribute
public static function forAttribute( $name, $value = null, int $code = self::CODE_FOR_ATTRIBUTE, Throwable $previous = null ): self { $message = self::DEFAULT_MESSAGE; if (null !== $value) { $message .= sprintf( self::MESSAGE_EXTENSION_FOR_ATTRIBUTE_FORMAT . self::MESSAGE_EXTENSION_FOR_ATTRIBUTE_WITH_VALUE_FORMAT, $name, var_export($value, true) ); } else { $message .= sprintf( self::MESSAGE_EXTENSION_FOR_ATTRIBUTE_FORMAT, $name ); } return new static($message, $code, $previous); }
php
public static function forAttribute( $name, $value = null, int $code = self::CODE_FOR_ATTRIBUTE, Throwable $previous = null ): self { $message = self::DEFAULT_MESSAGE; if (null !== $value) { $message .= sprintf( self::MESSAGE_EXTENSION_FOR_ATTRIBUTE_FORMAT . self::MESSAGE_EXTENSION_FOR_ATTRIBUTE_WITH_VALUE_FORMAT, $name, var_export($value, true) ); } else { $message .= sprintf( self::MESSAGE_EXTENSION_FOR_ATTRIBUTE_FORMAT, $name ); } return new static($message, $code, $previous); }
[ "public", "static", "function", "forAttribute", "(", "$", "name", ",", "$", "value", "=", "null", ",", "int", "$", "code", "=", "self", "::", "CODE_FOR_ATTRIBUTE", ",", "Throwable", "$", "previous", "=", "null", ")", ":", "self", "{", "$", "message", "...
Create an exception instance with an attribute's context. @param mixed $name The name of the attribute attempted to be modified. @param mixed|null $value The value attempted to be set. @param int $code The exception code. @param Throwable|null $previous A previous exception used for chaining. @return static The newly created exception.
[ "Create", "an", "exception", "instance", "with", "an", "attribute", "s", "context", "." ]
23d5179f994980d56dd32ae056498dc91e72c1f7
https://github.com/Rican7/incoming/blob/23d5179f994980d56dd32ae056498dc91e72c1f7/src/Incoming/Structure/Exception/ReadOnlyException.php#L84-L106
39,904
Rican7/incoming
src/Incoming/Hydrator/Exception/InvalidDelegateException.php
InvalidDelegateException.forNonCallable
public static function forNonCallable( string $name = null, int $code = self::CODE_FOR_NON_CALLABLE, Throwable $previous = null ): self { $message = self::DEFAULT_MESSAGE; if (null !== $name) { $message .= sprintf( self::MESSAGE_EXTENSION_NAME_FORMAT, $name ); } $message .= self::MESSAGE_EXTENSION_FOR_NON_CALLABLE; return new static($message, $code, $previous); }
php
public static function forNonCallable( string $name = null, int $code = self::CODE_FOR_NON_CALLABLE, Throwable $previous = null ): self { $message = self::DEFAULT_MESSAGE; if (null !== $name) { $message .= sprintf( self::MESSAGE_EXTENSION_NAME_FORMAT, $name ); } $message .= self::MESSAGE_EXTENSION_FOR_NON_CALLABLE; return new static($message, $code, $previous); }
[ "public", "static", "function", "forNonCallable", "(", "string", "$", "name", "=", "null", ",", "int", "$", "code", "=", "self", "::", "CODE_FOR_NON_CALLABLE", ",", "Throwable", "$", "previous", "=", "null", ")", ":", "self", "{", "$", "message", "=", "s...
Create an exception instance for a delegate that isn't callable. @param string|null $name The name of the delegate. @param int $code The exception code. @param Throwable|null $previous A previous exception used for chaining. @return static The newly created exception.
[ "Create", "an", "exception", "instance", "for", "a", "delegate", "that", "isn", "t", "callable", "." ]
23d5179f994980d56dd32ae056498dc91e72c1f7
https://github.com/Rican7/incoming/blob/23d5179f994980d56dd32ae056498dc91e72c1f7/src/Incoming/Hydrator/Exception/InvalidDelegateException.php#L82-L99
39,905
Rican7/incoming
src/Incoming/Hydrator/AbstractDelegateBuilderHydrator.php
AbstractDelegateBuilderHydrator.getDelegateHydrator
protected function getDelegateHydrator(): callable { $delegate = [$this, static::DEFAULT_DELEGATE_HYDRATE_METHOD_NAME]; if (!is_callable($delegate, false, $callable_name)) { throw InvalidDelegateException::forNonCallable($callable_name); } return $delegate; }
php
protected function getDelegateHydrator(): callable { $delegate = [$this, static::DEFAULT_DELEGATE_HYDRATE_METHOD_NAME]; if (!is_callable($delegate, false, $callable_name)) { throw InvalidDelegateException::forNonCallable($callable_name); } return $delegate; }
[ "protected", "function", "getDelegateHydrator", "(", ")", ":", "callable", "{", "$", "delegate", "=", "[", "$", "this", ",", "static", "::", "DEFAULT_DELEGATE_HYDRATE_METHOD_NAME", "]", ";", "if", "(", "!", "is_callable", "(", "$", "delegate", ",", "false", ...
Get the delegate hydration callable. Override this method if a custom delegate is desired. @return callable The delegate hydrator callable. @throws InvalidDelegateException If the delegate isn't callable.
[ "Get", "the", "delegate", "hydration", "callable", "." ]
23d5179f994980d56dd32ae056498dc91e72c1f7
https://github.com/Rican7/incoming/blob/23d5179f994980d56dd32ae056498dc91e72c1f7/src/Incoming/Hydrator/AbstractDelegateBuilderHydrator.php#L105-L114
39,906
Rican7/incoming
src/Incoming/Hydrator/Exception/UnresolvableHydratorException.php
UnresolvableHydratorException.forModel
public static function forModel( $model, int $code = self::CODE_FOR_MODEL, Throwable $previous = null ): self { $message = self::DEFAULT_MESSAGE . self::MESSAGE_EXTENSION_FOR_MODEL; $message .= sprintf( self::MESSAGE_EXTENSION_TYPE_FORMAT, is_object($model) ? get_class($model) : gettype($model) ); return new static($message, $code, $previous); }
php
public static function forModel( $model, int $code = self::CODE_FOR_MODEL, Throwable $previous = null ): self { $message = self::DEFAULT_MESSAGE . self::MESSAGE_EXTENSION_FOR_MODEL; $message .= sprintf( self::MESSAGE_EXTENSION_TYPE_FORMAT, is_object($model) ? get_class($model) : gettype($model) ); return new static($message, $code, $previous); }
[ "public", "static", "function", "forModel", "(", "$", "model", ",", "int", "$", "code", "=", "self", "::", "CODE_FOR_MODEL", ",", "Throwable", "$", "previous", "=", "null", ")", ":", "self", "{", "$", "message", "=", "self", "::", "DEFAULT_MESSAGE", ".",...
Create an exception instance for a problem resolving a hydrator for a given model. @param mixed $model The model to hydrate. @param int $code The exception code. @param Throwable|null $previous A previous exception used for chaining. @return static The newly created exception.
[ "Create", "an", "exception", "instance", "for", "a", "problem", "resolving", "a", "hydrator", "for", "a", "given", "model", "." ]
23d5179f994980d56dd32ae056498dc91e72c1f7
https://github.com/Rican7/incoming/blob/23d5179f994980d56dd32ae056498dc91e72c1f7/src/Incoming/Hydrator/Exception/UnresolvableHydratorException.php#L84-L97
39,907
XetaIO/Xetaravel-Mentions
src/Parser/MentionParser.php
MentionParser.parse
public function parse($input) { if (is_null($input) || empty($input)) { return $input; } $character = $this->getOption('character'); $regex = strtr($this->getOption('regex'), $this->getOption('regex_replacement')); preg_match_all($regex, $input, $matches); $matches = array_map([$this, 'mapper'], $matches[0]); $matches = $this->removeNullKeys($matches); $matches = $this->prepareArray($matches); $output = preg_replace_callback($matches, [$this, 'replace'], $input); return $output; }
php
public function parse($input) { if (is_null($input) || empty($input)) { return $input; } $character = $this->getOption('character'); $regex = strtr($this->getOption('regex'), $this->getOption('regex_replacement')); preg_match_all($regex, $input, $matches); $matches = array_map([$this, 'mapper'], $matches[0]); $matches = $this->removeNullKeys($matches); $matches = $this->prepareArray($matches); $output = preg_replace_callback($matches, [$this, 'replace'], $input); return $output; }
[ "public", "function", "parse", "(", "$", "input", ")", "{", "if", "(", "is_null", "(", "$", "input", ")", "||", "empty", "(", "$", "input", ")", ")", "{", "return", "$", "input", ";", "}", "$", "character", "=", "$", "this", "->", "getOption", "(...
Parse a text and determine if it contains mentions. If it does, then we transform the mentions to a markdown link and we notify the user. @param null|string $input The string to parse. @return null|string
[ "Parse", "a", "text", "and", "determine", "if", "it", "contains", "mentions", ".", "If", "it", "does", "then", "we", "transform", "the", "mentions", "to", "a", "markdown", "link", "and", "we", "notify", "the", "user", "." ]
7e0505fdafc76c310824cfd24f62c18aa5029358
https://github.com/XetaIO/Xetaravel-Mentions/blob/7e0505fdafc76c310824cfd24f62c18aa5029358/src/Parser/MentionParser.php#L58-L76
39,908
XetaIO/Xetaravel-Mentions
src/Parser/MentionParser.php
MentionParser.replace
protected function replace(array $match): string { $character = $this->getOption('character'); $mention = Str::title(str_replace($character, '', trim($match[0]))); $route = config('mentions.pools.' . $this->getOption('pool') . '.route'); $link = $route . $mention; return " [{$character}{$mention}]($link)"; }
php
protected function replace(array $match): string { $character = $this->getOption('character'); $mention = Str::title(str_replace($character, '', trim($match[0]))); $route = config('mentions.pools.' . $this->getOption('pool') . '.route'); $link = $route . $mention; return " [{$character}{$mention}]($link)"; }
[ "protected", "function", "replace", "(", "array", "$", "match", ")", ":", "string", "{", "$", "character", "=", "$", "this", "->", "getOption", "(", "'character'", ")", ";", "$", "mention", "=", "Str", "::", "title", "(", "str_replace", "(", "$", "char...
Replace the mention with a markdown link. @param array $match The mention to replace. @return string
[ "Replace", "the", "mention", "with", "a", "markdown", "link", "." ]
7e0505fdafc76c310824cfd24f62c18aa5029358
https://github.com/XetaIO/Xetaravel-Mentions/blob/7e0505fdafc76c310824cfd24f62c18aa5029358/src/Parser/MentionParser.php#L85-L95
39,909
XetaIO/Xetaravel-Mentions
src/Parser/MentionParser.php
MentionParser.mapper
protected function mapper(string $key) { $character = $this->getOption('character'); $config = config('mentions.pools.' . $this->getOption('pool')); $mention = str_replace($character, '', trim($key)); $mentionned = $config['model']::whereRaw("LOWER({$config['column']}) = ?", [Str::lower($mention)])->first(); if ($mentionned == false) { return null; } if ($this->getOption('mention') == true && $mentionned->getKey() !== Auth::id()) { $this->model->mention($mentionned, $this->getOption('notify')); } return '/' . preg_quote($key) . '(?!\w)/'; }
php
protected function mapper(string $key) { $character = $this->getOption('character'); $config = config('mentions.pools.' . $this->getOption('pool')); $mention = str_replace($character, '', trim($key)); $mentionned = $config['model']::whereRaw("LOWER({$config['column']}) = ?", [Str::lower($mention)])->first(); if ($mentionned == false) { return null; } if ($this->getOption('mention') == true && $mentionned->getKey() !== Auth::id()) { $this->model->mention($mentionned, $this->getOption('notify')); } return '/' . preg_quote($key) . '(?!\w)/'; }
[ "protected", "function", "mapper", "(", "string", "$", "key", ")", "{", "$", "character", "=", "$", "this", "->", "getOption", "(", "'character'", ")", ";", "$", "config", "=", "config", "(", "'mentions.pools.'", ".", "$", "this", "->", "getOption", "(",...
Handle a mention and return it has a regex. If you want to delete this mention from the out array, just return `null`. @param string $key The mention that has been matched. @return null|string
[ "Handle", "a", "mention", "and", "return", "it", "has", "a", "regex", ".", "If", "you", "want", "to", "delete", "this", "mention", "from", "the", "out", "array", "just", "return", "null", "." ]
7e0505fdafc76c310824cfd24f62c18aa5029358
https://github.com/XetaIO/Xetaravel-Mentions/blob/7e0505fdafc76c310824cfd24f62c18aa5029358/src/Parser/MentionParser.php#L139-L157
39,910
Rican7/incoming
src/Incoming/Hydrator/Exception/IncompatibleProcessException.php
IncompatibleProcessException.forRequiredContextCompatibility
public static function forRequiredContextCompatibility( $process = null, int $code = self::CODE_FOR_REQUIRED_CONTEXT_COMPATIBILITY, Throwable $previous = null ): self { if (self::CODE_FOR_REQUIRED_CONTEXT_COMPATIBILITY === $code) { if ($process instanceof Hydrator) { $code += self::CODE_FOR_HYDRATOR; } elseif ($process instanceof Builder) { $code += self::CODE_FOR_BUILDER; } } $message = self::DEFAULT_MESSAGE . self::MESSAGE_EXTENSION_FOR_REQUIRED_CONTEXT_COMPATIBILITY; return new static($message, $code, $previous); }
php
public static function forRequiredContextCompatibility( $process = null, int $code = self::CODE_FOR_REQUIRED_CONTEXT_COMPATIBILITY, Throwable $previous = null ): self { if (self::CODE_FOR_REQUIRED_CONTEXT_COMPATIBILITY === $code) { if ($process instanceof Hydrator) { $code += self::CODE_FOR_HYDRATOR; } elseif ($process instanceof Builder) { $code += self::CODE_FOR_BUILDER; } } $message = self::DEFAULT_MESSAGE . self::MESSAGE_EXTENSION_FOR_REQUIRED_CONTEXT_COMPATIBILITY; return new static($message, $code, $previous); }
[ "public", "static", "function", "forRequiredContextCompatibility", "(", "$", "process", "=", "null", ",", "int", "$", "code", "=", "self", "::", "CODE_FOR_REQUIRED_CONTEXT_COMPATIBILITY", ",", "Throwable", "$", "previous", "=", "null", ")", ":", "self", "{", "if...
Create an exception instance for when context compatibility is required. @param object|null $process The incompatible process. @param int $code The exception code. @param Throwable|null $previous A previous exception used for chaining. @return static The newly created exception.
[ "Create", "an", "exception", "instance", "for", "when", "context", "compatibility", "is", "required", "." ]
23d5179f994980d56dd32ae056498dc91e72c1f7
https://github.com/Rican7/incoming/blob/23d5179f994980d56dd32ae056498dc91e72c1f7/src/Incoming/Hydrator/Exception/IncompatibleProcessException.php#L93-L109
39,911
XetaIO/Xetaravel-Mentions
src/Models/Repositories/MentionRepository.php
MentionRepository.create
public static function create(Model $model, Model $recipient, $notify = true): Mention { $mention = Mention::firstOrCreate([ 'model_type' => get_class($model), 'model_id' => $model->getKey(), 'recipient_type' => get_class($recipient), 'recipient_id' => $recipient->getKey() ]); if ($notify) { $mention->notify($model, $recipient); } return $mention; }
php
public static function create(Model $model, Model $recipient, $notify = true): Mention { $mention = Mention::firstOrCreate([ 'model_type' => get_class($model), 'model_id' => $model->getKey(), 'recipient_type' => get_class($recipient), 'recipient_id' => $recipient->getKey() ]); if ($notify) { $mention->notify($model, $recipient); } return $mention; }
[ "public", "static", "function", "create", "(", "Model", "$", "model", ",", "Model", "$", "recipient", ",", "$", "notify", "=", "true", ")", ":", "Mention", "{", "$", "mention", "=", "Mention", "::", "firstOrCreate", "(", "[", "'model_type'", "=>", "get_c...
Creates a new mention. @return \Xetaio\Mentions\Models\Mention
[ "Creates", "a", "new", "mention", "." ]
7e0505fdafc76c310824cfd24f62c18aa5029358
https://github.com/XetaIO/Xetaravel-Mentions/blob/7e0505fdafc76c310824cfd24f62c18aa5029358/src/Models/Repositories/MentionRepository.php#L27-L41
39,912
tarsana/command
src/Config/Config.php
Config.get
public function get(string $path = null) { if (null === $path) return $this->data; $keys = explode('.', $path); $value = $this->data; foreach ($keys as $key) { if (!is_array($value) || !array_key_exists($key, $value)) throw new \Exception("Unable to find a configuration value with path '{$path}'"); $value = $value[$key]; } return $value; }
php
public function get(string $path = null) { if (null === $path) return $this->data; $keys = explode('.', $path); $value = $this->data; foreach ($keys as $key) { if (!is_array($value) || !array_key_exists($key, $value)) throw new \Exception("Unable to find a configuration value with path '{$path}'"); $value = $value[$key]; } return $value; }
[ "public", "function", "get", "(", "string", "$", "path", "=", "null", ")", "{", "if", "(", "null", "===", "$", "path", ")", "return", "$", "this", "->", "data", ";", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "path", ")", ";", "$", "val...
Gets a configuration value by path.
[ "Gets", "a", "configuration", "value", "by", "path", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Config/Config.php#L23-L35
39,913
tarsana/command
src/Console/ExceptionPrinter.php
ExceptionPrinter.printParseException
public function printParseException(ParseException $e) : string { $syntax = $e->syntax(); $error = ''; if ($syntax instanceof ObjectSyntax) { $i = $e->extra(); if ($i['type'] == 'invalid-field') $error = "{$i['field']} is invalid!"; if ($i['type'] == 'missing-field') $error = "{$i['field']} is missing!"; if ($i['type'] == 'additional-items') { $items = implode($syntax->separator(), $i['items']); $error = "additional items {$items}"; } } $syntax = $this->printSyntax($e->syntax()); $output = "<reset>Failed to parse <warn>'{$e->input()}'</warn> as <info>{$syntax}</info>"; if ('' != $error) $output .= " <error>{$error}</error>"; $previous = $e->previous(); if ($previous) { $output .= '<br>' . $this->printParseException($previous); } return $output; }
php
public function printParseException(ParseException $e) : string { $syntax = $e->syntax(); $error = ''; if ($syntax instanceof ObjectSyntax) { $i = $e->extra(); if ($i['type'] == 'invalid-field') $error = "{$i['field']} is invalid!"; if ($i['type'] == 'missing-field') $error = "{$i['field']} is missing!"; if ($i['type'] == 'additional-items') { $items = implode($syntax->separator(), $i['items']); $error = "additional items {$items}"; } } $syntax = $this->printSyntax($e->syntax()); $output = "<reset>Failed to parse <warn>'{$e->input()}'</warn> as <info>{$syntax}</info>"; if ('' != $error) $output .= " <error>{$error}</error>"; $previous = $e->previous(); if ($previous) { $output .= '<br>' . $this->printParseException($previous); } return $output; }
[ "public", "function", "printParseException", "(", "ParseException", "$", "e", ")", ":", "string", "{", "$", "syntax", "=", "$", "e", "->", "syntax", "(", ")", ";", "$", "error", "=", "''", ";", "if", "(", "$", "syntax", "instanceof", "ObjectSyntax", ")...
Converts a parse exception to a string. @param Tarsana\Syntax\Exceptions\ParseException $e @return string
[ "Converts", "a", "parse", "exception", "to", "a", "string", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Console/ExceptionPrinter.php#L33-L60
39,914
tarsana/command
src/Template/Twig/TwigTemplate.php
TwigTemplate.bind
public function bind (array $data) : TemplateInterface { $this->data = array_merge($this->data, $data); return $this; }
php
public function bind (array $data) : TemplateInterface { $this->data = array_merge($this->data, $data); return $this; }
[ "public", "function", "bind", "(", "array", "$", "data", ")", ":", "TemplateInterface", "{", "$", "this", "->", "data", "=", "array_merge", "(", "$", "this", "->", "data", ",", "$", "data", ")", ";", "return", "$", "this", ";", "}" ]
Binds data to the template. @param array $data @return self
[ "Binds", "data", "to", "the", "template", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Template/Twig/TwigTemplate.php#L31-L35
39,915
tarsana/command
src/Command.php
Command.name
public function name(string $value = null) { if (null === $value) { return $this->name; } $this->name = $value; return $this; }
php
public function name(string $value = null) { if (null === $value) { return $this->name; } $this->name = $value; return $this; }
[ "public", "function", "name", "(", "string", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "name", ";", "}", "$", "this", "->", "name", "=", "$", "value", ";", "return", "$", ...
name getter and setter. @param string @return mixed
[ "name", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L67-L74
39,916
tarsana/command
src/Command.php
Command.version
public function version(string $value = null) { if (null === $value) { return $this->version; } $this->version = $value; return $this; }
php
public function version(string $value = null) { if (null === $value) { return $this->version; } $this->version = $value; return $this; }
[ "public", "function", "version", "(", "string", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "version", ";", "}", "$", "this", "->", "version", "=", "$", "value", ";", "return",...
version getter and setter. @param string @return mixed
[ "version", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L82-L89
39,917
tarsana/command
src/Command.php
Command.description
public function description(string $value = null) { if (null === $value) { return $this->description; } $this->description = $value; return $this; }
php
public function description(string $value = null) { if (null === $value) { return $this->description; } $this->description = $value; return $this; }
[ "public", "function", "description", "(", "string", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "description", ";", "}", "$", "this", "->", "description", "=", "$", "value", ";",...
description getter and setter. @param string @return mixed
[ "description", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L97-L104
39,918
tarsana/command
src/Command.php
Command.descriptions
public function descriptions(array $value = null) { if (null === $value) { return $this->descriptions; } $this->descriptions = $value; return $this; }
php
public function descriptions(array $value = null) { if (null === $value) { return $this->descriptions; } $this->descriptions = $value; return $this; }
[ "public", "function", "descriptions", "(", "array", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "descriptions", ";", "}", "$", "this", "->", "descriptions", "=", "$", "value", ";...
descriptions getter and setter. @param string @return mixed
[ "descriptions", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L112-L119
39,919
tarsana/command
src/Command.php
Command.syntax
public function syntax(string $syntax = null) { if (null === $syntax) return $this->syntax; $this->syntax = S::syntax()->parse("{{$syntax}| }"); return $this; }
php
public function syntax(string $syntax = null) { if (null === $syntax) return $this->syntax; $this->syntax = S::syntax()->parse("{{$syntax}| }"); return $this; }
[ "public", "function", "syntax", "(", "string", "$", "syntax", "=", "null", ")", "{", "if", "(", "null", "===", "$", "syntax", ")", "return", "$", "this", "->", "syntax", ";", "$", "this", "->", "syntax", "=", "S", "::", "syntax", "(", ")", "->", ...
syntax getter and setter. @param string|null $syntax @return Syntax|self
[ "syntax", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L127-L134
39,920
tarsana/command
src/Command.php
Command.options
public function options(array $options = null) { if (null === $options) { return $this->options; } $this->options = []; foreach($options as $option) $this->options[$option] = false; return $this; }
php
public function options(array $options = null) { if (null === $options) { return $this->options; } $this->options = []; foreach($options as $option) $this->options[$option] = false; return $this; }
[ "public", "function", "options", "(", "array", "$", "options", "=", "null", ")", "{", "if", "(", "null", "===", "$", "options", ")", "{", "return", "$", "this", "->", "options", ";", "}", "$", "this", "->", "options", "=", "[", "]", ";", "foreach",...
options getter and setter. @param array @return mixed
[ "options", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L142-L153
39,921
tarsana/command
src/Command.php
Command.option
public function option(string $name) { if (!array_key_exists($name, $this->options)) throw new \InvalidArgumentException("Unknown option '{$name}'"); return $this->options[$name]; }
php
public function option(string $name) { if (!array_key_exists($name, $this->options)) throw new \InvalidArgumentException("Unknown option '{$name}'"); return $this->options[$name]; }
[ "public", "function", "option", "(", "string", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "options", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Unknown option '{$name}'\"", ")...
option getter. @param string @return mixed
[ "option", "getter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L161-L166
39,922
tarsana/command
src/Command.php
Command.args
public function args(\stdClass $value = null) { if (null === $value) { return $this->args; } $this->args = $value; return $this; }
php
public function args(\stdClass $value = null) { if (null === $value) { return $this->args; } $this->args = $value; return $this; }
[ "public", "function", "args", "(", "\\", "stdClass", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "args", ";", "}", "$", "this", "->", "args", "=", "$", "value", ";", "return"...
args getter and setter. @param stdClass @return mixed
[ "args", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L174-L181
39,923
tarsana/command
src/Command.php
Command.console
public function console(ConsoleInterface $value = null) { if (null === $value) { return $this->console; } $this->console = $value; foreach ($this->commands as $name => $command) { $command->console = $value; } return $this; }
php
public function console(ConsoleInterface $value = null) { if (null === $value) { return $this->console; } $this->console = $value; foreach ($this->commands as $name => $command) { $command->console = $value; } return $this; }
[ "public", "function", "console", "(", "ConsoleInterface", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "console", ";", "}", "$", "this", "->", "console", "=", "$", "value", ";", ...
console getter and setter. @param ConsoleInterface @return mixed
[ "console", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L189-L199
39,924
tarsana/command
src/Command.php
Command.fs
public function fs($value = null) { if (null === $value) { return $this->fs; } if (is_string($value)) $value = new Filesystem($value); $this->fs = $value; foreach ($this->commands as $name => $command) { $command->fs = $value; } return $this; }
php
public function fs($value = null) { if (null === $value) { return $this->fs; } if (is_string($value)) $value = new Filesystem($value); $this->fs = $value; foreach ($this->commands as $name => $command) { $command->fs = $value; } return $this; }
[ "public", "function", "fs", "(", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "fs", ";", "}", "if", "(", "is_string", "(", "$", "value", ")", ")", "$", "value", "=", "new", ...
fs getter and setter. @param Tarsana\IO\Filesystem|string @return mixed
[ "fs", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L207-L219
39,925
tarsana/command
src/Command.php
Command.templatesLoader
public function templatesLoader(TemplateLoaderInterface $value = null) { if (null === $value) { return $this->templatesLoader; } $this->templatesLoader = $value; foreach ($this->commands as $name => $command) { $command->templatesLoader = $value; } return $this; }
php
public function templatesLoader(TemplateLoaderInterface $value = null) { if (null === $value) { return $this->templatesLoader; } $this->templatesLoader = $value; foreach ($this->commands as $name => $command) { $command->templatesLoader = $value; } return $this; }
[ "public", "function", "templatesLoader", "(", "TemplateLoaderInterface", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "templatesLoader", ";", "}", "$", "this", "->", "templatesLoader", ...
templatesLoader getter and setter. @param Tarsana\Command\Interfaces\Template\TemplateLoaderInterface @return mixed
[ "templatesLoader", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L227-L237
39,926
tarsana/command
src/Command.php
Command.action
public function action(callable $value = null) { if (null === $value) { return $this->action; } $this->action = $value; return $this; }
php
public function action(callable $value = null) { if (null === $value) { return $this->action; } $this->action = $value; return $this; }
[ "public", "function", "action", "(", "callable", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "action", ";", "}", "$", "this", "->", "action", "=", "$", "value", ";", "return", ...
action getter and setter. @param callable @return mixed
[ "action", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L276-L283
39,927
tarsana/command
src/Command.php
Command.commands
public function commands(array $value = null) { if (null === $value) { return $this->commands; } $this->commands = []; foreach ($value as $name => $command) { $this->command($name, $command); } return $this; }
php
public function commands(array $value = null) { if (null === $value) { return $this->commands; } $this->commands = []; foreach ($value as $name => $command) { $this->command($name, $command); } return $this; }
[ "public", "function", "commands", "(", "array", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "commands", ";", "}", "$", "this", "->", "commands", "=", "[", "]", ";", "foreach", ...
commands getter and setter. @param array @return mixed
[ "commands", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Command.php#L291-L301
39,928
forceedge01/behat-sql-extension
src/Extension.php
Extension.load
public function load(ContainerBuilder $container, array $config) { if (isset($config['connection_details'])) { DEFINE('SQLDBENGINE', $config['connection_details']['engine']); DEFINE('SQLDBHOST', $config['connection_details']['host']); DEFINE('SQLDBSCHEMA', $config['connection_details']['schema']); DEFINE('SQLDBNAME', $config['connection_details']['dbname']); DEFINE('SQLDBUSERNAME', $config['connection_details']['username']); DEFINE('SQLDBPASSWORD', $config['connection_details']['password']); DEFINE('SQLDBPREFIX', $config['connection_details']['dbprefix']); session_start(); // Store any keywords set in behat.yml file if (isset($config['keywords']) and $config['keywords']) { foreach ($config['keywords'] as $keyword => $value) { $_SESSION['behat']['GenesisSqlExtension']['keywords'][$keyword] = $value; } } // Set 'notQuotableKeywords' for later use. $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords'] = []; if (isset($config['notQuotableKeywords'])) { $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords'] = $config['notQuotableKeywords']; } } }
php
public function load(ContainerBuilder $container, array $config) { if (isset($config['connection_details'])) { DEFINE('SQLDBENGINE', $config['connection_details']['engine']); DEFINE('SQLDBHOST', $config['connection_details']['host']); DEFINE('SQLDBSCHEMA', $config['connection_details']['schema']); DEFINE('SQLDBNAME', $config['connection_details']['dbname']); DEFINE('SQLDBUSERNAME', $config['connection_details']['username']); DEFINE('SQLDBPASSWORD', $config['connection_details']['password']); DEFINE('SQLDBPREFIX', $config['connection_details']['dbprefix']); session_start(); // Store any keywords set in behat.yml file if (isset($config['keywords']) and $config['keywords']) { foreach ($config['keywords'] as $keyword => $value) { $_SESSION['behat']['GenesisSqlExtension']['keywords'][$keyword] = $value; } } // Set 'notQuotableKeywords' for later use. $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords'] = []; if (isset($config['notQuotableKeywords'])) { $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords'] = $config['notQuotableKeywords']; } } }
[ "public", "function", "load", "(", "ContainerBuilder", "$", "container", ",", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'connection_details'", "]", ")", ")", "{", "DEFINE", "(", "'SQLDBENGINE'", ",", "$", "config", "...
Load and set the configuration options.
[ "Load", "and", "set", "the", "configuration", "options", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Extension.php#L29-L54
39,929
tarsana/command
src/SubCommand.php
SubCommand.parent
public function parent(Command $value = null) { if (null === $value) { return $this->parent; } $this->parent = $value; return $this; }
php
public function parent(Command $value = null) { if (null === $value) { return $this->parent; } $this->parent = $value; return $this; }
[ "public", "function", "parent", "(", "Command", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "this", "->", "parent", ";", "}", "$", "this", "->", "parent", "=", "$", "value", ";", "return", ...
parent getter and setter. @param Tarsana\Command\Command|null @return Tarsana\Command\Command
[ "parent", "getter", "and", "setter", "." ]
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/SubCommand.php#L38-L45
39,930
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.getConnection
public function getConnection() { if (! $this->connection) { list($dns, $username, $password) = $this->connectionString(); $this->setConnection(new \PDO($dns, $username, $password)); } return $this->connection; }
php
public function getConnection() { if (! $this->connection) { list($dns, $username, $password) = $this->connectionString(); $this->setConnection(new \PDO($dns, $username, $password)); } return $this->connection; }
[ "public", "function", "getConnection", "(", ")", "{", "if", "(", "!", "$", "this", "->", "connection", ")", "{", "list", "(", "$", "dns", ",", "$", "username", ",", "$", "password", ")", "=", "$", "this", "->", "connectionString", "(", ")", ";", "$...
Gets the connection for query execution.
[ "Gets", "the", "connection", "for", "query", "execution", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L48-L57
39,931
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.setDBParams
public function setDBParams(array $dbParams = array()) { if (defined('SQLDBENGINE')) { $this->params = [ 'DBSCHEMA' => SQLDBSCHEMA, 'DBNAME' => SQLDBNAME, 'DBPREFIX' => SQLDBPREFIX ]; // Allow params to be over-ridable. $this->params['DBHOST'] = (isset($dbParams['host']) ? $dbParams['host'] : SQLDBHOST); $this->params['DBUSER'] = (isset($dbParams['username']) ? $dbParams['username'] : SQLDBUSERNAME); $this->params['DBPASSWORD'] = (isset($dbParams['password']) ? $dbParams['password'] : SQLDBPASSWORD); $this->params['DBENGINE'] = (isset($dbParams['engine']) ? $dbParams['engine'] : SQLDBENGINE); } else { $params = getenv('BEHAT_ENV_PARAMS'); if (! $params) { throw new \Exception('"BEHAT_ENV_PARAMS" environment variable was not found.'); } $params = explode(';', $params); foreach ($params as $param) { list($key, $val) = explode(':', $param); $this->params[$key] = trim($val); } } return $this; }
php
public function setDBParams(array $dbParams = array()) { if (defined('SQLDBENGINE')) { $this->params = [ 'DBSCHEMA' => SQLDBSCHEMA, 'DBNAME' => SQLDBNAME, 'DBPREFIX' => SQLDBPREFIX ]; // Allow params to be over-ridable. $this->params['DBHOST'] = (isset($dbParams['host']) ? $dbParams['host'] : SQLDBHOST); $this->params['DBUSER'] = (isset($dbParams['username']) ? $dbParams['username'] : SQLDBUSERNAME); $this->params['DBPASSWORD'] = (isset($dbParams['password']) ? $dbParams['password'] : SQLDBPASSWORD); $this->params['DBENGINE'] = (isset($dbParams['engine']) ? $dbParams['engine'] : SQLDBENGINE); } else { $params = getenv('BEHAT_ENV_PARAMS'); if (! $params) { throw new \Exception('"BEHAT_ENV_PARAMS" environment variable was not found.'); } $params = explode(';', $params); foreach ($params as $param) { list($key, $val) = explode(':', $param); $this->params[$key] = trim($val); } } return $this; }
[ "public", "function", "setDBParams", "(", "array", "$", "dbParams", "=", "array", "(", ")", ")", "{", "if", "(", "defined", "(", "'SQLDBENGINE'", ")", ")", "{", "$", "this", "->", "params", "=", "[", "'DBSCHEMA'", "=>", "SQLDBSCHEMA", ",", "'DBNAME'", ...
Sets the database param from either the environment variable or params passed in by behat.yml, params have precedence over env variable.
[ "Sets", "the", "database", "param", "from", "either", "the", "environment", "variable", "or", "params", "passed", "in", "by", "behat", ".", "yml", "params", "have", "precedence", "over", "env", "variable", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L73-L103
39,932
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.connectionString
private function connectionString() { return [ sprintf( '%s:dbname=%s;host=%s', $this->params['DBENGINE'], $this->params['DBNAME'], $this->params['DBHOST'] ), $this->params['DBUSER'], $this->params['DBPASSWORD'] ]; }
php
private function connectionString() { return [ sprintf( '%s:dbname=%s;host=%s', $this->params['DBENGINE'], $this->params['DBNAME'], $this->params['DBHOST'] ), $this->params['DBUSER'], $this->params['DBPASSWORD'] ]; }
[ "private", "function", "connectionString", "(", ")", "{", "return", "[", "sprintf", "(", "'%s:dbname=%s;host=%s'", ",", "$", "this", "->", "params", "[", "'DBENGINE'", "]", ",", "$", "this", "->", "params", "[", "'DBNAME'", "]", ",", "$", "this", "->", "...
Creates the connection string for the pdo object.
[ "Creates", "the", "connection", "string", "for", "the", "pdo", "object", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L116-L128
39,933
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.requiredTableColumns
protected function requiredTableColumns($table) { // If the DBSCHEMA is not set, try using the database name if provided with the table. if (! $this->params['DBSCHEMA']) { preg_match('/(.*)\./', $table, $db); if (isset($db[1])) { $this->params['DBSCHEMA'] = $db[1]; } } // Parse out the table name. $table = preg_replace('/(.*\.)/', '', $table); $table = trim($table, '`'); // Statement to extract all required columns for a table. $sqlStatement = " SELECT column_name, data_type FROM information_schema.columns WHERE is_nullable = 'NO' AND table_name = '%s' AND table_schema = '%s';"; // Get not null columns $sql = sprintf( $sqlStatement, $table, $this->params['DBSCHEMA'] ); $statement = $this->execute($sql); $this->throwExceptionIfErrors($statement); $result = $statement->fetchAll(); if (! $result) { return []; } $cols = []; foreach ($result as $column) { $cols[$column['column_name']] = $column['data_type']; } // Dont populate primary key, let db handle that unset($cols['id']); return $cols; }
php
protected function requiredTableColumns($table) { // If the DBSCHEMA is not set, try using the database name if provided with the table. if (! $this->params['DBSCHEMA']) { preg_match('/(.*)\./', $table, $db); if (isset($db[1])) { $this->params['DBSCHEMA'] = $db[1]; } } // Parse out the table name. $table = preg_replace('/(.*\.)/', '', $table); $table = trim($table, '`'); // Statement to extract all required columns for a table. $sqlStatement = " SELECT column_name, data_type FROM information_schema.columns WHERE is_nullable = 'NO' AND table_name = '%s' AND table_schema = '%s';"; // Get not null columns $sql = sprintf( $sqlStatement, $table, $this->params['DBSCHEMA'] ); $statement = $this->execute($sql); $this->throwExceptionIfErrors($statement); $result = $statement->fetchAll(); if (! $result) { return []; } $cols = []; foreach ($result as $column) { $cols[$column['column_name']] = $column['data_type']; } // Dont populate primary key, let db handle that unset($cols['id']); return $cols; }
[ "protected", "function", "requiredTableColumns", "(", "$", "table", ")", "{", "// If the DBSCHEMA is not set, try using the database name if provided with the table.", "if", "(", "!", "$", "this", "->", "params", "[", "'DBSCHEMA'", "]", ")", "{", "preg_match", "(", "'/(...
Gets a column list for a table with their type.
[ "Gets", "a", "column", "list", "for", "a", "table", "with", "their", "type", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L133-L185
39,934
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.sampleData
public function sampleData($type) { switch (strtolower($type)) { case 'boolean': return 'false'; case 'integer': case 'double': case 'int': return rand(); case 'tinyint': return rand(0, 9); case 'string': case 'text': case 'varchar': case 'character varying': case 'tinytext': case 'longtext': return $this->quoteOrNot(sprintf("behat-test-string-%s", time())); case 'char': return "'f'"; case 'timestamp': case 'timestamp with time zone': return 'NOW()'; case 'null': return null; default: return $this->quoteOrNot(sprintf("behat-test-string-%s", time())); } }
php
public function sampleData($type) { switch (strtolower($type)) { case 'boolean': return 'false'; case 'integer': case 'double': case 'int': return rand(); case 'tinyint': return rand(0, 9); case 'string': case 'text': case 'varchar': case 'character varying': case 'tinytext': case 'longtext': return $this->quoteOrNot(sprintf("behat-test-string-%s", time())); case 'char': return "'f'"; case 'timestamp': case 'timestamp with time zone': return 'NOW()'; case 'null': return null; default: return $this->quoteOrNot(sprintf("behat-test-string-%s", time())); } }
[ "public", "function", "sampleData", "(", "$", "type", ")", "{", "switch", "(", "strtolower", "(", "$", "type", ")", ")", "{", "case", "'boolean'", ":", "return", "'false'", ";", "case", "'integer'", ":", "case", "'double'", ":", "case", "'int'", ":", "...
returns sample data for a data type.
[ "returns", "sample", "data", "for", "a", "data", "type", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L190-L218
39,935
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.constructSQLClause
public function constructSQLClause($glue, array $columns) { $whereClause = []; foreach ($columns as $column => $value) { $newValue = ltrim($value, '!'); $quotedValue = $this->quoteOrNot($newValue); $comparator = '%s='; $notOperator = ''; // Check if the supplied value is null, if so change the format. if (strtolower($newValue) == 'null') { $comparator = 'is%s'; } // Check if a not is applied to the value. if ($newValue !== $value) { if (strtolower($newValue) == 'null') { $notOperator = ' not'; } else { $notOperator = '!'; } } // Check if the value is surrounded by wildcards. If so, we'll want to use a LIKE comparator. if (preg_match('/^%.+%$/', $value)) { $comparator = 'LIKE'; } // Make up the sql. $comparator = sprintf($comparator, $notOperator); $whereClause[] = sprintf('%s %s %s', $column, $comparator, $quotedValue); } return implode($glue, $whereClause); }
php
public function constructSQLClause($glue, array $columns) { $whereClause = []; foreach ($columns as $column => $value) { $newValue = ltrim($value, '!'); $quotedValue = $this->quoteOrNot($newValue); $comparator = '%s='; $notOperator = ''; // Check if the supplied value is null, if so change the format. if (strtolower($newValue) == 'null') { $comparator = 'is%s'; } // Check if a not is applied to the value. if ($newValue !== $value) { if (strtolower($newValue) == 'null') { $notOperator = ' not'; } else { $notOperator = '!'; } } // Check if the value is surrounded by wildcards. If so, we'll want to use a LIKE comparator. if (preg_match('/^%.+%$/', $value)) { $comparator = 'LIKE'; } // Make up the sql. $comparator = sprintf($comparator, $notOperator); $whereClause[] = sprintf('%s %s %s', $column, $comparator, $quotedValue); } return implode($glue, $whereClause); }
[ "public", "function", "constructSQLClause", "(", "$", "glue", ",", "array", "$", "columns", ")", "{", "$", "whereClause", "=", "[", "]", ";", "foreach", "(", "$", "columns", "as", "$", "column", "=>", "$", "value", ")", "{", "$", "newValue", "=", "lt...
Constructs a clause based on the glue, to be used for where and update clause.
[ "Constructs", "a", "clause", "based", "on", "the", "glue", "to", "be", "used", "for", "where", "and", "update", "clause", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L223-L259
39,936
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.getTableColumns
protected function getTableColumns($entity) { $columnClause = []; // Get all columns for insertion $allColumns = array_merge($this->requiredTableColumns($entity), $this->columns); // Set values for columns foreach ($allColumns as $col => $type) { $columnClause[$col] = isset($this->columns[$col]) ? $this->quoteOrNot($this->columns[$col]) : $this->sampleData($type); } $columnNames = implode(', ', array_keys($columnClause)); $columnValues = implode(', ', $columnClause); return [$columnNames, $columnValues]; }
php
protected function getTableColumns($entity) { $columnClause = []; // Get all columns for insertion $allColumns = array_merge($this->requiredTableColumns($entity), $this->columns); // Set values for columns foreach ($allColumns as $col => $type) { $columnClause[$col] = isset($this->columns[$col]) ? $this->quoteOrNot($this->columns[$col]) : $this->sampleData($type); } $columnNames = implode(', ', array_keys($columnClause)); $columnValues = implode(', ', $columnClause); return [$columnNames, $columnValues]; }
[ "protected", "function", "getTableColumns", "(", "$", "entity", ")", "{", "$", "columnClause", "=", "[", "]", ";", "// Get all columns for insertion", "$", "allColumns", "=", "array_merge", "(", "$", "this", "->", "requiredTableColumns", "(", "$", "entity", ")",...
Gets table columns and its values, returns array.
[ "Gets", "table", "columns", "and", "its", "values", "returns", "array", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L264-L282
39,937
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.filterAndConvertToArray
public function filterAndConvertToArray($columns) { $this->columns = []; $columns = explode(',', $columns); foreach ($columns as $column) { try { list($col, $val) = explode(':', $column, self::EXPLODE_MAX_LIMIT); } catch (\Exception $e) { throw new \Exception('Unable to explode columns based on ":" separator'); } $val = $this->checkForKeyword(trim($val)); $this->columns[trim($col)] = $val; } return $this; }
php
public function filterAndConvertToArray($columns) { $this->columns = []; $columns = explode(',', $columns); foreach ($columns as $column) { try { list($col, $val) = explode(':', $column, self::EXPLODE_MAX_LIMIT); } catch (\Exception $e) { throw new \Exception('Unable to explode columns based on ":" separator'); } $val = $this->checkForKeyword(trim($val)); $this->columns[trim($col)] = $val; } return $this; }
[ "public", "function", "filterAndConvertToArray", "(", "$", "columns", ")", "{", "$", "this", "->", "columns", "=", "[", "]", ";", "$", "columns", "=", "explode", "(", "','", ",", "$", "columns", ")", ";", "foreach", "(", "$", "columns", "as", "$", "c...
Converts the incoming string param from steps to array.
[ "Converts", "the", "incoming", "string", "param", "from", "steps", "to", "array", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L287-L304
39,938
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.setKeyword
public function setKeyword($key, $value) { $this->debugLog(sprintf( 'Saving keyword "%s" with value "%s"', $key, $value )); $_SESSION['behat']['GenesisSqlExtension']['keywords'][$key] = $value; return $this; }
php
public function setKeyword($key, $value) { $this->debugLog(sprintf( 'Saving keyword "%s" with value "%s"', $key, $value )); $_SESSION['behat']['GenesisSqlExtension']['keywords'][$key] = $value; return $this; }
[ "public", "function", "setKeyword", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "debugLog", "(", "sprintf", "(", "'Saving keyword \"%s\" with value \"%s\"'", ",", "$", "key", ",", "$", "value", ")", ")", ";", "$", "_SESSION", "[", "'...
Sets a behat keyword.
[ "Sets", "a", "behat", "keyword", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L309-L320
39,939
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.getKeyword
public function getKeyword($key) { $this->debugLog(sprintf( 'Retrieving keyword "%s"', $key )); if (! isset($_SESSION['behat']['GenesisSqlExtension']['keywords'][$key])) { throw new \Exception(sprintf( 'Key "%s" not found in behat store, all keys available: %s', $key, print_r($_SESSION['behat']['GenesisSqlExtension']['keywords'], true) )); } $value = $_SESSION['behat']['GenesisSqlExtension']['keywords'][$key]; $this->debugLog(sprintf( 'Retrieved keyword "%s" with value "%s"', $key, $value )); return $value; }
php
public function getKeyword($key) { $this->debugLog(sprintf( 'Retrieving keyword "%s"', $key )); if (! isset($_SESSION['behat']['GenesisSqlExtension']['keywords'][$key])) { throw new \Exception(sprintf( 'Key "%s" not found in behat store, all keys available: %s', $key, print_r($_SESSION['behat']['GenesisSqlExtension']['keywords'], true) )); } $value = $_SESSION['behat']['GenesisSqlExtension']['keywords'][$key]; $this->debugLog(sprintf( 'Retrieved keyword "%s" with value "%s"', $key, $value )); return $value; }
[ "public", "function", "getKeyword", "(", "$", "key", ")", "{", "$", "this", "->", "debugLog", "(", "sprintf", "(", "'Retrieving keyword \"%s\"'", ",", "$", "key", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "'behat'", "]", "[", ...
Fetches a specific keyword from the behat keywords store.
[ "Fetches", "a", "specific", "keyword", "from", "the", "behat", "keywords", "store", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L325-L349
39,940
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.checkForKeyword
private function checkForKeyword($value) { if (! isset($_SESSION['behat']['GenesisSqlExtension']['keywords'])) { return $value; } foreach ($_SESSION['behat']['GenesisSqlExtension']['keywords'] as $keyword => $val) { $key = sprintf('{%s}', $keyword); if ($value == $key) { $value = str_replace($key, $val, $value); } } return $value; }
php
private function checkForKeyword($value) { if (! isset($_SESSION['behat']['GenesisSqlExtension']['keywords'])) { return $value; } foreach ($_SESSION['behat']['GenesisSqlExtension']['keywords'] as $keyword => $val) { $key = sprintf('{%s}', $keyword); if ($value == $key) { $value = str_replace($key, $val, $value); } } return $value; }
[ "private", "function", "checkForKeyword", "(", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "'behat'", "]", "[", "'GenesisSqlExtension'", "]", "[", "'keywords'", "]", ")", ")", "{", "return", "$", "value", ";", "}", "fore...
Checks the value for possible keywords set in behat.yml file.
[ "Checks", "the", "value", "for", "possible", "keywords", "set", "in", "behat", ".", "yml", "file", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L354-L369
39,941
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.debugLog
public function debugLog($log) { if (defined('DEBUG_MODE') and DEBUG_MODE == 1) { $log = 'DEBUG >>> ' . $log; echo $log . PHP_EOL . PHP_EOL; } return $this; }
php
public function debugLog($log) { if (defined('DEBUG_MODE') and DEBUG_MODE == 1) { $log = 'DEBUG >>> ' . $log; echo $log . PHP_EOL . PHP_EOL; } return $this; }
[ "public", "function", "debugLog", "(", "$", "log", ")", "{", "if", "(", "defined", "(", "'DEBUG_MODE'", ")", "and", "DEBUG_MODE", "==", "1", ")", "{", "$", "log", "=", "'DEBUG >>> '", ".", "$", "log", ";", "echo", "$", "log", ".", "PHP_EOL", ".", "...
Prints out messages when in debug mode.
[ "Prints", "out", "messages", "when", "in", "debug", "mode", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L374-L382
39,942
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.execute
protected function execute($sql) { $this->lastQuery = $sql; $this->debugLog(sprintf('Executing SQL: %s', $sql)); $this->sqlStatement = $this->getConnection()->prepare($sql, []); $this->sqlStatement->execute(); $this->lastId = $this->connection->lastInsertId(sprintf('%s_id_seq', $this->getEntity())); // If their is an id, save it! if ($this->lastId) { $this->handleLastId($this->getEntity(), $this->lastId); } return $this->sqlStatement; }
php
protected function execute($sql) { $this->lastQuery = $sql; $this->debugLog(sprintf('Executing SQL: %s', $sql)); $this->sqlStatement = $this->getConnection()->prepare($sql, []); $this->sqlStatement->execute(); $this->lastId = $this->connection->lastInsertId(sprintf('%s_id_seq', $this->getEntity())); // If their is an id, save it! if ($this->lastId) { $this->handleLastId($this->getEntity(), $this->lastId); } return $this->sqlStatement; }
[ "protected", "function", "execute", "(", "$", "sql", ")", "{", "$", "this", "->", "lastQuery", "=", "$", "sql", ";", "$", "this", "->", "debugLog", "(", "sprintf", "(", "'Executing SQL: %s'", ",", "$", "sql", ")", ")", ";", "$", "this", "->", "sqlSta...
Executes sql command.
[ "Executes", "sql", "command", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L387-L403
39,943
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.saveLastId
protected function saveLastId($entity, $id) { $this->debugLog(sprintf('Last ID fetched: %d', $id)); $_SESSION['behat']['GenesisSqlExtension']['last_id'][$entity][] = $id; }
php
protected function saveLastId($entity, $id) { $this->debugLog(sprintf('Last ID fetched: %d', $id)); $_SESSION['behat']['GenesisSqlExtension']['last_id'][$entity][] = $id; }
[ "protected", "function", "saveLastId", "(", "$", "entity", ",", "$", "id", ")", "{", "$", "this", "->", "debugLog", "(", "sprintf", "(", "'Last ID fetched: %d'", ",", "$", "id", ")", ")", ";", "$", "_SESSION", "[", "'behat'", "]", "[", "'GenesisSqlExtens...
Save the last insert id in the session for later retrieval.
[ "Save", "the", "last", "insert", "id", "in", "the", "session", "for", "later", "retrieval", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L408-L413
39,944
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.throwErrorIfNoRowsAffected
public function throwErrorIfNoRowsAffected($sqlStatement, $ignoreDuplicate = false) { if (! $this->hasFetchedRows($sqlStatement)) { $error = print_r($sqlStatement->errorInfo(), true); if ($ignoreDuplicate and preg_match('/duplicate/i', $error)) { return $sqlStatement->errorInfo(); } throw new \Exception( sprintf( 'No rows were effected!%sSQL: "%s",%sError: %s', PHP_EOL, $sqlStatement->queryString, PHP_EOL, $error ) ); } return false; }
php
public function throwErrorIfNoRowsAffected($sqlStatement, $ignoreDuplicate = false) { if (! $this->hasFetchedRows($sqlStatement)) { $error = print_r($sqlStatement->errorInfo(), true); if ($ignoreDuplicate and preg_match('/duplicate/i', $error)) { return $sqlStatement->errorInfo(); } throw new \Exception( sprintf( 'No rows were effected!%sSQL: "%s",%sError: %s', PHP_EOL, $sqlStatement->queryString, PHP_EOL, $error ) ); } return false; }
[ "public", "function", "throwErrorIfNoRowsAffected", "(", "$", "sqlStatement", ",", "$", "ignoreDuplicate", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "hasFetchedRows", "(", "$", "sqlStatement", ")", ")", "{", "$", "error", "=", "print_r", "...
Check for any mysql errors.
[ "Check", "for", "any", "mysql", "errors", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L430-L451
39,945
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.throwExceptionIfErrors
public function throwExceptionIfErrors($sqlStatement) { if ((int) $sqlStatement->errorCode()) { throw new \Exception( print_r($sqlStatement->errorInfo(), true) ); } return false; }
php
public function throwExceptionIfErrors($sqlStatement) { if ((int) $sqlStatement->errorCode()) { throw new \Exception( print_r($sqlStatement->errorInfo(), true) ); } return false; }
[ "public", "function", "throwExceptionIfErrors", "(", "$", "sqlStatement", ")", "{", "if", "(", "(", "int", ")", "$", "sqlStatement", "->", "errorCode", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "print_r", "(", "$", "sqlStatement", "->", ...
Errors found then throw exception.
[ "Errors", "found", "then", "throw", "exception", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L456-L465
39,946
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.quoteOrNot
public function quoteOrNot($val) { return ((is_string($val) || is_numeric($val)) and !$this->isNotQuotable($val)) ? sprintf("'%s'", $val) : $val; }
php
public function quoteOrNot($val) { return ((is_string($val) || is_numeric($val)) and !$this->isNotQuotable($val)) ? sprintf("'%s'", $val) : $val; }
[ "public", "function", "quoteOrNot", "(", "$", "val", ")", "{", "return", "(", "(", "is_string", "(", "$", "val", ")", "||", "is_numeric", "(", "$", "val", ")", ")", "and", "!", "$", "this", "->", "isNotQuotable", "(", "$", "val", ")", ")", "?", "...
Quotes value if needed for sql.
[ "Quotes", "value", "if", "needed", "for", "sql", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L482-L485
39,947
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.getKeyFromDuplicateError
public function getKeyFromDuplicateError($error) { if (! isset($error[2])) { return false; } // Extract duplicate key and run update using it $matches = []; if (preg_match('/.*DETAIL:\s*Key (.*)=.*/sim', $error[2], $matches)) { // Index 1 holds the name of the key matched $key = trim($matches[1], '()'); echo sprintf('Duplicate record, running update using "%s"...%s', $key, PHP_EOL); return $key; } return false; }
php
public function getKeyFromDuplicateError($error) { if (! isset($error[2])) { return false; } // Extract duplicate key and run update using it $matches = []; if (preg_match('/.*DETAIL:\s*Key (.*)=.*/sim', $error[2], $matches)) { // Index 1 holds the name of the key matched $key = trim($matches[1], '()'); echo sprintf('Duplicate record, running update using "%s"...%s', $key, PHP_EOL); return $key; } return false; }
[ "public", "function", "getKeyFromDuplicateError", "(", "$", "error", ")", "{", "if", "(", "!", "isset", "(", "$", "error", "[", "2", "]", ")", ")", "{", "return", "false", ";", "}", "// Extract duplicate key and run update using it", "$", "matches", "=", "["...
Get the duplicate key from the error message.
[ "Get", "the", "duplicate", "key", "from", "the", "error", "message", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L490-L508
39,948
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.setLastIdWhere
protected function setLastIdWhere($entity, $criteria) { $sql = sprintf('SELECT id FROM %s WHERE %s', $entity, $criteria); $statement = $this->execute($sql); $this->throwErrorIfNoRowsAffected($statement); $result = $statement->fetchAll(); if (! isset($result[0]['id'])) { throw new \Exception('Id not found in table.'); } $this->debugLog(sprintf('Last ID fetched: %d', $result[0]['id'])); $this->handleLastId($entity, $result[0]['id']); return $statement; }
php
protected function setLastIdWhere($entity, $criteria) { $sql = sprintf('SELECT id FROM %s WHERE %s', $entity, $criteria); $statement = $this->execute($sql); $this->throwErrorIfNoRowsAffected($statement); $result = $statement->fetchAll(); if (! isset($result[0]['id'])) { throw new \Exception('Id not found in table.'); } $this->debugLog(sprintf('Last ID fetched: %d', $result[0]['id'])); $this->handleLastId($entity, $result[0]['id']); return $statement; }
[ "protected", "function", "setLastIdWhere", "(", "$", "entity", ",", "$", "criteria", ")", "{", "$", "sql", "=", "sprintf", "(", "'SELECT id FROM %s WHERE %s'", ",", "$", "entity", ",", "$", "criteria", ")", ";", "$", "statement", "=", "$", "this", "->", ...
Sets the last id by executing a select on the id column.
[ "Sets", "the", "last", "id", "by", "executing", "a", "select", "on", "the", "id", "column", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L513-L528
39,949
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.handleLastId
protected function handleLastId($entity, $id) { $entity = $this->getUserInputEntity($entity); $this->lastId = $id; $entity = $this->makeSQLUnsafe($entity); $this->saveLastId($entity, $this->lastId); $this->setKeyword($entity . '_id', $this->lastId); }
php
protected function handleLastId($entity, $id) { $entity = $this->getUserInputEntity($entity); $this->lastId = $id; $entity = $this->makeSQLUnsafe($entity); $this->saveLastId($entity, $this->lastId); $this->setKeyword($entity . '_id', $this->lastId); }
[ "protected", "function", "handleLastId", "(", "$", "entity", ",", "$", "id", ")", "{", "$", "entity", "=", "$", "this", "->", "getUserInputEntity", "(", "$", "entity", ")", ";", "$", "this", "->", "lastId", "=", "$", "id", ";", "$", "entity", "=", ...
Do what needs to be done with the last insert id.
[ "Do", "what", "needs", "to", "be", "done", "with", "the", "last", "insert", "id", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L533-L540
39,950
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.getUserInputEntity
private function getUserInputEntity($entity) { // Get rid of any special chars introduced. $entity = $this->makeSQLUnsafe($entity); // Only replace first occurrence. return preg_replace('/' . $this->getParams()['DBPREFIX'] . '/', '', $entity, 1); }
php
private function getUserInputEntity($entity) { // Get rid of any special chars introduced. $entity = $this->makeSQLUnsafe($entity); // Only replace first occurrence. return preg_replace('/' . $this->getParams()['DBPREFIX'] . '/', '', $entity, 1); }
[ "private", "function", "getUserInputEntity", "(", "$", "entity", ")", "{", "// Get rid of any special chars introduced.", "$", "entity", "=", "$", "this", "->", "makeSQLUnsafe", "(", "$", "entity", ")", ";", "// Only replace first occurrence.", "return", "preg_replace",...
Get the entity the way the user had inputted it.
[ "Get", "the", "entity", "the", "way", "the", "user", "had", "inputted", "it", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L545-L552
39,951
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.isNotQuotable
private function isNotQuotable($val) { $keywords = [ 'true', 'false', 'null', 'NOW\(\)', 'COUNT\(.*\)', 'MAX\(.*\)', '\d+' ]; $keywords = array_merge($keywords, $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords']); // Check if the val is a keyword foreach ($keywords as $keyword) { if (preg_match(sprintf('/^%s$/is', $keyword), $val)) { return true; } } return false; }
php
private function isNotQuotable($val) { $keywords = [ 'true', 'false', 'null', 'NOW\(\)', 'COUNT\(.*\)', 'MAX\(.*\)', '\d+' ]; $keywords = array_merge($keywords, $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords']); // Check if the val is a keyword foreach ($keywords as $keyword) { if (preg_match(sprintf('/^%s$/is', $keyword), $val)) { return true; } } return false; }
[ "private", "function", "isNotQuotable", "(", "$", "val", ")", "{", "$", "keywords", "=", "[", "'true'", ",", "'false'", ",", "'null'", ",", "'NOW\\(\\)'", ",", "'COUNT\\(.*\\)'", ",", "'MAX\\(.*\\)'", ",", "'\\d+'", "]", ";", "$", "keywords", "=", "array_m...
Checks if the value isn't a keyword.
[ "Checks", "if", "the", "value", "isn", "t", "a", "keyword", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L557-L579
39,952
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.makeSQLSafe
public function makeSQLSafe($string) { $string = str_replace('', '', $string); $chunks = explode('.', $string); return implode('.', $chunks); }
php
public function makeSQLSafe($string) { $string = str_replace('', '', $string); $chunks = explode('.', $string); return implode('.', $chunks); }
[ "public", "function", "makeSQLSafe", "(", "$", "string", ")", "{", "$", "string", "=", "str_replace", "(", "''", ",", "''", ",", "$", "string", ")", ";", "$", "chunks", "=", "explode", "(", "'.'", ",", "$", "string", ")", ";", "return", "implode", ...
Make a string SQL safe.
[ "Make", "a", "string", "SQL", "safe", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L657-L664
39,953
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.setEntity
public function setEntity($entity) { $this->debugLog(sprintf('ENTITY: %s', $entity)); $expectedEntity = $this->makeSQLSafe($this->getParams()['DBPREFIX'] . $entity); $this->debugLog(sprintf('SET ENTITY: %s', $expectedEntity)); // Concatinate the entity with the sqldbprefix value only if not already done. if ($expectedEntity !== $this->entity) { $this->entity = $expectedEntity; } return $this; }
php
public function setEntity($entity) { $this->debugLog(sprintf('ENTITY: %s', $entity)); $expectedEntity = $this->makeSQLSafe($this->getParams()['DBPREFIX'] . $entity); $this->debugLog(sprintf('SET ENTITY: %s', $expectedEntity)); // Concatinate the entity with the sqldbprefix value only if not already done. if ($expectedEntity !== $this->entity) { $this->entity = $expectedEntity; } return $this; }
[ "public", "function", "setEntity", "(", "$", "entity", ")", "{", "$", "this", "->", "debugLog", "(", "sprintf", "(", "'ENTITY: %s'", ",", "$", "entity", ")", ")", ";", "$", "expectedEntity", "=", "$", "this", "->", "makeSQLSafe", "(", "$", "this", "->"...
Set the entity for further processing.
[ "Set", "the", "entity", "for", "further", "processing", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L677-L691
39,954
tarsana/command
src/Template/TemplateLoader.php
TemplateLoader.load
public function load (string $name) : TemplateInterface { $supportedExtensions = array_keys(self::$providers); $fsPathLength = strlen($this->fs->path()); $files = $this->fs ->find("{$name}.*") ->files() ->asArray(); $found = []; foreach ($files as $file) { $ext = $file->extension(); if (!in_array($ext, $supportedExtensions)) continue; $found[] = [ 'name' => substr($file->path(), $fsPathLength), 'extension' => $ext ]; } if (count($found) == 0) { throw new \InvalidArgumentException("Unable to find template with name '{$name}' on '{$this->fs->path()}'"); } if (count($found) > 1) { throw new \InvalidArgumentException("Mutiple templates found for the name '{$name}' on '{$this->fs->path()}'"); } return $this->loaders[$found[0]['extension']]->load($found[0]['name']); }
php
public function load (string $name) : TemplateInterface { $supportedExtensions = array_keys(self::$providers); $fsPathLength = strlen($this->fs->path()); $files = $this->fs ->find("{$name}.*") ->files() ->asArray(); $found = []; foreach ($files as $file) { $ext = $file->extension(); if (!in_array($ext, $supportedExtensions)) continue; $found[] = [ 'name' => substr($file->path(), $fsPathLength), 'extension' => $ext ]; } if (count($found) == 0) { throw new \InvalidArgumentException("Unable to find template with name '{$name}' on '{$this->fs->path()}'"); } if (count($found) > 1) { throw new \InvalidArgumentException("Mutiple templates found for the name '{$name}' on '{$this->fs->path()}'"); } return $this->loaders[$found[0]['extension']]->load($found[0]['name']); }
[ "public", "function", "load", "(", "string", "$", "name", ")", ":", "TemplateInterface", "{", "$", "supportedExtensions", "=", "array_keys", "(", "self", "::", "$", "providers", ")", ";", "$", "fsPathLength", "=", "strlen", "(", "$", "this", "->", "fs", ...
Load a template by name. The name is the relative path of the template file from the templates folder The name is given without extension; Exceptions are thrown if no file with supported extension is found or if many exists. @param string $name @return Tarsana\Command\Interfaces\TemplateInterface @throws Tarsana\Command\Exceptions\TemplateNotFound @throws Tarsana\Command\Exceptions\TemplateNameConflict
[ "Load", "a", "template", "by", "name", ".", "The", "name", "is", "the", "relative", "path", "of", "the", "template", "file", "from", "the", "templates", "folder", "The", "name", "is", "given", "without", "extension", ";", "Exceptions", "are", "thrown", "if...
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Template/TemplateLoader.php#L77-L108
39,955
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.delete
public function delete(string $path, $callback, ...$args): FrameworkHandler { return $this->route('delete', $path, $callback, ...$args); }
php
public function delete(string $path, $callback, ...$args): FrameworkHandler { return $this->route('delete', $path, $callback, ...$args); }
[ "public", "function", "delete", "(", "string", "$", "path", ",", "$", "callback", ",", "...", "$", "args", ")", ":", "FrameworkHandler", "{", "return", "$", "this", "->", "route", "(", "'delete'", ",", "$", "path", ",", "$", "callback", ",", "...", "...
Adds routing middleware for DELETE method @param *string $path The route path @param *callable|string $callback The middleware handler @param callable|string ...$args Arguments for flow @return FrameworkHandler
[ "Adds", "routing", "middleware", "for", "DELETE", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L101-L104
39,956
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.get
public function get(string $path, $callback, ...$args): FrameworkHandler { return $this->route('get', $path, $callback, ...$args); }
php
public function get(string $path, $callback, ...$args): FrameworkHandler { return $this->route('get', $path, $callback, ...$args); }
[ "public", "function", "get", "(", "string", "$", "path", ",", "$", "callback", ",", "...", "$", "args", ")", ":", "FrameworkHandler", "{", "return", "$", "this", "->", "route", "(", "'get'", ",", "$", "path", ",", "$", "callback", ",", "...", "$", ...
Adds routing middleware for GET method @param *string $path The route path @param *callable|string $callback The middleware handler @param callable|string ...$args Arguments for flow @return FrameworkHandler
[ "Adds", "routing", "middleware", "for", "GET", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L115-L118
39,957
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.getPackages
public function getPackages(string $name = null): array { if (isset($this->packages[$name])) { return $this->packages[$name]; } return $this->packages; }
php
public function getPackages(string $name = null): array { if (isset($this->packages[$name])) { return $this->packages[$name]; } return $this->packages; }
[ "public", "function", "getPackages", "(", "string", "$", "name", "=", "null", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "this", "->", "packages", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "packages", "[", "$", ...
Returns all the packages @param string|null $name Name of package @return array
[ "Returns", "all", "the", "packages" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L127-L134
39,958
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.export
public function export(string $event, bool $map = false) { $handler = $this; $next = function (...$args) use ($handler, $event, $map) { $request = $handler->getRequest(); $response = $handler->getResponse(); $meta = $handler //do this directly from the handler ->getEventHandler() //trigger ->trigger($event, $request, $response, ...$args) //if our events returns false //lets tell the interface the same ->getMeta(); //no map ? let's try our best //if we have meta if ($meta === EventHandler::STATUS_OK) { //return the response return $response->getContent(true); } //otherwise return false return false; }; if (!$map) { return $next; } $request = $handler->getRequest(); $response = $handler->getResponse(); return [$request, $response, $next]; }
php
public function export(string $event, bool $map = false) { $handler = $this; $next = function (...$args) use ($handler, $event, $map) { $request = $handler->getRequest(); $response = $handler->getResponse(); $meta = $handler //do this directly from the handler ->getEventHandler() //trigger ->trigger($event, $request, $response, ...$args) //if our events returns false //lets tell the interface the same ->getMeta(); //no map ? let's try our best //if we have meta if ($meta === EventHandler::STATUS_OK) { //return the response return $response->getContent(true); } //otherwise return false return false; }; if (!$map) { return $next; } $request = $handler->getRequest(); $response = $handler->getResponse(); return [$request, $response, $next]; }
[ "public", "function", "export", "(", "string", "$", "event", ",", "bool", "$", "map", "=", "false", ")", "{", "$", "handler", "=", "$", "this", ";", "$", "next", "=", "function", "(", "...", "$", "args", ")", "use", "(", "$", "handler", ",", "$",...
Exports a flow to another external interface @param *string $event @param bool $map @return Closure|array
[ "Exports", "a", "flow", "to", "another", "external", "interface" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L154-L190
39,959
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.import
public function import(array $flows): FrameworkHandler { foreach ($flows as $flow) { //it's gotta be an array if (!is_array($flow)) { continue; } $this->flow(...$flow); } return $this; }
php
public function import(array $flows): FrameworkHandler { foreach ($flows as $flow) { //it's gotta be an array if (!is_array($flow)) { continue; } $this->flow(...$flow); } return $this; }
[ "public", "function", "import", "(", "array", "$", "flows", ")", ":", "FrameworkHandler", "{", "foreach", "(", "$", "flows", "as", "$", "flow", ")", "{", "//it's gotta be an array", "if", "(", "!", "is_array", "(", "$", "flow", ")", ")", "{", "continue",...
Imports a set of flows @param *array $flows @return FrameworkHandler
[ "Imports", "a", "set", "of", "flows" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L199-L211
39,960
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.makePayload
public function makePayload($load = true) { $request = Request::i(); $response = Response::i(); if ($load) { $request->load(); $response->load(); $stage = $this->getRequest()->getStage(); if (is_array($stage)) { $request->setSoftStage($stage); } } return [ 'request' => $request, 'response' => $response ]; }
php
public function makePayload($load = true) { $request = Request::i(); $response = Response::i(); if ($load) { $request->load(); $response->load(); $stage = $this->getRequest()->getStage(); if (is_array($stage)) { $request->setSoftStage($stage); } } return [ 'request' => $request, 'response' => $response ]; }
[ "public", "function", "makePayload", "(", "$", "load", "=", "true", ")", "{", "$", "request", "=", "Request", "::", "i", "(", ")", ";", "$", "response", "=", "Response", "::", "i", "(", ")", ";", "if", "(", "$", "load", ")", "{", "$", "request", ...
Creates a new Request and Response @param bool $load whether to load the RnRs @return array
[ "Creates", "a", "new", "Request", "and", "Response" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L220-L240
39,961
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.method
public function method($event, $request = [], Response $response = null) { if (is_array($request)) { $request = Request::i()->load()->setStage($request); } if (!($request instanceof Request)) { $request = Request::i()->load(); } if (is_null($response)) { $response = Response::i()->load(); } $this->trigger($event, $request, $response); if ($response->isError()) { return false; } return $response->getResults(); }
php
public function method($event, $request = [], Response $response = null) { if (is_array($request)) { $request = Request::i()->load()->setStage($request); } if (!($request instanceof Request)) { $request = Request::i()->load(); } if (is_null($response)) { $response = Response::i()->load(); } $this->trigger($event, $request, $response); if ($response->isError()) { return false; } return $response->getResults(); }
[ "public", "function", "method", "(", "$", "event", ",", "$", "request", "=", "[", "]", ",", "Response", "$", "response", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "request", ")", ")", "{", "$", "request", "=", "Request", "::", "i", ...
Runs an event like a method @param bool $load whether to load the RnRs @return array
[ "Runs", "an", "event", "like", "a", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L249-L270
39,962
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.post
public function post(string $path, $callback, ...$args): FrameworkHandler { return $this->route('post', $path, $callback, ...$args); }
php
public function post(string $path, $callback, ...$args): FrameworkHandler { return $this->route('post', $path, $callback, ...$args); }
[ "public", "function", "post", "(", "string", "$", "path", ",", "$", "callback", ",", "...", "$", "args", ")", ":", "FrameworkHandler", "{", "return", "$", "this", "->", "route", "(", "'post'", ",", "$", "path", ",", "$", "callback", ",", "...", "$", ...
Adds routing middleware for POST method @param *string $path The route path @param *callable|string $callback The middleware handler @param callable|string ...$args Arguments for flow @return FrameworkHandler
[ "Adds", "routing", "middleware", "for", "POST", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L281-L284
39,963
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.put
public function put(string $path, $callback, ...$args): FrameworkHandler { return $this->route('put', $path, $callback, ...$args); }
php
public function put(string $path, $callback, ...$args): FrameworkHandler { return $this->route('put', $path, $callback, ...$args); }
[ "public", "function", "put", "(", "string", "$", "path", ",", "$", "callback", ",", "...", "$", "args", ")", ":", "FrameworkHandler", "{", "return", "$", "this", "->", "route", "(", "'put'", ",", "$", "path", ",", "$", "callback", ",", "...", "$", ...
Adds routing middleware for PUT method @param *string $path The route path @param *callable|string $callback The middleware handler @param callable|string ...$args Arguments for flow @return FrameworkHandler
[ "Adds", "routing", "middleware", "for", "PUT", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L295-L298
39,964
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.register
public function register($vendor): FrameworkHandler { //if it's callable if (is_callable($vendor)) { //it's not a package //it's a preprocess return $this->preprocess($vendor); } return $this->registerPackage($vendor); }
php
public function register($vendor): FrameworkHandler { //if it's callable if (is_callable($vendor)) { //it's not a package //it's a preprocess return $this->preprocess($vendor); } return $this->registerPackage($vendor); }
[ "public", "function", "register", "(", "$", "vendor", ")", ":", "FrameworkHandler", "{", "//if it's callable", "if", "(", "is_callable", "(", "$", "vendor", ")", ")", "{", "//it's not a package", "//it's a preprocess", "return", "$", "this", "->", "preprocess", ...
Registers and initializes a package @param *string|callable $vendor The vendor/package name @return FrameworkHandler
[ "Registers", "and", "initializes", "a", "package" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L307-L317
39,965
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.handler
public function handler(string $root, FrameworkHandler $handler = null): FrameworkHandler { //if we have this handler in memory if (isset($this->handlers[$root])) { //if a handler was provided if ($handler instanceof FrameworkHandler) { //we mean to change up the handler $this->handlers[$root] = $handler; } //either way return the handler return $this->handlers[$root]; } //otherwise the handler is not in memory if (!($handler instanceof FrameworkHandler)) { // By default // - Routes are unique per Handler. // - Middleware are unique per Handler. // - Child pre processors aren't triggered. // - Child post processors aren't triggered. // - Child error processors are set by Parent. // - Child protocols are set by Parent. // - Child packages are set by Parent. // - Child requests are set by Parent. // - Child responses are set by Parent. // - Events are still global. $handler = FrameworkHandler::i()->setParent($this); } //remember the handler $this->handlers[$root] = $handler; //since this is out first time with this, //lets have the parent listen to the root and all possible $this->all($root . '**', function ($request, $response) use ($root) { //we need the original path $path = $request->getPath('string'); //determine the sub route $route = substr($path, strlen($root)); //because substr('/', 1); --> false if (!is_string($route) || !strlen($route)) { $route = '/'; } //set up the sub rout in request $request->setPath($route); //we want to lazy load this in because it is //possible that the hander could have changed $this->handler($root) ->setRequest($request) ->setResponse($response) ->process(); //bring the path back $request->setPath($path); }); return $this->handlers[$root]; }
php
public function handler(string $root, FrameworkHandler $handler = null): FrameworkHandler { //if we have this handler in memory if (isset($this->handlers[$root])) { //if a handler was provided if ($handler instanceof FrameworkHandler) { //we mean to change up the handler $this->handlers[$root] = $handler; } //either way return the handler return $this->handlers[$root]; } //otherwise the handler is not in memory if (!($handler instanceof FrameworkHandler)) { // By default // - Routes are unique per Handler. // - Middleware are unique per Handler. // - Child pre processors aren't triggered. // - Child post processors aren't triggered. // - Child error processors are set by Parent. // - Child protocols are set by Parent. // - Child packages are set by Parent. // - Child requests are set by Parent. // - Child responses are set by Parent. // - Events are still global. $handler = FrameworkHandler::i()->setParent($this); } //remember the handler $this->handlers[$root] = $handler; //since this is out first time with this, //lets have the parent listen to the root and all possible $this->all($root . '**', function ($request, $response) use ($root) { //we need the original path $path = $request->getPath('string'); //determine the sub route $route = substr($path, strlen($root)); //because substr('/', 1); --> false if (!is_string($route) || !strlen($route)) { $route = '/'; } //set up the sub rout in request $request->setPath($route); //we want to lazy load this in because it is //possible that the hander could have changed $this->handler($root) ->setRequest($request) ->setResponse($response) ->process(); //bring the path back $request->setPath($path); }); return $this->handlers[$root]; }
[ "public", "function", "handler", "(", "string", "$", "root", ",", "FrameworkHandler", "$", "handler", "=", "null", ")", ":", "FrameworkHandler", "{", "//if we have this handler in memory", "if", "(", "isset", "(", "$", "this", "->", "handlers", "[", "$", "root...
Sets up a sub handler given the path. @param *string $root The root path to handle @param FrameworkHandler|null $handler the child handler @return FrameworkHandler
[ "Sets", "up", "a", "sub", "handler", "given", "the", "path", "." ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L373-L434
39,966
CradlePHP/framework
src/CommandLine.php
CommandLine.setMap
public static function setMap($map = null) { if (is_null(self::$map)) { self::$map = include(__DIR__ . '/CommandLine/map.php'); } if (!is_null($map)) { self::$map = $map; } }
php
public static function setMap($map = null) { if (is_null(self::$map)) { self::$map = include(__DIR__ . '/CommandLine/map.php'); } if (!is_null($map)) { self::$map = $map; } }
[ "public", "static", "function", "setMap", "(", "$", "map", "=", "null", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "map", ")", ")", "{", "self", "::", "$", "map", "=", "include", "(", "__DIR__", ".", "'/CommandLine/map.php'", ")", ";", ...
Setups the output map @param string|null $map
[ "Setups", "the", "output", "map" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/CommandLine.php#L316-L325
39,967
CradlePHP/framework
src/Package.php
Package.addMethod
public function addMethod(string $name, Closure $callback): Package { $this->methods[$name] = $callback->bindTo($this, get_class($this)); return $this; }
php
public function addMethod(string $name, Closure $callback): Package { $this->methods[$name] = $callback->bindTo($this, get_class($this)); return $this; }
[ "public", "function", "addMethod", "(", "string", "$", "name", ",", "Closure", "$", "callback", ")", ":", "Package", "{", "$", "this", "->", "methods", "[", "$", "name", "]", "=", "$", "callback", "->", "bindTo", "(", "$", "this", ",", "get_class", "...
Registers a method to be used @param *string $name The class route name @param *Closure $callback The callback handler @return Package
[ "Registers", "a", "method", "to", "be", "used" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/Package.php#L96-L101
39,968
CradlePHP/framework
src/Package.php
Package.getPackagePath
public function getPackagePath() { $type = $this->getPackageType(); if ($type === self::TYPE_PSEUDO) { return false; } $root = $this->getPackageRoot(); //the vendor name also represents the path $path = $this->name; //if it's a root package if ($type === self::TYPE_ROOT) { $path = substr($path, 1); } return $root . '/' . $path; }
php
public function getPackagePath() { $type = $this->getPackageType(); if ($type === self::TYPE_PSEUDO) { return false; } $root = $this->getPackageRoot(); //the vendor name also represents the path $path = $this->name; //if it's a root package if ($type === self::TYPE_ROOT) { $path = substr($path, 1); } return $root . '/' . $path; }
[ "public", "function", "getPackagePath", "(", ")", "{", "$", "type", "=", "$", "this", "->", "getPackageType", "(", ")", ";", "if", "(", "$", "type", "===", "self", "::", "TYPE_PSEUDO", ")", "{", "return", "false", ";", "}", "$", "root", "=", "$", "...
Returns the path of the project @return string|false
[ "Returns", "the", "path", "of", "the", "project" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/Package.php#L108-L126
39,969
CradlePHP/framework
src/Package.php
Package.getPackageRoot
public function getPackageRoot() { $type = $this->getPackageType(); if ($type === self::TYPE_PSEUDO) { return false; } if (is_string($this->packageRoot)) { return $this->packageRoot; } //determine where it is located //luckily we know where we are in vendor folder :) //is there a better recommended way? $root = __DIR__ . '/../../..'; //HAX using the composer package to get the root of the vendor folder //is there a better recommended way? if (class_exists(SpdxLicenses::class) && method_exists(SpdxLicenses::class, 'getResourcesDir') && realpath(SpdxLicenses::getResourcesDir() . '/../../..') ) { $root = realpath(SpdxLicenses::getResourcesDir() . '/../../..'); } //if it's a root package if ($type === self::TYPE_ROOT) { $root .= '/..'; } $this->packageRoot = realpath($root); return $this->packageRoot; }
php
public function getPackageRoot() { $type = $this->getPackageType(); if ($type === self::TYPE_PSEUDO) { return false; } if (is_string($this->packageRoot)) { return $this->packageRoot; } //determine where it is located //luckily we know where we are in vendor folder :) //is there a better recommended way? $root = __DIR__ . '/../../..'; //HAX using the composer package to get the root of the vendor folder //is there a better recommended way? if (class_exists(SpdxLicenses::class) && method_exists(SpdxLicenses::class, 'getResourcesDir') && realpath(SpdxLicenses::getResourcesDir() . '/../../..') ) { $root = realpath(SpdxLicenses::getResourcesDir() . '/../../..'); } //if it's a root package if ($type === self::TYPE_ROOT) { $root .= '/..'; } $this->packageRoot = realpath($root); return $this->packageRoot; }
[ "public", "function", "getPackageRoot", "(", ")", "{", "$", "type", "=", "$", "this", "->", "getPackageType", "(", ")", ";", "if", "(", "$", "type", "===", "self", "::", "TYPE_PSEUDO", ")", "{", "return", "false", ";", "}", "if", "(", "is_string", "(...
Returns the root path of the project @return string|false
[ "Returns", "the", "root", "path", "of", "the", "project" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/Package.php#L133-L166
39,970
CradlePHP/framework
src/Package.php
Package.getPackageType
public function getPackageType(): string { //if it starts with / like /foo/bar if (strpos($this->name, '/') === 0) { //it's a root package return self::TYPE_ROOT; } //if theres a slash like foo/bar if (strpos($this->name, '/') !== false) { //it's vendor package return self::TYPE_VENDOR; } //by default it's a pseudo package return self::TYPE_PSEUDO; }
php
public function getPackageType(): string { //if it starts with / like /foo/bar if (strpos($this->name, '/') === 0) { //it's a root package return self::TYPE_ROOT; } //if theres a slash like foo/bar if (strpos($this->name, '/') !== false) { //it's vendor package return self::TYPE_VENDOR; } //by default it's a pseudo package return self::TYPE_PSEUDO; }
[ "public", "function", "getPackageType", "(", ")", ":", "string", "{", "//if it starts with / like /foo/bar", "if", "(", "strpos", "(", "$", "this", "->", "name", ",", "'/'", ")", "===", "0", ")", "{", "//it's a root package", "return", "self", "::", "TYPE_ROOT...
Returns the package type @return string
[ "Returns", "the", "package", "type" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/Package.php#L173-L189
39,971
CradlePHP/framework
src/PackageTrait.php
PackageTrait.package
public function package(string $vendor) { if (!array_key_exists($vendor, $this->packages)) { throw Exception::forPackageNotFound($vendor); } return $this->packages[$vendor]; }
php
public function package(string $vendor) { if (!array_key_exists($vendor, $this->packages)) { throw Exception::forPackageNotFound($vendor); } return $this->packages[$vendor]; }
[ "public", "function", "package", "(", "string", "$", "vendor", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "vendor", ",", "$", "this", "->", "packages", ")", ")", "{", "throw", "Exception", "::", "forPackageNotFound", "(", "$", "vendor", ")",...
Returns a package space @param *string $vendor The vendor/package name @return PackageTrait
[ "Returns", "a", "package", "space" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/PackageTrait.php#L62-L69
39,972
CradlePHP/framework
src/PackageTrait.php
PackageTrait.register
public function register(string $vendor, ...$args) { //determine class if (method_exists($this, 'resolve')) { $this->packages[$vendor] = $this->resolve(Package::class, $vendor); // @codeCoverageIgnoreStart } else { $this->packages[$vendor] = new Package($vendor); } // @codeCoverageIgnoreEnd //if the type is not pseudo (vendor or root) if ($this->packages[$vendor]->getPackageType() !== Package::TYPE_PSEUDO) { //let's try to call the bootstrap $cradle = $this; //we should check for events $file = $this->packages[$vendor]->getPackagePath() . '/' . $this->bootstrapFile; // @codeCoverageIgnoreStart if (file_exists($file)) { //so you can access cradle //within the included file include_once($file); } else if (file_exists($file . '.php')) { //so the IDE can have color include_once($file . '.php'); } // @codeCoverageIgnoreEnd } return $this; }
php
public function register(string $vendor, ...$args) { //determine class if (method_exists($this, 'resolve')) { $this->packages[$vendor] = $this->resolve(Package::class, $vendor); // @codeCoverageIgnoreStart } else { $this->packages[$vendor] = new Package($vendor); } // @codeCoverageIgnoreEnd //if the type is not pseudo (vendor or root) if ($this->packages[$vendor]->getPackageType() !== Package::TYPE_PSEUDO) { //let's try to call the bootstrap $cradle = $this; //we should check for events $file = $this->packages[$vendor]->getPackagePath() . '/' . $this->bootstrapFile; // @codeCoverageIgnoreStart if (file_exists($file)) { //so you can access cradle //within the included file include_once($file); } else if (file_exists($file . '.php')) { //so the IDE can have color include_once($file . '.php'); } // @codeCoverageIgnoreEnd } return $this; }
[ "public", "function", "register", "(", "string", "$", "vendor", ",", "...", "$", "args", ")", "{", "//determine class", "if", "(", "method_exists", "(", "$", "this", ",", "'resolve'", ")", ")", "{", "$", "this", "->", "packages", "[", "$", "vendor", "]...
Registers and initializes a plugin @param *string $vendor The vendor/package name @param mixed ...$args @return PackageTrait
[ "Registers", "and", "initializes", "a", "plugin" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/PackageTrait.php#L79-L111
39,973
TerranetMD/localizer
src/Terranet/Localizer/Provider.php
Provider.find
public function find($locale) { if (null === static::$language) { foreach ($this->fetchAll() as $item) { if ($item->locale() == $locale || $item->iso6391() == $locale) { static::$language = $item; break; } } } return static::$language; }
php
public function find($locale) { if (null === static::$language) { foreach ($this->fetchAll() as $item) { if ($item->locale() == $locale || $item->iso6391() == $locale) { static::$language = $item; break; } } } return static::$language; }
[ "public", "function", "find", "(", "$", "locale", ")", "{", "if", "(", "null", "===", "static", "::", "$", "language", ")", "{", "foreach", "(", "$", "this", "->", "fetchAll", "(", ")", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", ...
Find language by locale @param $locale @return mixed
[ "Find", "language", "by", "locale" ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Provider.php#L57-L69
39,974
TerranetMD/localizer
src/Terranet/Localizer/Provider.php
Provider.fetchAll
public function fetchAll() { if (static::$languages === null) { static::$languages = $this->driver()->fetchAll(); static::$languages = array_map(function ($language) { return new Locale($language); }, static::$languages); } return static::$languages; }
php
public function fetchAll() { if (static::$languages === null) { static::$languages = $this->driver()->fetchAll(); static::$languages = array_map(function ($language) { return new Locale($language); }, static::$languages); } return static::$languages; }
[ "public", "function", "fetchAll", "(", ")", "{", "if", "(", "static", "::", "$", "languages", "===", "null", ")", "{", "static", "::", "$", "languages", "=", "$", "this", "->", "driver", "(", ")", "->", "fetchAll", "(", ")", ";", "static", "::", "$...
Fetch all active languages @return mixed
[ "Fetch", "all", "active", "languages" ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Provider.php#L76-L87
39,975
TerranetMD/localizer
src/Terranet/Localizer/Resolvers/RequestResolver.php
RequestResolver.resolveHeader
private function resolveHeader() { if (null === static::$languages) { $httpLanguages = $this->request->server(config('localizer.request.header', 'HTTP_ACCEPT_LANGUAGE')); if (empty($httpLanguages)) { static::$languages = []; } else { $accepted = preg_split('/,\s*/', $httpLanguages); static::$languages = empty($languages = $this->buildCollection($accepted, $languages = [])) ? null : array_keys($languages)[0]; } } return static::$languages; }
php
private function resolveHeader() { if (null === static::$languages) { $httpLanguages = $this->request->server(config('localizer.request.header', 'HTTP_ACCEPT_LANGUAGE')); if (empty($httpLanguages)) { static::$languages = []; } else { $accepted = preg_split('/,\s*/', $httpLanguages); static::$languages = empty($languages = $this->buildCollection($accepted, $languages = [])) ? null : array_keys($languages)[0]; } } return static::$languages; }
[ "private", "function", "resolveHeader", "(", ")", "{", "if", "(", "null", "===", "static", "::", "$", "languages", ")", "{", "$", "httpLanguages", "=", "$", "this", "->", "request", "->", "server", "(", "config", "(", "'localizer.request.header'", ",", "'H...
Resolve language using HTTP_ACCEPT_LANGUAGE header which is used mostly by API requests @return array|null
[ "Resolve", "language", "using", "HTTP_ACCEPT_LANGUAGE", "header", "which", "is", "used", "mostly", "by", "API", "requests" ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Resolvers/RequestResolver.php#L52-L69
39,976
TerranetMD/localizer
src/Terranet/Localizer/Resolvers/RequestResolver.php
RequestResolver.assemble
public function assemble($iso, $url = null) { $url = rtrim($url, '/'); $locales = locales()->map->iso6391()->all(); $default = getDefault()->iso6391(); foreach ($locales as $locale) { # handle urls that contains language in request uri: /en | /en/profile # skip urls that starts with string equals with one of locales: /english if (starts_with($url, "/{$locale}/") || "/{$locale}" === $url) { return url(preg_replace( '~^\/' . $locale . '~si', $iso === $default ? "" : "/{$iso}", $url )); } } # prepend url with $iso return url( ($iso === $default ? "" : $iso . '/') . ltrim($url, '/') ); }
php
public function assemble($iso, $url = null) { $url = rtrim($url, '/'); $locales = locales()->map->iso6391()->all(); $default = getDefault()->iso6391(); foreach ($locales as $locale) { # handle urls that contains language in request uri: /en | /en/profile # skip urls that starts with string equals with one of locales: /english if (starts_with($url, "/{$locale}/") || "/{$locale}" === $url) { return url(preg_replace( '~^\/' . $locale . '~si', $iso === $default ? "" : "/{$iso}", $url )); } } # prepend url with $iso return url( ($iso === $default ? "" : $iso . '/') . ltrim($url, '/') ); }
[ "public", "function", "assemble", "(", "$", "iso", ",", "$", "url", "=", "null", ")", "{", "$", "url", "=", "rtrim", "(", "$", "url", ",", "'/'", ")", ";", "$", "locales", "=", "locales", "(", ")", "->", "map", "->", "iso6391", "(", ")", "->", ...
Re-Assemble current url with different locale. @param $iso @param null $url @return mixed
[ "Re", "-", "Assemble", "current", "url", "with", "different", "locale", "." ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Resolvers/RequestResolver.php#L121-L143
39,977
TerranetMD/localizer
src/Terranet/Localizer/Resolvers/DomainResolver.php
DomainResolver.resolve
public function resolve() { $httpHost = $this->request->getHttpHost(); $domains = explode('.', $httpHost); $level = config('localizer.domain.level', 3); return ($total = count($domains)) >= $level ? $domains[$total - $level] : null; }
php
public function resolve() { $httpHost = $this->request->getHttpHost(); $domains = explode('.', $httpHost); $level = config('localizer.domain.level', 3); return ($total = count($domains)) >= $level ? $domains[$total - $level] : null; }
[ "public", "function", "resolve", "(", ")", "{", "$", "httpHost", "=", "$", "this", "->", "request", "->", "getHttpHost", "(", ")", ";", "$", "domains", "=", "explode", "(", "'.'", ",", "$", "httpHost", ")", ";", "$", "level", "=", "config", "(", "'...
Resolve locale using domain name @return mixed
[ "Resolve", "locale", "using", "domain", "name" ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Resolvers/DomainResolver.php#L31-L38
39,978
thujohn/rss-l4
src/Thujohn/Rss/SimpleXMLElement.php
SimpleXMLElement.setChildCdataValue
private function setChildCdataValue($value) { $domNode = dom_import_simplexml($this); $domNode->appendChild($domNode->ownerDocument->createCDATASection($value)); }
php
private function setChildCdataValue($value) { $domNode = dom_import_simplexml($this); $domNode->appendChild($domNode->ownerDocument->createCDATASection($value)); }
[ "private", "function", "setChildCdataValue", "(", "$", "value", ")", "{", "$", "domNode", "=", "dom_import_simplexml", "(", "$", "this", ")", ";", "$", "domNode", "->", "appendChild", "(", "$", "domNode", "->", "ownerDocument", "->", "createCDATASection", "(",...
Sets a cdata value for this child @param string $value The value to be enclosed in CDATA @return void
[ "Sets", "a", "cdata", "value", "for", "this", "child" ]
b65908ca63101b0f6bf53972b0245b0d0454d5ca
https://github.com/thujohn/rss-l4/blob/b65908ca63101b0f6bf53972b0245b0d0454d5ca/src/Thujohn/Rss/SimpleXMLElement.php#L49-L52
39,979
gravatarphp/gravatar
src/Gravatar.php
Gravatar.avatar
public function avatar(string $email, array $options = [], ?bool $secure = null, bool $validateOptions = false): string { $url = 'avatar/'.$this->createEmailHash($email); $options = array_merge($this->defaults, array_filter($options)); if ($validateOptions) { $this->validateOptions($options); } if (!empty($options)) { $url .= '?'.http_build_query($options); } return $this->buildUrl($url, $secure); }
php
public function avatar(string $email, array $options = [], ?bool $secure = null, bool $validateOptions = false): string { $url = 'avatar/'.$this->createEmailHash($email); $options = array_merge($this->defaults, array_filter($options)); if ($validateOptions) { $this->validateOptions($options); } if (!empty($options)) { $url .= '?'.http_build_query($options); } return $this->buildUrl($url, $secure); }
[ "public", "function", "avatar", "(", "string", "$", "email", ",", "array", "$", "options", "=", "[", "]", ",", "?", "bool", "$", "secure", "=", "null", ",", "bool", "$", "validateOptions", "=", "false", ")", ":", "string", "{", "$", "url", "=", "'a...
Returns an Avatar URL.
[ "Returns", "an", "Avatar", "URL", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L83-L98
39,980
gravatarphp/gravatar
src/Gravatar.php
Gravatar.profile
public function profile(string $email, ?bool $secure = null): string { return $this->buildUrl($this->createEmailHash($email), $secure); }
php
public function profile(string $email, ?bool $secure = null): string { return $this->buildUrl($this->createEmailHash($email), $secure); }
[ "public", "function", "profile", "(", "string", "$", "email", ",", "?", "bool", "$", "secure", "=", "null", ")", ":", "string", "{", "return", "$", "this", "->", "buildUrl", "(", "$", "this", "->", "createEmailHash", "(", "$", "email", ")", ",", "$",...
Returns a profile URL.
[ "Returns", "a", "profile", "URL", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L103-L106
39,981
gravatarphp/gravatar
src/Gravatar.php
Gravatar.vcard
public function vcard(string $email, ?bool $secure = null): string { return $this->profile($email, $secure).'.vcf'; }
php
public function vcard(string $email, ?bool $secure = null): string { return $this->profile($email, $secure).'.vcf'; }
[ "public", "function", "vcard", "(", "string", "$", "email", ",", "?", "bool", "$", "secure", "=", "null", ")", ":", "string", "{", "return", "$", "this", "->", "profile", "(", "$", "email", ",", "$", "secure", ")", ".", "'.vcf'", ";", "}" ]
Returns a vCard URL.
[ "Returns", "a", "vCard", "URL", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L111-L114
39,982
gravatarphp/gravatar
src/Gravatar.php
Gravatar.qrCode
public function qrCode(string $email, ?bool $secure = null): string { return $this->profile($email, $secure).'.qr'; }
php
public function qrCode(string $email, ?bool $secure = null): string { return $this->profile($email, $secure).'.qr'; }
[ "public", "function", "qrCode", "(", "string", "$", "email", ",", "?", "bool", "$", "secure", "=", "null", ")", ":", "string", "{", "return", "$", "this", "->", "profile", "(", "$", "email", ",", "$", "secure", ")", ".", "'.qr'", ";", "}" ]
Returns a QR Code URL.
[ "Returns", "a", "QR", "Code", "URL", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L119-L122
39,983
gravatarphp/gravatar
src/Gravatar.php
Gravatar.createEmailHash
private function createEmailHash(string $email): string { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new \InvalidArgumentException('Invalid email address'); } return md5(strtolower(trim($email))); }
php
private function createEmailHash(string $email): string { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new \InvalidArgumentException('Invalid email address'); } return md5(strtolower(trim($email))); }
[ "private", "function", "createEmailHash", "(", "string", "$", "email", ")", ":", "string", "{", "if", "(", "!", "filter_var", "(", "$", "email", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid email...
Creates a hash from an email address.
[ "Creates", "a", "hash", "from", "an", "email", "address", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L127-L134
39,984
gravatarphp/gravatar
src/Gravatar.php
Gravatar.buildUrl
private function buildUrl(string $resource, ?bool $secure): string { $secure = isset($secure) ? (bool) $secure : $this->secure; $endpoint = $secure ? self::HTTPS_ENDPOINT : self::HTTP_ENDPOINT; return sprintf('%s/%s', $endpoint, $resource); }
php
private function buildUrl(string $resource, ?bool $secure): string { $secure = isset($secure) ? (bool) $secure : $this->secure; $endpoint = $secure ? self::HTTPS_ENDPOINT : self::HTTP_ENDPOINT; return sprintf('%s/%s', $endpoint, $resource); }
[ "private", "function", "buildUrl", "(", "string", "$", "resource", ",", "?", "bool", "$", "secure", ")", ":", "string", "{", "$", "secure", "=", "isset", "(", "$", "secure", ")", "?", "(", "bool", ")", "$", "secure", ":", "$", "this", "->", "secure...
Builds the URL based on the given parameters.
[ "Builds", "the", "URL", "based", "on", "the", "given", "parameters", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L220-L227
39,985
johnstevenson/json-works
src/Utils.php
Utils.dataToJson
public static function dataToJson($data, $pretty) { $newLine = $pretty ? chr(10) : null; if (version_compare(PHP_VERSION, '5.4', '>=')) { $pprint = $pretty ? JSON_PRETTY_PRINT : 0; $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | $pprint; return static::finalizeJson(json_encode($data, $options), $newLine); } $json = json_encode($data); $len = strlen($json); $result = $string = ''; $inString = $escaped = false; $level = 0; $space = $pretty ? chr(32) : null; $convert = function_exists('mb_convert_encoding'); for ($i = 0; $i < $len; $i++) { $char = $json[$i]; # are we inside a json string? if ('"' === $char && !$escaped) { $inString = !$inString; } if ($inString) { $string .= $char; $escaped = '\\' === $char ? !$escaped : false; continue; } elseif ($string) { # end of the json string $string .= $char; # unescape slashes $string = str_replace('\\/', '/', $string); # unescape unicode if ($convert) { $string = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); }, $string); } $result .= $string; $string = ''; continue; } if (':' === $char) { # add space after colon $char .= $space; } elseif (strpbrk($char, '}]')) { # char is an end element, so add a newline $result .= $newLine; # decrease indent level $level--; $result .= str_repeat($space, $level * 4); } $result .= $char; if (strpbrk($char, ',{[')) { # char is a start element, so add a newline $result .= $newLine; # increase indent level if not a comma if (',' !== $char) { $level++; } $result .= str_repeat($space, $level * 4); } } return static::finalizeJson($result, $newLine); }
php
public static function dataToJson($data, $pretty) { $newLine = $pretty ? chr(10) : null; if (version_compare(PHP_VERSION, '5.4', '>=')) { $pprint = $pretty ? JSON_PRETTY_PRINT : 0; $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | $pprint; return static::finalizeJson(json_encode($data, $options), $newLine); } $json = json_encode($data); $len = strlen($json); $result = $string = ''; $inString = $escaped = false; $level = 0; $space = $pretty ? chr(32) : null; $convert = function_exists('mb_convert_encoding'); for ($i = 0; $i < $len; $i++) { $char = $json[$i]; # are we inside a json string? if ('"' === $char && !$escaped) { $inString = !$inString; } if ($inString) { $string .= $char; $escaped = '\\' === $char ? !$escaped : false; continue; } elseif ($string) { # end of the json string $string .= $char; # unescape slashes $string = str_replace('\\/', '/', $string); # unescape unicode if ($convert) { $string = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); }, $string); } $result .= $string; $string = ''; continue; } if (':' === $char) { # add space after colon $char .= $space; } elseif (strpbrk($char, '}]')) { # char is an end element, so add a newline $result .= $newLine; # decrease indent level $level--; $result .= str_repeat($space, $level * 4); } $result .= $char; if (strpbrk($char, ',{[')) { # char is a start element, so add a newline $result .= $newLine; # increase indent level if not a comma if (',' !== $char) { $level++; } $result .= str_repeat($space, $level * 4); } } return static::finalizeJson($result, $newLine); }
[ "public", "static", "function", "dataToJson", "(", "$", "data", ",", "$", "pretty", ")", "{", "$", "newLine", "=", "$", "pretty", "?", "chr", "(", "10", ")", ":", "null", ";", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.4'", ",", "'>='...
Encodes data into JSON @param mixed $data The data to be encoded @param boolean $pretty Format the output @return string Encoded json
[ "Encodes", "data", "into", "JSON" ]
97eca2c9956894374d41dcaf8031d123a8705100
https://github.com/johnstevenson/json-works/blob/97eca2c9956894374d41dcaf8031d123a8705100/src/Utils.php#L193-L273
39,986
madkom/nginx-configurator
src/Factory.php
Factory.createServer
public function createServer(int $port = 80) : Server { $listenIPv4 = new Directive('listen', [new Param($port)]); $listenIPv6 = new Directive('listen', [new Param("[::]:{$port}"), new Param('default'), new Param('ipv6only=on')]); return new Server([$listenIPv4, $listenIPv6]); }
php
public function createServer(int $port = 80) : Server { $listenIPv4 = new Directive('listen', [new Param($port)]); $listenIPv6 = new Directive('listen', [new Param("[::]:{$port}"), new Param('default'), new Param('ipv6only=on')]); return new Server([$listenIPv4, $listenIPv6]); }
[ "public", "function", "createServer", "(", "int", "$", "port", "=", "80", ")", ":", "Server", "{", "$", "listenIPv4", "=", "new", "Directive", "(", "'listen'", ",", "[", "new", "Param", "(", "$", "port", ")", "]", ")", ";", "$", "listenIPv6", "=", ...
Creates Server node @param int $port @return Server
[ "Creates", "Server", "node" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Factory.php#L27-L33
39,987
madkom/nginx-configurator
src/Factory.php
Factory.createLocation
public function createLocation(string $location, string $match = null) : Location { return new Location(new Param($location), is_null($match) ? null : new Param($match)); }
php
public function createLocation(string $location, string $match = null) : Location { return new Location(new Param($location), is_null($match) ? null : new Param($match)); }
[ "public", "function", "createLocation", "(", "string", "$", "location", ",", "string", "$", "match", "=", "null", ")", ":", "Location", "{", "return", "new", "Location", "(", "new", "Param", "(", "$", "location", ")", ",", "is_null", "(", "$", "match", ...
Creates Location node @param string $location @param string|null $match @return Location
[ "Creates", "Location", "node" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Factory.php#L41-L44
39,988
breeswish/php-marked
src/Marked/Parser.php
Parser.doParse
public static function doParse($src, $src_links, $options) { $parser = new Parser($options); return $parser->parse($src, $src_links); }
php
public static function doParse($src, $src_links, $options) { $parser = new Parser($options); return $parser->parse($src, $src_links); }
[ "public", "static", "function", "doParse", "(", "$", "src", ",", "$", "src_links", ",", "$", "options", ")", "{", "$", "parser", "=", "new", "Parser", "(", "$", "options", ")", ";", "return", "$", "parser", "->", "parse", "(", "$", "src", ",", "$",...
Static Parse Method
[ "Static", "Parse", "Method" ]
b67fe5bdc90beb877e03974a899e98f856e0006d
https://github.com/breeswish/php-marked/blob/b67fe5bdc90beb877e03974a899e98f856e0006d/src/Marked/Parser.php#L20-L24
39,989
breeswish/php-marked
src/Marked/Parser.php
Parser.peek
public function peek() { $l = count($this->tokens); if ($l == 0) { return null; } else { return $this->tokens[$l - 1]; } }
php
public function peek() { $l = count($this->tokens); if ($l == 0) { return null; } else { return $this->tokens[$l - 1]; } }
[ "public", "function", "peek", "(", ")", "{", "$", "l", "=", "count", "(", "$", "this", "->", "tokens", ")", ";", "if", "(", "$", "l", "==", "0", ")", "{", "return", "null", ";", "}", "else", "{", "return", "$", "this", "->", "tokens", "[", "$...
Preview Next Token
[ "Preview", "Next", "Token" ]
b67fe5bdc90beb877e03974a899e98f856e0006d
https://github.com/breeswish/php-marked/blob/b67fe5bdc90beb877e03974a899e98f856e0006d/src/Marked/Parser.php#L69-L77
39,990
breeswish/php-marked
src/Marked/Parser.php
Parser.parseText
public function parseText() { $body = $this->token['text']; $p = $this->peek(); while (isset($p) && $p['type'] === 'text') { $n = $this->next(); $body .= "\n" . $n['text']; $p = $this->peek(); } return $this->inline->output($body); }
php
public function parseText() { $body = $this->token['text']; $p = $this->peek(); while (isset($p) && $p['type'] === 'text') { $n = $this->next(); $body .= "\n" . $n['text']; $p = $this->peek(); } return $this->inline->output($body); }
[ "public", "function", "parseText", "(", ")", "{", "$", "body", "=", "$", "this", "->", "token", "[", "'text'", "]", ";", "$", "p", "=", "$", "this", "->", "peek", "(", ")", ";", "while", "(", "isset", "(", "$", "p", ")", "&&", "$", "p", "[", ...
Parse Text Tokens
[ "Parse", "Text", "Tokens" ]
b67fe5bdc90beb877e03974a899e98f856e0006d
https://github.com/breeswish/php-marked/blob/b67fe5bdc90beb877e03974a899e98f856e0006d/src/Marked/Parser.php#L82-L94
39,991
madkom/nginx-configurator
src/Node/Node.php
Node.append
public function append(Node $node) : bool { $node->parent = $this; return $this->childNodes->add($node); }
php
public function append(Node $node) : bool { $node->parent = $this; return $this->childNodes->add($node); }
[ "public", "function", "append", "(", "Node", "$", "node", ")", ":", "bool", "{", "$", "node", "->", "parent", "=", "$", "this", ";", "return", "$", "this", "->", "childNodes", "->", "add", "(", "$", "node", ")", ";", "}" ]
Append new child node @param Node $node @return bool
[ "Append", "new", "child", "node" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Node/Node.php#L62-L67
39,992
madkom/nginx-configurator
src/Parser.php
Parser.parseFile
public function parseFile(string $filename) : RootNode { $this->content = null; $this->filename = $filename; return $this->parse(file_get_contents($filename)); }
php
public function parseFile(string $filename) : RootNode { $this->content = null; $this->filename = $filename; return $this->parse(file_get_contents($filename)); }
[ "public", "function", "parseFile", "(", "string", "$", "filename", ")", ":", "RootNode", "{", "$", "this", "->", "content", "=", "null", ";", "$", "this", "->", "filename", "=", "$", "filename", ";", "return", "$", "this", "->", "parse", "(", "file_get...
Parses config file @param string $filename @return mixed @throws ParseFailureException
[ "Parses", "config", "file" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Parser.php#L134-L140
39,993
madkom/nginx-configurator
src/Parser.php
Parser.parseSection
protected function parseSection($section, $space0, $params, $open, $space1, $directives) : Context { switch ($section) { case 'server': return new Server($directives); case 'http': return new Http($directives); case 'location': $modifier = null; if (sizeof($params) == 2) { list($modifier, $location) = $params; } elseif (sizeof($params) == 1) { $location = $params[0]; } else { throw new GrammarException( sprintf( "Location context missing in %s", $this->filename ? var_export($this->filename, true) : var_export($this->content, true) ) ); } return new Location($location, $modifier, $directives); case 'events': return new Events($directives); case 'upstream': list($upstream) = $params; return new Upstream($upstream, $directives); } throw new UnrecognizedContextException( sprintf( "Unrecognized context: {$section} found in %s", $this->filename ? var_export($this->filename, true) : var_export($this->content, true) ) ); }
php
protected function parseSection($section, $space0, $params, $open, $space1, $directives) : Context { switch ($section) { case 'server': return new Server($directives); case 'http': return new Http($directives); case 'location': $modifier = null; if (sizeof($params) == 2) { list($modifier, $location) = $params; } elseif (sizeof($params) == 1) { $location = $params[0]; } else { throw new GrammarException( sprintf( "Location context missing in %s", $this->filename ? var_export($this->filename, true) : var_export($this->content, true) ) ); } return new Location($location, $modifier, $directives); case 'events': return new Events($directives); case 'upstream': list($upstream) = $params; return new Upstream($upstream, $directives); } throw new UnrecognizedContextException( sprintf( "Unrecognized context: {$section} found in %s", $this->filename ? var_export($this->filename, true) : var_export($this->content, true) ) ); }
[ "protected", "function", "parseSection", "(", "$", "section", ",", "$", "space0", ",", "$", "params", ",", "$", "open", ",", "$", "space1", ",", "$", "directives", ")", ":", "Context", "{", "switch", "(", "$", "section", ")", "{", "case", "'server'", ...
Parses section entries @param string $section Section name @param null $space0 Ignored @param Param[] $params Params collection @param null $open Ignored @param null $space1 Ignored @param Directive[] $directives Directives collection @return Context @throws GrammarException @throws UnrecognizedContextException
[ "Parses", "section", "entries" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Parser.php#L168-L207
39,994
marciioluucas/phiber
src/Phiber/Util/FuncoesString.php
FuncoesString.separaString
public function separaString($string, $posicaoInicial, $posicaoFinal = null) { if ($posicaoFinal == null) { return substr($string, $posicaoInicial - 1); } return substr($string, $posicaoInicial - 1, ($posicaoFinal - 1) * (-1)); }
php
public function separaString($string, $posicaoInicial, $posicaoFinal = null) { if ($posicaoFinal == null) { return substr($string, $posicaoInicial - 1); } return substr($string, $posicaoInicial - 1, ($posicaoFinal - 1) * (-1)); }
[ "public", "function", "separaString", "(", "$", "string", ",", "$", "posicaoInicial", ",", "$", "posicaoFinal", "=", "null", ")", "{", "if", "(", "$", "posicaoFinal", "==", "null", ")", "{", "return", "substr", "(", "$", "string", ",", "$", "posicaoInici...
Separa uma string. @param string $string @param int $posicaoInicial @param int $posicaoFinal default null @return string
[ "Separa", "uma", "string", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/Util/FuncoesString.php#L73-L80
39,995
marciioluucas/phiber
src/Phiber/ORM/Logger/PhiberLogger.php
PhiberLogger.create
public static function create($languageReference, $level = 'info', $objectName = '', $execTime = null) { if (JsonReader::read(BASE_DIR.'/phiber_config.json')->phiber->log == 1 ? true : false) { $date = date('Y-m-d H:i:s'); switch ($level) { case 'info': $levelStr = strtoupper(new Internationalization("log_info")); $msg = "\033[0;35m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; case 'warning': $levelStr = strtoupper(new Internationalization("log_warning")); $msg = "\033[1;33m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; case 'error': $levelStr = strtoupper(new Internationalization("log_error")); $msg = "\033[0;31m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; } } }
php
public static function create($languageReference, $level = 'info', $objectName = '', $execTime = null) { if (JsonReader::read(BASE_DIR.'/phiber_config.json')->phiber->log == 1 ? true : false) { $date = date('Y-m-d H:i:s'); switch ($level) { case 'info': $levelStr = strtoupper(new Internationalization("log_info")); $msg = "\033[0;35m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; case 'warning': $levelStr = strtoupper(new Internationalization("log_warning")); $msg = "\033[1;33m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; case 'error': $levelStr = strtoupper(new Internationalization("log_error")); $msg = "\033[0;31m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; } } }
[ "public", "static", "function", "create", "(", "$", "languageReference", ",", "$", "level", "=", "'info'", ",", "$", "objectName", "=", "''", ",", "$", "execTime", "=", "null", ")", "{", "if", "(", "JsonReader", "::", "read", "(", "BASE_DIR", ".", "'/p...
Cria o log. @param $languageReference @param string $level @param string $objectName @param null $execTime
[ "Cria", "o", "log", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Logger/PhiberLogger.php#L24-L66
39,996
marciioluucas/phiber
src/Phiber/ORM/Persistence/TableMySql.php
TableMySql.drop
static function drop($obj) { $tabela = strtolower(FuncoesReflections::pegaNomeClasseObjeto($obj)); $atributosObjeto = FuncoesReflections::pegaAtributosDoObjeto($obj); $columnsTabela = self::columns($tabela); $arrayCamposTabela = []; for ($i = 0; $i < count($columnsTabela); $i++) { array_push($arrayCamposTabela, $columnsTabela[$i]['Field']); } $arrayDiff = array_diff($arrayCamposTabela, $atributosObjeto); $arrayDiff = array_values($arrayDiff); $sqlDrop = "ALTER TABLE $tabela \n"; for ($j = 0; $j < count($arrayDiff); $j++) { if ($j != count($arrayDiff) - 1) { $sqlDrop .= "DROP " . $arrayDiff[$j] . ", "; } else { $sqlDrop .= "DROP " . $arrayDiff[$j] . ";"; } } $contentFile = JsonReader::read(BASE_DIR."/phiber_config.json")->phiber->code_sync == 1 ? true : false; if ($contentFile) { $pdo = self::getConnection()->prepare($sqlDrop); if ($pdo->execute()) { return true; }; } else { return $sqlDrop; } return false; }
php
static function drop($obj) { $tabela = strtolower(FuncoesReflections::pegaNomeClasseObjeto($obj)); $atributosObjeto = FuncoesReflections::pegaAtributosDoObjeto($obj); $columnsTabela = self::columns($tabela); $arrayCamposTabela = []; for ($i = 0; $i < count($columnsTabela); $i++) { array_push($arrayCamposTabela, $columnsTabela[$i]['Field']); } $arrayDiff = array_diff($arrayCamposTabela, $atributosObjeto); $arrayDiff = array_values($arrayDiff); $sqlDrop = "ALTER TABLE $tabela \n"; for ($j = 0; $j < count($arrayDiff); $j++) { if ($j != count($arrayDiff) - 1) { $sqlDrop .= "DROP " . $arrayDiff[$j] . ", "; } else { $sqlDrop .= "DROP " . $arrayDiff[$j] . ";"; } } $contentFile = JsonReader::read(BASE_DIR."/phiber_config.json")->phiber->code_sync == 1 ? true : false; if ($contentFile) { $pdo = self::getConnection()->prepare($sqlDrop); if ($pdo->execute()) { return true; }; } else { return $sqlDrop; } return false; }
[ "static", "function", "drop", "(", "$", "obj", ")", "{", "$", "tabela", "=", "strtolower", "(", "FuncoesReflections", "::", "pegaNomeClasseObjeto", "(", "$", "obj", ")", ")", ";", "$", "atributosObjeto", "=", "FuncoesReflections", "::", "pegaAtributosDoObjeto", ...
Deleta a tabela do banco de dados. @param Object $obj @return bool|string
[ "Deleta", "a", "tabela", "do", "banco", "de", "dados", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Persistence/TableMySql.php#L74-L107
39,997
marciioluucas/phiber
src/Phiber/ORM/Persistence/TableMySql.php
TableMySql.columns
static function columns($table) { $sql = "show columns from " . strtolower($table); $contentFile = JsonReader::read(BASE_DIR . "/phiber_config.json")->phiber->execute_querys == 1 ? true : false; if ($contentFile) { $pdo = self::getConnection()->prepare($sql); if ($pdo->execute()) { return $pdo->fetchAll(\PDO::FETCH_ASSOC); } else { return false; } } else { return false; } }
php
static function columns($table) { $sql = "show columns from " . strtolower($table); $contentFile = JsonReader::read(BASE_DIR . "/phiber_config.json")->phiber->execute_querys == 1 ? true : false; if ($contentFile) { $pdo = self::getConnection()->prepare($sql); if ($pdo->execute()) { return $pdo->fetchAll(\PDO::FETCH_ASSOC); } else { return false; } } else { return false; } }
[ "static", "function", "columns", "(", "$", "table", ")", "{", "$", "sql", "=", "\"show columns from \"", ".", "strtolower", "(", "$", "table", ")", ";", "$", "contentFile", "=", "JsonReader", "::", "read", "(", "BASE_DIR", ".", "\"/phiber_config.json\"", ")"...
Mostra as colunas daquela tabela. @param string $table @return array|bool
[ "Mostra", "as", "colunas", "daquela", "tabela", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Persistence/TableMySql.php#L115-L130
39,998
marciioluucas/phiber
src/Phiber/ORM/Queries/PhiberQueryWriter.php
PhiberQueryWriter.update
public function update($infos) { $tabela = $infos['table']; $campos = $infos['fields']; $camposV = $infos['values']; $whereCriteria = $infos['where']; try { $camposNome = []; for ($i = 0; $i < count($campos); $i++) { if ($camposV[$i] != null) { $camposNome[$i] = $campos[$i]; } } $camposNome = array_values($camposNome); $this->sql = "UPDATE $tabela SET "; for ($i = 0; $i < count($camposNome); $i++) { if (!empty($camposNome[$i])) { if ($i != count($camposNome) - 1) { $this->sql .= $camposNome[$i] . " = :" . $camposNome[$i] . ", "; } else { $this->sql .= $camposNome[$i] . " = :" . $camposNome[$i]; } } } if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria . " "; } return $this->sql . ";"; } catch (PhiberException $e) { throw new PhiberException(new Internationalization("query_processor_error")); } }
php
public function update($infos) { $tabela = $infos['table']; $campos = $infos['fields']; $camposV = $infos['values']; $whereCriteria = $infos['where']; try { $camposNome = []; for ($i = 0; $i < count($campos); $i++) { if ($camposV[$i] != null) { $camposNome[$i] = $campos[$i]; } } $camposNome = array_values($camposNome); $this->sql = "UPDATE $tabela SET "; for ($i = 0; $i < count($camposNome); $i++) { if (!empty($camposNome[$i])) { if ($i != count($camposNome) - 1) { $this->sql .= $camposNome[$i] . " = :" . $camposNome[$i] . ", "; } else { $this->sql .= $camposNome[$i] . " = :" . $camposNome[$i]; } } } if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria . " "; } return $this->sql . ";"; } catch (PhiberException $e) { throw new PhiberException(new Internationalization("query_processor_error")); } }
[ "public", "function", "update", "(", "$", "infos", ")", "{", "$", "tabela", "=", "$", "infos", "[", "'table'", "]", ";", "$", "campos", "=", "$", "infos", "[", "'fields'", "]", ";", "$", "camposV", "=", "$", "infos", "[", "'values'", "]", ";", "$...
Faz a query de update de um registro no banco com os dados. @param $infos @return mixed @throws PhiberException @internal param $object @internal param $id
[ "Faz", "a", "query", "de", "update", "de", "um", "registro", "no", "banco", "com", "os", "dados", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Queries/PhiberQueryWriter.php#L92-L129
39,999
marciioluucas/phiber
src/Phiber/ORM/Queries/PhiberQueryWriter.php
PhiberQueryWriter.delete
public function delete(array $infos) { $tabela = $infos['table']; $whereCriteria = $infos['where']; try { $this->sql = "DELETE FROM $tabela "; if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria . " "; } return $this->sql . ";"; } catch (PhiberException $e) { throw new PhiberException(new Internationalization("query_processor_error")); } }
php
public function delete(array $infos) { $tabela = $infos['table']; $whereCriteria = $infos['where']; try { $this->sql = "DELETE FROM $tabela "; if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria . " "; } return $this->sql . ";"; } catch (PhiberException $e) { throw new PhiberException(new Internationalization("query_processor_error")); } }
[ "public", "function", "delete", "(", "array", "$", "infos", ")", "{", "$", "tabela", "=", "$", "infos", "[", "'table'", "]", ";", "$", "whereCriteria", "=", "$", "infos", "[", "'where'", "]", ";", "try", "{", "$", "this", "->", "sql", "=", "\"DELET...
Faz a query de delete de um registro no banco com os dados. @param array $infos @return bool|string @throws PhiberException @internal param $object @internal param array $conditions @internal param array $conjunctions
[ "Faz", "a", "query", "de", "delete", "de", "um", "registro", "no", "banco", "com", "os", "dados", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Queries/PhiberQueryWriter.php#L141-L157