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
45,600
spiral/database
src/Schema/Reflector.php
Reflector.run
public function run() { $hasChanges = false; foreach ($this->tables as $table) { if ( $table->getComparator()->hasChanges() || $table->getStatus() == AbstractTable::STATUS_DECLARED_DROPPED ) { $hasChanges = true; break; } } if (!$hasChanges) { //Nothing to do return; } $this->beginTransaction(); try { //Drop not-needed foreign keys and alter everything else $this->dropForeignKeys(); //Drop not-needed indexes $this->dropIndexes(); //Other changes [NEW TABLES WILL BE CREATED HERE!] foreach ($this->commitChanges() as $table) { $table->save(HandlerInterface::CREATE_FOREIGN_KEYS, true); } } catch (\Throwable $e) { $this->rollbackTransaction(); throw $e; } $this->commitTransaction(); }
php
public function run() { $hasChanges = false; foreach ($this->tables as $table) { if ( $table->getComparator()->hasChanges() || $table->getStatus() == AbstractTable::STATUS_DECLARED_DROPPED ) { $hasChanges = true; break; } } if (!$hasChanges) { //Nothing to do return; } $this->beginTransaction(); try { //Drop not-needed foreign keys and alter everything else $this->dropForeignKeys(); //Drop not-needed indexes $this->dropIndexes(); //Other changes [NEW TABLES WILL BE CREATED HERE!] foreach ($this->commitChanges() as $table) { $table->save(HandlerInterface::CREATE_FOREIGN_KEYS, true); } } catch (\Throwable $e) { $this->rollbackTransaction(); throw $e; } $this->commitTransaction(); }
[ "public", "function", "run", "(", ")", "{", "$", "hasChanges", "=", "false", ";", "foreach", "(", "$", "this", "->", "tables", "as", "$", "table", ")", "{", "if", "(", "$", "table", "->", "getComparator", "(", ")", "->", "hasChanges", "(", ")", "||...
Synchronize tables. @throws \Throwable
[ "Synchronize", "tables", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Schema/Reflector.php#L82-L119
45,601
spiral/database
src/Schema/Reflector.php
Reflector.dropForeignKeys
protected function dropForeignKeys() { foreach ($this->sortedTables() as $table) { if ($table->exists()) { $table->save(HandlerInterface::DROP_FOREIGN_KEYS, false); } } }
php
protected function dropForeignKeys() { foreach ($this->sortedTables() as $table) { if ($table->exists()) { $table->save(HandlerInterface::DROP_FOREIGN_KEYS, false); } } }
[ "protected", "function", "dropForeignKeys", "(", ")", "{", "foreach", "(", "$", "this", "->", "sortedTables", "(", ")", "as", "$", "table", ")", "{", "if", "(", "$", "table", "->", "exists", "(", ")", ")", "{", "$", "table", "->", "save", "(", "Han...
Drop all removed table references.
[ "Drop", "all", "removed", "table", "references", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Schema/Reflector.php#L124-L131
45,602
spiral/database
src/Schema/Reflector.php
Reflector.dropIndexes
protected function dropIndexes() { foreach ($this->sortedTables() as $table) { if ($table->exists()) { $table->save(HandlerInterface::DROP_INDEXES, false); } } }
php
protected function dropIndexes() { foreach ($this->sortedTables() as $table) { if ($table->exists()) { $table->save(HandlerInterface::DROP_INDEXES, false); } } }
[ "protected", "function", "dropIndexes", "(", ")", "{", "foreach", "(", "$", "this", "->", "sortedTables", "(", ")", "as", "$", "table", ")", "{", "if", "(", "$", "table", "->", "exists", "(", ")", ")", "{", "$", "table", "->", "save", "(", "Handler...
Drop all removed table indexes.
[ "Drop", "all", "removed", "table", "indexes", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Schema/Reflector.php#L136-L143
45,603
spiral/database
src/Schema/Reflector.php
Reflector.collectDrivers
private function collectDrivers() { foreach ($this->tables as $table) { if (!in_array($table->getDriver(), $this->drivers, true)) { $this->drivers[] = $table->getDriver(); } } }
php
private function collectDrivers() { foreach ($this->tables as $table) { if (!in_array($table->getDriver(), $this->drivers, true)) { $this->drivers[] = $table->getDriver(); } } }
[ "private", "function", "collectDrivers", "(", ")", "{", "foreach", "(", "$", "this", "->", "tables", "as", "$", "table", ")", "{", "if", "(", "!", "in_array", "(", "$", "table", "->", "getDriver", "(", ")", ",", "$", "this", "->", "drivers", ",", "...
Collecting all involved drivers.
[ "Collecting", "all", "involved", "drivers", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Schema/Reflector.php#L172-L179
45,604
spiral/database
src/Query/UpdateQuery.php
UpdateQuery.set
public function set(string $column, $value): UpdateQuery { $this->values[$column] = $value; return $this; }
php
public function set(string $column, $value): UpdateQuery { $this->values[$column] = $value; return $this; }
[ "public", "function", "set", "(", "string", "$", "column", ",", "$", "value", ")", ":", "UpdateQuery", "{", "$", "this", "->", "values", "[", "$", "column", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set update value. @param string $column @param mixed $value @return self|$this
[ "Set", "update", "value", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Query/UpdateQuery.php#L110-L115
45,605
spiral/database
src/Schema/AbstractIndex.php
AbstractIndex.columns
public function columns($columns): AbstractIndex { if (!is_array($columns)) { $columns = func_get_args(); } $this->columns = $columns; return $this; }
php
public function columns($columns): AbstractIndex { if (!is_array($columns)) { $columns = func_get_args(); } $this->columns = $columns; return $this; }
[ "public", "function", "columns", "(", "$", "columns", ")", ":", "AbstractIndex", "{", "if", "(", "!", "is_array", "(", "$", "columns", ")", ")", "{", "$", "columns", "=", "func_get_args", "(", ")", ";", "}", "$", "this", "->", "columns", "=", "$", ...
Change set of index forming columns. Method must support both array and string parameters. Example: $index->columns('key'); $index->columns('key', 'key2'); $index->columns(['key', 'key2']); @param string|array $columns Columns array or comma separated list of parameters. @return self
[ "Change", "set", "of", "index", "forming", "columns", ".", "Method", "must", "support", "both", "array", "and", "string", "parameters", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Schema/AbstractIndex.php#L95-L104
45,606
spiral/database
src/Schema/AbstractIndex.php
AbstractIndex.sqlStatement
public function sqlStatement(DriverInterface $driver, bool $includeTable = true): string { $statement = [$this->type == self::UNIQUE ? 'UNIQUE INDEX' : 'INDEX']; $statement[] = $driver->identifier($this->name); if ($includeTable) { $statement[] = "ON {$driver->identifier($this->table)}"; } //Wrapping column names $columns = implode(', ', array_map([$driver, 'identifier'], $this->columns)); $statement[] = "({$columns})"; return implode(' ', $statement); }
php
public function sqlStatement(DriverInterface $driver, bool $includeTable = true): string { $statement = [$this->type == self::UNIQUE ? 'UNIQUE INDEX' : 'INDEX']; $statement[] = $driver->identifier($this->name); if ($includeTable) { $statement[] = "ON {$driver->identifier($this->table)}"; } //Wrapping column names $columns = implode(', ', array_map([$driver, 'identifier'], $this->columns)); $statement[] = "({$columns})"; return implode(' ', $statement); }
[ "public", "function", "sqlStatement", "(", "DriverInterface", "$", "driver", ",", "bool", "$", "includeTable", "=", "true", ")", ":", "string", "{", "$", "statement", "=", "[", "$", "this", "->", "type", "==", "self", "::", "UNIQUE", "?", "'UNIQUE INDEX'",...
Index sql creation syntax. @param DriverInterface $driver @param bool $includeTable Include table ON statement (not required for inline index creation). @return string
[ "Index", "sql", "creation", "syntax", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Schema/AbstractIndex.php#L113-L129
45,607
spiral/database
src/Driver/SQLite/SQLiteHandler.php
SQLiteHandler.requiresRebuild
private function requiresRebuild(AbstractTable $table): bool { $comparator = $table->getComparator(); $difference = [ count($comparator->addedColumns()), count($comparator->droppedColumns()), count($comparator->alteredColumns()), count($comparator->addedForeignKeys()), count($comparator->droppedForeignKeys()), count($comparator->alteredForeignKeys()), ]; return array_sum($difference) != 0; }
php
private function requiresRebuild(AbstractTable $table): bool { $comparator = $table->getComparator(); $difference = [ count($comparator->addedColumns()), count($comparator->droppedColumns()), count($comparator->alteredColumns()), count($comparator->addedForeignKeys()), count($comparator->droppedForeignKeys()), count($comparator->alteredForeignKeys()), ]; return array_sum($difference) != 0; }
[ "private", "function", "requiresRebuild", "(", "AbstractTable", "$", "table", ")", ":", "bool", "{", "$", "comparator", "=", "$", "table", "->", "getComparator", "(", ")", ";", "$", "difference", "=", "[", "count", "(", "$", "comparator", "->", "addedColum...
Rebuild is required when columns or foreign keys are altered. @param AbstractTable $table @return bool
[ "Rebuild", "is", "required", "when", "columns", "or", "foreign", "keys", "are", "altered", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/SQLite/SQLiteHandler.php#L138-L153
45,608
spiral/database
src/Driver/SQLite/SQLiteHandler.php
SQLiteHandler.createTemporary
protected function createTemporary(AbstractTable $table): AbstractTable { //Temporary table is required to copy data over $temporary = clone $table; $temporary->setName('spiral_temp_' . $table->getName() . '_' . uniqid()); //We don't need any indexes in temporary table foreach ($temporary->getIndexes() as $index) { $temporary->dropIndex($index->getColumns()); } $this->createTable($temporary); return $temporary; }
php
protected function createTemporary(AbstractTable $table): AbstractTable { //Temporary table is required to copy data over $temporary = clone $table; $temporary->setName('spiral_temp_' . $table->getName() . '_' . uniqid()); //We don't need any indexes in temporary table foreach ($temporary->getIndexes() as $index) { $temporary->dropIndex($index->getColumns()); } $this->createTable($temporary); return $temporary; }
[ "protected", "function", "createTemporary", "(", "AbstractTable", "$", "table", ")", ":", "AbstractTable", "{", "//Temporary table is required to copy data over", "$", "temporary", "=", "clone", "$", "table", ";", "$", "temporary", "->", "setName", "(", "'spiral_temp_...
Temporary table based on parent. @param AbstractTable $table @return AbstractTable
[ "Temporary", "table", "based", "on", "parent", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/SQLite/SQLiteHandler.php#L161-L175
45,609
spiral/database
src/Driver/SQLite/SQLiteHandler.php
SQLiteHandler.copyData
private function copyData(string $source, string $to, array $mapping) { $sourceColumns = array_keys($mapping); $targetColumns = array_values($mapping); //Preparing mapping $sourceColumns = array_map([$this, 'identify'], $sourceColumns); $targetColumns = array_map([$this, 'identify'], $targetColumns); $query = sprintf( 'INSERT INTO %s (%s) SELECT %s FROM %s', $this->identify($to), implode(', ', $targetColumns), implode(', ', $sourceColumns), $this->identify($source) ); $this->run($query); }
php
private function copyData(string $source, string $to, array $mapping) { $sourceColumns = array_keys($mapping); $targetColumns = array_values($mapping); //Preparing mapping $sourceColumns = array_map([$this, 'identify'], $sourceColumns); $targetColumns = array_map([$this, 'identify'], $targetColumns); $query = sprintf( 'INSERT INTO %s (%s) SELECT %s FROM %s', $this->identify($to), implode(', ', $targetColumns), implode(', ', $sourceColumns), $this->identify($source) ); $this->run($query); }
[ "private", "function", "copyData", "(", "string", "$", "source", ",", "string", "$", "to", ",", "array", "$", "mapping", ")", "{", "$", "sourceColumns", "=", "array_keys", "(", "$", "mapping", ")", ";", "$", "targetColumns", "=", "array_values", "(", "$"...
Copy table data to another location. @see http://stackoverflow.com/questions/4007014/alter-column-in-sqlite @param string $source @param string $to @param array $mapping (destination => source) @throws HandlerException
[ "Copy", "table", "data", "to", "another", "location", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/SQLite/SQLiteHandler.php#L188-L206
45,610
spiral/database
src/Driver/SQLite/SQLiteHandler.php
SQLiteHandler.createMapping
private function createMapping(AbstractTable $source, AbstractTable $target) { $mapping = []; foreach ($target->getColumns() as $name => $column) { if ($source->hasColumn($name)) { $mapping[$name] = $column->getName(); } } return $mapping; }
php
private function createMapping(AbstractTable $source, AbstractTable $target) { $mapping = []; foreach ($target->getColumns() as $name => $column) { if ($source->hasColumn($name)) { $mapping[$name] = $column->getName(); } } return $mapping; }
[ "private", "function", "createMapping", "(", "AbstractTable", "$", "source", ",", "AbstractTable", "$", "target", ")", "{", "$", "mapping", "=", "[", "]", ";", "foreach", "(", "$", "target", "->", "getColumns", "(", ")", "as", "$", "name", "=>", "$", "...
Get mapping between new and initial columns. @param AbstractTable $source @param AbstractTable $target @return array
[ "Get", "mapping", "between", "new", "and", "initial", "columns", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/SQLite/SQLiteHandler.php#L215-L225
45,611
spiral/database
src/Query/Traits/JoinTrait.php
JoinTrait.on
public function on(...$args) { $this->createToken( 'AND', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWrapper() ); return $this; }
php
public function on(...$args) { $this->createToken( 'AND', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWrapper() ); return $this; }
[ "public", "function", "on", "(", "...", "$", "args", ")", "{", "$", "this", "->", "createToken", "(", "'AND'", ",", "$", "args", ",", "$", "this", "->", "joinTokens", "[", "$", "this", "->", "activeJoin", "]", "[", "'on'", "]", ",", "$", "this", ...
Simple ON condition with various set of arguments. Can only be used to link column values together, no parametric values allowed. @param mixed ...$args [(column, outer column), (column, operator, outer column)] @return $this @throws BuilderException
[ "Simple", "ON", "condition", "with", "various", "set", "of", "arguments", ".", "Can", "only", "be", "used", "to", "link", "column", "values", "together", "no", "parametric", "values", "allowed", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Query/Traits/JoinTrait.php#L230-L240
45,612
spiral/database
src/Query/Traits/JoinTrait.php
JoinTrait.andOn
public function andOn(...$args) { $this->createToken( 'AND', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWrapper() ); return $this; }
php
public function andOn(...$args) { $this->createToken( 'AND', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWrapper() ); return $this; }
[ "public", "function", "andOn", "(", "...", "$", "args", ")", "{", "$", "this", "->", "createToken", "(", "'AND'", ",", "$", "args", ",", "$", "this", "->", "joinTokens", "[", "$", "this", "->", "activeJoin", "]", "[", "'on'", "]", ",", "$", "this",...
Simple AND ON condition with various set of arguments. Can only be used to link column values together, no parametric values allowed. @param mixed ...$args [(column, outer column), (column, operator, outer column)] @return $this @throws BuilderException
[ "Simple", "AND", "ON", "condition", "with", "various", "set", "of", "arguments", ".", "Can", "only", "be", "used", "to", "link", "column", "values", "together", "no", "parametric", "values", "allowed", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Query/Traits/JoinTrait.php#L252-L262
45,613
spiral/database
src/Query/Traits/JoinTrait.php
JoinTrait.orOn
public function orOn(...$args) { $this->createToken( 'OR', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWrapper() ); return $this; }
php
public function orOn(...$args) { $this->createToken( 'OR', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWrapper() ); return $this; }
[ "public", "function", "orOn", "(", "...", "$", "args", ")", "{", "$", "this", "->", "createToken", "(", "'OR'", ",", "$", "args", ",", "$", "this", "->", "joinTokens", "[", "$", "this", "->", "activeJoin", "]", "[", "'on'", "]", ",", "$", "this", ...
Simple OR ON condition with various set of arguments. Can only be used to link column values together, no parametric values allowed. @param mixed ...$args [(column, outer column), (column, operator, outer column)] @return $this @throws BuilderException
[ "Simple", "OR", "ON", "condition", "with", "various", "set", "of", "arguments", ".", "Can", "only", "be", "used", "to", "link", "column", "values", "together", "no", "parametric", "values", "allowed", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Query/Traits/JoinTrait.php#L274-L284
45,614
spiral/database
src/Query/Traits/JoinTrait.php
JoinTrait.onWhere
public function onWhere(...$args) { $this->createToken( 'AND', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWhereWrapper() ); return $this; }
php
public function onWhere(...$args) { $this->createToken( 'AND', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWhereWrapper() ); return $this; }
[ "public", "function", "onWhere", "(", "...", "$", "args", ")", "{", "$", "this", "->", "createToken", "(", "'AND'", ",", "$", "args", ",", "$", "this", "->", "joinTokens", "[", "$", "this", "->", "activeJoin", "]", "[", "'on'", "]", ",", "$", "this...
Simple ON WHERE condition with various set of arguments. You can use parametric values in such methods. @param mixed ...$args [(column, value), (column, operator, value)] @return $this @throws BuilderException @see AbstractWhere
[ "Simple", "ON", "WHERE", "condition", "with", "various", "set", "of", "arguments", ".", "You", "can", "use", "parametric", "values", "in", "such", "methods", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Query/Traits/JoinTrait.php#L298-L308
45,615
spiral/database
src/Query/Traits/JoinTrait.php
JoinTrait.andOnWhere
public function andOnWhere(...$args) { $this->createToken( 'AND', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWhereWrapper() ); return $this; }
php
public function andOnWhere(...$args) { $this->createToken( 'AND', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWhereWrapper() ); return $this; }
[ "public", "function", "andOnWhere", "(", "...", "$", "args", ")", "{", "$", "this", "->", "createToken", "(", "'AND'", ",", "$", "args", ",", "$", "this", "->", "joinTokens", "[", "$", "this", "->", "activeJoin", "]", "[", "'on'", "]", ",", "$", "t...
Simple AND ON WHERE condition with various set of arguments. You can use parametric values in such methods. @param mixed ...$args [(column, value), (column, operator, value)] @return $this @throws BuilderException @see AbstractWhere
[ "Simple", "AND", "ON", "WHERE", "condition", "with", "various", "set", "of", "arguments", ".", "You", "can", "use", "parametric", "values", "in", "such", "methods", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Query/Traits/JoinTrait.php#L322-L332
45,616
spiral/database
src/Query/Traits/JoinTrait.php
JoinTrait.orOnWhere
public function orOnWhere(...$args) { $this->createToken( 'OR', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWhereWrapper() ); return $this; }
php
public function orOnWhere(...$args) { $this->createToken( 'OR', $args, $this->joinTokens[$this->activeJoin]['on'], $this->onWhereWrapper() ); return $this; }
[ "public", "function", "orOnWhere", "(", "...", "$", "args", ")", "{", "$", "this", "->", "createToken", "(", "'OR'", ",", "$", "args", ",", "$", "this", "->", "joinTokens", "[", "$", "this", "->", "activeJoin", "]", "[", "'on'", "]", ",", "$", "thi...
Simple OR ON WHERE condition with various set of arguments. You can use parametric values in such methods. @param mixed ...$args [(column, value), (column, operator, value)] @return $this @throws BuilderException @see AbstractWhere
[ "Simple", "OR", "ON", "WHERE", "condition", "with", "various", "set", "of", "arguments", ".", "You", "can", "use", "parametric", "values", "in", "such", "methods", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Query/Traits/JoinTrait.php#L346-L356
45,617
spiral/database
src/Query/Traits/JoinTrait.php
JoinTrait.onWhereWrapper
private function onWhereWrapper() { return function ($parameter) { if ($parameter instanceof FragmentInterface) { //We are only not creating bindings for plan fragments if (!$parameter instanceof ParameterInterface && !$parameter instanceof BuilderInterface) { return $parameter; } } if (is_array($parameter)) { throw new BuilderException('Arrays must be wrapped with Parameter instance'); } //Wrapping all values with ParameterInterface if (!$parameter instanceof ParameterInterface && !$parameter instanceof ExpressionInterface) { $parameter = new Parameter($parameter, Parameter::DETECT_TYPE); }; //Let's store to sent to driver when needed $this->onParameters[] = $parameter; return $parameter; }; }
php
private function onWhereWrapper() { return function ($parameter) { if ($parameter instanceof FragmentInterface) { //We are only not creating bindings for plan fragments if (!$parameter instanceof ParameterInterface && !$parameter instanceof BuilderInterface) { return $parameter; } } if (is_array($parameter)) { throw new BuilderException('Arrays must be wrapped with Parameter instance'); } //Wrapping all values with ParameterInterface if (!$parameter instanceof ParameterInterface && !$parameter instanceof ExpressionInterface) { $parameter = new Parameter($parameter, Parameter::DETECT_TYPE); }; //Let's store to sent to driver when needed $this->onParameters[] = $parameter; return $parameter; }; }
[ "private", "function", "onWhereWrapper", "(", ")", "{", "return", "function", "(", "$", "parameter", ")", "{", "if", "(", "$", "parameter", "instanceof", "FragmentInterface", ")", "{", "//We are only not creating bindings for plan fragments", "if", "(", "!", "$", ...
Applied to every potential parameter while ON WHERE tokens generation. @return \Closure
[ "Applied", "to", "every", "potential", "parameter", "while", "ON", "WHERE", "tokens", "generation", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Query/Traits/JoinTrait.php#L399-L423
45,618
spiral/database
src/Config/DatabaseConfig.php
DatabaseConfig.getDatabases
public function getDatabases(): array { $result = []; foreach (array_keys($this->config['databases'] ?? []) as $database) { $result[$database] = $this->getDatabase($database); } return $result; }
php
public function getDatabases(): array { $result = []; foreach (array_keys($this->config['databases'] ?? []) as $database) { $result[$database] = $this->getDatabase($database); } return $result; }
[ "public", "function", "getDatabases", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "config", "[", "'databases'", "]", "??", "[", "]", ")", "as", "$", "database", ")", "{", "$"...
Get named list of all databases. @return DatabasePartial[]
[ "Get", "named", "list", "of", "all", "databases", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Config/DatabaseConfig.php#L48-L56
45,619
spiral/database
src/Config/DatabaseConfig.php
DatabaseConfig.getDrivers
public function getDrivers(): array { $result = []; foreach (array_keys($this->config['connections'] ?? $this->config['drivers'] ?? []) as $driver) { $result[$driver] = $this->getDriver($driver); } return $result; }
php
public function getDrivers(): array { $result = []; foreach (array_keys($this->config['connections'] ?? $this->config['drivers'] ?? []) as $driver) { $result[$driver] = $this->getDriver($driver); } return $result; }
[ "public", "function", "getDrivers", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "config", "[", "'connections'", "]", "??", "$", "this", "->", "config", "[", "'drivers'", "]", "...
Get names list of all driver connections. @return Autowire[]
[ "Get", "names", "list", "of", "all", "driver", "connections", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Config/DatabaseConfig.php#L63-L71
45,620
spiral/database
src/Driver/SQLServer/SQLServerHandler.php
SQLServerHandler.alterColumn
public function alterColumn( AbstractTable $table, AbstractColumn $initial, AbstractColumn $column ) { if (!$initial instanceof SQLServerColumn || !$column instanceof SQLServerColumn) { throw new SchemaException('SQlServer handler can work only with SQLServer columns'); } //In SQLServer we have to drop ALL related indexes and foreign keys while //applying type change... yeah... $indexesBackup = []; $foreignBackup = []; foreach ($table->getIndexes() as $index) { if (in_array($column->getName(), $index->getColumns())) { $indexesBackup[] = $index; $this->dropIndex($table, $index); } } foreach ($table->getForeignKeys() as $foreign) { if ($column->getName() == $foreign->getColumn()) { $foreignBackup[] = $foreign; $this->dropForeignKey($table, $foreign); } } //Column will recreate needed constraints foreach ($column->getConstraints() as $constraint) { $this->dropConstrain($table, $constraint); } //Rename is separate operation if ($column->getName() != $initial->getName()) { $this->renameColumn($table, $initial, $column); //This call is required to correctly built set of alter operations $initial->setName($column->getName()); } foreach ($column->alterOperations($this->driver, $initial) as $operation) { $this->run("ALTER TABLE {$this->identify($table)} {$operation}"); } //Restoring indexes and foreign keys foreach ($indexesBackup as $index) { $this->createIndex($table, $index); } foreach ($foreignBackup as $foreign) { $this->createForeignKey($table, $foreign); } }
php
public function alterColumn( AbstractTable $table, AbstractColumn $initial, AbstractColumn $column ) { if (!$initial instanceof SQLServerColumn || !$column instanceof SQLServerColumn) { throw new SchemaException('SQlServer handler can work only with SQLServer columns'); } //In SQLServer we have to drop ALL related indexes and foreign keys while //applying type change... yeah... $indexesBackup = []; $foreignBackup = []; foreach ($table->getIndexes() as $index) { if (in_array($column->getName(), $index->getColumns())) { $indexesBackup[] = $index; $this->dropIndex($table, $index); } } foreach ($table->getForeignKeys() as $foreign) { if ($column->getName() == $foreign->getColumn()) { $foreignBackup[] = $foreign; $this->dropForeignKey($table, $foreign); } } //Column will recreate needed constraints foreach ($column->getConstraints() as $constraint) { $this->dropConstrain($table, $constraint); } //Rename is separate operation if ($column->getName() != $initial->getName()) { $this->renameColumn($table, $initial, $column); //This call is required to correctly built set of alter operations $initial->setName($column->getName()); } foreach ($column->alterOperations($this->driver, $initial) as $operation) { $this->run("ALTER TABLE {$this->identify($table)} {$operation}"); } //Restoring indexes and foreign keys foreach ($indexesBackup as $index) { $this->createIndex($table, $index); } foreach ($foreignBackup as $foreign) { $this->createForeignKey($table, $foreign); } }
[ "public", "function", "alterColumn", "(", "AbstractTable", "$", "table", ",", "AbstractColumn", "$", "initial", ",", "AbstractColumn", "$", "column", ")", "{", "if", "(", "!", "$", "initial", "instanceof", "SQLServerColumn", "||", "!", "$", "column", "instance...
Driver specific column alter command. @param AbstractTable $table @param AbstractColumn $initial @param AbstractColumn $column @throws SchemaException
[ "Driver", "specific", "column", "alter", "command", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/SQLServer/SQLServerHandler.php#L46-L99
45,621
spiral/database
src/Driver/SQLServer/Schema/SQLServerColumn.php
SQLServerColumn.alterOperations
public function alterOperations(DriverInterface $driver, AbstractColumn $initial): array { $operations = []; $currentType = [ $this->type, $this->size, $this->precision, $this->scale, $this->nullable, ]; $initType = [ $initial->type, $initial->size, $initial->precision, $initial->scale, $initial->nullable, ]; if ($currentType != $initType) { if ($this->getAbstractType() == 'enum') { //Getting longest value $enumSize = $this->size; foreach ($this->enumValues as $value) { $enumSize = max($enumSize, strlen($value)); } $type = "ALTER COLUMN {$driver->identifier($this->getName())} varchar($enumSize)"; $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL'); } else { $type = "ALTER COLUMN {$driver->identifier($this->getName())} {$this->type}"; if (!empty($this->size)) { $type .= "($this->size)"; } elseif ($this->type == 'varchar' || $this->type == 'varbinary') { $type .= '(max)'; } elseif (!empty($this->precision)) { $type .= "($this->precision, $this->scale)"; } $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL'); } } //Constraint should be already removed it this moment (see doColumnChange in TableSchema) if ($this->hasDefaultValue()) { $operations[] = "ADD CONSTRAINT {$this->defaultConstrain()} " . "DEFAULT {$this->quoteDefault($driver)} " . "FOR {$driver->identifier($this->getName())}"; } //Constraint should be already removed it this moment (see alterColumn in SQLServerHandler) if ($this->getAbstractType() == 'enum') { $operations[] = "ADD {$this->enumStatement($driver)}"; } return $operations; }
php
public function alterOperations(DriverInterface $driver, AbstractColumn $initial): array { $operations = []; $currentType = [ $this->type, $this->size, $this->precision, $this->scale, $this->nullable, ]; $initType = [ $initial->type, $initial->size, $initial->precision, $initial->scale, $initial->nullable, ]; if ($currentType != $initType) { if ($this->getAbstractType() == 'enum') { //Getting longest value $enumSize = $this->size; foreach ($this->enumValues as $value) { $enumSize = max($enumSize, strlen($value)); } $type = "ALTER COLUMN {$driver->identifier($this->getName())} varchar($enumSize)"; $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL'); } else { $type = "ALTER COLUMN {$driver->identifier($this->getName())} {$this->type}"; if (!empty($this->size)) { $type .= "($this->size)"; } elseif ($this->type == 'varchar' || $this->type == 'varbinary') { $type .= '(max)'; } elseif (!empty($this->precision)) { $type .= "($this->precision, $this->scale)"; } $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL'); } } //Constraint should be already removed it this moment (see doColumnChange in TableSchema) if ($this->hasDefaultValue()) { $operations[] = "ADD CONSTRAINT {$this->defaultConstrain()} " . "DEFAULT {$this->quoteDefault($driver)} " . "FOR {$driver->identifier($this->getName())}"; } //Constraint should be already removed it this moment (see alterColumn in SQLServerHandler) if ($this->getAbstractType() == 'enum') { $operations[] = "ADD {$this->enumStatement($driver)}"; } return $operations; }
[ "public", "function", "alterOperations", "(", "DriverInterface", "$", "driver", ",", "AbstractColumn", "$", "initial", ")", ":", "array", "{", "$", "operations", "=", "[", "]", ";", "$", "currentType", "=", "[", "$", "this", "->", "type", ",", "$", "this...
Generate set of operations need to change column. We are expecting that column constrains will be dropped separately. @param DriverInterface $driver @param AbstractColumn $initial @return array
[ "Generate", "set", "of", "operations", "need", "to", "change", "column", ".", "We", "are", "expecting", "that", "column", "constrains", "will", "be", "dropped", "separately", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/SQLServer/Schema/SQLServerColumn.php#L243-L301
45,622
spiral/database
src/Driver/SQLServer/Schema/SQLServerColumn.php
SQLServerColumn.enumStatement
private function enumStatement(DriverInterface $driver): string { $enumValues = []; foreach ($this->enumValues as $value) { $enumValues[] = $driver->quote($value); } $constrain = $driver->identifier($this->enumConstraint()); $column = $driver->identifier($this->getName()); $enumValues = implode(', ', $enumValues); return "CONSTRAINT {$constrain} CHECK ({$column} IN ({$enumValues}))"; }
php
private function enumStatement(DriverInterface $driver): string { $enumValues = []; foreach ($this->enumValues as $value) { $enumValues[] = $driver->quote($value); } $constrain = $driver->identifier($this->enumConstraint()); $column = $driver->identifier($this->getName()); $enumValues = implode(', ', $enumValues); return "CONSTRAINT {$constrain} CHECK ({$column} IN ({$enumValues}))"; }
[ "private", "function", "enumStatement", "(", "DriverInterface", "$", "driver", ")", ":", "string", "{", "$", "enumValues", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "enumValues", "as", "$", "value", ")", "{", "$", "enumValues", "[", "]", "...
In SQLServer we can emulate enums similar way as in Postgres via column constrain. @param DriverInterface $driver @return string
[ "In", "SQLServer", "we", "can", "emulate", "enums", "similar", "way", "as", "in", "Postgres", "via", "column", "constrain", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/SQLServer/Schema/SQLServerColumn.php#L337-L349
45,623
spiral/database
src/Driver/SQLServer/Schema/SQLServerColumn.php
SQLServerColumn.resolveEnum
private static function resolveEnum( DriverInterface $driver, array $schema, SQLServerColumn $column ) { $query = 'SELECT object_definition([o].[object_id]) AS [definition], ' . "OBJECT_NAME([o].[object_id]) AS [name]\nFROM [sys].[objects] AS [o]\n" . "JOIN [sys].[sysconstraints] AS [c] ON [o].[object_id] = [c].[constid]\n" . "WHERE [type_desc] = 'CHECK_CONSTRAINT' AND [parent_object_id] = ? AND [c].[colid] = ?"; $constraints = $driver->query($query, [$schema['object_id'], $schema['column_id']]); foreach ($constraints as $constraint) { $column->enumConstraint = $constraint['name']; $column->constrainedEnum = true; $name = preg_quote($driver->identifier($column->getName())); //We made some assumptions here... if (preg_match_all( '/' . $name . '=[\']?([^\']+)[\']?/i', $constraint['definition'], $matches )) { //Fetching enum values $column->enumValues = $matches[1]; sort($column->enumValues); } } }
php
private static function resolveEnum( DriverInterface $driver, array $schema, SQLServerColumn $column ) { $query = 'SELECT object_definition([o].[object_id]) AS [definition], ' . "OBJECT_NAME([o].[object_id]) AS [name]\nFROM [sys].[objects] AS [o]\n" . "JOIN [sys].[sysconstraints] AS [c] ON [o].[object_id] = [c].[constid]\n" . "WHERE [type_desc] = 'CHECK_CONSTRAINT' AND [parent_object_id] = ? AND [c].[colid] = ?"; $constraints = $driver->query($query, [$schema['object_id'], $schema['column_id']]); foreach ($constraints as $constraint) { $column->enumConstraint = $constraint['name']; $column->constrainedEnum = true; $name = preg_quote($driver->identifier($column->getName())); //We made some assumptions here... if (preg_match_all( '/' . $name . '=[\']?([^\']+)[\']?/i', $constraint['definition'], $matches )) { //Fetching enum values $column->enumValues = $matches[1]; sort($column->enumValues); } } }
[ "private", "static", "function", "resolveEnum", "(", "DriverInterface", "$", "driver", ",", "array", "$", "schema", ",", "SQLServerColumn", "$", "column", ")", "{", "$", "query", "=", "'SELECT object_definition([o].[object_id]) AS [definition], '", ".", "\"OBJECT_NAME([...
Resolve enum values if any. @param DriverInterface $driver @param array $schema @param SQLServerColumn $column
[ "Resolve", "enum", "values", "if", "any", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/SQLServer/Schema/SQLServerColumn.php#L443-L472
45,624
spiral/database
src/Driver/Handler.php
Handler.run
protected function run(string $statement, array $parameters = []): int { try { return $this->driver->execute($statement, $parameters); } catch (StatementException $e) { throw new HandlerException($e); } }
php
protected function run(string $statement, array $parameters = []): int { try { return $this->driver->execute($statement, $parameters); } catch (StatementException $e) { throw new HandlerException($e); } }
[ "protected", "function", "run", "(", "string", "$", "statement", ",", "array", "$", "parameters", "=", "[", "]", ")", ":", "int", "{", "try", "{", "return", "$", "this", "->", "driver", "->", "execute", "(", "$", "statement", ",", "$", "parameters", ...
Execute statement. @param string $statement @param array $parameters @return int @throws HandlerException
[ "Execute", "statement", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/Handler.php#L250-L257
45,625
spiral/database
src/Driver/Handler.php
Handler.identify
protected function identify($element): string { if (is_string($element)) { return $this->driver->identifier($element); } if (!$element instanceof ElementInterface && !$element instanceof AbstractTable) { throw new InvalidArgumentException("Invalid argument type"); } return $this->driver->identifier($element->getName()); }
php
protected function identify($element): string { if (is_string($element)) { return $this->driver->identifier($element); } if (!$element instanceof ElementInterface && !$element instanceof AbstractTable) { throw new InvalidArgumentException("Invalid argument type"); } return $this->driver->identifier($element->getName()); }
[ "protected", "function", "identify", "(", "$", "element", ")", ":", "string", "{", "if", "(", "is_string", "(", "$", "element", ")", ")", "{", "return", "$", "this", "->", "driver", "->", "identifier", "(", "$", "element", ")", ";", "}", "if", "(", ...
Create element identifier. @param ElementInterface|AbstractTable|string $element @return string
[ "Create", "element", "identifier", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/Handler.php#L265-L276
45,626
spiral/database
src/Driver/Quoter.php
Quoter.expression
protected function expression(string $identifier): string { return preg_replace_callback('/([a-z][0-9_a-z\.]*\(?)/i', function ($match) { $identifier = $match[1]; //Function name if ($this->hasExpressions($identifier)) { return $identifier; } return $this->quote($identifier); }, $identifier); }
php
protected function expression(string $identifier): string { return preg_replace_callback('/([a-z][0-9_a-z\.]*\(?)/i', function ($match) { $identifier = $match[1]; //Function name if ($this->hasExpressions($identifier)) { return $identifier; } return $this->quote($identifier); }, $identifier); }
[ "protected", "function", "expression", "(", "string", "$", "identifier", ")", ":", "string", "{", "return", "preg_replace_callback", "(", "'/([a-z][0-9_a-z\\.]*\\(?)/i'", ",", "function", "(", "$", "match", ")", "{", "$", "identifier", "=", "$", "match", "[", ...
Quoting columns and tables in complex expression. @param string $identifier @return string
[ "Quoting", "columns", "and", "tables", "in", "complex", "expression", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/Quoter.php#L106-L118
45,627
spiral/database
src/Driver/Quoter.php
Quoter.aliasing
protected function aliasing(string $identifier, string $alias, bool $isTable): string { $quoted = $this->quote($identifier, $isTable) . ' AS ' . $this->driver->identifier($alias); if ($isTable && strpos($identifier, '.') === false) { //We have to apply operation post factum to prevent self aliasing (name AS name) //when db has prefix, expected: prefix_name as name) $this->registerAlias($alias, $identifier); } return $quoted; }
php
protected function aliasing(string $identifier, string $alias, bool $isTable): string { $quoted = $this->quote($identifier, $isTable) . ' AS ' . $this->driver->identifier($alias); if ($isTable && strpos($identifier, '.') === false) { //We have to apply operation post factum to prevent self aliasing (name AS name) //when db has prefix, expected: prefix_name as name) $this->registerAlias($alias, $identifier); } return $quoted; }
[ "protected", "function", "aliasing", "(", "string", "$", "identifier", ",", "string", "$", "alias", ",", "bool", "$", "isTable", ")", ":", "string", "{", "$", "quoted", "=", "$", "this", "->", "quote", "(", "$", "identifier", ",", "$", "isTable", ")", ...
Handle "IDENTIFIER AS ALIAS" expression. @param string $identifier @param string $alias @param bool $isTable @return string
[ "Handle", "IDENTIFIER", "AS", "ALIAS", "expression", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/Quoter.php#L128-L139
45,628
spiral/database
src/Driver/Quoter.php
Quoter.hasExpressions
protected function hasExpressions(string $string): bool { foreach (self::STOPS as $symbol) { if (strpos($string, $symbol) !== false) { return true; } } return false; }
php
protected function hasExpressions(string $string): bool { foreach (self::STOPS as $symbol) { if (strpos($string, $symbol) !== false) { return true; } } return false; }
[ "protected", "function", "hasExpressions", "(", "string", "$", "string", ")", ":", "bool", "{", "foreach", "(", "self", "::", "STOPS", "as", "$", "symbol", ")", "{", "if", "(", "strpos", "(", "$", "string", ",", "$", "symbol", ")", "!==", "false", ")...
Check if string has expression markers. @param string $string @return bool
[ "Check", "if", "string", "has", "expression", "markers", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/Quoter.php#L182-L191
45,629
spiral/database
src/Driver/Postgres/Schema/PostgresColumn.php
PostgresColumn.alterOperations
public function alterOperations(DriverInterface $driver, AbstractColumn $initial): array { $operations = []; //To simplify comparation $currentType = [$this->type, $this->size, $this->precision, $this->scale]; $initialType = [$initial->type, $initial->size, $initial->precision, $initial->scale]; $identifier = $driver->identifier($this->getName()); /* * This block defines column type and all variations. */ if ($currentType != $initialType) { if ($this->getAbstractType() == 'enum') { //Getting longest value $enumSize = $this->size; foreach ($this->enumValues as $value) { $enumSize = max($enumSize, strlen($value)); } $type = "ALTER COLUMN {$identifier} TYPE character varying($enumSize)"; $operations[] = $type; } else { $type = "ALTER COLUMN {$identifier} TYPE {$this->type}"; if (!empty($this->size)) { $type .= "($this->size)"; } elseif (!empty($this->precision)) { $type .= "($this->precision, $this->scale)"; } //Required to perform cross conversion $operations[] = "{$type} USING {$identifier}::{$this->type}"; } } //Dropping enum constrain before any operation if ($initial->getAbstractType() == 'enum' && $this->constrained) { $operations[] = 'DROP CONSTRAINT ' . $driver->identifier($this->enumConstraint()); } //Default value set and dropping if ($initial->defaultValue != $this->defaultValue) { if (is_null($this->defaultValue)) { $operations[] = "ALTER COLUMN {$identifier} DROP DEFAULT"; } else { $operations[] = "ALTER COLUMN {$identifier} SET DEFAULT {$this->quoteDefault($driver)}"; } } //Nullable option if ($initial->nullable != $this->nullable) { $operations[] = "ALTER COLUMN {$identifier} " . (!$this->nullable ? 'SET' : 'DROP') . ' NOT NULL'; } if ($this->getAbstractType() == 'enum') { $enumValues = []; foreach ($this->enumValues as $value) { $enumValues[] = $driver->quote($value); } $operations[] = "ADD CONSTRAINT {$driver->identifier($this->enumConstraint())} " . "CHECK ({$identifier} IN (" . implode(', ', $enumValues) . '))'; } return $operations; }
php
public function alterOperations(DriverInterface $driver, AbstractColumn $initial): array { $operations = []; //To simplify comparation $currentType = [$this->type, $this->size, $this->precision, $this->scale]; $initialType = [$initial->type, $initial->size, $initial->precision, $initial->scale]; $identifier = $driver->identifier($this->getName()); /* * This block defines column type and all variations. */ if ($currentType != $initialType) { if ($this->getAbstractType() == 'enum') { //Getting longest value $enumSize = $this->size; foreach ($this->enumValues as $value) { $enumSize = max($enumSize, strlen($value)); } $type = "ALTER COLUMN {$identifier} TYPE character varying($enumSize)"; $operations[] = $type; } else { $type = "ALTER COLUMN {$identifier} TYPE {$this->type}"; if (!empty($this->size)) { $type .= "($this->size)"; } elseif (!empty($this->precision)) { $type .= "($this->precision, $this->scale)"; } //Required to perform cross conversion $operations[] = "{$type} USING {$identifier}::{$this->type}"; } } //Dropping enum constrain before any operation if ($initial->getAbstractType() == 'enum' && $this->constrained) { $operations[] = 'DROP CONSTRAINT ' . $driver->identifier($this->enumConstraint()); } //Default value set and dropping if ($initial->defaultValue != $this->defaultValue) { if (is_null($this->defaultValue)) { $operations[] = "ALTER COLUMN {$identifier} DROP DEFAULT"; } else { $operations[] = "ALTER COLUMN {$identifier} SET DEFAULT {$this->quoteDefault($driver)}"; } } //Nullable option if ($initial->nullable != $this->nullable) { $operations[] = "ALTER COLUMN {$identifier} " . (!$this->nullable ? 'SET' : 'DROP') . ' NOT NULL'; } if ($this->getAbstractType() == 'enum') { $enumValues = []; foreach ($this->enumValues as $value) { $enumValues[] = $driver->quote($value); } $operations[] = "ADD CONSTRAINT {$driver->identifier($this->enumConstraint())} " . "CHECK ({$identifier} IN (" . implode(', ', $enumValues) . '))'; } return $operations; }
[ "public", "function", "alterOperations", "(", "DriverInterface", "$", "driver", ",", "AbstractColumn", "$", "initial", ")", ":", "array", "{", "$", "operations", "=", "[", "]", ";", "//To simplify comparation", "$", "currentType", "=", "[", "$", "this", "->", ...
Generate set of operations need to change column. @param DriverInterface $driver @param AbstractColumn $initial @return array
[ "Generate", "set", "of", "operations", "need", "to", "change", "column", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/Postgres/Schema/PostgresColumn.php#L229-L296
45,630
spiral/database
src/Driver/Postgres/Schema/PostgresColumn.php
PostgresColumn.resolveConstrains
private static function resolveConstrains( DriverInterface $driver, $tableOID, PostgresColumn $column ) { $query = "SELECT conname, consrc FROM pg_constraint WHERE conrelid = ? AND contype = 'c' AND " . "(consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ?)"; $constraints = $driver->query($query, [ $tableOID, '(' . $column->name . '%', '("' . $column->name . '%', '(("' . $column->name . '%', '(("' . $column->name . '%', //Postgres magic $column->name . '::text%', '%(' . $column->name . ')::text%' ]); foreach ($constraints as $constraint) { if (preg_match('/ARRAY\[([^\]]+)\]/', $constraint['consrc'], $matches)) { $enumValues = explode(',', $matches[1]); foreach ($enumValues as &$value) { if (preg_match("/^'?(.*?)'?::(.+)/", trim($value, ' ()'), $matches)) { //In database: 'value'::TYPE $value = $matches[1]; } unset($value); } $column->enumValues = $enumValues; $column->constrainName = $constraint['conname']; $column->constrained = true; } } }
php
private static function resolveConstrains( DriverInterface $driver, $tableOID, PostgresColumn $column ) { $query = "SELECT conname, consrc FROM pg_constraint WHERE conrelid = ? AND contype = 'c' AND " . "(consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ? OR consrc LIKE ?)"; $constraints = $driver->query($query, [ $tableOID, '(' . $column->name . '%', '("' . $column->name . '%', '(("' . $column->name . '%', '(("' . $column->name . '%', //Postgres magic $column->name . '::text%', '%(' . $column->name . ')::text%' ]); foreach ($constraints as $constraint) { if (preg_match('/ARRAY\[([^\]]+)\]/', $constraint['consrc'], $matches)) { $enumValues = explode(',', $matches[1]); foreach ($enumValues as &$value) { if (preg_match("/^'?(.*?)'?::(.+)/", trim($value, ' ()'), $matches)) { //In database: 'value'::TYPE $value = $matches[1]; } unset($value); } $column->enumValues = $enumValues; $column->constrainName = $constraint['conname']; $column->constrained = true; } } }
[ "private", "static", "function", "resolveConstrains", "(", "DriverInterface", "$", "driver", ",", "$", "tableOID", ",", "PostgresColumn", "$", "column", ")", "{", "$", "query", "=", "\"SELECT conname, consrc FROM pg_constraint WHERE conrelid = ? AND contype = 'c' AND \"", "...
Resolving enum constrain and converting it into proper enum values set. @param DriverInterface $driver @param string|int $tableOID @param PostgresColumn $column
[ "Resolving", "enum", "constrain", "and", "converting", "it", "into", "proper", "enum", "values", "set", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/Postgres/Schema/PostgresColumn.php#L415-L451
45,631
spiral/database
src/Driver/Postgres/Schema/PostgresColumn.php
PostgresColumn.resolveEnum
private static function resolveEnum(DriverInterface $driver, PostgresColumn $column) { $range = $driver->query('SELECT enum_range(NULL::' . $column->type . ')')->fetchColumn(0); $column->enumValues = explode(',', substr($range, 1, -1)); if (!empty($column->defaultValue)) { //In database: 'value'::enumType $column->defaultValue = substr( $column->defaultValue, 1, strpos($column->defaultValue, $column->type) - 4 ); } }
php
private static function resolveEnum(DriverInterface $driver, PostgresColumn $column) { $range = $driver->query('SELECT enum_range(NULL::' . $column->type . ')')->fetchColumn(0); $column->enumValues = explode(',', substr($range, 1, -1)); if (!empty($column->defaultValue)) { //In database: 'value'::enumType $column->defaultValue = substr( $column->defaultValue, 1, strpos($column->defaultValue, $column->type) - 4 ); } }
[ "private", "static", "function", "resolveEnum", "(", "DriverInterface", "$", "driver", ",", "PostgresColumn", "$", "column", ")", "{", "$", "range", "=", "$", "driver", "->", "query", "(", "'SELECT enum_range(NULL::'", ".", "$", "column", "->", "type", ".", ...
Resolve native ENUM type if presented. @param DriverInterface $driver @param PostgresColumn $column
[ "Resolve", "native", "ENUM", "type", "if", "presented", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/Postgres/Schema/PostgresColumn.php#L459-L473
45,632
spiral/database
src/Driver/Postgres/PostgresDriver.php
PostgresDriver.getPrimary
public function getPrimary(string $prefix, string $table): ?string { $name = $prefix . $table; if (array_key_exists($name, $this->primaryKeys)) { return $this->primaryKeys[$name]; } if (!$this->hasTable($name)) { throw new DriverException( "Unable to fetch table primary key, no such table '{$name}' exists" ); } $this->primaryKeys[$name] = $this->getSchema($table, $prefix)->getPrimaryKeys(); if (count($this->primaryKeys[$name]) === 1) { //We do support only single primary key $this->primaryKeys[$name] = $this->primaryKeys[$name][0]; } else { $this->primaryKeys[$name] = null; } return $this->primaryKeys[$name]; }
php
public function getPrimary(string $prefix, string $table): ?string { $name = $prefix . $table; if (array_key_exists($name, $this->primaryKeys)) { return $this->primaryKeys[$name]; } if (!$this->hasTable($name)) { throw new DriverException( "Unable to fetch table primary key, no such table '{$name}' exists" ); } $this->primaryKeys[$name] = $this->getSchema($table, $prefix)->getPrimaryKeys(); if (count($this->primaryKeys[$name]) === 1) { //We do support only single primary key $this->primaryKeys[$name] = $this->primaryKeys[$name][0]; } else { $this->primaryKeys[$name] = null; } return $this->primaryKeys[$name]; }
[ "public", "function", "getPrimary", "(", "string", "$", "prefix", ",", "string", "$", "table", ")", ":", "?", "string", "{", "$", "name", "=", "$", "prefix", ".", "$", "table", ";", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", ...
Get singular primary key associated with desired table. Used to emulate last insert id. @param string $prefix Database prefix if any. @param string $table Fully specified table name, including postfix. @return string|null @throws DriverException
[ "Get", "singular", "primary", "key", "associated", "with", "desired", "table", ".", "Used", "to", "emulate", "last", "insert", "id", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/Postgres/PostgresDriver.php#L81-L103
45,633
spiral/database
src/Schema/AbstractForeignKey.php
AbstractForeignKey.references
public function references( string $table, string $column = 'id', bool $forcePrefix = true ): AbstractForeignKey { $this->foreignTable = ($forcePrefix ? $this->tablePrefix : '') . $table; $this->foreignKey = $column; return $this; }
php
public function references( string $table, string $column = 'id', bool $forcePrefix = true ): AbstractForeignKey { $this->foreignTable = ($forcePrefix ? $this->tablePrefix : '') . $table; $this->foreignKey = $column; return $this; }
[ "public", "function", "references", "(", "string", "$", "table", ",", "string", "$", "column", "=", "'id'", ",", "bool", "$", "forcePrefix", "=", "true", ")", ":", "AbstractForeignKey", "{", "$", "this", "->", "foreignTable", "=", "(", "$", "forcePrefix", ...
Set foreign table name and key local column must reference to. Make sure local and foreign column types are identical. @param string $table Foreign table name with or without database prefix (see 3rd argument). @param string $column Foreign key name (id by default). @param bool $forcePrefix When true foreign table will get same prefix as table being modified. @return self
[ "Set", "foreign", "table", "name", "and", "key", "local", "column", "must", "reference", "to", ".", "Make", "sure", "local", "and", "foreign", "column", "types", "are", "identical", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Schema/AbstractForeignKey.php#L144-L153
45,634
spiral/database
src/Schema/AbstractForeignKey.php
AbstractForeignKey.onDelete
public function onDelete(string $rule = self::NO_ACTION): AbstractForeignKey { $this->deleteRule = strtoupper($rule); return $this; }
php
public function onDelete(string $rule = self::NO_ACTION): AbstractForeignKey { $this->deleteRule = strtoupper($rule); return $this; }
[ "public", "function", "onDelete", "(", "string", "$", "rule", "=", "self", "::", "NO_ACTION", ")", ":", "AbstractForeignKey", "{", "$", "this", "->", "deleteRule", "=", "strtoupper", "(", "$", "rule", ")", ";", "return", "$", "this", ";", "}" ]
Set foreign key delete behaviour. @param string $rule Possible values: NO ACTION, CASCADE, etc (driver specific). @return self
[ "Set", "foreign", "key", "delete", "behaviour", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Schema/AbstractForeignKey.php#L161-L166
45,635
spiral/database
src/Schema/AbstractForeignKey.php
AbstractForeignKey.onUpdate
public function onUpdate(string $rule = self::NO_ACTION): AbstractForeignKey { $this->updateRule = strtoupper($rule); return $this; }
php
public function onUpdate(string $rule = self::NO_ACTION): AbstractForeignKey { $this->updateRule = strtoupper($rule); return $this; }
[ "public", "function", "onUpdate", "(", "string", "$", "rule", "=", "self", "::", "NO_ACTION", ")", ":", "AbstractForeignKey", "{", "$", "this", "->", "updateRule", "=", "strtoupper", "(", "$", "rule", ")", ";", "return", "$", "this", ";", "}" ]
Set foreign key update behaviour. @param string $rule Possible values: NO ACTION, CASCADE, etc (driver specific). @return self
[ "Set", "foreign", "key", "update", "behaviour", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Schema/AbstractForeignKey.php#L174-L179
45,636
spiral/database
src/Driver/SQLite/Schema/SQLiteForeign.php
SQLiteForeign.compare
public function compare(AbstractForeignKey $initial): bool { return $this->getColumn() == $initial->getColumn() && $this->getForeignTable() == $initial->getForeignTable() && $this->getForeignKey() == $initial->getForeignKey() && $this->getUpdateRule() == $initial->getUpdateRule() && $this->getDeleteRule() == $initial->getDeleteRule(); }
php
public function compare(AbstractForeignKey $initial): bool { return $this->getColumn() == $initial->getColumn() && $this->getForeignTable() == $initial->getForeignTable() && $this->getForeignKey() == $initial->getForeignKey() && $this->getUpdateRule() == $initial->getUpdateRule() && $this->getDeleteRule() == $initial->getDeleteRule(); }
[ "public", "function", "compare", "(", "AbstractForeignKey", "$", "initial", ")", ":", "bool", "{", "return", "$", "this", "->", "getColumn", "(", ")", "==", "$", "initial", "->", "getColumn", "(", ")", "&&", "$", "this", "->", "getForeignTable", "(", ")"...
Name insensitive compare. @param AbstractForeignKey $initial @return bool
[ "Name", "insensitive", "compare", "." ]
93a6010feadf24a41af39c46346737d5c532e57f
https://github.com/spiral/database/blob/93a6010feadf24a41af39c46346737d5c532e57f/src/Driver/SQLite/Schema/SQLiteForeign.php#L52-L59
45,637
gamajo/genesis-theme-toolkit
src/Layouts.php
Layouts.apply
public function apply() { if ($this->config->hasKey(self::REGISTER)) { $registerConfig = $this->config->getSubConfig(self::REGISTER); $this->register($registerConfig->getArrayCopy()); } if ($this->config->hasKey(self::UNREGISTER)) { $unregisterConfig = $this->config->getSubConfig(self::UNREGISTER); $this->unregister($unregisterConfig->getArrayCopy()); } if ($this->config->hasKey(self::DEFAULTLAYOUT)) { $this->setDefault($this->config->getKey(self::DEFAULTLAYOUT)); } }
php
public function apply() { if ($this->config->hasKey(self::REGISTER)) { $registerConfig = $this->config->getSubConfig(self::REGISTER); $this->register($registerConfig->getArrayCopy()); } if ($this->config->hasKey(self::UNREGISTER)) { $unregisterConfig = $this->config->getSubConfig(self::UNREGISTER); $this->unregister($unregisterConfig->getArrayCopy()); } if ($this->config->hasKey(self::DEFAULTLAYOUT)) { $this->setDefault($this->config->getKey(self::DEFAULTLAYOUT)); } }
[ "public", "function", "apply", "(", ")", "{", "if", "(", "$", "this", "->", "config", "->", "hasKey", "(", "self", "::", "REGISTER", ")", ")", "{", "$", "registerConfig", "=", "$", "this", "->", "config", "->", "getSubConfig", "(", "self", "::", "REG...
Apply layout registrations and unregistrations.
[ "Apply", "layout", "registrations", "and", "unregistrations", "." ]
051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff
https://github.com/gamajo/genesis-theme-toolkit/blob/051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff/src/Layouts.php#L63-L78
45,638
gamajo/genesis-theme-toolkit
src/Layouts.php
Layouts.register
protected function register(array $args) { array_walk($args, function (array $value, string $key) { \genesis_register_layout($key, $value); }); }
php
protected function register(array $args) { array_walk($args, function (array $value, string $key) { \genesis_register_layout($key, $value); }); }
[ "protected", "function", "register", "(", "array", "$", "args", ")", "{", "array_walk", "(", "$", "args", ",", "function", "(", "array", "$", "value", ",", "string", "$", "key", ")", "{", "\\", "genesis_register_layout", "(", "$", "key", ",", "$", "val...
Register a new Genesis layout for given keys and values. @param array $args Keys and their values.
[ "Register", "a", "new", "Genesis", "layout", "for", "given", "keys", "and", "values", "." ]
051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff
https://github.com/gamajo/genesis-theme-toolkit/blob/051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff/src/Layouts.php#L85-L90
45,639
php-yaoi/php-yaoi
src/Service.php
Service.getInstance
public static function getInstance($identifier = self::PRIMARY) { $serviceClassName = get_called_class(); return self::findOrCreateInstance($serviceClassName, $identifier); }
php
public static function getInstance($identifier = self::PRIMARY) { $serviceClassName = get_called_class(); return self::findOrCreateInstance($serviceClassName, $identifier); }
[ "public", "static", "function", "getInstance", "(", "$", "identifier", "=", "self", "::", "PRIMARY", ")", "{", "$", "serviceClassName", "=", "get_called_class", "(", ")", ";", "return", "self", "::", "findOrCreateInstance", "(", "$", "serviceClassName", ",", "...
Returns client instance @param string|Service|Settings|Closure $identifier @return static @throws Service\Exception fallback instead default
[ "Returns", "client", "instance" ]
5be99ff5757e11af01ed1cc3dbabf0438100f94e
https://github.com/php-yaoi/php-yaoi/blob/5be99ff5757e11af01ed1cc3dbabf0438100f94e/src/Service.php#L169-L175
45,640
etechnika/idna-convert
lib/phlylabs/uctc.php
uctc.convert
public static function convert($data, $from, $to, $safe_mode = false, $safe_char = 0xFFFC) { self::$safe_mode = ($safe_mode) ? true : false; self::$safe_char = ($safe_char) ? $safe_char : 0xFFFC; if (self::$safe_mode) self::$allow_overlong = true; if (!in_array($from, self::$mechs)) throw new Exception('Invalid input format specified'); if (!in_array($to, self::$mechs)) throw new Exception('Invalid output format specified'); if ($from != 'ucs4array') eval('$data = self::'.$from.'_ucs4array($data);'); if ($to != 'ucs4array') eval('$data = self::ucs4array_'.$to.'($data);'); return $data; }
php
public static function convert($data, $from, $to, $safe_mode = false, $safe_char = 0xFFFC) { self::$safe_mode = ($safe_mode) ? true : false; self::$safe_char = ($safe_char) ? $safe_char : 0xFFFC; if (self::$safe_mode) self::$allow_overlong = true; if (!in_array($from, self::$mechs)) throw new Exception('Invalid input format specified'); if (!in_array($to, self::$mechs)) throw new Exception('Invalid output format specified'); if ($from != 'ucs4array') eval('$data = self::'.$from.'_ucs4array($data);'); if ($to != 'ucs4array') eval('$data = self::ucs4array_'.$to.'($data);'); return $data; }
[ "public", "static", "function", "convert", "(", "$", "data", ",", "$", "from", ",", "$", "to", ",", "$", "safe_mode", "=", "false", ",", "$", "safe_char", "=", "0xFFFC", ")", "{", "self", "::", "$", "safe_mode", "=", "(", "$", "safe_mode", ")", "?"...
The actual conversion routine @param mixed $data The data to convert, usually a string, array when converting from UCS-4 array @param string $from Original encoding of the data @param string $to Target encoding of the data @param bool $safe_mode SafeMode tries to correct invalid codepoints @return mixed False on failure, String or array on success, depending on target encoding @access public @since 0.0.1
[ "The", "actual", "conversion", "routine" ]
e6c49ff6f13b18f2f22ed26ba4f6e870788b8033
https://github.com/etechnika/idna-convert/blob/e6c49ff6f13b18f2f22ed26ba4f6e870788b8033/lib/phlylabs/uctc.php#L37-L47
45,641
gamajo/genesis-theme-toolkit
src/CustomLogo.php
CustomLogo.inlineLogoMarkup
public function inlineLogoMarkup($title, $inside, $wrap): string { if (!$this->hasCustomLogo()) { return $title; } $inside = sprintf( '<span class="screen-reader-text">%s</span>%s', esc_html(get_bloginfo('name')), get_custom_logo() ); // Build the title. $title = genesis_markup(array( 'open' => sprintf("<{$wrap} %s>", genesis_attr('site-title')), 'close' => "</{$wrap}>", 'content' => $inside, 'context' => 'site-title', 'echo' => false, 'params' => array( 'wrap' => $wrap, ), )); return $title; }
php
public function inlineLogoMarkup($title, $inside, $wrap): string { if (!$this->hasCustomLogo()) { return $title; } $inside = sprintf( '<span class="screen-reader-text">%s</span>%s', esc_html(get_bloginfo('name')), get_custom_logo() ); // Build the title. $title = genesis_markup(array( 'open' => sprintf("<{$wrap} %s>", genesis_attr('site-title')), 'close' => "</{$wrap}>", 'content' => $inside, 'context' => 'site-title', 'echo' => false, 'params' => array( 'wrap' => $wrap, ), )); return $title; }
[ "public", "function", "inlineLogoMarkup", "(", "$", "title", ",", "$", "inside", ",", "$", "wrap", ")", ":", "string", "{", "if", "(", "!", "$", "this", "->", "hasCustomLogo", "(", ")", ")", "{", "return", "$", "title", ";", "}", "$", "inside", "="...
Add an image inline in the site title element for the logo. @author @_AlphaBlossom @author @_neilgee @author @_JiveDig @author @_srikat @param string $title Current markup of title. @param string $inside Markup inside the title. @param string $wrap Wrapping element for the title. @return string Updated site title markup.
[ "Add", "an", "image", "inline", "in", "the", "site", "title", "element", "for", "the", "logo", "." ]
051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff
https://github.com/gamajo/genesis-theme-toolkit/blob/051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff/src/CustomLogo.php#L94-L119
45,642
gamajo/genesis-theme-toolkit
src/ThemeSettings.php
ThemeSettings.themeSettingsDefaults
public function themeSettingsDefaults($defaults): array { $defaultsConfig = $this->config->getSubConfig(self::DEFAULTS); foreach ($defaultsConfig->getArrayCopy() as $key => $value) { $defaults[$key] = $value; } return $defaults; }
php
public function themeSettingsDefaults($defaults): array { $defaultsConfig = $this->config->getSubConfig(self::DEFAULTS); foreach ($defaultsConfig->getArrayCopy() as $key => $value) { $defaults[$key] = $value; } return $defaults; }
[ "public", "function", "themeSettingsDefaults", "(", "$", "defaults", ")", ":", "array", "{", "$", "defaultsConfig", "=", "$", "this", "->", "config", "->", "getSubConfig", "(", "self", "::", "DEFAULTS", ")", ";", "foreach", "(", "$", "defaultsConfig", "->", ...
Change the theme settings defaults. @param array $defaults Existing theme settings defaults. @return array Theme settings defaults.
[ "Change", "the", "theme", "settings", "defaults", "." ]
051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff
https://github.com/gamajo/genesis-theme-toolkit/blob/051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff/src/ThemeSettings.php#L121-L129
45,643
gamajo/genesis-theme-toolkit
src/ThemeSettings.php
ThemeSettings.forceValues
public function forceValues() { $forceConfig = $this->config->getSubConfig(self::FORCE); foreach ($forceConfig->getArrayCopy() as $key => $value) { add_filter("genesis_pre_get_option_{$key}", function () use ($value) { return $value; }); } }
php
public function forceValues() { $forceConfig = $this->config->getSubConfig(self::FORCE); foreach ($forceConfig->getArrayCopy() as $key => $value) { add_filter("genesis_pre_get_option_{$key}", function () use ($value) { return $value; }); } }
[ "public", "function", "forceValues", "(", ")", "{", "$", "forceConfig", "=", "$", "this", "->", "config", "->", "getSubConfig", "(", "self", "::", "FORCE", ")", ";", "foreach", "(", "$", "forceConfig", "->", "getArrayCopy", "(", ")", "as", "$", "key", ...
Force specific values to be returned.
[ "Force", "specific", "values", "to", "be", "returned", "." ]
051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff
https://github.com/gamajo/genesis-theme-toolkit/blob/051bf78f75f71ebbfdcf3cad2935fd5d5abbc9ff/src/ThemeSettings.php#L134-L142
45,644
etechnika/idna-convert
lib/phlylabs/idna_convert.class.php
idna_convert._apply_cannonical_ordering
protected function _apply_cannonical_ordering($input) { $swap = true; $size = count($input); while ($swap) { $swap = false; $last = $this->_get_combining_class(intval($input[0])); for ($i = 0; $i < $size - 1; ++$i) { $next = $this->_get_combining_class(intval($input[$i + 1])); if ($next != 0 && $last > $next) { // Move item leftward until it fits for ($j = $i + 1; $j > 0; --$j) { if ($this->_get_combining_class(intval($input[$j - 1])) <= $next) { break; } $t = intval($input[$j]); $input[$j] = intval($input[$j - 1]); $input[$j - 1] = $t; $swap = true; } // Reentering the loop looking at the old character again $next = $last; } $last = $next; } } return $input; }
php
protected function _apply_cannonical_ordering($input) { $swap = true; $size = count($input); while ($swap) { $swap = false; $last = $this->_get_combining_class(intval($input[0])); for ($i = 0; $i < $size - 1; ++$i) { $next = $this->_get_combining_class(intval($input[$i + 1])); if ($next != 0 && $last > $next) { // Move item leftward until it fits for ($j = $i + 1; $j > 0; --$j) { if ($this->_get_combining_class(intval($input[$j - 1])) <= $next) { break; } $t = intval($input[$j]); $input[$j] = intval($input[$j - 1]); $input[$j - 1] = $t; $swap = true; } // Reentering the loop looking at the old character again $next = $last; } $last = $next; } } return $input; }
[ "protected", "function", "_apply_cannonical_ordering", "(", "$", "input", ")", "{", "$", "swap", "=", "true", ";", "$", "size", "=", "count", "(", "$", "input", ")", ";", "while", "(", "$", "swap", ")", "{", "$", "swap", "=", "false", ";", "$", "la...
Applies the cannonical ordering of a decomposed UCS4 sequence @param array Decomposed UCS4 sequence @return array Ordered USC4 sequence
[ "Applies", "the", "cannonical", "ordering", "of", "a", "decomposed", "UCS4", "sequence" ]
e6c49ff6f13b18f2f22ed26ba4f6e870788b8033
https://github.com/etechnika/idna-convert/blob/e6c49ff6f13b18f2f22ed26ba4f6e870788b8033/lib/phlylabs/idna_convert.class.php#L779-L806
45,645
etechnika/idna-convert
src/Etechnika/IdnaConvert/TranscodeWrapper.php
TranscodeWrapper.encodeUtf8
public static function encodeUtf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false) { return encode_utf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false); }
php
public static function encodeUtf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false) { return encode_utf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false); }
[ "public", "static", "function", "encodeUtf8", "(", "$", "strValue", "=", "''", ",", "$", "strEncoding", "=", "'iso-8859-1'", ",", "$", "booSafemode", "=", "false", ")", "{", "return", "encode_utf8", "(", "$", "strValue", "=", "''", ",", "$", "strEncoding",...
Convert a string to UTF-8 Return the encoded string or false on failure @param string $strValue @param string $strEncoding @param bool $booSafemode @return string string|false on failure @see encode_utf8
[ "Convert", "a", "string", "to", "UTF", "-", "8" ]
e6c49ff6f13b18f2f22ed26ba4f6e870788b8033
https://github.com/etechnika/idna-convert/blob/e6c49ff6f13b18f2f22ed26ba4f6e870788b8033/src/Etechnika/IdnaConvert/TranscodeWrapper.php#L26-L29
45,646
etechnika/idna-convert
src/Etechnika/IdnaConvert/TranscodeWrapper.php
TranscodeWrapper.decodeUtf8
public static function decodeUtf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false) { return decode_utf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false); }
php
public static function decodeUtf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false) { return decode_utf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false); }
[ "public", "static", "function", "decodeUtf8", "(", "$", "strValue", "=", "''", ",", "$", "strEncoding", "=", "'iso-8859-1'", ",", "$", "booSafemode", "=", "false", ")", "{", "return", "decode_utf8", "(", "$", "strValue", "=", "''", ",", "$", "strEncoding",...
Convert a string from UTF-8 to any of various encodings Return if set to TRUE, the original string is retunred on errors @param string $strValue @param string $strEncoding @param bool $booSafemode @return string|false on failure @see decode_utf8
[ "Convert", "a", "string", "from", "UTF", "-", "8", "to", "any", "of", "various", "encodings" ]
e6c49ff6f13b18f2f22ed26ba4f6e870788b8033
https://github.com/etechnika/idna-convert/blob/e6c49ff6f13b18f2f22ed26ba4f6e870788b8033/src/Etechnika/IdnaConvert/TranscodeWrapper.php#L44-L47
45,647
php-yaoi/php-yaoi
src/Database/Entity.php
Entity.table
public static function table($alias = null) { $className = get_called_class(); $tableKey = $className . ($alias ? ':' . $alias : ''); $table = &self::$tables[$tableKey]; if (null !== $table) { return $table; } /* if (isset(self::$settingColumns[$tableKey])) { throw new Exception('Already setting columns'); } $columns = new \stdClass(); self::$settingColumns[$tableKey] = $columns; unset(self::$settingColumns[$tableKey]); */ $schemaName = Utils::fromCamelCase(str_replace('\\', '', $className)); $table = new Table(null, self::getDatabase($className), $schemaName); $table->entityClassName = $className; $table->alias = $alias; static::setUpColumns($table->columns); static::setUpTable($table, $table->columns); return $table; }
php
public static function table($alias = null) { $className = get_called_class(); $tableKey = $className . ($alias ? ':' . $alias : ''); $table = &self::$tables[$tableKey]; if (null !== $table) { return $table; } /* if (isset(self::$settingColumns[$tableKey])) { throw new Exception('Already setting columns'); } $columns = new \stdClass(); self::$settingColumns[$tableKey] = $columns; unset(self::$settingColumns[$tableKey]); */ $schemaName = Utils::fromCamelCase(str_replace('\\', '', $className)); $table = new Table(null, self::getDatabase($className), $schemaName); $table->entityClassName = $className; $table->alias = $alias; static::setUpColumns($table->columns); static::setUpTable($table, $table->columns); return $table; }
[ "public", "static", "function", "table", "(", "$", "alias", "=", "null", ")", "{", "$", "className", "=", "get_called_class", "(", ")", ";", "$", "tableKey", "=", "$", "className", ".", "(", "$", "alias", "?", "':'", ".", "$", "alias", ":", "''", "...
Method should return table definition of entity @return Table
[ "Method", "should", "return", "table", "definition", "of", "entity" ]
5be99ff5757e11af01ed1cc3dbabf0438100f94e
https://github.com/php-yaoi/php-yaoi/blob/5be99ff5757e11af01ed1cc3dbabf0438100f94e/src/Database/Entity.php#L30-L54
45,648
atk4/core
src/Exception.php
Exception.toString
public function toString($val) { if (is_object($val) && !$val instanceof \Closure) { if (isset($val->_trackableTrait)) { return get_class($val).' ('.$val->name.')'; } return 'Object '.get_class($val); } return json_encode($val); }
php
public function toString($val) { if (is_object($val) && !$val instanceof \Closure) { if (isset($val->_trackableTrait)) { return get_class($val).' ('.$val->name.')'; } return 'Object '.get_class($val); } return json_encode($val); }
[ "public", "function", "toString", "(", "$", "val", ")", "{", "if", "(", "is_object", "(", "$", "val", ")", "&&", "!", "$", "val", "instanceof", "\\", "Closure", ")", "{", "if", "(", "isset", "(", "$", "val", "->", "_trackableTrait", ")", ")", "{", ...
Safely converts some value to string. @param mixed $val @return string
[ "Safely", "converts", "some", "value", "to", "string", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/Exception.php#L373-L384
45,649
atk4/core
src/ContainerTrait.php
ContainerTrait._shorten
protected function _shorten($desired) { if ( isset($this->_appScopeTrait) && isset($this->app->max_name_length) && strlen($desired) > $this->app->max_name_length ) { /* * Basic rules: hash is 10 character long (8+2 for separator) * We need at least 5 characters on the right side. Total must not exceed * max_name_length. First chop will be max-10, then chop size will increase by * max-15 */ $len = strlen($desired); $left = $len - ($len - 10) % ($this->app->max_name_length - 15) - 5; $key = substr($desired, 0, $left); $rest = substr($desired, $left); if (!isset($this->app->unique_hashes[$key])) { $this->app->unique_hashes[$key] = '_'.dechex(crc32($key)); } $desired = $this->app->unique_hashes[$key].'__'.$rest; } return $desired; }
php
protected function _shorten($desired) { if ( isset($this->_appScopeTrait) && isset($this->app->max_name_length) && strlen($desired) > $this->app->max_name_length ) { /* * Basic rules: hash is 10 character long (8+2 for separator) * We need at least 5 characters on the right side. Total must not exceed * max_name_length. First chop will be max-10, then chop size will increase by * max-15 */ $len = strlen($desired); $left = $len - ($len - 10) % ($this->app->max_name_length - 15) - 5; $key = substr($desired, 0, $left); $rest = substr($desired, $left); if (!isset($this->app->unique_hashes[$key])) { $this->app->unique_hashes[$key] = '_'.dechex(crc32($key)); } $desired = $this->app->unique_hashes[$key].'__'.$rest; } return $desired; }
[ "protected", "function", "_shorten", "(", "$", "desired", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_appScopeTrait", ")", "&&", "isset", "(", "$", "this", "->", "app", "->", "max_name_length", ")", "&&", "strlen", "(", "$", "desired", ")",...
Method used internally for shortening object names. @param string $desired Desired name of new object. @return string Shortened name of new object.
[ "Method", "used", "internally", "for", "shortening", "object", "names", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/ContainerTrait.php#L192-L219
45,650
atk4/core
src/ContainerTrait.php
ContainerTrait.hasElement
public function hasElement($short_name) { return isset($this->elements[$short_name]) ? $this->elements[$short_name] : false; }
php
public function hasElement($short_name) { return isset($this->elements[$short_name]) ? $this->elements[$short_name] : false; }
[ "public", "function", "hasElement", "(", "$", "short_name", ")", "{", "return", "isset", "(", "$", "this", "->", "elements", "[", "$", "short_name", "]", ")", "?", "$", "this", "->", "elements", "[", "$", "short_name", "]", ":", "false", ";", "}" ]
Find child element. Use in condition. @param string $short_name Short name of the child element @return object|bool
[ "Find", "child", "element", ".", "Use", "in", "condition", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/ContainerTrait.php#L249-L254
45,651
atk4/core
src/ConfigTrait.php
ConfigTrait.getConfig
public function getConfig($path, $default_value = null) { $pos = &$this->_lookupConfigElement($path, false); // path element don't exist - return default value if ($pos === false) { return $default_value; } return $pos; }
php
public function getConfig($path, $default_value = null) { $pos = &$this->_lookupConfigElement($path, false); // path element don't exist - return default value if ($pos === false) { return $default_value; } return $pos; }
[ "public", "function", "getConfig", "(", "$", "path", ",", "$", "default_value", "=", "null", ")", "{", "$", "pos", "=", "&", "$", "this", "->", "_lookupConfigElement", "(", "$", "path", ",", "false", ")", ";", "// path element don't exist - return default valu...
Get configuration element. @param string $path Path to configuration element. @param mixed $default_value Default value returned if element don't exist @return mixed
[ "Get", "configuration", "element", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/ConfigTrait.php#L126-L136
45,652
atk4/core
src/ConfigTrait.php
ConfigTrait.&
protected function &_lookupConfigElement($path, $create_elements = false) { $path = explode('/', $path); $pos = &$this->config; foreach ($path as $el) { // create empty element if it doesn't exist if (!array_key_exists($el, $pos) && $create_elements) { $pos[$el] = []; } // if it still doesn't exist, then just return false (no error) if (!array_key_exists($el, $pos) && !$create_elements) { // trick to return false because we need reference here $false = false; return $false; } $pos = &$pos[$el]; } return $pos; }
php
protected function &_lookupConfigElement($path, $create_elements = false) { $path = explode('/', $path); $pos = &$this->config; foreach ($path as $el) { // create empty element if it doesn't exist if (!array_key_exists($el, $pos) && $create_elements) { $pos[$el] = []; } // if it still doesn't exist, then just return false (no error) if (!array_key_exists($el, $pos) && !$create_elements) { // trick to return false because we need reference here $false = false; return $false; } $pos = &$pos[$el]; } return $pos; }
[ "protected", "function", "&", "_lookupConfigElement", "(", "$", "path", ",", "$", "create_elements", "=", "false", ")", "{", "$", "path", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "$", "pos", "=", "&", "$", "this", "->", "config", ";", ...
Internal method to lookup config element by given path. @param string $path Path to navigate to @param bool $create_elements Should we create elements it they don't exist @return &pos|false Pointer to element in $this->config or false is element don't exist and $create_elements===false Returns false if element don't exist and $create_elements===false
[ "Internal", "method", "to", "lookup", "config", "element", "by", "given", "path", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/ConfigTrait.php#L147-L168
45,653
atk4/core
src/TrackableTrait.php
TrackableTrait.destroy
public function destroy() { if ( isset($this->owner) && $this->owner->_containerTrait ) { $this->owner->removeElement($this->short_name); } }
php
public function destroy() { if ( isset($this->owner) && $this->owner->_containerTrait ) { $this->owner->removeElement($this->short_name); } }
[ "public", "function", "destroy", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "owner", ")", "&&", "$", "this", "->", "owner", "->", "_containerTrait", ")", "{", "$", "this", "->", "owner", "->", "removeElement", "(", "$", "this", "->", ...
Removes object from parent, so that PHP's Garbage Collector can dispose of it.
[ "Removes", "object", "from", "parent", "so", "that", "PHP", "s", "Garbage", "Collector", "can", "dispose", "of", "it", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/TrackableTrait.php#L50-L58
45,654
atk4/core
src/DebugTrait.php
DebugTrait.debug
public function debug($message = true, array $context = []) { // using this to switch on/off the debug for this object if (is_bool($message)) { $this->debug = $message; return $this; } // if debug is enabled, then log it if ($this->debug) { if (!isset($this->app) || !isset($this->app->logger) || !$this->app->logger instanceof \Psr\Log\LoggerInterface) { $message = '['.get_class($this).']: '.$message; } $this->log(LogLevel::DEBUG, $message, $context); } return $this; }
php
public function debug($message = true, array $context = []) { // using this to switch on/off the debug for this object if (is_bool($message)) { $this->debug = $message; return $this; } // if debug is enabled, then log it if ($this->debug) { if (!isset($this->app) || !isset($this->app->logger) || !$this->app->logger instanceof \Psr\Log\LoggerInterface) { $message = '['.get_class($this).']: '.$message; } $this->log(LogLevel::DEBUG, $message, $context); } return $this; }
[ "public", "function", "debug", "(", "$", "message", "=", "true", ",", "array", "$", "context", "=", "[", "]", ")", "{", "// using this to switch on/off the debug for this object", "if", "(", "is_bool", "(", "$", "message", ")", ")", "{", "$", "this", "->", ...
Send some info to debug stream. @param bool|string $message @param array $context @return $this
[ "Send", "some", "info", "to", "debug", "stream", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DebugTrait.php#L42-L60
45,655
atk4/core
src/DebugTrait.php
DebugTrait.log
public function log($level, $message, array $context = []) { if (isset($this->app) && isset($this->app->logger) && $this->app->logger instanceof \Psr\Log\LoggerInterface) { $this->app->logger->log($level, $message, $context); } else { $this->_echo_stderr("$message\n"); } return $this; }
php
public function log($level, $message, array $context = []) { if (isset($this->app) && isset($this->app->logger) && $this->app->logger instanceof \Psr\Log\LoggerInterface) { $this->app->logger->log($level, $message, $context); } else { $this->_echo_stderr("$message\n"); } return $this; }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "app", ")", "&&", "isset", "(", "$", "this", "->", "app", "->", "logger", ")...
Output log message. @param string $level @param string $message @param array $context @return $this
[ "Output", "log", "message", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DebugTrait.php#L71-L80
45,656
atk4/core
src/DebugTrait.php
DebugTrait.debugTraceChange
public function debugTraceChange($trace = 'default') { $bt = []; foreach (debug_backtrace() as $line) { if (isset($line['file'])) { $bt[] = $line['file'].':'.$line['line']; } } if (isset($this->_prev_bt[$trace]) && array_diff($this->_prev_bt[$trace], $bt)) { $d1 = array_diff($this->_prev_bt[$trace], $bt); $d2 = array_diff($bt, $this->_prev_bt[$trace]); $this->log('debug', 'Call path for '.$trace.' has diverged (was '.implode(', ', $d1).', now '.implode(', ', $d2).")\n"); } $this->_prev_bt[$trace] = $bt; }
php
public function debugTraceChange($trace = 'default') { $bt = []; foreach (debug_backtrace() as $line) { if (isset($line['file'])) { $bt[] = $line['file'].':'.$line['line']; } } if (isset($this->_prev_bt[$trace]) && array_diff($this->_prev_bt[$trace], $bt)) { $d1 = array_diff($this->_prev_bt[$trace], $bt); $d2 = array_diff($bt, $this->_prev_bt[$trace]); $this->log('debug', 'Call path for '.$trace.' has diverged (was '.implode(', ', $d1).', now '.implode(', ', $d2).")\n"); } $this->_prev_bt[$trace] = $bt; }
[ "public", "function", "debugTraceChange", "(", "$", "trace", "=", "'default'", ")", "{", "$", "bt", "=", "[", "]", ";", "foreach", "(", "debug_backtrace", "(", ")", "as", "$", "line", ")", "{", "if", "(", "isset", "(", "$", "line", "[", "'file'", "...
Method designed to intercept one of the hardest-to-debug situations within Agile Toolkit. Suppose you define a hook and the hook needs to be called only once, but somehow it is being called multiple times. You want to know where and how those calls come through. Place debugTraceChange inside your hook and give unique $trace identifier. If the method is invoked through different call paths, this debug info will be logged. Do not leave this method in production code !!! @param string $trace
[ "Method", "designed", "to", "intercept", "one", "of", "the", "hardest", "-", "to", "-", "debug", "situations", "within", "Agile", "Toolkit", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DebugTrait.php#L117-L134
45,657
atk4/core
src/DynamicMethodTrait.php
DynamicMethodTrait.tryCall
public function tryCall($method, $arguments) { if (isset($this->_hookTrait) && $ret = $this->hook('method-'.$method, $arguments)) { return $ret; } if (isset($this->_appScopeTrait) && isset($this->app->_hookTrait)) { array_unshift($arguments, $this); if ($ret = $this->app->hook('global-method-'.$method, $arguments)) { return $ret; } } }
php
public function tryCall($method, $arguments) { if (isset($this->_hookTrait) && $ret = $this->hook('method-'.$method, $arguments)) { return $ret; } if (isset($this->_appScopeTrait) && isset($this->app->_hookTrait)) { array_unshift($arguments, $this); if ($ret = $this->app->hook('global-method-'.$method, $arguments)) { return $ret; } } }
[ "public", "function", "tryCall", "(", "$", "method", ",", "$", "arguments", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_hookTrait", ")", "&&", "$", "ret", "=", "$", "this", "->", "hook", "(", "'method-'", ".", "$", "method", ",", "$", ...
Tries to call dynamic method. @param string $name Name of the method @param array $arguments Array of arguments to pass to this method @return mixed|null
[ "Tries", "to", "call", "dynamic", "method", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DynamicMethodTrait.php#L47-L59
45,658
atk4/core
src/DynamicMethodTrait.php
DynamicMethodTrait.hasGlobalMethod
public function hasGlobalMethod($name) { return isset($this->_appScopeTrait) && isset($this->app->_hookTrait) && $this->app->hookHasCallbacks('global-method-'.$name); }
php
public function hasGlobalMethod($name) { return isset($this->_appScopeTrait) && isset($this->app->_hookTrait) && $this->app->hookHasCallbacks('global-method-'.$name); }
[ "public", "function", "hasGlobalMethod", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "_appScopeTrait", ")", "&&", "isset", "(", "$", "this", "->", "app", "->", "_hookTrait", ")", "&&", "$", "this", "->", "app", "->", "hookHas...
Return true if such global method exists. @param string $name Name of the method @return bool
[ "Return", "true", "if", "such", "global", "method", "exists", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DynamicMethodTrait.php#L172-L178
45,659
atk4/core
src/DynamicMethodTrait.php
DynamicMethodTrait.removeGlobalMethod
public function removeGlobalMethod($name) { if (isset($this->_appScopeTrait) && isset($this->app->_hookTrait)) { $this->app->removeHook('global-method-'.$name); } return $this; }
php
public function removeGlobalMethod($name) { if (isset($this->_appScopeTrait) && isset($this->app->_hookTrait)) { $this->app->removeHook('global-method-'.$name); } return $this; }
[ "public", "function", "removeGlobalMethod", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_appScopeTrait", ")", "&&", "isset", "(", "$", "this", "->", "app", "->", "_hookTrait", ")", ")", "{", "$", "this", "->", "app", "->"...
Remove dynamically registered global method. @param string $name Name of the method @return $this
[ "Remove", "dynamically", "registered", "global", "method", "." ]
ec99f0d020056b1eef34796f72df553f12b143bf
https://github.com/atk4/core/blob/ec99f0d020056b1eef34796f72df553f12b143bf/src/DynamicMethodTrait.php#L187-L194
45,660
TheDMSGroup/mautic-health
Model/HealthModel.php
HealthModel.getCache
public function getCache() { if (!$this->cache) { $this->cache = new CacheStorageHelper( CacheStorageHelper::ADAPTOR_DATABASE, 'Health', $this->em->getConnection() ); } return [ 'delays' => $this->cache->get('delays'), 'lastCached' => $this->cache->get('lastCached'), ]; }
php
public function getCache() { if (!$this->cache) { $this->cache = new CacheStorageHelper( CacheStorageHelper::ADAPTOR_DATABASE, 'Health', $this->em->getConnection() ); } return [ 'delays' => $this->cache->get('delays'), 'lastCached' => $this->cache->get('lastCached'), ]; }
[ "public", "function", "getCache", "(", ")", "{", "if", "(", "!", "$", "this", "->", "cache", ")", "{", "$", "this", "->", "cache", "=", "new", "CacheStorageHelper", "(", "CacheStorageHelper", "::", "ADAPTOR_DATABASE", ",", "'Health'", ",", "$", "this", "...
Get last delays from the cache.
[ "Get", "last", "delays", "from", "the", "cache", "." ]
a9be743542d4a889a6cd647b5442d976af8c540d
https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Model/HealthModel.php#L255-L269
45,661
TheDMSGroup/mautic-health
Model/HealthModel.php
HealthModel.setCache
public function setCache() { if (!$this->cache) { $this->cache = new CacheStorageHelper( CacheStorageHelper::ADAPTOR_DATABASE, 'Health', $this->em->getConnection() ); } usort( $this->delays, function ($a, $b) { return $b['avg_delay_s'] - $a['avg_delay_s']; } ); $this->cache->set('delays', $this->delays, null); $this->cache->set('lastCached', time(), null); $this->delays = []; }
php
public function setCache() { if (!$this->cache) { $this->cache = new CacheStorageHelper( CacheStorageHelper::ADAPTOR_DATABASE, 'Health', $this->em->getConnection() ); } usort( $this->delays, function ($a, $b) { return $b['avg_delay_s'] - $a['avg_delay_s']; } ); $this->cache->set('delays', $this->delays, null); $this->cache->set('lastCached', time(), null); $this->delays = []; }
[ "public", "function", "setCache", "(", ")", "{", "if", "(", "!", "$", "this", "->", "cache", ")", "{", "$", "this", "->", "cache", "=", "new", "CacheStorageHelper", "(", "CacheStorageHelper", "::", "ADAPTOR_DATABASE", ",", "'Health'", ",", "$", "this", "...
Store current delays in the cache and purge.
[ "Store", "current", "delays", "in", "the", "cache", "and", "purge", "." ]
a9be743542d4a889a6cd647b5442d976af8c540d
https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Model/HealthModel.php#L274-L292
45,662
TheDMSGroup/mautic-health
Model/HealthModel.php
HealthModel.reportIncidents
public function reportIncidents(OutputInterface $output = null) { if (!$this->integration) { return; } if ($this->incidents && !empty($this->settings['statuspage_component_id'])) { $name = 'Processing Delays'; $body = []; foreach ($this->incidents as $incident) { if (!empty($incident['body'])) { $body[] = $incident['body']; } } $body = implode(' ', $body); if ($output && $body) { $output->writeln( '<info>'.'Notifying Statuspage.io'.'</info>' ); } $this->integration->setComponentStatus('monitoring', 'degraded_performance', $name, $body); } else { $this->integration->setComponentStatus('resolved', 'operational', null, 'Application is healthy'); } }
php
public function reportIncidents(OutputInterface $output = null) { if (!$this->integration) { return; } if ($this->incidents && !empty($this->settings['statuspage_component_id'])) { $name = 'Processing Delays'; $body = []; foreach ($this->incidents as $incident) { if (!empty($incident['body'])) { $body[] = $incident['body']; } } $body = implode(' ', $body); if ($output && $body) { $output->writeln( '<info>'.'Notifying Statuspage.io'.'</info>' ); } $this->integration->setComponentStatus('monitoring', 'degraded_performance', $name, $body); } else { $this->integration->setComponentStatus('resolved', 'operational', null, 'Application is healthy'); } }
[ "public", "function", "reportIncidents", "(", "OutputInterface", "$", "output", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "integration", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "incidents", "&&", "!", "empty", "(", ...
If Statuspage is enabled and configured, report incidents. @param OutputInterface|null $output
[ "If", "Statuspage", "is", "enabled", "and", "configured", "report", "incidents", "." ]
a9be743542d4a889a6cd647b5442d976af8c540d
https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Model/HealthModel.php#L385-L408
45,663
TheDMSGroup/mautic-health
Integration/HealthIntegration.php
HealthIntegration.getComponents
private function getComponents() { $components = []; if ($this->isConfigured()) { $clientIdKey = $this->getClientIdKey(); $cacheKey = 'statuspageComponents'.$this->keys[$clientIdKey]; $cacheExpire = 10; if (!$components = $this->cache->get($cacheKey, $cacheExpire)) { $clientSKey = $this->getClientSecretKey(); $state = $this->getAuthLoginState(); $url = $this->getAuthenticationUrl() .'pages/'.$this->keys[$clientIdKey].'/components.json' .'?api_key='.$this->keys[$clientSKey] .'&response_type=code' .'&state='.$state; $components = $this->makeRequest($url, ['ignore_event_dispatch' => true]); if (is_array($components) && count($components)) { $this->cache->set($cacheKey, $components, $cacheExpire); } } } return $components; }
php
private function getComponents() { $components = []; if ($this->isConfigured()) { $clientIdKey = $this->getClientIdKey(); $cacheKey = 'statuspageComponents'.$this->keys[$clientIdKey]; $cacheExpire = 10; if (!$components = $this->cache->get($cacheKey, $cacheExpire)) { $clientSKey = $this->getClientSecretKey(); $state = $this->getAuthLoginState(); $url = $this->getAuthenticationUrl() .'pages/'.$this->keys[$clientIdKey].'/components.json' .'?api_key='.$this->keys[$clientSKey] .'&response_type=code' .'&state='.$state; $components = $this->makeRequest($url, ['ignore_event_dispatch' => true]); if (is_array($components) && count($components)) { $this->cache->set($cacheKey, $components, $cacheExpire); } } } return $components; }
[ "private", "function", "getComponents", "(", ")", "{", "$", "components", "=", "[", "]", ";", "if", "(", "$", "this", "->", "isConfigured", "(", ")", ")", "{", "$", "clientIdKey", "=", "$", "this", "->", "getClientIdKey", "(", ")", ";", "$", "cacheKe...
Get the list of statuspage components to possibly update. @return array
[ "Get", "the", "list", "of", "statuspage", "components", "to", "possibly", "update", "." ]
a9be743542d4a889a6cd647b5442d976af8c540d
https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Integration/HealthIntegration.php#L111-L134
45,664
TheDMSGroup/mautic-health
Integration/HealthIntegration.php
HealthIntegration.getIncidents
private function getIncidents($componentId = null, $unresolvedOnly = true) { $incidents = []; if ($this->isConfigured()) { $clientIdKey = $this->getClientIdKey(); $cacheKey = 'statuspageIncidents'.$this->keys[$clientIdKey]; $cacheExpire = 10; if (!$incidents = $this->cache->get($cacheKey, $cacheExpire)) { $clientSKey = $this->getClientSecretKey(); $state = $this->getAuthLoginState(); $url = $this->getAuthenticationUrl(); if ($unresolvedOnly) { $url .= 'pages/'.$this->keys[$clientIdKey].'/incidents/unresolved.json'; } else { $url .= 'pages/'.$this->keys[$clientIdKey].'/incidents.json'; } $url .= '?api_key='.$this->keys[$clientSKey] .'&response_type=code' .'&state='.$state; $incidents = $this->makeRequest($url, ['ignore_event_dispatch' => true]); if (is_array($incidents) && count($incidents)) { $this->cache->set($cacheKey, $incidents, $cacheExpire); } } } // Narrow down to just the affected component if specified. if ($incidents && $componentId) { $affected = []; foreach ($incidents as $incident) { if (!empty($incident['incident_updates'])) { foreach ($incident['incident_updates'] as $update) { if (!empty($update['affected_components'])) { foreach ($update['affected_components'] as $component) { if (!empty($component['code']) && $component['code'] === $componentId) { $affected[] = $incident; continue; } } } } } } $incidents = $affected; } return $incidents; }
php
private function getIncidents($componentId = null, $unresolvedOnly = true) { $incidents = []; if ($this->isConfigured()) { $clientIdKey = $this->getClientIdKey(); $cacheKey = 'statuspageIncidents'.$this->keys[$clientIdKey]; $cacheExpire = 10; if (!$incidents = $this->cache->get($cacheKey, $cacheExpire)) { $clientSKey = $this->getClientSecretKey(); $state = $this->getAuthLoginState(); $url = $this->getAuthenticationUrl(); if ($unresolvedOnly) { $url .= 'pages/'.$this->keys[$clientIdKey].'/incidents/unresolved.json'; } else { $url .= 'pages/'.$this->keys[$clientIdKey].'/incidents.json'; } $url .= '?api_key='.$this->keys[$clientSKey] .'&response_type=code' .'&state='.$state; $incidents = $this->makeRequest($url, ['ignore_event_dispatch' => true]); if (is_array($incidents) && count($incidents)) { $this->cache->set($cacheKey, $incidents, $cacheExpire); } } } // Narrow down to just the affected component if specified. if ($incidents && $componentId) { $affected = []; foreach ($incidents as $incident) { if (!empty($incident['incident_updates'])) { foreach ($incident['incident_updates'] as $update) { if (!empty($update['affected_components'])) { foreach ($update['affected_components'] as $component) { if (!empty($component['code']) && $component['code'] === $componentId) { $affected[] = $incident; continue; } } } } } } $incidents = $affected; } return $incidents; }
[ "private", "function", "getIncidents", "(", "$", "componentId", "=", "null", ",", "$", "unresolvedOnly", "=", "true", ")", "{", "$", "incidents", "=", "[", "]", ";", "if", "(", "$", "this", "->", "isConfigured", "(", ")", ")", "{", "$", "clientIdKey", ...
Get the list of statuspage active incidents. @param null $componentId @param bool $unresolvedOnly @return array|bool|mixed|string
[ "Get", "the", "list", "of", "statuspage", "active", "incidents", "." ]
a9be743542d4a889a6cd647b5442d976af8c540d
https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Integration/HealthIntegration.php#L152-L198
45,665
TheDMSGroup/mautic-health
Integration/HealthIntegration.php
HealthIntegration.updateIncident
private function updateIncident($incidentId, $incidentStatus = null, $name = null, $body = null, $componentIds = []) { $result = []; if ($this->isConfigured()) { $clientIdKey = $this->getClientIdKey(); $cacheKey = 'statuspageUpdateIncident'.$this->keys[$clientIdKey].implode('-', $componentIds); $cacheExpire = 10; if (!$result = $this->cache->get($cacheKey, $cacheExpire)) { $clientSKey = $this->getClientSecretKey(); $state = $this->getAuthLoginState(); $url = $this->getAuthenticationUrl() .'pages/'.$this->keys[$clientIdKey].'/incidents/'.$incidentId.'.json' .'?api_key='.$this->keys[$clientSKey] .'&response_type=code' .'&state='.$state; if ($body) { $url .= '&incident[body]='.urlencode($body); } if ($incidentStatus) { $url .= '&incident[status]='.urlencode($incidentStatus); } if ($name) { $url .= '&incident[name]='.urlencode($name); } foreach ($componentIds as $componentId) { $url .= '&incident[component_ids][]='.(int) $componentId; } $result = $this->makeRequest($url, ['ignore_event_dispatch' => true], 'PATCH'); if (is_array($result) && count($result)) { $this->cache->set($cacheKey, $result, $cacheExpire); } } } return $result; }
php
private function updateIncident($incidentId, $incidentStatus = null, $name = null, $body = null, $componentIds = []) { $result = []; if ($this->isConfigured()) { $clientIdKey = $this->getClientIdKey(); $cacheKey = 'statuspageUpdateIncident'.$this->keys[$clientIdKey].implode('-', $componentIds); $cacheExpire = 10; if (!$result = $this->cache->get($cacheKey, $cacheExpire)) { $clientSKey = $this->getClientSecretKey(); $state = $this->getAuthLoginState(); $url = $this->getAuthenticationUrl() .'pages/'.$this->keys[$clientIdKey].'/incidents/'.$incidentId.'.json' .'?api_key='.$this->keys[$clientSKey] .'&response_type=code' .'&state='.$state; if ($body) { $url .= '&incident[body]='.urlencode($body); } if ($incidentStatus) { $url .= '&incident[status]='.urlencode($incidentStatus); } if ($name) { $url .= '&incident[name]='.urlencode($name); } foreach ($componentIds as $componentId) { $url .= '&incident[component_ids][]='.(int) $componentId; } $result = $this->makeRequest($url, ['ignore_event_dispatch' => true], 'PATCH'); if (is_array($result) && count($result)) { $this->cache->set($cacheKey, $result, $cacheExpire); } } } return $result; }
[ "private", "function", "updateIncident", "(", "$", "incidentId", ",", "$", "incidentStatus", "=", "null", ",", "$", "name", "=", "null", ",", "$", "body", "=", "null", ",", "$", "componentIds", "=", "[", "]", ")", "{", "$", "result", "=", "[", "]", ...
Update an active statuspage incident. @param $incidentId @param null $incidentStatus The status, one of investigating|identified|monitoring|resolved @param null $name The name of the incident @param null $body The body of the new incident update that will be created @param array $componentIds List of components affected by the incident @return array|mixed|string
[ "Update", "an", "active", "statuspage", "incident", "." ]
a9be743542d4a889a6cd647b5442d976af8c540d
https://github.com/TheDMSGroup/mautic-health/blob/a9be743542d4a889a6cd647b5442d976af8c540d/Integration/HealthIntegration.php#L211-L246
45,666
contentful/contentful-core.php
src/File/ImageOptions.php
ImageOptions.setWidth
public function setWidth(int $width = \null) { if (\null !== $width && $width < 0) { throw new \InvalidArgumentException('Width must not be negative.'); } $this->width = $width; return $this; }
php
public function setWidth(int $width = \null) { if (\null !== $width && $width < 0) { throw new \InvalidArgumentException('Width must not be negative.'); } $this->width = $width; return $this; }
[ "public", "function", "setWidth", "(", "int", "$", "width", "=", "\\", "null", ")", "{", "if", "(", "\\", "null", "!==", "$", "width", "&&", "$", "width", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Width must not be nega...
Set the width of the image. The image will by default not be stretched, skewed or enlarged. Instead it will be fit into the bounding box given by the width and height parameters. Can be set to null to not set a width. @param int|null $width the width in pixel @throws \InvalidArgumentException If $width is negative @return $this
[ "Set", "the", "width", "of", "the", "image", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L129-L138
45,667
contentful/contentful-core.php
src/File/ImageOptions.php
ImageOptions.setHeight
public function setHeight(int $height = \null) { if (\null !== $height && $height < 0) { throw new \InvalidArgumentException('Height must not be negative.'); } $this->height = $height; return $this; }
php
public function setHeight(int $height = \null) { if (\null !== $height && $height < 0) { throw new \InvalidArgumentException('Height must not be negative.'); } $this->height = $height; return $this; }
[ "public", "function", "setHeight", "(", "int", "$", "height", "=", "\\", "null", ")", "{", "if", "(", "\\", "null", "!==", "$", "height", "&&", "$", "height", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Height must not be...
Set the height of the image. The image will by default not be stretched, skewed or enlarged. Instead it will be fit into the bounding box given by the width and height parameters. Can be set to null to not set a height. @param int|null $height the height in pixel @throws \InvalidArgumentException If $height is negative @return $this
[ "Set", "the", "height", "of", "the", "image", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L155-L164
45,668
contentful/contentful-core.php
src/File/ImageOptions.php
ImageOptions.setFormat
public function setFormat(string $format = \null) { $validValues = ['png', 'jpg', 'webp']; if (\null !== $format && !\in_array($format, $validValues, \true)) { throw new \InvalidArgumentException(\sprintf( 'Unknown format "%s" given. Expected "%s" or null.', $format, \implode(', ', $validValues) )); } $this->format = $format; return $this; }
php
public function setFormat(string $format = \null) { $validValues = ['png', 'jpg', 'webp']; if (\null !== $format && !\in_array($format, $validValues, \true)) { throw new \InvalidArgumentException(\sprintf( 'Unknown format "%s" given. Expected "%s" or null.', $format, \implode(', ', $validValues) )); } $this->format = $format; return $this; }
[ "public", "function", "setFormat", "(", "string", "$", "format", "=", "\\", "null", ")", "{", "$", "validValues", "=", "[", "'png'", ",", "'jpg'", ",", "'webp'", "]", ";", "if", "(", "\\", "null", "!==", "$", "format", "&&", "!", "\\", "in_array", ...
Set the format of the image. Valid values are "png" and "jpg". Can be set to null to not enforce a format. @param string|null $format @throws \InvalidArgumentException If $format is not a valid value @return $this
[ "Set", "the", "format", "of", "the", "image", ".", "Valid", "values", "are", "png", "and", "jpg", ".", "Can", "be", "set", "to", "null", "to", "not", "enforce", "a", "format", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L176-L191
45,669
contentful/contentful-core.php
src/File/ImageOptions.php
ImageOptions.setQuality
public function setQuality(int $quality = \null) { if (\null !== $quality && ($quality < 1 || $quality > 100)) { throw new \InvalidArgumentException(\sprintf( 'Quality must be between 1 and 100, "%d" given.', $quality )); } $this->quality = $quality; return $this; }
php
public function setQuality(int $quality = \null) { if (\null !== $quality && ($quality < 1 || $quality > 100)) { throw new \InvalidArgumentException(\sprintf( 'Quality must be between 1 and 100, "%d" given.', $quality )); } $this->quality = $quality; return $this; }
[ "public", "function", "setQuality", "(", "int", "$", "quality", "=", "\\", "null", ")", "{", "if", "(", "\\", "null", "!==", "$", "quality", "&&", "(", "$", "quality", "<", "1", "||", "$", "quality", ">", "100", ")", ")", "{", "throw", "new", "\\...
Quality of the JPEG encoded image. The image format will be forced to JPEG. @param int|null $quality if an int, between 1 and 100 @throws \InvalidArgumentException If $quality is out of range @return $this
[ "Quality", "of", "the", "JPEG", "encoded", "image", ".", "The", "image", "format", "will", "be", "forced", "to", "JPEG", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L203-L215
45,670
contentful/contentful-core.php
src/File/ImageOptions.php
ImageOptions.setResizeFit
public function setResizeFit(string $resizeFit = \null) { $validValues = ['pad', 'crop', 'fill', 'thumb', 'scale']; if (\null !== $resizeFit && !\in_array($resizeFit, $validValues, \true)) { throw new \InvalidArgumentException(\sprintf( 'Unknown resize fit "%s" given. Expected "%s" or null.', $resizeFit, \implode(', ', $validValues) )); } $this->resizeFit = $resizeFit; return $this; }
php
public function setResizeFit(string $resizeFit = \null) { $validValues = ['pad', 'crop', 'fill', 'thumb', 'scale']; if (\null !== $resizeFit && !\in_array($resizeFit, $validValues, \true)) { throw new \InvalidArgumentException(\sprintf( 'Unknown resize fit "%s" given. Expected "%s" or null.', $resizeFit, \implode(', ', $validValues) )); } $this->resizeFit = $resizeFit; return $this; }
[ "public", "function", "setResizeFit", "(", "string", "$", "resizeFit", "=", "\\", "null", ")", "{", "$", "validValues", "=", "[", "'pad'", ",", "'crop'", ",", "'fill'", ",", "'thumb'", ",", "'scale'", "]", ";", "if", "(", "\\", "null", "!==", "$", "r...
Change the behavior when resizing the image. By default, images are resized to fit inside the bounding box set trough setWidth and setHeight while retaining their aspect ratio. Possible values are: - null for the default value - 'pad' Same as the default, but add padding so that the generated image has exactly the given dimensions. - 'crop' Crop a part of the original image. - 'fill' Fill the given dimensions by cropping the image. - 'thumb' Create a thumbnail of detected faces from image, used with 'setFocus'. - 'scale' Scale the image regardless of the original aspect ratio. @param string|null $resizeFit @throws \InvalidArgumentException For unknown values of $resizeBehavior @return $this
[ "Change", "the", "behavior", "when", "resizing", "the", "image", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L267-L282
45,671
contentful/contentful-core.php
src/File/ImageOptions.php
ImageOptions.setResizeFocus
public function setResizeFocus(string $resizeFocus = \null) { $validValues = [ 'face', 'faces', 'top', 'bottom', 'right', 'left', 'top_right', 'top_left', 'bottom_right', 'bottom_left', ]; if (\null !== $resizeFocus && !\in_array($resizeFocus, $validValues, \true)) { throw new \InvalidArgumentException(\sprintf( 'Unknown resize focus "%s" given. Expected "%s" or null.', $resizeFocus, \implode(', ', $validValues) )); } $this->resizeFocus = $resizeFocus; return $this; }
php
public function setResizeFocus(string $resizeFocus = \null) { $validValues = [ 'face', 'faces', 'top', 'bottom', 'right', 'left', 'top_right', 'top_left', 'bottom_right', 'bottom_left', ]; if (\null !== $resizeFocus && !\in_array($resizeFocus, $validValues, \true)) { throw new \InvalidArgumentException(\sprintf( 'Unknown resize focus "%s" given. Expected "%s" or null.', $resizeFocus, \implode(', ', $validValues) )); } $this->resizeFocus = $resizeFocus; return $this; }
[ "public", "function", "setResizeFocus", "(", "string", "$", "resizeFocus", "=", "\\", "null", ")", "{", "$", "validValues", "=", "[", "'face'", ",", "'faces'", ",", "'top'", ",", "'bottom'", ",", "'right'", ",", "'left'", ",", "'top_right'", ",", "'top_lef...
Set the focus area when the resize fit is set to 'thumb'. Possible values are: - 'top', 'right', 'left', 'bottom' - A combination like 'bottom_right' - 'face' or 'faces' to focus the resizing via face detection @param string|null $resizeFocus @throws \InvalidArgumentException For unknown values of $resizeFocus @return $this
[ "Set", "the", "focus", "area", "when", "the", "resize", "fit", "is", "set", "to", "thumb", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/File/ImageOptions.php#L298-L324
45,672
silverstripe/silverstripe-reports
code/ReportAdmin.php
ReportAdmin.Reports
public function Reports() { $output = new ArrayList(); /** @var Report $report */ foreach (Report::get_reports() as $report) { if ($report->canView()) { $output->push($report); } } return $output; }
php
public function Reports() { $output = new ArrayList(); /** @var Report $report */ foreach (Report::get_reports() as $report) { if ($report->canView()) { $output->push($report); } } return $output; }
[ "public", "function", "Reports", "(", ")", "{", "$", "output", "=", "new", "ArrayList", "(", ")", ";", "/** @var Report $report */", "foreach", "(", "Report", "::", "get_reports", "(", ")", "as", "$", "report", ")", "{", "if", "(", "$", "report", "->", ...
Return a SS_List of SS_Report subclasses that are available for use. @return SS_List
[ "Return", "a", "SS_List", "of", "SS_Report", "subclasses", "that", "are", "available", "for", "use", "." ]
1f1278b8203536e93ebba3df03adbca9a1ac1ead
https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/ReportAdmin.php#L105-L115
45,673
silverstripe/silverstripe-reports
code/ReportAdmin.php
ReportAdmin.Breadcrumbs
public function Breadcrumbs($unlinked = false) { $items = parent::Breadcrumbs($unlinked); // The root element should explicitly point to the root node. // Uses session state for current record otherwise. $items[0]->Link = singleton('SilverStripe\\Reports\\ReportAdmin')->Link(); if ($report = $this->reportObject) { $breadcrumbs = $report->getBreadcrumbs(); if (!empty($breadcrumbs)) { foreach ($breadcrumbs as $crumb) { $items->push($crumb); } } //build breadcrumb trail to the current report $items->push(new ArrayData(array( 'Title' => $report->title(), 'Link' => Controller::join_links( $this->Link(), '?' . http_build_query(array('q' => $this->request->requestVar('q'))) ) ))); } return $items; }
php
public function Breadcrumbs($unlinked = false) { $items = parent::Breadcrumbs($unlinked); // The root element should explicitly point to the root node. // Uses session state for current record otherwise. $items[0]->Link = singleton('SilverStripe\\Reports\\ReportAdmin')->Link(); if ($report = $this->reportObject) { $breadcrumbs = $report->getBreadcrumbs(); if (!empty($breadcrumbs)) { foreach ($breadcrumbs as $crumb) { $items->push($crumb); } } //build breadcrumb trail to the current report $items->push(new ArrayData(array( 'Title' => $report->title(), 'Link' => Controller::join_links( $this->Link(), '?' . http_build_query(array('q' => $this->request->requestVar('q'))) ) ))); } return $items; }
[ "public", "function", "Breadcrumbs", "(", "$", "unlinked", "=", "false", ")", "{", "$", "items", "=", "parent", "::", "Breadcrumbs", "(", "$", "unlinked", ")", ";", "// The root element should explicitly point to the root node.", "// Uses session state for current record ...
Returns the Breadcrumbs for the ReportAdmin @param bool $unlinked @return ArrayList
[ "Returns", "the", "Breadcrumbs", "for", "the", "ReportAdmin" ]
1f1278b8203536e93ebba3df03adbca9a1ac1ead
https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/ReportAdmin.php#L167-L194
45,674
silverstripe/silverstripe-reports
code/ReportAdmin.php
ReportAdmin.Link
public function Link($action = null) { if ($this->reportObject) { return $this->reportObject->getLink($action); } // Basic link to this cms section return parent::Link($action); }
php
public function Link($action = null) { if ($this->reportObject) { return $this->reportObject->getLink($action); } // Basic link to this cms section return parent::Link($action); }
[ "public", "function", "Link", "(", "$", "action", "=", "null", ")", "{", "if", "(", "$", "this", "->", "reportObject", ")", "{", "return", "$", "this", "->", "reportObject", "->", "getLink", "(", "$", "action", ")", ";", "}", "// Basic link to this cms s...
Returns the link to the report admin section, or the specific report that is currently displayed @param string $action @return string
[ "Returns", "the", "link", "to", "the", "report", "admin", "section", "or", "the", "specific", "report", "that", "is", "currently", "displayed" ]
1f1278b8203536e93ebba3df03adbca9a1ac1ead
https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/ReportAdmin.php#L202-L210
45,675
contentful/contentful-core.php
src/Api/UserAgentGenerator.php
UserAgentGenerator.getUserAgent
public function getUserAgent(): string { if (null === $this->cachedUserAgent) { $this->cachedUserAgent = $this->generate(); } return $this->cachedUserAgent; }
php
public function getUserAgent(): string { if (null === $this->cachedUserAgent) { $this->cachedUserAgent = $this->generate(); } return $this->cachedUserAgent; }
[ "public", "function", "getUserAgent", "(", ")", ":", "string", "{", "if", "(", "null", "===", "$", "this", "->", "cachedUserAgent", ")", "{", "$", "this", "->", "cachedUserAgent", "=", "$", "this", "->", "generate", "(", ")", ";", "}", "return", "$", ...
Returns the value of the User-Agent header for any requests made to Contentful. @return string
[ "Returns", "the", "value", "of", "the", "User", "-", "Agent", "header", "for", "any", "requests", "made", "to", "Contentful", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/UserAgentGenerator.php#L128-L135
45,676
contentful/contentful-core.php
src/Api/BaseQuery.php
BaseQuery.getQueryData
public function getQueryData(): array { return \array_merge($this->whereConditions, [ 'limit' => $this->limit, 'skip' => $this->skip, 'content_type' => $this->contentType, 'mimetype_group' => $this->mimeTypeGroup, 'order' => $this->orderConditions ? \implode(',', $this->orderConditions) : null, 'select' => $this->select, 'links_to_entry' => $this->linksToEntry, 'links_to_asset' => $this->linksToAsset, ]); }
php
public function getQueryData(): array { return \array_merge($this->whereConditions, [ 'limit' => $this->limit, 'skip' => $this->skip, 'content_type' => $this->contentType, 'mimetype_group' => $this->mimeTypeGroup, 'order' => $this->orderConditions ? \implode(',', $this->orderConditions) : null, 'select' => $this->select, 'links_to_entry' => $this->linksToEntry, 'links_to_asset' => $this->linksToAsset, ]); }
[ "public", "function", "getQueryData", "(", ")", ":", "array", "{", "return", "\\", "array_merge", "(", "$", "this", "->", "whereConditions", ",", "[", "'limit'", "=>", "$", "this", "->", "limit", ",", "'skip'", "=>", "$", "this", "->", "skip", ",", "'c...
Returns the parameters to execute this query. @return array
[ "Returns", "the", "parameters", "to", "execute", "this", "query", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L132-L144
45,677
contentful/contentful-core.php
src/Api/BaseQuery.php
BaseQuery.setSkip
public function setSkip(int $skip = null) { if (null !== $skip && $skip < 0) { throw new \RangeException(\sprintf( 'Skip value must be 0 or bigger, "%d" given.', $skip )); } $this->skip = $skip; return $this; }
php
public function setSkip(int $skip = null) { if (null !== $skip && $skip < 0) { throw new \RangeException(\sprintf( 'Skip value must be 0 or bigger, "%d" given.', $skip )); } $this->skip = $skip; return $this; }
[ "public", "function", "setSkip", "(", "int", "$", "skip", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "skip", "&&", "$", "skip", "<", "0", ")", "{", "throw", "new", "\\", "RangeException", "(", "\\", "sprintf", "(", "'Skip value must be 0 or ...
Sets the index of the first result to retrieve. To reset set to NULL. @param int|null $skip The index of the first result that will be retrieved. Must be >= 0. @throws \RangeException If $skip is not within the specified range @return $this
[ "Sets", "the", "index", "of", "the", "first", "result", "to", "retrieve", ".", "To", "reset", "set", "to", "NULL", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L165-L177
45,678
contentful/contentful-core.php
src/Api/BaseQuery.php
BaseQuery.setLimit
public function setLimit(int $limit = null) { if (null !== $limit && ($limit < 1 || $limit > 1000)) { throw new \RangeException(\sprintf( 'Limit value must be between 0 and 1000, "%d" given.', $limit )); } $this->limit = $limit; return $this; }
php
public function setLimit(int $limit = null) { if (null !== $limit && ($limit < 1 || $limit > 1000)) { throw new \RangeException(\sprintf( 'Limit value must be between 0 and 1000, "%d" given.', $limit )); } $this->limit = $limit; return $this; }
[ "public", "function", "setLimit", "(", "int", "$", "limit", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "limit", "&&", "(", "$", "limit", "<", "1", "||", "$", "limit", ">", "1000", ")", ")", "{", "throw", "new", "\\", "RangeException", ...
Set the maximum number of results to retrieve. To reset set to NULL;. @param int|null $limit The maximum number of results to retrieve, must be between 1 and 1000 or null @throws \RangeException If $maxArguments is not withing the specified range @return $this
[ "Set", "the", "maximum", "number", "of", "results", "to", "retrieve", ".", "To", "reset", "set", "to", "NULL", ";", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L188-L200
45,679
contentful/contentful-core.php
src/Api/BaseQuery.php
BaseQuery.orderBy
public function orderBy(string $field, bool $reverse = false) { if ($reverse) { $field = '-'.$field; } $this->orderConditions[] = $field; return $this; }
php
public function orderBy(string $field, bool $reverse = false) { if ($reverse) { $field = '-'.$field; } $this->orderConditions[] = $field; return $this; }
[ "public", "function", "orderBy", "(", "string", "$", "field", ",", "bool", "$", "reverse", "=", "false", ")", "{", "if", "(", "$", "reverse", ")", "{", "$", "field", "=", "'-'", ".", "$", "field", ";", "}", "$", "this", "->", "orderConditions", "["...
Set the order of the items retrieved by this query. Note that when ordering Entries by fields you must set the content_type URI query parameter to the ID of the Content Type you want to filter by. Can be called multiple times to order by multiple values. @param string $field @param bool $reverse @return $this
[ "Set", "the", "order", "of", "the", "items", "retrieved", "by", "this", "query", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L213-L222
45,680
contentful/contentful-core.php
src/Api/BaseQuery.php
BaseQuery.where
public function where(string $field, $value) { $matches = []; // We check whether there is a specific operator in the field name, // and if so we validate it against a whitelist if (\preg_match('/(.+)\[([a-zA-Z]+)\]/', $field, $matches)) { $operator = \mb_strtolower($matches[2]); if (!\in_array($operator, self::$validOperators, true)) { throw new \InvalidArgumentException(\sprintf( 'Unknown operator "%s" given. Expected "%s" or no operator.', $operator, \implode(', ', self::$validOperators) )); } } if ($value instanceof \DateTimeInterface) { $value = $value->format(self::DATE_FORMAT); } if ($value instanceof Location) { $value = $value->queryStringFormatted(); } if (\is_array($value)) { $value = \implode(',', $value); } $this->whereConditions[$field] = $value; return $this; }
php
public function where(string $field, $value) { $matches = []; // We check whether there is a specific operator in the field name, // and if so we validate it against a whitelist if (\preg_match('/(.+)\[([a-zA-Z]+)\]/', $field, $matches)) { $operator = \mb_strtolower($matches[2]); if (!\in_array($operator, self::$validOperators, true)) { throw new \InvalidArgumentException(\sprintf( 'Unknown operator "%s" given. Expected "%s" or no operator.', $operator, \implode(', ', self::$validOperators) )); } } if ($value instanceof \DateTimeInterface) { $value = $value->format(self::DATE_FORMAT); } if ($value instanceof Location) { $value = $value->queryStringFormatted(); } if (\is_array($value)) { $value = \implode(',', $value); } $this->whereConditions[$field] = $value; return $this; }
[ "public", "function", "where", "(", "string", "$", "field", ",", "$", "value", ")", "{", "$", "matches", "=", "[", "]", ";", "// We check whether there is a specific operator in the field name,", "// and if so we validate it against a whitelist", "if", "(", "\\", "preg_...
Add a filter condition to this query. @param string $field @param string|array|\DateTimeInterface|Location $value @throws \InvalidArgumentException If $operator is not one of the valid values @return $this
[ "Add", "a", "filter", "condition", "to", "this", "query", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L272-L302
45,681
contentful/contentful-core.php
src/Api/BaseQuery.php
BaseQuery.select
public function select(array $select) { $select = \array_filter($select, function (string $value): bool { return 0 !== \mb_strpos($value, 'sys'); }); $select[] = 'sys'; $this->select = \implode(',', $select); return $this; }
php
public function select(array $select) { $select = \array_filter($select, function (string $value): bool { return 0 !== \mb_strpos($value, 'sys'); }); $select[] = 'sys'; $this->select = \implode(',', $select); return $this; }
[ "public", "function", "select", "(", "array", "$", "select", ")", "{", "$", "select", "=", "\\", "array_filter", "(", "$", "select", ",", "function", "(", "string", "$", "value", ")", ":", "bool", "{", "return", "0", "!==", "\\", "mb_strpos", "(", "$...
The select operator allows you to choose what to return from an entity. You provide one or multiple JSON paths and the API will return the properties at those paths. To only request the metadata simply query for 'sys'. @param string[] $select @return $this
[ "The", "select", "operator", "allows", "you", "to", "choose", "what", "to", "return", "from", "an", "entity", ".", "You", "provide", "one", "or", "multiple", "JSON", "paths", "and", "the", "API", "will", "return", "the", "properties", "at", "those", "paths...
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseQuery.php#L314-L324
45,682
contentful/contentful-core.php
src/ResourceBuilder/BaseResourceBuilder.php
BaseResourceBuilder.getMapper
public function getMapper($fqcn) { if (!isset($this->mappers[$fqcn])) { $this->mappers[$fqcn] = $this->createMapper($fqcn); } return $this->mappers[$fqcn]; }
php
public function getMapper($fqcn) { if (!isset($this->mappers[$fqcn])) { $this->mappers[$fqcn] = $this->createMapper($fqcn); } return $this->mappers[$fqcn]; }
[ "public", "function", "getMapper", "(", "$", "fqcn", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "mappers", "[", "$", "fqcn", "]", ")", ")", "{", "$", "this", "->", "mappers", "[", "$", "fqcn", "]", "=", "$", "this", "->", "creat...
Returns the mapper object appropriate for the given data. @param string $fqcn @throws \RuntimeException @return MapperInterface
[ "Returns", "the", "mapper", "object", "appropriate", "for", "the", "given", "data", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/ResourceBuilder/BaseResourceBuilder.php#L74-L81
45,683
contentful/contentful-core.php
src/ResourceBuilder/BaseResourceBuilder.php
BaseResourceBuilder.determineMapperFqcn
private function determineMapperFqcn(array $data) { $type = $this->getSystemType($data); $fqcn = $this->mapperNamespace.'\\'.$type; if (isset($this->dataMapperMatchers[$type])) { $matchedFqcn = $this->dataMapperMatchers[$type]($data); if (!$matchedFqcn) { return $fqcn; } if (!\class_exists($matchedFqcn, \true)) { throw new \RuntimeException(\sprintf( 'Mapper class "%s" does not exist.', $matchedFqcn )); } return $matchedFqcn; } return $fqcn; }
php
private function determineMapperFqcn(array $data) { $type = $this->getSystemType($data); $fqcn = $this->mapperNamespace.'\\'.$type; if (isset($this->dataMapperMatchers[$type])) { $matchedFqcn = $this->dataMapperMatchers[$type]($data); if (!$matchedFqcn) { return $fqcn; } if (!\class_exists($matchedFqcn, \true)) { throw new \RuntimeException(\sprintf( 'Mapper class "%s" does not exist.', $matchedFqcn )); } return $matchedFqcn; } return $fqcn; }
[ "private", "function", "determineMapperFqcn", "(", "array", "$", "data", ")", "{", "$", "type", "=", "$", "this", "->", "getSystemType", "(", "$", "data", ")", ";", "$", "fqcn", "=", "$", "this", "->", "mapperNamespace", ".", "'\\\\'", ".", "$", "type"...
Determines the fully-qualified class name of the mapper object that will handle the mapping process. This function will use user-defined data matchers, if available. If the user-defined matcher does not return anything, we default to the base mapper, so the user doesn't have to manually return the default value. @param array $data The raw API data @return string The mapper's fully-qualified class name
[ "Determines", "the", "fully", "-", "qualified", "class", "name", "of", "the", "mapper", "object", "that", "will", "handle", "the", "mapping", "process", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/ResourceBuilder/BaseResourceBuilder.php#L97-L120
45,684
contentful/contentful-core.php
src/Api/Message.php
Message.createFromString
public static function createFromString(string $json): self { $data = guzzle_json_decode($json, true); if ( !isset($data['api']) || !isset($data['request']) || !isset($data['response']) || !isset($data['duration']) || !isset($data['exception']) ) { throw new \InvalidArgumentException( 'String passed to Message::createFromString() is valid JSON but does not contain required fields.' ); } return new self( $data['api'], $data['duration'], guzzle_parse_request($data['request']), $data['response'] ? guzzle_parse_response($data['response']) : null, $data['exception'] ? \unserialize($data['exception']) : null ); }
php
public static function createFromString(string $json): self { $data = guzzle_json_decode($json, true); if ( !isset($data['api']) || !isset($data['request']) || !isset($data['response']) || !isset($data['duration']) || !isset($data['exception']) ) { throw new \InvalidArgumentException( 'String passed to Message::createFromString() is valid JSON but does not contain required fields.' ); } return new self( $data['api'], $data['duration'], guzzle_parse_request($data['request']), $data['response'] ? guzzle_parse_response($data['response']) : null, $data['exception'] ? \unserialize($data['exception']) : null ); }
[ "public", "static", "function", "createFromString", "(", "string", "$", "json", ")", ":", "self", "{", "$", "data", "=", "guzzle_json_decode", "(", "$", "json", ",", "true", ")", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'api'", "]", ")",...
Creates a new instance of the class from a JSON string. @param string $json @return self
[ "Creates", "a", "new", "instance", "of", "the", "class", "from", "a", "JSON", "string", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/Message.php#L93-L116
45,685
contentful/contentful-core.php
src/Api/DateTimeImmutable.php
DateTimeImmutable.formatForJson
public function formatForJson(): string { $date = $this->setTimezone(new \DateTimeZone('Etc/UTC')); $result = $date->format('Y-m-d\TH:i:s'); $milliseconds = \floor($date->format('u') / 1000); if ($milliseconds > 0) { $result .= '.'.\str_pad((string) $milliseconds, 3, '0', \STR_PAD_LEFT); } return $result.'Z'; }
php
public function formatForJson(): string { $date = $this->setTimezone(new \DateTimeZone('Etc/UTC')); $result = $date->format('Y-m-d\TH:i:s'); $milliseconds = \floor($date->format('u') / 1000); if ($milliseconds > 0) { $result .= '.'.\str_pad((string) $milliseconds, 3, '0', \STR_PAD_LEFT); } return $result.'Z'; }
[ "public", "function", "formatForJson", "(", ")", ":", "string", "{", "$", "date", "=", "$", "this", "->", "setTimezone", "(", "new", "\\", "DateTimeZone", "(", "'Etc/UTC'", ")", ")", ";", "$", "result", "=", "$", "date", "->", "format", "(", "'Y-m-d\\T...
Formats the string for an easier interoperability with Contentful. @return string
[ "Formats", "the", "string", "for", "an", "easier", "interoperability", "with", "Contentful", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/DateTimeImmutable.php#L26-L37
45,686
silverstripe/silverstripe-reports
code/Report.php
Report.records
public function records($params) { if ($this->hasMethod('sourceRecords')) { return $this->sourceRecords($params, null, null); } else { $query = $this->sourceQuery($params); $results = ArrayList::create(); foreach ($query->execute() as $data) { $class = $this->dataClass(); $result = Injector::inst()->create($class, $data); $results->push($result); } return $results; } }
php
public function records($params) { if ($this->hasMethod('sourceRecords')) { return $this->sourceRecords($params, null, null); } else { $query = $this->sourceQuery($params); $results = ArrayList::create(); foreach ($query->execute() as $data) { $class = $this->dataClass(); $result = Injector::inst()->create($class, $data); $results->push($result); } return $results; } }
[ "public", "function", "records", "(", "$", "params", ")", "{", "if", "(", "$", "this", "->", "hasMethod", "(", "'sourceRecords'", ")", ")", "{", "return", "$", "this", "->", "sourceRecords", "(", "$", "params", ",", "null", ",", "null", ")", ";", "}"...
Return a SS_List records for this report. @param array $params @return SS_List
[ "Return", "a", "SS_List", "records", "for", "this", "report", "." ]
1f1278b8203536e93ebba3df03adbca9a1ac1ead
https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/Report.php#L163-L177
45,687
silverstripe/silverstripe-reports
code/Report.php
Report.getCount
public function getCount($params = array()) { $sourceRecords = $this->sourceRecords($params, null, null); if (!$sourceRecords instanceof SS_List) { user_error(static::class . "::sourceRecords does not return an SS_List", E_USER_NOTICE); return "-1"; } return $sourceRecords->count(); }
php
public function getCount($params = array()) { $sourceRecords = $this->sourceRecords($params, null, null); if (!$sourceRecords instanceof SS_List) { user_error(static::class . "::sourceRecords does not return an SS_List", E_USER_NOTICE); return "-1"; } return $sourceRecords->count(); }
[ "public", "function", "getCount", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "sourceRecords", "=", "$", "this", "->", "sourceRecords", "(", "$", "params", ",", "null", ",", "null", ")", ";", "if", "(", "!", "$", "sourceRecords", "inst...
counts the number of objects returned @param array $params - any parameters for the sourceRecords @return int
[ "counts", "the", "number", "of", "objects", "returned" ]
1f1278b8203536e93ebba3df03adbca9a1ac1ead
https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/Report.php#L219-L227
45,688
silverstripe/silverstripe-reports
code/Report.php
Report.get_reports
public static function get_reports() { $reports = ClassInfo::subclassesFor(get_called_class()); $reportsArray = []; if ($reports && count($reports) > 0) { $excludedReports = static::get_excluded_reports(); // Collect reports into array with an attribute for 'sort' foreach ($reports as $report) { // Don't use the Report superclass, or any excluded report classes if (in_array($report, $excludedReports)) { continue; } $reflectionClass = new ReflectionClass($report); // Don't use abstract classes if ($reflectionClass->isAbstract()) { continue; } /** @var Report $reportObj */ $reportObj = $report::create(); if ($reportObj->hasMethod('sort')) { // Use the sort method to specify the sort field $reportObj->sort = $reportObj->sort(); } $reportsArray[$report] = $reportObj; } } uasort($reportsArray, function ($a, $b) { if ($a->sort == $b->sort) { return 0; } else { return ($a->sort < $b->sort) ? -1 : 1; } }); return $reportsArray; }
php
public static function get_reports() { $reports = ClassInfo::subclassesFor(get_called_class()); $reportsArray = []; if ($reports && count($reports) > 0) { $excludedReports = static::get_excluded_reports(); // Collect reports into array with an attribute for 'sort' foreach ($reports as $report) { // Don't use the Report superclass, or any excluded report classes if (in_array($report, $excludedReports)) { continue; } $reflectionClass = new ReflectionClass($report); // Don't use abstract classes if ($reflectionClass->isAbstract()) { continue; } /** @var Report $reportObj */ $reportObj = $report::create(); if ($reportObj->hasMethod('sort')) { // Use the sort method to specify the sort field $reportObj->sort = $reportObj->sort(); } $reportsArray[$report] = $reportObj; } } uasort($reportsArray, function ($a, $b) { if ($a->sort == $b->sort) { return 0; } else { return ($a->sort < $b->sort) ? -1 : 1; } }); return $reportsArray; }
[ "public", "static", "function", "get_reports", "(", ")", "{", "$", "reports", "=", "ClassInfo", "::", "subclassesFor", "(", "get_called_class", "(", ")", ")", ";", "$", "reportsArray", "=", "[", "]", ";", "if", "(", "$", "reports", "&&", "count", "(", ...
Return the SS_Report objects making up the given list. @return Report[] Array of Report objects
[ "Return", "the", "SS_Report", "objects", "making", "up", "the", "given", "list", "." ]
1f1278b8203536e93ebba3df03adbca9a1ac1ead
https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/Report.php#L245-L283
45,689
silverstripe/silverstripe-reports
code/Report.php
Report.getSourceParams
protected function getSourceParams() { $params = []; if (Injector::inst()->has(HTTPRequest::class)) { /** @var HTTPRequest $request */ $request = Injector::inst()->get(HTTPRequest::class); $params = $request->param('filters') ?: $request->requestVar('filters') ?: []; } $this->extend('updateSourceParams', $params); return $params; }
php
protected function getSourceParams() { $params = []; if (Injector::inst()->has(HTTPRequest::class)) { /** @var HTTPRequest $request */ $request = Injector::inst()->get(HTTPRequest::class); $params = $request->param('filters') ?: $request->requestVar('filters') ?: []; } $this->extend('updateSourceParams', $params); return $params; }
[ "protected", "function", "getSourceParams", "(", ")", "{", "$", "params", "=", "[", "]", ";", "if", "(", "Injector", "::", "inst", "(", ")", "->", "has", "(", "HTTPRequest", "::", "class", ")", ")", "{", "/** @var HTTPRequest $request */", "$", "request", ...
Get source params for the report to filter by @return array
[ "Get", "source", "params", "for", "the", "report", "to", "filter", "by" ]
1f1278b8203536e93ebba3df03adbca9a1ac1ead
https://github.com/silverstripe/silverstripe-reports/blob/1f1278b8203536e93ebba3df03adbca9a1ac1ead/code/Report.php#L488-L500
45,690
contentful/contentful-core.php
src/Api/Requester.php
Requester.sendRequest
public function sendRequest(RequestInterface $request): Message { $startTime = \microtime(true); $exception = null; try { $response = $this->httpClient->send($request); } catch (ClientException $exception) { $response = $exception->hasResponse() ? $exception->getResponse() : null; $exception = $this->createCustomException($exception); } $duration = \microtime(true) - $startTime; return new Message( $this->api, $duration, $request, $response, $exception ); }
php
public function sendRequest(RequestInterface $request): Message { $startTime = \microtime(true); $exception = null; try { $response = $this->httpClient->send($request); } catch (ClientException $exception) { $response = $exception->hasResponse() ? $exception->getResponse() : null; $exception = $this->createCustomException($exception); } $duration = \microtime(true) - $startTime; return new Message( $this->api, $duration, $request, $response, $exception ); }
[ "public", "function", "sendRequest", "(", "RequestInterface", "$", "request", ")", ":", "Message", "{", "$", "startTime", "=", "\\", "microtime", "(", "true", ")", ";", "$", "exception", "=", "null", ";", "try", "{", "$", "response", "=", "$", "this", ...
Queries the API, and returns a message object which contains all information needed for processing and logging. @param RequestInterface $request @return Message
[ "Queries", "the", "API", "and", "returns", "a", "message", "object", "which", "contains", "all", "information", "needed", "for", "processing", "and", "logging", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/Requester.php#L58-L82
45,691
contentful/contentful-core.php
src/Api/Requester.php
Requester.createCustomException
private function createCustomException(ClientException $exception): Exception { $errorId = ''; $response = $exception->getResponse(); if ($response) { $data = guzzle_json_decode((string) $response->getBody(), true); $errorId = (string) $data['sys']['id'] ?? ''; } $exceptionClass = $this->getExceptionClass($errorId); return new $exceptionClass($exception); }
php
private function createCustomException(ClientException $exception): Exception { $errorId = ''; $response = $exception->getResponse(); if ($response) { $data = guzzle_json_decode((string) $response->getBody(), true); $errorId = (string) $data['sys']['id'] ?? ''; } $exceptionClass = $this->getExceptionClass($errorId); return new $exceptionClass($exception); }
[ "private", "function", "createCustomException", "(", "ClientException", "$", "exception", ")", ":", "Exception", "{", "$", "errorId", "=", "''", ";", "$", "response", "=", "$", "exception", "->", "getResponse", "(", ")", ";", "if", "(", "$", "response", ")...
Attempts to create a custom exception. It will return a default exception if no suitable class is found. @param ClientException $exception @return Exception
[ "Attempts", "to", "create", "a", "custom", "exception", ".", "It", "will", "return", "a", "default", "exception", "if", "no", "suitable", "class", "is", "found", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/Requester.php#L92-L104
45,692
contentful/contentful-core.php
src/Api/Requester.php
Requester.getExceptionClass
private function getExceptionClass(string $apiError): string { if ($this->exceptionNamespace) { $class = $this->exceptionNamespace.'\\'.$apiError.'Exception'; if (\class_exists($class)) { return $class; } } $class = '\\Contentful\\Core\\Exception\\'.$apiError.'Exception'; return \class_exists($class) ? $class : Exception::class; }
php
private function getExceptionClass(string $apiError): string { if ($this->exceptionNamespace) { $class = $this->exceptionNamespace.'\\'.$apiError.'Exception'; if (\class_exists($class)) { return $class; } } $class = '\\Contentful\\Core\\Exception\\'.$apiError.'Exception'; return \class_exists($class) ? $class : Exception::class; }
[ "private", "function", "getExceptionClass", "(", "string", "$", "apiError", ")", ":", "string", "{", "if", "(", "$", "this", "->", "exceptionNamespace", ")", "{", "$", "class", "=", "$", "this", "->", "exceptionNamespace", ".", "'\\\\'", ".", "$", "apiErro...
Returns the FQCN of an exception class to be used for the given API error. @param string $apiError @return string
[ "Returns", "the", "FQCN", "of", "an", "exception", "class", "to", "be", "used", "for", "the", "given", "API", "error", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/Requester.php#L113-L126
45,693
contentful/contentful-core.php
src/Api/BaseClient.php
BaseClient.callApi
protected function callApi(string $method, string $uri, array $options = []): array { $request = $this->requestBuilder->build($method, $uri, $options); $message = $this->requester->sendRequest($request); $this->messages[] = $message; $this->logMessage($message); $exception = $message->getException(); if (null !== $exception) { throw $exception; } return $this->parseResponse($message->getResponse()); }
php
protected function callApi(string $method, string $uri, array $options = []): array { $request = $this->requestBuilder->build($method, $uri, $options); $message = $this->requester->sendRequest($request); $this->messages[] = $message; $this->logMessage($message); $exception = $message->getException(); if (null !== $exception) { throw $exception; } return $this->parseResponse($message->getResponse()); }
[ "protected", "function", "callApi", "(", "string", "$", "method", ",", "string", "$", "uri", ",", "array", "$", "options", "=", "[", "]", ")", ":", "array", "{", "$", "request", "=", "$", "this", "->", "requestBuilder", "->", "build", "(", "$", "meth...
Make a call to the API and returns the parsed JSON. @param string $method The HTTP method @param string $uri The URI path @param array $options An array of optional parameters. The following keys are accepted: * query An array of query parameters that will be appended to the URI * headers An array of headers that will be added to the request * body The request body * host A string that can be used to override the default client base URI @throws \Exception @return array
[ "Make", "a", "call", "to", "the", "API", "and", "returns", "the", "parsed", "JSON", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseClient.php#L106-L121
45,694
contentful/contentful-core.php
src/Api/BaseClient.php
BaseClient.logMessage
private function logMessage(Message $message) { $logMessage = \sprintf( '%s %s (%.3Fs)', $message->getRequest()->getMethod(), (string) $message->getRequest()->getUri(), $message->getDuration() ); // This is a "simple" log, for general purpose $this->logger->log( $message->getLogLevel(), $logMessage ); // This is a debug log, with all message details, useful for debugging $this->logger->debug($logMessage, $message->jsonSerialize()); }
php
private function logMessage(Message $message) { $logMessage = \sprintf( '%s %s (%.3Fs)', $message->getRequest()->getMethod(), (string) $message->getRequest()->getUri(), $message->getDuration() ); // This is a "simple" log, for general purpose $this->logger->log( $message->getLogLevel(), $logMessage ); // This is a debug log, with all message details, useful for debugging $this->logger->debug($logMessage, $message->jsonSerialize()); }
[ "private", "function", "logMessage", "(", "Message", "$", "message", ")", "{", "$", "logMessage", "=", "\\", "sprintf", "(", "'%s %s (%.3Fs)'", ",", "$", "message", "->", "getRequest", "(", ")", "->", "getMethod", "(", ")", ",", "(", "string", ")", "$", ...
Write information about a message object into the logger. @param Message $message
[ "Write", "information", "about", "a", "message", "object", "into", "the", "logger", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseClient.php#L128-L145
45,695
contentful/contentful-core.php
src/Api/BaseClient.php
BaseClient.parseResponse
private function parseResponse(ResponseInterface $response = null): array { $body = $response ? (string) $response->getBody() : null; return $body ? guzzle_json_decode($body, true) : []; }
php
private function parseResponse(ResponseInterface $response = null): array { $body = $response ? (string) $response->getBody() : null; return $body ? guzzle_json_decode($body, true) : []; }
[ "private", "function", "parseResponse", "(", "ResponseInterface", "$", "response", "=", "null", ")", ":", "array", "{", "$", "body", "=", "$", "response", "?", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ":", "null", ";", "return", ...
Parse the body of a JSON response. @param ResponseInterface|null $response @return array
[ "Parse", "the", "body", "of", "a", "JSON", "response", "." ]
46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536
https://github.com/contentful/contentful-core.php/blob/46e2c49f1d42c0b84f4e4a3b4dcb01c7fed94536/src/Api/BaseClient.php#L154-L163
45,696
eveseat/services
src/Repositories/Character/Notifications.php
Notifications.getCharacterNotifications
public function getCharacterNotifications(int $character_id, int $chunk = 50): Collection { return CharacterNotification::where('character_id', $character_id) ->take($chunk) ->orderBy('timestamp', 'desc') ->get(); }
php
public function getCharacterNotifications(int $character_id, int $chunk = 50): Collection { return CharacterNotification::where('character_id', $character_id) ->take($chunk) ->orderBy('timestamp', 'desc') ->get(); }
[ "public", "function", "getCharacterNotifications", "(", "int", "$", "character_id", ",", "int", "$", "chunk", "=", "50", ")", ":", "Collection", "{", "return", "CharacterNotification", "::", "where", "(", "'character_id'", ",", "$", "character_id", ")", "->", ...
Return notifications for a character. @param int $character_id @param int $chunk @return \Illuminate\Support\Collection
[ "Return", "notifications", "for", "a", "character", "." ]
89562547b16d1a59f49bb0fe12426ce8d6133ee6
https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Notifications.php#L42-L49
45,697
eveseat/services
src/Repositories/Character/Industry.php
Industry.getCharacterIndustry
public function getCharacterIndustry(int $character_id, bool $get = true) { $industry = DB::table('character_industry_jobs as a') ->select(DB::raw(' a.*, ramActivities.*, blueprintType.typeName as blueprintTypeName, productType.typeName as productTypeName, -- -- Start Facility Name Lookup -- CASE when a.station_id BETWEEN 66015148 AND 66015151 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.station_id-6000000) when a.station_id BETWEEN 66000000 AND 66014933 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.station_id-6000001) when a.station_id BETWEEN 66014934 AND 67999999 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.station_id-6000000) when a.station_id BETWEEN 60014861 AND 60014928 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.station_id) when a.station_id BETWEEN 60000000 AND 61000000 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.station_id) when a.station_id >= 61000000 then (SELECT c.name FROM `universe_structures` AS c WHERE c.structure_id = a.station_id) else (SELECT m.itemName FROM mapDenormalize AS m WHERE m.itemID = a.station_id) end AS facilityName')) ->leftJoin( 'ramActivities', 'ramActivities.activityID', '=', 'a.activity_id')// character_industry_jobs aliased to a ->join( 'invTypes as blueprintType', 'blueprintType.typeID', '=', 'a.blueprint_type_id' ) ->join( 'invTypes as productType', 'productType.typeID', '=', 'a.product_type_id' ) ->where('a.character_id', $character_id); if ($get) return $industry->orderBy('end_date', 'desc') ->get(); return $industry; }
php
public function getCharacterIndustry(int $character_id, bool $get = true) { $industry = DB::table('character_industry_jobs as a') ->select(DB::raw(' a.*, ramActivities.*, blueprintType.typeName as blueprintTypeName, productType.typeName as productTypeName, -- -- Start Facility Name Lookup -- CASE when a.station_id BETWEEN 66015148 AND 66015151 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.station_id-6000000) when a.station_id BETWEEN 66000000 AND 66014933 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.station_id-6000001) when a.station_id BETWEEN 66014934 AND 67999999 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.station_id-6000000) when a.station_id BETWEEN 60014861 AND 60014928 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.station_id) when a.station_id BETWEEN 60000000 AND 61000000 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.station_id) when a.station_id >= 61000000 then (SELECT c.name FROM `universe_structures` AS c WHERE c.structure_id = a.station_id) else (SELECT m.itemName FROM mapDenormalize AS m WHERE m.itemID = a.station_id) end AS facilityName')) ->leftJoin( 'ramActivities', 'ramActivities.activityID', '=', 'a.activity_id')// character_industry_jobs aliased to a ->join( 'invTypes as blueprintType', 'blueprintType.typeID', '=', 'a.blueprint_type_id' ) ->join( 'invTypes as productType', 'productType.typeID', '=', 'a.product_type_id' ) ->where('a.character_id', $character_id); if ($get) return $industry->orderBy('end_date', 'desc') ->get(); return $industry; }
[ "public", "function", "getCharacterIndustry", "(", "int", "$", "character_id", ",", "bool", "$", "get", "=", "true", ")", "{", "$", "industry", "=", "DB", "::", "table", "(", "'character_industry_jobs as a'", ")", "->", "select", "(", "DB", "::", "raw", "(...
Return the industry jobs for a character. @param int $character_id @param bool $get @return \Illuminate\Support\Collection
[ "Return", "the", "industry", "jobs", "for", "a", "character", "." ]
89562547b16d1a59f49bb0fe12426ce8d6133ee6
https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Industry.php#L41-L100
45,698
eveseat/services
src/Repositories/Corporation/Contracts.php
Contracts.getCorporationContracts
public function getCorporationContracts( int $corporation_id, bool $get = true, int $chunk = 50) { $contracts = DB::table(DB::raw('contract_details as a')) ->select(DB::raw( ' -- -- All Columns -- *, -- -- Start Location Lookup -- CASE when a.start_location_id BETWEEN 66015148 AND 66015151 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.start_location_id-6000000) when a.start_location_id BETWEEN 66000000 AND 66014933 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.start_location_id-6000001) when a.start_location_id BETWEEN 66014934 AND 67999999 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.start_location_id-6000000) when a.start_location_id BETWEEN 60014861 AND 60014928 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.start_location_id) when a.start_location_id BETWEEN 60000000 AND 61000000 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.start_location_id) when a.start_location_id >= 61000000 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.start_location_id) else (SELECT m.itemName FROM mapDenormalize AS m WHERE m.itemID = a.start_location_id) end AS startlocation, -- -- End Location Lookup -- CASE when a.end_location_id BETWEEN 66015148 AND 66015151 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.end_location_id-6000000) when a.end_location_id BETWEEN 66000000 AND 66014933 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.end_location_id-6000001) when a.end_location_id BETWEEN 66014934 AND 67999999 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.end_location_id-6000000) when a.end_location_id BETWEEN 60014861 AND 60014928 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.end_location_id) when a.end_location_id BETWEEN 60000000 AND 61000000 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.end_location_id) when a.end_location_id >= 61000000 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.end_location_id) else (SELECT m.itemName FROM mapDenormalize AS m WHERE m.itemID = a.end_location_id) end AS endlocation ')) ->join('corporation_contracts', 'corporation_contracts.contract_id', '=', 'a.contract_id') ->where('corporation_contracts.corporation_id', $corporation_id); if ($get) return $contracts ->orderBy('date_issued', 'desc') ->paginate($chunk); return $contracts; }
php
public function getCorporationContracts( int $corporation_id, bool $get = true, int $chunk = 50) { $contracts = DB::table(DB::raw('contract_details as a')) ->select(DB::raw( ' -- -- All Columns -- *, -- -- Start Location Lookup -- CASE when a.start_location_id BETWEEN 66015148 AND 66015151 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.start_location_id-6000000) when a.start_location_id BETWEEN 66000000 AND 66014933 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.start_location_id-6000001) when a.start_location_id BETWEEN 66014934 AND 67999999 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.start_location_id-6000000) when a.start_location_id BETWEEN 60014861 AND 60014928 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.start_location_id) when a.start_location_id BETWEEN 60000000 AND 61000000 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.start_location_id) when a.start_location_id >= 61000000 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.start_location_id) else (SELECT m.itemName FROM mapDenormalize AS m WHERE m.itemID = a.start_location_id) end AS startlocation, -- -- End Location Lookup -- CASE when a.end_location_id BETWEEN 66015148 AND 66015151 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.end_location_id-6000000) when a.end_location_id BETWEEN 66000000 AND 66014933 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.end_location_id-6000001) when a.end_location_id BETWEEN 66014934 AND 67999999 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.end_location_id-6000000) when a.end_location_id BETWEEN 60014861 AND 60014928 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.end_location_id) when a.end_location_id BETWEEN 60000000 AND 61000000 then (SELECT s.stationName FROM staStations AS s WHERE s.stationID = a.end_location_id) when a.end_location_id >= 61000000 then (SELECT d.name FROM `sovereignty_structures` AS c JOIN universe_stations d ON c.structure_id = d.station_id WHERE c.structure_id = a.end_location_id) else (SELECT m.itemName FROM mapDenormalize AS m WHERE m.itemID = a.end_location_id) end AS endlocation ')) ->join('corporation_contracts', 'corporation_contracts.contract_id', '=', 'a.contract_id') ->where('corporation_contracts.corporation_id', $corporation_id); if ($get) return $contracts ->orderBy('date_issued', 'desc') ->paginate($chunk); return $contracts; }
[ "public", "function", "getCorporationContracts", "(", "int", "$", "corporation_id", ",", "bool", "$", "get", "=", "true", ",", "int", "$", "chunk", "=", "50", ")", "{", "$", "contracts", "=", "DB", "::", "table", "(", "DB", "::", "raw", "(", "'contract...
Return the contracts for a Corporation. @param int $corporation_id @param bool $get @param int $chunk @return \Illuminate\Pagination\LengthAwarePaginator
[ "Return", "the", "contracts", "for", "a", "Corporation", "." ]
89562547b16d1a59f49bb0fe12426ce8d6133ee6
https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Contracts.php#L44-L122
45,699
eveseat/services
src/Repositories/Character/Pi.php
Pi.getCharacterPlanetaryColonies
public function getCharacterPlanetaryColonies(int $character_id): Collection { return CharacterPlanet::where('character_id', $character_id) ->join('mapDenormalize as system', 'system.itemID', '=', 'solar_system_id') ->join('mapDenormalize as planet', 'planet.itemID', '=', 'planet_id') ->select('character_planets.*', 'system.itemName', 'planet.typeID') ->get(); }
php
public function getCharacterPlanetaryColonies(int $character_id): Collection { return CharacterPlanet::where('character_id', $character_id) ->join('mapDenormalize as system', 'system.itemID', '=', 'solar_system_id') ->join('mapDenormalize as planet', 'planet.itemID', '=', 'planet_id') ->select('character_planets.*', 'system.itemName', 'planet.typeID') ->get(); }
[ "public", "function", "getCharacterPlanetaryColonies", "(", "int", "$", "character_id", ")", ":", "Collection", "{", "return", "CharacterPlanet", "::", "where", "(", "'character_id'", ",", "$", "character_id", ")", "->", "join", "(", "'mapDenormalize as system'", ",...
Return the Planetary Colonies for a character. @param int $character_id @return \Illuminate\Support\Collection
[ "Return", "the", "Planetary", "Colonies", "for", "a", "character", "." ]
89562547b16d1a59f49bb0fe12426ce8d6133ee6
https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Character/Pi.php#L41-L49