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
225,600
Eve-PHP/Framework
src/Error.php
Error.htmlDetails
public function htmlDetails( $type, $level, $class, $file, $line, $message, $trace, $offset) { $history = array(); for(; isset($trace[$offset]); $offset++) { $row = $trace[$offset]; //lets formulate the method $method = $row['function'].'()'; if(isset($row['class'])) { $method = $row['class'].'->'.$method; } $rowLine = isset($row['line']) ? $row['line'] : 'N/A'; $rowFile = isset($row['file']) ? $row['file'] : 'Virtual Call'; //add to history $history[] = sprintf('%s File: %s Line: %s', $method, $rowFile, $rowLine); } $message = sprintf( '%s %s: "%s" from %s in %s on line %s', $type, $level, $message, $class, $file, $line); return implode("<br />", array( '<h4>'.$message.'</h4>', implode("<br />", $history) )); }
php
public function htmlDetails( $type, $level, $class, $file, $line, $message, $trace, $offset) { $history = array(); for(; isset($trace[$offset]); $offset++) { $row = $trace[$offset]; //lets formulate the method $method = $row['function'].'()'; if(isset($row['class'])) { $method = $row['class'].'->'.$method; } $rowLine = isset($row['line']) ? $row['line'] : 'N/A'; $rowFile = isset($row['file']) ? $row['file'] : 'Virtual Call'; //add to history $history[] = sprintf('%s File: %s Line: %s', $method, $rowFile, $rowLine); } $message = sprintf( '%s %s: "%s" from %s in %s on line %s', $type, $level, $message, $class, $file, $line); return implode("<br />", array( '<h4>'.$message.'</h4>', implode("<br />", $history) )); }
[ "public", "function", "htmlDetails", "(", "$", "type", ",", "$", "level", ",", "$", "class", ",", "$", "file", ",", "$", "line", ",", "$", "message", ",", "$", "trace", ",", "$", "offset", ")", "{", "$", "history", "=", "array", "(", ")", ";", "for", "(", ";", "isset", "(", "$", "trace", "[", "$", "offset", "]", ")", ";", "$", "offset", "++", ")", "{", "$", "row", "=", "$", "trace", "[", "$", "offset", "]", ";", "//lets formulate the method", "$", "method", "=", "$", "row", "[", "'function'", "]", ".", "'()'", ";", "if", "(", "isset", "(", "$", "row", "[", "'class'", "]", ")", ")", "{", "$", "method", "=", "$", "row", "[", "'class'", "]", ".", "'->'", ".", "$", "method", ";", "}", "$", "rowLine", "=", "isset", "(", "$", "row", "[", "'line'", "]", ")", "?", "$", "row", "[", "'line'", "]", ":", "'N/A'", ";", "$", "rowFile", "=", "isset", "(", "$", "row", "[", "'file'", "]", ")", "?", "$", "row", "[", "'file'", "]", ":", "'Virtual Call'", ";", "//add to history", "$", "history", "[", "]", "=", "sprintf", "(", "'%s File: %s Line: %s'", ",", "$", "method", ",", "$", "rowFile", ",", "$", "rowLine", ")", ";", "}", "$", "message", "=", "sprintf", "(", "'%s %s: \"%s\" from %s in %s on line %s'", ",", "$", "type", ",", "$", "level", ",", "$", "message", ",", "$", "class", ",", "$", "file", ",", "$", "line", ")", ";", "return", "implode", "(", "\"<br />\"", ",", "array", "(", "'<h4>'", ".", "$", "message", ".", "'</h4>'", ",", "implode", "(", "\"<br />\"", ",", "$", "history", ")", ")", ")", ";", "}" ]
Output the error details in HTML @param *string $type The error type @param *string $level The error level @param *string $class The class where the error came from @param *string $file The file where the error came from @param *string $line The line where the error came from @param *string $message The error message @param *array $trace The back trace @param *int $offset To only report a subset of the back trace @return void
[ "Output", "the", "error", "details", "in", "HTML" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Error.php#L36-L72
225,601
Eve-PHP/Framework
src/Error.php
Error.jsonDetails
public function jsonDetails( $type, $level, $class, $file, $line, $message, $trace, $offset) { $history = array(); for(; isset($trace[$offset]); $offset++) { $row = $trace[$offset]; //lets formulate the method $method = $row['function'].'()'; if(isset($row['class'])) { $method = $row['class'].'->'.$method; } $rowLine = isset($row['line']) ? $row['line'] : 'N/A'; $rowFile = isset($row['file']) ? $row['file'] : 'Virtual Call'; //add to history $history[] = sprintf('%s File: %s Line: %s', $method, $rowFile, $rowLine); } $message = sprintf( '%s %s: "%s" from %s in %s on line %s', $type, $level, $message, $class, $file, $line); return json_encode(array( 'error' => true, 'message' => $message, 'trace' => $history), JSON_PRETTY_PRINT); }
php
public function jsonDetails( $type, $level, $class, $file, $line, $message, $trace, $offset) { $history = array(); for(; isset($trace[$offset]); $offset++) { $row = $trace[$offset]; //lets formulate the method $method = $row['function'].'()'; if(isset($row['class'])) { $method = $row['class'].'->'.$method; } $rowLine = isset($row['line']) ? $row['line'] : 'N/A'; $rowFile = isset($row['file']) ? $row['file'] : 'Virtual Call'; //add to history $history[] = sprintf('%s File: %s Line: %s', $method, $rowFile, $rowLine); } $message = sprintf( '%s %s: "%s" from %s in %s on line %s', $type, $level, $message, $class, $file, $line); return json_encode(array( 'error' => true, 'message' => $message, 'trace' => $history), JSON_PRETTY_PRINT); }
[ "public", "function", "jsonDetails", "(", "$", "type", ",", "$", "level", ",", "$", "class", ",", "$", "file", ",", "$", "line", ",", "$", "message", ",", "$", "trace", ",", "$", "offset", ")", "{", "$", "history", "=", "array", "(", ")", ";", "for", "(", ";", "isset", "(", "$", "trace", "[", "$", "offset", "]", ")", ";", "$", "offset", "++", ")", "{", "$", "row", "=", "$", "trace", "[", "$", "offset", "]", ";", "//lets formulate the method", "$", "method", "=", "$", "row", "[", "'function'", "]", ".", "'()'", ";", "if", "(", "isset", "(", "$", "row", "[", "'class'", "]", ")", ")", "{", "$", "method", "=", "$", "row", "[", "'class'", "]", ".", "'->'", ".", "$", "method", ";", "}", "$", "rowLine", "=", "isset", "(", "$", "row", "[", "'line'", "]", ")", "?", "$", "row", "[", "'line'", "]", ":", "'N/A'", ";", "$", "rowFile", "=", "isset", "(", "$", "row", "[", "'file'", "]", ")", "?", "$", "row", "[", "'file'", "]", ":", "'Virtual Call'", ";", "//add to history", "$", "history", "[", "]", "=", "sprintf", "(", "'%s File: %s Line: %s'", ",", "$", "method", ",", "$", "rowFile", ",", "$", "rowLine", ")", ";", "}", "$", "message", "=", "sprintf", "(", "'%s %s: \"%s\" from %s in %s on line %s'", ",", "$", "type", ",", "$", "level", ",", "$", "message", ",", "$", "class", ",", "$", "file", ",", "$", "line", ")", ";", "return", "json_encode", "(", "array", "(", "'error'", "=>", "true", ",", "'message'", "=>", "$", "message", ",", "'trace'", "=>", "$", "history", ")", ",", "JSON_PRETTY_PRINT", ")", ";", "}" ]
Output the error details in JSON @param *string $type The error type @param *string $level The error level @param *string $class The class where the error came from @param *string $file The file where the error came from @param *string $line The line where the error came from @param *string $message The error message @param *array $trace The back trace @param *int $offset To only report a subset of the back trace @return void
[ "Output", "the", "error", "details", "in", "JSON" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Error.php#L115-L152
225,602
Eve-PHP/Framework
src/Error.php
Error.jsonGeneric
public function jsonGeneric( $type, $level, $class, $file, $line, $message, $trace, $offset) { return json_encode(array( 'error' => true, 'message' => 'A server Error occurred'), JSON_PRETTY_PRINT); }
php
public function jsonGeneric( $type, $level, $class, $file, $line, $message, $trace, $offset) { return json_encode(array( 'error' => true, 'message' => 'A server Error occurred'), JSON_PRETTY_PRINT); }
[ "public", "function", "jsonGeneric", "(", "$", "type", ",", "$", "level", ",", "$", "class", ",", "$", "file", ",", "$", "line", ",", "$", "message", ",", "$", "trace", ",", "$", "offset", ")", "{", "return", "json_encode", "(", "array", "(", "'error'", "=>", "true", ",", "'message'", "=>", "'A server Error occurred'", ")", ",", "JSON_PRETTY_PRINT", ")", ";", "}" ]
Output the generic error in JSON @param *string $type The error type @param *string $level The error level @param *string $class The class where the error came from @param *string $file The file where the error came from @param *string $line The line where the error came from @param *string $message The error message @param *array $trace The back trace @param *int $offset To only report a subset of the back trace @return void
[ "Output", "the", "generic", "error", "in", "JSON" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Error.php#L168-L182
225,603
Eve-PHP/Framework
src/Queue.php
Queue.save
public function save($queue = 'queue') { // declare queue container $this->channel->queue_declare( $queue, false, $this->durable, false, false, false, ['x-max-priority' => ['I', 10]]); // set message $message = new AMQPMessage(json_encode($this->message), $this->setOptions()); // if no delay queue it now if (!$this->delay) { $this->channel->exchange_declare($queue.'-xchnge', 'direct'); $this->channel->queue_bind($queue, $queue.'-xchnge'); // queue it up main queue container $this->channel->basic_publish($message, $queue.'-xchnge'); return $this; } $this->channel->exchange_declare('xchnge-delay', 'x-delayed-message', false, /* passive, create if exchange doesn't exist */ true, /* durable, persist through server reboots */ false, /* autodelete */ false, /* internal */ false, /* nowait */ ['x-delayed-type' => ['S', 'direct']]); $this->channel->queue_bind($queue, 'xchnge-delay', 'delay_route'); // queue it up on delay container $this->channel->basic_publish($message, 'xchnge-delay', 'delay_route'); return $this; }
php
public function save($queue = 'queue') { // declare queue container $this->channel->queue_declare( $queue, false, $this->durable, false, false, false, ['x-max-priority' => ['I', 10]]); // set message $message = new AMQPMessage(json_encode($this->message), $this->setOptions()); // if no delay queue it now if (!$this->delay) { $this->channel->exchange_declare($queue.'-xchnge', 'direct'); $this->channel->queue_bind($queue, $queue.'-xchnge'); // queue it up main queue container $this->channel->basic_publish($message, $queue.'-xchnge'); return $this; } $this->channel->exchange_declare('xchnge-delay', 'x-delayed-message', false, /* passive, create if exchange doesn't exist */ true, /* durable, persist through server reboots */ false, /* autodelete */ false, /* internal */ false, /* nowait */ ['x-delayed-type' => ['S', 'direct']]); $this->channel->queue_bind($queue, 'xchnge-delay', 'delay_route'); // queue it up on delay container $this->channel->basic_publish($message, 'xchnge-delay', 'delay_route'); return $this; }
[ "public", "function", "save", "(", "$", "queue", "=", "'queue'", ")", "{", "// declare queue container", "$", "this", "->", "channel", "->", "queue_declare", "(", "$", "queue", ",", "false", ",", "$", "this", "->", "durable", ",", "false", ",", "false", ",", "false", ",", "[", "'x-max-priority'", "=>", "[", "'I'", ",", "10", "]", "]", ")", ";", "// set message", "$", "message", "=", "new", "AMQPMessage", "(", "json_encode", "(", "$", "this", "->", "message", ")", ",", "$", "this", "->", "setOptions", "(", ")", ")", ";", "// if no delay queue it now", "if", "(", "!", "$", "this", "->", "delay", ")", "{", "$", "this", "->", "channel", "->", "exchange_declare", "(", "$", "queue", ".", "'-xchnge'", ",", "'direct'", ")", ";", "$", "this", "->", "channel", "->", "queue_bind", "(", "$", "queue", ",", "$", "queue", ".", "'-xchnge'", ")", ";", "// queue it up main queue container", "$", "this", "->", "channel", "->", "basic_publish", "(", "$", "message", ",", "$", "queue", ".", "'-xchnge'", ")", ";", "return", "$", "this", ";", "}", "$", "this", "->", "channel", "->", "exchange_declare", "(", "'xchnge-delay'", ",", "'x-delayed-message'", ",", "false", ",", "/* passive, create if exchange doesn't exist */", "true", ",", "/* durable, persist through server reboots */", "false", ",", "/* autodelete */", "false", ",", "/* internal */", "false", ",", "/* nowait */", "[", "'x-delayed-type'", "=>", "[", "'S'", ",", "'direct'", "]", "]", ")", ";", "$", "this", "->", "channel", "->", "queue_bind", "(", "$", "queue", ",", "'xchnge-delay'", ",", "'delay_route'", ")", ";", "// queue it up on delay container", "$", "this", "->", "channel", "->", "basic_publish", "(", "$", "message", ",", "'xchnge-delay'", ",", "'delay_route'", ")", ";", "return", "$", "this", ";", "}" ]
Process the add queue request @return Eve\Framework\Queue
[ "Process", "the", "add", "queue", "request" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Queue.php#L381-L422
225,604
Innmind/Filesystem
src/File/File.php
File.withContent
public function withContent(Readable $content): self { $file = clone $this; $file->content = $content; return $file; }
php
public function withContent(Readable $content): self { $file = clone $this; $file->content = $content; return $file; }
[ "public", "function", "withContent", "(", "Readable", "$", "content", ")", ":", "self", "{", "$", "file", "=", "clone", "$", "this", ";", "$", "file", "->", "content", "=", "$", "content", ";", "return", "$", "file", ";", "}" ]
New file reference with a different content @return self
[ "New", "file", "reference", "with", "a", "different", "content" ]
21700d8424bc88e99fd5c612c5316613e4c45a3b
https://github.com/Innmind/Filesystem/blob/21700d8424bc88e99fd5c612c5316613e4c45a3b/src/File/File.php#L56-L62
225,605
ricardopedias/report-collection
src/Libs/OldCollector.php
OldCollector.createFromArray
public static function createFromArray(array $array) { self::$instance = new Collector; self::$instance->buffer = null; $spreadsheet = new Spreadsheet(); $spreadsheet->getActiveSheet() ->fromArray( $array, // os dados a adicionar NULL // itens com este valor não serão setados ); self::$instance->buffer = $spreadsheet; self::$instance->debug_info = ['created_with' => __METHOD__]; return self::$instance; }
php
public static function createFromArray(array $array) { self::$instance = new Collector; self::$instance->buffer = null; $spreadsheet = new Spreadsheet(); $spreadsheet->getActiveSheet() ->fromArray( $array, // os dados a adicionar NULL // itens com este valor não serão setados ); self::$instance->buffer = $spreadsheet; self::$instance->debug_info = ['created_with' => __METHOD__]; return self::$instance; }
[ "public", "static", "function", "createFromArray", "(", "array", "$", "array", ")", "{", "self", "::", "$", "instance", "=", "new", "Collector", ";", "self", "::", "$", "instance", "->", "buffer", "=", "null", ";", "$", "spreadsheet", "=", "new", "Spreadsheet", "(", ")", ";", "$", "spreadsheet", "->", "getActiveSheet", "(", ")", "->", "fromArray", "(", "$", "array", ",", "// os dados a adicionar", "NULL", "// itens com este valor não serão setados", ")", ";", "self", "::", "$", "instance", "->", "buffer", "=", "$", "spreadsheet", ";", "self", "::", "$", "instance", "->", "debug_info", "=", "[", "'created_with'", "=>", "__METHOD__", "]", ";", "return", "self", "::", "$", "instance", ";", "}" ]
Cria uma planilha a partir de um array @param array $array
[ "Cria", "uma", "planilha", "a", "partir", "de", "um", "array" ]
8536e2c48f83fa12b5cea20737d50da20945b71d
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/OldCollector.php#L186-L204
225,606
ricardopedias/report-collection
src/Libs/OldCollector.php
OldCollector.setupBody
private function setupBody() { $ended_row = $this->getLastRow(); $ended_col = $this->getLastColumn(); // Aplica os estilos a cada célula independente for ($row=1; $row<=$ended_row; $row++) { for ($col=1; $col<=$ended_col; $col++) { $this->applyStyles('body', $row, $col); } } }
php
private function setupBody() { $ended_row = $this->getLastRow(); $ended_col = $this->getLastColumn(); // Aplica os estilos a cada célula independente for ($row=1; $row<=$ended_row; $row++) { for ($col=1; $col<=$ended_col; $col++) { $this->applyStyles('body', $row, $col); } } }
[ "private", "function", "setupBody", "(", ")", "{", "$", "ended_row", "=", "$", "this", "->", "getLastRow", "(", ")", ";", "$", "ended_col", "=", "$", "this", "->", "getLastColumn", "(", ")", ";", "// Aplica os estilos a cada célula independente", "for", "(", "$", "row", "=", "1", ";", "$", "row", "<=", "$", "ended_row", ";", "$", "row", "++", ")", "{", "for", "(", "$", "col", "=", "1", ";", "$", "col", "<=", "$", "ended_col", ";", "$", "col", "++", ")", "{", "$", "this", "->", "applyStyles", "(", "'body'", ",", "$", "row", ",", "$", "col", ")", ";", "}", "}", "}" ]
Prepara e configura o corpo da planilha.
[ "Prepara", "e", "configura", "o", "corpo", "da", "planilha", "." ]
8536e2c48f83fa12b5cea20737d50da20945b71d
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/OldCollector.php#L387-L399
225,607
ricardopedias/report-collection
src/Libs/OldCollector.php
OldCollector.toArray
public function toArray() { // Planilhas do Gnumeric e Xlsx // possuem linha e colunas nulas na exportação de array // por isso, são removidas aqui $list = []; $array = $this->getActiveSheet()->toArray(); // Linhas foreach($array as $row_id => $rows) { $line = array_filter($rows, function($v){ return !is_null($v); }); if (!empty($line)) { $list[] = $line; } } return $list; }
php
public function toArray() { // Planilhas do Gnumeric e Xlsx // possuem linha e colunas nulas na exportação de array // por isso, são removidas aqui $list = []; $array = $this->getActiveSheet()->toArray(); // Linhas foreach($array as $row_id => $rows) { $line = array_filter($rows, function($v){ return !is_null($v); }); if (!empty($line)) { $list[] = $line; } } return $list; }
[ "public", "function", "toArray", "(", ")", "{", "// Planilhas do Gnumeric e Xlsx", "// possuem linha e colunas nulas na exportação de array", "// por isso, são removidas aqui", "$", "list", "=", "[", "]", ";", "$", "array", "=", "$", "this", "->", "getActiveSheet", "(", ")", "->", "toArray", "(", ")", ";", "// Linhas", "foreach", "(", "$", "array", "as", "$", "row_id", "=>", "$", "rows", ")", "{", "$", "line", "=", "array_filter", "(", "$", "rows", ",", "function", "(", "$", "v", ")", "{", "return", "!", "is_null", "(", "$", "v", ")", ";", "}", ")", ";", "if", "(", "!", "empty", "(", "$", "line", ")", ")", "{", "$", "list", "[", "]", "=", "$", "line", ";", "}", "}", "return", "$", "list", ";", "}" ]
Devolve os dados da planilha em forma de array. @return array
[ "Devolve", "os", "dados", "da", "planilha", "em", "forma", "de", "array", "." ]
8536e2c48f83fa12b5cea20737d50da20945b71d
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/OldCollector.php#L824-L843
225,608
ricardopedias/report-collection
src/Libs/OldCollector.php
OldCollector.toXml
public function toXml() { $data = $this->toArray(); $writer = new \SimpleXMLElement('<Table/>'); $headers = []; foreach ($data as $index => $item) { if ($index==0) { $headers = $item; } $child = $writer->addChild('Row'); foreach ($headers as $k => $name) { $child->addChild('Cell', $item[$k]); } } $dom = dom_import_simplexml($writer)->ownerDocument; $dom->formatOutput = true; // $dom->save($filename); return $dom->saveXML(); }
php
public function toXml() { $data = $this->toArray(); $writer = new \SimpleXMLElement('<Table/>'); $headers = []; foreach ($data as $index => $item) { if ($index==0) { $headers = $item; } $child = $writer->addChild('Row'); foreach ($headers as $k => $name) { $child->addChild('Cell', $item[$k]); } } $dom = dom_import_simplexml($writer)->ownerDocument; $dom->formatOutput = true; // $dom->save($filename); return $dom->saveXML(); }
[ "public", "function", "toXml", "(", ")", "{", "$", "data", "=", "$", "this", "->", "toArray", "(", ")", ";", "$", "writer", "=", "new", "\\", "SimpleXMLElement", "(", "'<Table/>'", ")", ";", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "index", "=>", "$", "item", ")", "{", "if", "(", "$", "index", "==", "0", ")", "{", "$", "headers", "=", "$", "item", ";", "}", "$", "child", "=", "$", "writer", "->", "addChild", "(", "'Row'", ")", ";", "foreach", "(", "$", "headers", "as", "$", "k", "=>", "$", "name", ")", "{", "$", "child", "->", "addChild", "(", "'Cell'", ",", "$", "item", "[", "$", "k", "]", ")", ";", "}", "}", "$", "dom", "=", "dom_import_simplexml", "(", "$", "writer", ")", "->", "ownerDocument", ";", "$", "dom", "->", "formatOutput", "=", "true", ";", "// $dom->save($filename);", "return", "$", "dom", "->", "saveXML", "(", ")", ";", "}" ]
Devolve os dados da planilha em forma de xml. @return string
[ "Devolve", "os", "dados", "da", "planilha", "em", "forma", "de", "xml", "." ]
8536e2c48f83fa12b5cea20737d50da20945b71d
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/OldCollector.php#L850-L871
225,609
bytic/Common
src/Records/Traits/Media/Images/RecordTrait.php
RecordTrait.uploadImage
public function uploadImage() { $image = $this->getTempImage(); $file = $_FILES['Filedata']; $uploadError = Nip_File_System::instance()->getUploadError($file, $image->extensions); if (!$uploadError) { $image->setResourceFromUpload($file); if ($image->validate()) { $image->resize(); $image->save(); $imageCrop = $this->getTempImage(); $imageCrop->copyResource($image); $ratio = $imageCrop->getRatio(); $max_width = $imageCrop->minWidth > 600 ? $imageCrop->minWidth : 600; $heightCalculated = round($max_width / $ratio); if ($heightCalculated < $imageCrop->minHeight) { $max_width = round($imageCrop->minHeight * $ratio); } $imageCrop->max_width = $max_width; $imageCrop->setName('crop-' . $image->name); $imageCrop->resize(); $imageCrop->save(); return $imageCrop; } else { $this->errors['upload'] = 'Eroare dimensiuni.'; } } else { $this->errors['upload'] = $uploadError; } return false; }
php
public function uploadImage() { $image = $this->getTempImage(); $file = $_FILES['Filedata']; $uploadError = Nip_File_System::instance()->getUploadError($file, $image->extensions); if (!$uploadError) { $image->setResourceFromUpload($file); if ($image->validate()) { $image->resize(); $image->save(); $imageCrop = $this->getTempImage(); $imageCrop->copyResource($image); $ratio = $imageCrop->getRatio(); $max_width = $imageCrop->minWidth > 600 ? $imageCrop->minWidth : 600; $heightCalculated = round($max_width / $ratio); if ($heightCalculated < $imageCrop->minHeight) { $max_width = round($imageCrop->minHeight * $ratio); } $imageCrop->max_width = $max_width; $imageCrop->setName('crop-' . $image->name); $imageCrop->resize(); $imageCrop->save(); return $imageCrop; } else { $this->errors['upload'] = 'Eroare dimensiuni.'; } } else { $this->errors['upload'] = $uploadError; } return false; }
[ "public", "function", "uploadImage", "(", ")", "{", "$", "image", "=", "$", "this", "->", "getTempImage", "(", ")", ";", "$", "file", "=", "$", "_FILES", "[", "'Filedata'", "]", ";", "$", "uploadError", "=", "Nip_File_System", "::", "instance", "(", ")", "->", "getUploadError", "(", "$", "file", ",", "$", "image", "->", "extensions", ")", ";", "if", "(", "!", "$", "uploadError", ")", "{", "$", "image", "->", "setResourceFromUpload", "(", "$", "file", ")", ";", "if", "(", "$", "image", "->", "validate", "(", ")", ")", "{", "$", "image", "->", "resize", "(", ")", ";", "$", "image", "->", "save", "(", ")", ";", "$", "imageCrop", "=", "$", "this", "->", "getTempImage", "(", ")", ";", "$", "imageCrop", "->", "copyResource", "(", "$", "image", ")", ";", "$", "ratio", "=", "$", "imageCrop", "->", "getRatio", "(", ")", ";", "$", "max_width", "=", "$", "imageCrop", "->", "minWidth", ">", "600", "?", "$", "imageCrop", "->", "minWidth", ":", "600", ";", "$", "heightCalculated", "=", "round", "(", "$", "max_width", "/", "$", "ratio", ")", ";", "if", "(", "$", "heightCalculated", "<", "$", "imageCrop", "->", "minHeight", ")", "{", "$", "max_width", "=", "round", "(", "$", "imageCrop", "->", "minHeight", "*", "$", "ratio", ")", ";", "}", "$", "imageCrop", "->", "max_width", "=", "$", "max_width", ";", "$", "imageCrop", "->", "setName", "(", "'crop-'", ".", "$", "image", "->", "name", ")", ";", "$", "imageCrop", "->", "resize", "(", ")", ";", "$", "imageCrop", "->", "save", "(", ")", ";", "return", "$", "imageCrop", ";", "}", "else", "{", "$", "this", "->", "errors", "[", "'upload'", "]", "=", "'Eroare dimensiuni.'", ";", "}", "}", "else", "{", "$", "this", "->", "errors", "[", "'upload'", "]", "=", "$", "uploadError", ";", "}", "return", "false", ";", "}" ]
Uploads image to temporary directory @return mixed
[ "Uploads", "image", "to", "temporary", "directory" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/Media/Images/RecordTrait.php#L32-L69
225,610
bytic/Common
src/Records/Traits/Media/Images/RecordTrait.php
RecordTrait.cropImages
public function cropImages($request) { $path = $request['path']; $coords = $this->getCropCoordinates($request); $images = $this->getNewImages(); $full = reset($this->_imageTypes); $cropperImage = $this->getTempImage(); $cropperImage->setResourceFromFile(UPLOADS_PATH . 'tmp/' . $path); $originalImage = $this->getTempImage(); $originalImage->setResourceFromFile(UPLOADS_PATH . 'tmp/' . str_replace('crop-', '', $path)); $images[$full]->setResourceFromFile($originalImage->getFile()); $images[$full]->save(); $crop = next($this->_imageTypes); $images[$crop]->copyResource($images[$full]); $ratio = $images[$full]->getWidth() / $cropperImage->getWidth(); $adjustX = round($coords['x'] * $ratio); $adjustY = round($coords['y'] * $ratio); $adjustWidth = round($coords['width'] * $ratio); $adjustHeight = round($coords['height'] * $ratio); $images[$crop]->crop( $adjustX, $adjustY, $this->getImageWidth($crop), $this->getImageHeight($crop), $adjustWidth, $adjustHeight); while ($size = next($this->_imageTypes)) { $images[$size]->copyResource($images[$crop])->resize()->unsharpMask()->save(); } $images[$crop]->unsharpMask()->save(); Nip_File_System::instance()->deleteFile($cropperImage->getFile()); Nip_File_System::instance()->deleteFile($originalImage->getFile()); return $images['default']; }
php
public function cropImages($request) { $path = $request['path']; $coords = $this->getCropCoordinates($request); $images = $this->getNewImages(); $full = reset($this->_imageTypes); $cropperImage = $this->getTempImage(); $cropperImage->setResourceFromFile(UPLOADS_PATH . 'tmp/' . $path); $originalImage = $this->getTempImage(); $originalImage->setResourceFromFile(UPLOADS_PATH . 'tmp/' . str_replace('crop-', '', $path)); $images[$full]->setResourceFromFile($originalImage->getFile()); $images[$full]->save(); $crop = next($this->_imageTypes); $images[$crop]->copyResource($images[$full]); $ratio = $images[$full]->getWidth() / $cropperImage->getWidth(); $adjustX = round($coords['x'] * $ratio); $adjustY = round($coords['y'] * $ratio); $adjustWidth = round($coords['width'] * $ratio); $adjustHeight = round($coords['height'] * $ratio); $images[$crop]->crop( $adjustX, $adjustY, $this->getImageWidth($crop), $this->getImageHeight($crop), $adjustWidth, $adjustHeight); while ($size = next($this->_imageTypes)) { $images[$size]->copyResource($images[$crop])->resize()->unsharpMask()->save(); } $images[$crop]->unsharpMask()->save(); Nip_File_System::instance()->deleteFile($cropperImage->getFile()); Nip_File_System::instance()->deleteFile($originalImage->getFile()); return $images['default']; }
[ "public", "function", "cropImages", "(", "$", "request", ")", "{", "$", "path", "=", "$", "request", "[", "'path'", "]", ";", "$", "coords", "=", "$", "this", "->", "getCropCoordinates", "(", "$", "request", ")", ";", "$", "images", "=", "$", "this", "->", "getNewImages", "(", ")", ";", "$", "full", "=", "reset", "(", "$", "this", "->", "_imageTypes", ")", ";", "$", "cropperImage", "=", "$", "this", "->", "getTempImage", "(", ")", ";", "$", "cropperImage", "->", "setResourceFromFile", "(", "UPLOADS_PATH", ".", "'tmp/'", ".", "$", "path", ")", ";", "$", "originalImage", "=", "$", "this", "->", "getTempImage", "(", ")", ";", "$", "originalImage", "->", "setResourceFromFile", "(", "UPLOADS_PATH", ".", "'tmp/'", ".", "str_replace", "(", "'crop-'", ",", "''", ",", "$", "path", ")", ")", ";", "$", "images", "[", "$", "full", "]", "->", "setResourceFromFile", "(", "$", "originalImage", "->", "getFile", "(", ")", ")", ";", "$", "images", "[", "$", "full", "]", "->", "save", "(", ")", ";", "$", "crop", "=", "next", "(", "$", "this", "->", "_imageTypes", ")", ";", "$", "images", "[", "$", "crop", "]", "->", "copyResource", "(", "$", "images", "[", "$", "full", "]", ")", ";", "$", "ratio", "=", "$", "images", "[", "$", "full", "]", "->", "getWidth", "(", ")", "/", "$", "cropperImage", "->", "getWidth", "(", ")", ";", "$", "adjustX", "=", "round", "(", "$", "coords", "[", "'x'", "]", "*", "$", "ratio", ")", ";", "$", "adjustY", "=", "round", "(", "$", "coords", "[", "'y'", "]", "*", "$", "ratio", ")", ";", "$", "adjustWidth", "=", "round", "(", "$", "coords", "[", "'width'", "]", "*", "$", "ratio", ")", ";", "$", "adjustHeight", "=", "round", "(", "$", "coords", "[", "'height'", "]", "*", "$", "ratio", ")", ";", "$", "images", "[", "$", "crop", "]", "->", "crop", "(", "$", "adjustX", ",", "$", "adjustY", ",", "$", "this", "->", "getImageWidth", "(", "$", "crop", ")", ",", "$", "this", "->", "getImageHeight", "(", "$", "crop", ")", ",", "$", "adjustWidth", ",", "$", "adjustHeight", ")", ";", "while", "(", "$", "size", "=", "next", "(", "$", "this", "->", "_imageTypes", ")", ")", "{", "$", "images", "[", "$", "size", "]", "->", "copyResource", "(", "$", "images", "[", "$", "crop", "]", ")", "->", "resize", "(", ")", "->", "unsharpMask", "(", ")", "->", "save", "(", ")", ";", "}", "$", "images", "[", "$", "crop", "]", "->", "unsharpMask", "(", ")", "->", "save", "(", ")", ";", "Nip_File_System", "::", "instance", "(", ")", "->", "deleteFile", "(", "$", "cropperImage", "->", "getFile", "(", ")", ")", ";", "Nip_File_System", "::", "instance", "(", ")", "->", "deleteFile", "(", "$", "originalImage", "->", "getFile", "(", ")", ")", ";", "return", "$", "images", "[", "'default'", "]", ";", "}" ]
Saves cropped images @param array $request
[ "Saves", "cropped", "images" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/Media/Images/RecordTrait.php#L266-L307
225,611
DrNixx/yii2-onix
src/i18n/TranslationTrait.php
TranslationTrait.initI18N
public function initI18N($dir = '', $cat = '') { if (empty($cat) && empty($this->_msgCat)) { return; } if (empty($cat)) { $cat = $this->_msgCat; } if (empty($dir)) { $reflector = new \ReflectionClass(get_class($this)); $dir = dirname($reflector->getFileName()); } Yii::setAlias("@{$cat}", $dir); $config = [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => "@{$cat}/messages", 'forceTranslation' => true ]; $globalConfig = ArrayHelper::getValue(Yii::$app->i18n->translations, "{$cat}*", []); if (!empty($globalConfig)) { $config = array_merge($config, is_array($globalConfig) ? $globalConfig : (array) $globalConfig); } if (!empty($this->i18n) && is_array($this->i18n)) { $config = array_merge($config, $this->i18n); } Yii::$app->i18n->translations["{$cat}*"] = $config; }
php
public function initI18N($dir = '', $cat = '') { if (empty($cat) && empty($this->_msgCat)) { return; } if (empty($cat)) { $cat = $this->_msgCat; } if (empty($dir)) { $reflector = new \ReflectionClass(get_class($this)); $dir = dirname($reflector->getFileName()); } Yii::setAlias("@{$cat}", $dir); $config = [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => "@{$cat}/messages", 'forceTranslation' => true ]; $globalConfig = ArrayHelper::getValue(Yii::$app->i18n->translations, "{$cat}*", []); if (!empty($globalConfig)) { $config = array_merge($config, is_array($globalConfig) ? $globalConfig : (array) $globalConfig); } if (!empty($this->i18n) && is_array($this->i18n)) { $config = array_merge($config, $this->i18n); } Yii::$app->i18n->translations["{$cat}*"] = $config; }
[ "public", "function", "initI18N", "(", "$", "dir", "=", "''", ",", "$", "cat", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "cat", ")", "&&", "empty", "(", "$", "this", "->", "_msgCat", ")", ")", "{", "return", ";", "}", "if", "(", "empty", "(", "$", "cat", ")", ")", "{", "$", "cat", "=", "$", "this", "->", "_msgCat", ";", "}", "if", "(", "empty", "(", "$", "dir", ")", ")", "{", "$", "reflector", "=", "new", "\\", "ReflectionClass", "(", "get_class", "(", "$", "this", ")", ")", ";", "$", "dir", "=", "dirname", "(", "$", "reflector", "->", "getFileName", "(", ")", ")", ";", "}", "Yii", "::", "setAlias", "(", "\"@{$cat}\"", ",", "$", "dir", ")", ";", "$", "config", "=", "[", "'class'", "=>", "'yii\\i18n\\PhpMessageSource'", ",", "'basePath'", "=>", "\"@{$cat}/messages\"", ",", "'forceTranslation'", "=>", "true", "]", ";", "$", "globalConfig", "=", "ArrayHelper", "::", "getValue", "(", "Yii", "::", "$", "app", "->", "i18n", "->", "translations", ",", "\"{$cat}*\"", ",", "[", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "globalConfig", ")", ")", "{", "$", "config", "=", "array_merge", "(", "$", "config", ",", "is_array", "(", "$", "globalConfig", ")", "?", "$", "globalConfig", ":", "(", "array", ")", "$", "globalConfig", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "i18n", ")", "&&", "is_array", "(", "$", "this", "->", "i18n", ")", ")", "{", "$", "config", "=", "array_merge", "(", "$", "config", ",", "$", "this", "->", "i18n", ")", ";", "}", "Yii", "::", "$", "app", "->", "i18n", "->", "translations", "[", "\"{$cat}*\"", "]", "=", "$", "config", ";", "}" ]
Yii i18n messages configuration for generating translations @param string $dir the directory path where translation files will exist @param string $cat the message category @return void
[ "Yii", "i18n", "messages", "configuration", "for", "generating", "translations" ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/i18n/TranslationTrait.php#L22-L54
225,612
stubbles/stubbles-input
src/main/php/valuereader/DefaultValueReader.php
DefaultValueReader.checkDefaultType
private function checkDefaultType(\Closure $isCorrectType, string $expectedType) { if (!$isCorrectType()) { throw new \LogicException( 'Default value is not of type ' . $expectedType . ' but of type ' . typeOf($this->default) ); } }
php
private function checkDefaultType(\Closure $isCorrectType, string $expectedType) { if (!$isCorrectType()) { throw new \LogicException( 'Default value is not of type ' . $expectedType . ' but of type ' . typeOf($this->default) ); } }
[ "private", "function", "checkDefaultType", "(", "\\", "Closure", "$", "isCorrectType", ",", "string", "$", "expectedType", ")", "{", "if", "(", "!", "$", "isCorrectType", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Default value is not of type '", ".", "$", "expectedType", ".", "' but of type '", ".", "typeOf", "(", "$", "this", "->", "default", ")", ")", ";", "}", "}" ]
checks type of default value @param \Closure $isCorrectType check to be executed when default value is not null @param string $expectedType expected type of default value @throws \LogicException
[ "checks", "type", "of", "default", "value" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/valuereader/DefaultValueReader.php#L59-L67
225,613
SetBased/php-abc-url
src/Url.php
Url.combine
public static function combine(string $uri1, string $uri2): string { $parts2 = parse_url($uri2); if (isset($parts2['scheme']) || isset($parts2['host'])) { // The second URI is an absolute URI. Take all parts from second URI. $combined_uri_parts = $parts2; // The scheme might by omitted. The default scheme is http. if (!isset($combined_uri_parts['scheme'])) $combined_uri_parts['scheme'] = 'http'; } else { $parts1 = parse_url($uri1); $combined_uri_parts = array_merge($parts1, $parts2); // Handle spacial cases for the path part of the URI. if (!isset($parts2['path'])) { // Checking path in $uri2_parts and if path is empty, getting path from $_uri using [normalize_path] $combined_uri_parts['path'] = self::normalizePath($parts1['path']); } elseif (strpos($parts2['path'], '/')===0) { // Checking path in $uri2_parts and if path have '/', do nothing. ; } else { // Else create path using $_uri['path'] and $uri2_parts['path']. With using [normalize_path]. $_path = $parts1['path']; if (strpos($_path, '/')===false) { $_path = ''; } else { $_path = preg_replace('/\/[^\/]+$/', '/', $_path); } if (!isset($_path) && !isset($parts1['host'])) { $_path = '/'; } $combined_uri_parts['path'] = self::normalizePath($_path.$parts2['path']); } // Handle spacial cases for the query part of the URI. if (!isset($parts2['path'])) { if (!isset($parts2['query'])) { $combined_uri_parts['query'] = $parts1['query']; } } elseif (strpos($parts2['path'], '/')===0) { if (isset($parts2['query'])) { $combined_uri_parts['query'] = $parts2['query']; } else { $combined_uri_parts['query'] = null; } } else { if (isset($parts2['query'])) { $combined_uri_parts['query'] = $parts2['query']; } else { $combined_uri_parts['query'] = null; } } } return self::unParseUrl($combined_uri_parts); }
php
public static function combine(string $uri1, string $uri2): string { $parts2 = parse_url($uri2); if (isset($parts2['scheme']) || isset($parts2['host'])) { // The second URI is an absolute URI. Take all parts from second URI. $combined_uri_parts = $parts2; // The scheme might by omitted. The default scheme is http. if (!isset($combined_uri_parts['scheme'])) $combined_uri_parts['scheme'] = 'http'; } else { $parts1 = parse_url($uri1); $combined_uri_parts = array_merge($parts1, $parts2); // Handle spacial cases for the path part of the URI. if (!isset($parts2['path'])) { // Checking path in $uri2_parts and if path is empty, getting path from $_uri using [normalize_path] $combined_uri_parts['path'] = self::normalizePath($parts1['path']); } elseif (strpos($parts2['path'], '/')===0) { // Checking path in $uri2_parts and if path have '/', do nothing. ; } else { // Else create path using $_uri['path'] and $uri2_parts['path']. With using [normalize_path]. $_path = $parts1['path']; if (strpos($_path, '/')===false) { $_path = ''; } else { $_path = preg_replace('/\/[^\/]+$/', '/', $_path); } if (!isset($_path) && !isset($parts1['host'])) { $_path = '/'; } $combined_uri_parts['path'] = self::normalizePath($_path.$parts2['path']); } // Handle spacial cases for the query part of the URI. if (!isset($parts2['path'])) { if (!isset($parts2['query'])) { $combined_uri_parts['query'] = $parts1['query']; } } elseif (strpos($parts2['path'], '/')===0) { if (isset($parts2['query'])) { $combined_uri_parts['query'] = $parts2['query']; } else { $combined_uri_parts['query'] = null; } } else { if (isset($parts2['query'])) { $combined_uri_parts['query'] = $parts2['query']; } else { $combined_uri_parts['query'] = null; } } } return self::unParseUrl($combined_uri_parts); }
[ "public", "static", "function", "combine", "(", "string", "$", "uri1", ",", "string", "$", "uri2", ")", ":", "string", "{", "$", "parts2", "=", "parse_url", "(", "$", "uri2", ")", ";", "if", "(", "isset", "(", "$", "parts2", "[", "'scheme'", "]", ")", "||", "isset", "(", "$", "parts2", "[", "'host'", "]", ")", ")", "{", "// The second URI is an absolute URI. Take all parts from second URI.", "$", "combined_uri_parts", "=", "$", "parts2", ";", "// The scheme might by omitted. The default scheme is http.", "if", "(", "!", "isset", "(", "$", "combined_uri_parts", "[", "'scheme'", "]", ")", ")", "$", "combined_uri_parts", "[", "'scheme'", "]", "=", "'http'", ";", "}", "else", "{", "$", "parts1", "=", "parse_url", "(", "$", "uri1", ")", ";", "$", "combined_uri_parts", "=", "array_merge", "(", "$", "parts1", ",", "$", "parts2", ")", ";", "// Handle spacial cases for the path part of the URI.", "if", "(", "!", "isset", "(", "$", "parts2", "[", "'path'", "]", ")", ")", "{", "// Checking path in $uri2_parts and if path is empty, getting path from $_uri using [normalize_path]", "$", "combined_uri_parts", "[", "'path'", "]", "=", "self", "::", "normalizePath", "(", "$", "parts1", "[", "'path'", "]", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "parts2", "[", "'path'", "]", ",", "'/'", ")", "===", "0", ")", "{", "// Checking path in $uri2_parts and if path have '/', do nothing.", ";", "}", "else", "{", "// Else create path using $_uri['path'] and $uri2_parts['path']. With using [normalize_path].", "$", "_path", "=", "$", "parts1", "[", "'path'", "]", ";", "if", "(", "strpos", "(", "$", "_path", ",", "'/'", ")", "===", "false", ")", "{", "$", "_path", "=", "''", ";", "}", "else", "{", "$", "_path", "=", "preg_replace", "(", "'/\\/[^\\/]+$/'", ",", "'/'", ",", "$", "_path", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "_path", ")", "&&", "!", "isset", "(", "$", "parts1", "[", "'host'", "]", ")", ")", "{", "$", "_path", "=", "'/'", ";", "}", "$", "combined_uri_parts", "[", "'path'", "]", "=", "self", "::", "normalizePath", "(", "$", "_path", ".", "$", "parts2", "[", "'path'", "]", ")", ";", "}", "// Handle spacial cases for the query part of the URI.", "if", "(", "!", "isset", "(", "$", "parts2", "[", "'path'", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "parts2", "[", "'query'", "]", ")", ")", "{", "$", "combined_uri_parts", "[", "'query'", "]", "=", "$", "parts1", "[", "'query'", "]", ";", "}", "}", "elseif", "(", "strpos", "(", "$", "parts2", "[", "'path'", "]", ",", "'/'", ")", "===", "0", ")", "{", "if", "(", "isset", "(", "$", "parts2", "[", "'query'", "]", ")", ")", "{", "$", "combined_uri_parts", "[", "'query'", "]", "=", "$", "parts2", "[", "'query'", "]", ";", "}", "else", "{", "$", "combined_uri_parts", "[", "'query'", "]", "=", "null", ";", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "parts2", "[", "'query'", "]", ")", ")", "{", "$", "combined_uri_parts", "[", "'query'", "]", "=", "$", "parts2", "[", "'query'", "]", ";", "}", "else", "{", "$", "combined_uri_parts", "[", "'query'", "]", "=", "null", ";", "}", "}", "}", "return", "self", "::", "unParseUrl", "(", "$", "combined_uri_parts", ")", ";", "}" ]
Combines two URIs to a single URL. In most cases the first URI will the an absolute URL and the second URI a path and optionally a query. @param string $uri1 The first URI. @param string $uri2 The second URI. @return string @since 1.0.0 @api
[ "Combines", "two", "URIs", "to", "a", "single", "URL", ".", "In", "most", "cases", "the", "first", "URI", "will", "the", "an", "absolute", "URL", "and", "the", "second", "URI", "a", "path", "and", "optionally", "a", "query", "." ]
398227e333cea3d77eb371b73b73b869d6d00ce8
https://github.com/SetBased/php-abc-url/blob/398227e333cea3d77eb371b73b73b869d6d00ce8/src/Url.php#L24-L103
225,614
SetBased/php-abc-url
src/Url.php
Url.isRelative
public static function isRelative(string $url): bool { if ($url!=='') { return ((mb_substr($url, 0, 1)=='/' && (mb_strlen($url)==1 || (mb_substr($url, 1, 1)!='/' && mb_substr($url, 1, 1)!='\\'))) || (mb_strlen($url)>1 && mb_substr($url, 0, 2)=='~/')); } return false; }
php
public static function isRelative(string $url): bool { if ($url!=='') { return ((mb_substr($url, 0, 1)=='/' && (mb_strlen($url)==1 || (mb_substr($url, 1, 1)!='/' && mb_substr($url, 1, 1)!='\\'))) || (mb_strlen($url)>1 && mb_substr($url, 0, 2)=='~/')); } return false; }
[ "public", "static", "function", "isRelative", "(", "string", "$", "url", ")", ":", "bool", "{", "if", "(", "$", "url", "!==", "''", ")", "{", "return", "(", "(", "mb_substr", "(", "$", "url", ",", "0", ",", "1", ")", "==", "'/'", "&&", "(", "mb_strlen", "(", "$", "url", ")", "==", "1", "||", "(", "mb_substr", "(", "$", "url", ",", "1", ",", "1", ")", "!=", "'/'", "&&", "mb_substr", "(", "$", "url", ",", "1", ",", "1", ")", "!=", "'\\\\'", ")", ")", ")", "||", "(", "mb_strlen", "(", "$", "url", ")", ">", "1", "&&", "mb_substr", "(", "$", "url", ",", "0", ",", "2", ")", "==", "'~/'", ")", ")", ";", "}", "return", "false", ";", "}" ]
Returns true if and only if an URL is a relative URL. Examples of relative URLs: * / * /foo * ~/ * ~/foo Counter examples: * // * /\ * https://www.setbased.nl/ @param string $url The URL. @return bool @since 1.0.0 @api
[ "Returns", "true", "if", "and", "only", "if", "an", "URL", "is", "a", "relative", "URL", "." ]
398227e333cea3d77eb371b73b73b869d6d00ce8
https://github.com/SetBased/php-abc-url/blob/398227e333cea3d77eb371b73b73b869d6d00ce8/src/Url.php#L126-L136
225,615
SetBased/php-abc-url
src/Url.php
Url.normalizePath
public static function normalizePath(?string $path): string { // With thanks to monkeysuffrage, see https://github.com/monkeysuffrage/phpuri/blob/master/phpuri.php. if ($path===null || $path==='') { return ''; } $normalized_path = $path; $normalized_path = preg_replace('`//+`', '/', $normalized_path, -1, $c0); $normalized_path = preg_replace('`^/\\.\\.?/`', '/', $normalized_path, -1, $c1); $normalized_path = preg_replace('`/\\.(/|$)`', '/', $normalized_path, -1, $c2); $normalized_path = preg_replace('`/[^/]*?/\\.\\.(/|$)`', '/', $normalized_path, 1, $c3); $_num_matches = $c0 + $c1 + $c2 + $c3; return ($_num_matches>0) ? self::normalizePath($normalized_path) : $normalized_path; }
php
public static function normalizePath(?string $path): string { // With thanks to monkeysuffrage, see https://github.com/monkeysuffrage/phpuri/blob/master/phpuri.php. if ($path===null || $path==='') { return ''; } $normalized_path = $path; $normalized_path = preg_replace('`//+`', '/', $normalized_path, -1, $c0); $normalized_path = preg_replace('`^/\\.\\.?/`', '/', $normalized_path, -1, $c1); $normalized_path = preg_replace('`/\\.(/|$)`', '/', $normalized_path, -1, $c2); $normalized_path = preg_replace('`/[^/]*?/\\.\\.(/|$)`', '/', $normalized_path, 1, $c3); $_num_matches = $c0 + $c1 + $c2 + $c3; return ($_num_matches>0) ? self::normalizePath($normalized_path) : $normalized_path; }
[ "public", "static", "function", "normalizePath", "(", "?", "string", "$", "path", ")", ":", "string", "{", "// With thanks to monkeysuffrage, see https://github.com/monkeysuffrage/phpuri/blob/master/phpuri.php.", "if", "(", "$", "path", "===", "null", "||", "$", "path", "===", "''", ")", "{", "return", "''", ";", "}", "$", "normalized_path", "=", "$", "path", ";", "$", "normalized_path", "=", "preg_replace", "(", "'`//+`'", ",", "'/'", ",", "$", "normalized_path", ",", "-", "1", ",", "$", "c0", ")", ";", "$", "normalized_path", "=", "preg_replace", "(", "'`^/\\\\.\\\\.?/`'", ",", "'/'", ",", "$", "normalized_path", ",", "-", "1", ",", "$", "c1", ")", ";", "$", "normalized_path", "=", "preg_replace", "(", "'`/\\\\.(/|$)`'", ",", "'/'", ",", "$", "normalized_path", ",", "-", "1", ",", "$", "c2", ")", ";", "$", "normalized_path", "=", "preg_replace", "(", "'`/[^/]*?/\\\\.\\\\.(/|$)`'", ",", "'/'", ",", "$", "normalized_path", ",", "1", ",", "$", "c3", ")", ";", "$", "_num_matches", "=", "$", "c0", "+", "$", "c1", "+", "$", "c2", "+", "$", "c3", ";", "return", "(", "$", "_num_matches", ">", "0", ")", "?", "self", "::", "normalizePath", "(", "$", "normalized_path", ")", ":", "$", "normalized_path", ";", "}" ]
Normalize path to format with slashes only. @param string|null $path The path. @return string @since 1.0.0 @api
[ "Normalize", "path", "to", "format", "with", "slashes", "only", "." ]
398227e333cea3d77eb371b73b73b869d6d00ce8
https://github.com/SetBased/php-abc-url/blob/398227e333cea3d77eb371b73b73b869d6d00ce8/src/Url.php#L149-L166
225,616
n2n/n2n-log4php
src/app/n2n/log4php/renderer/RendererMap.php
RendererMap.addRenderer
public function addRenderer($renderedClass, $renderingClass) { // Check the rendering class exists if (!class_exists($renderingClass)) { throw new \n2n\log4php\LoggerException("log4php: Failed adding renderer. Rendering class [$renderingClass] not found."); return; } // Create the instance $renderer = new $renderingClass(); // Check the class implements the right interface if (!($renderer instanceof \n2n\log4php\LoggerRenderer)) { throw new \n2n\log4php\LoggerException("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the \n2n\log4php\LoggerRenderer interface."); return; } // Convert to lowercase since class names in PHP are not case sensitive $renderedClass = strtolower($renderedClass); $this->map[$renderedClass] = $renderer; }
php
public function addRenderer($renderedClass, $renderingClass) { // Check the rendering class exists if (!class_exists($renderingClass)) { throw new \n2n\log4php\LoggerException("log4php: Failed adding renderer. Rendering class [$renderingClass] not found."); return; } // Create the instance $renderer = new $renderingClass(); // Check the class implements the right interface if (!($renderer instanceof \n2n\log4php\LoggerRenderer)) { throw new \n2n\log4php\LoggerException("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the \n2n\log4php\LoggerRenderer interface."); return; } // Convert to lowercase since class names in PHP are not case sensitive $renderedClass = strtolower($renderedClass); $this->map[$renderedClass] = $renderer; }
[ "public", "function", "addRenderer", "(", "$", "renderedClass", ",", "$", "renderingClass", ")", "{", "// Check the rendering class exists\r", "if", "(", "!", "class_exists", "(", "$", "renderingClass", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Failed adding renderer. Rendering class [$renderingClass] not found.\"", ")", ";", "return", ";", "}", "// Create the instance\r", "$", "renderer", "=", "new", "$", "renderingClass", "(", ")", ";", "// Check the class implements the right interface\r", "if", "(", "!", "(", "$", "renderer", "instanceof", "\\", "n2n", "\\", "log4php", "\\", "LoggerRenderer", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the \\n2n\\log4php\\LoggerRenderer interface.\"", ")", ";", "return", ";", "}", "// Convert to lowercase since class names in PHP are not case sensitive\r", "$", "renderedClass", "=", "strtolower", "(", "$", "renderedClass", ")", ";", "$", "this", "->", "map", "[", "$", "renderedClass", "]", "=", "$", "renderer", ";", "}" ]
Adds a renderer to the map. If a renderer already exists for the given <var>$renderedClass</var> it will be overwritten without warning. @param string $renderedClass The name of the class which will be rendered by the renderer. @param string $renderingClass The name of the class which will perform the rendering.
[ "Adds", "a", "renderer", "to", "the", "map", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/renderer/RendererMap.php#L62-L82
225,617
n2n/n2n-log4php
src/app/n2n/log4php/renderer/RendererMap.php
RendererMap.setDefaultRenderer
public function setDefaultRenderer($renderingClass) { // Check the class exists if (!class_exists($renderingClass)) { throw new \n2n\log4php\LoggerException("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found."); return; } // Create the instance $renderer = new $renderingClass(); // Check the class implements the right interface if (!($renderer instanceof \n2n\log4php\LoggerRenderer)) { throw new \n2n\log4php\LoggerException("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the \n2n\log4php\LoggerRenderer interface."); return; } $this->defaultRenderer = $renderer; }
php
public function setDefaultRenderer($renderingClass) { // Check the class exists if (!class_exists($renderingClass)) { throw new \n2n\log4php\LoggerException("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found."); return; } // Create the instance $renderer = new $renderingClass(); // Check the class implements the right interface if (!($renderer instanceof \n2n\log4php\LoggerRenderer)) { throw new \n2n\log4php\LoggerException("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the \n2n\log4php\LoggerRenderer interface."); return; } $this->defaultRenderer = $renderer; }
[ "public", "function", "setDefaultRenderer", "(", "$", "renderingClass", ")", "{", "// Check the class exists\r", "if", "(", "!", "class_exists", "(", "$", "renderingClass", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.\"", ")", ";", "return", ";", "}", "// Create the instance\r", "$", "renderer", "=", "new", "$", "renderingClass", "(", ")", ";", "// Check the class implements the right interface\r", "if", "(", "!", "(", "$", "renderer", "instanceof", "\\", "n2n", "\\", "log4php", "\\", "LoggerRenderer", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the \\n2n\\log4php\\LoggerRenderer interface.\"", ")", ";", "return", ";", "}", "$", "this", "->", "defaultRenderer", "=", "$", "renderer", ";", "}" ]
Sets a custom default renderer class. TODO: there's code duplication here. This method is almost identical to addRenderer(). However, it has custom error messages so let it sit for now. @param string $renderingClass The name of the class which will perform the rendering.
[ "Sets", "a", "custom", "default", "renderer", "class", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/renderer/RendererMap.php#L94-L111
225,618
n2n/n2n-log4php
src/app/n2n/log4php/renderer/RendererMap.php
RendererMap.reset
public function reset() { $this->defaultRenderer = new \n2n\log4php\renderer\RendererDefault(); $this->clear(); $this->addRenderer('Exception', '\n2n\log4php\renderer\RendererException'); }
php
public function reset() { $this->defaultRenderer = new \n2n\log4php\renderer\RendererDefault(); $this->clear(); $this->addRenderer('Exception', '\n2n\log4php\renderer\RendererException'); }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "defaultRenderer", "=", "new", "\\", "n2n", "\\", "log4php", "\\", "renderer", "\\", "RendererDefault", "(", ")", ";", "$", "this", "->", "clear", "(", ")", ";", "$", "this", "->", "addRenderer", "(", "'Exception'", ",", "'\\n2n\\log4php\\renderer\\RendererException'", ")", ";", "}" ]
Resets the renderer map to it's default configuration.
[ "Resets", "the", "renderer", "map", "to", "it", "s", "default", "configuration", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/renderer/RendererMap.php#L182-L186
225,619
SetBased/php-abc-form
src/Control/FieldSet.php
FieldSet.createLegend
public function createLegend($type = 'legend') { switch ($type) { case 'legend': $tmp = new Legend(); break; default: $tmp = new $type(); } $this->legend = $tmp; return $tmp; }
php
public function createLegend($type = 'legend') { switch ($type) { case 'legend': $tmp = new Legend(); break; default: $tmp = new $type(); } $this->legend = $tmp; return $tmp; }
[ "public", "function", "createLegend", "(", "$", "type", "=", "'legend'", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'legend'", ":", "$", "tmp", "=", "new", "Legend", "(", ")", ";", "break", ";", "default", ":", "$", "tmp", "=", "new", "$", "type", "(", ")", ";", "}", "$", "this", "->", "legend", "=", "$", "tmp", ";", "return", "$", "tmp", ";", "}" ]
Creates a legend for this fieldset. @param string $type The class name of the legend. @return Legend
[ "Creates", "a", "legend", "for", "this", "fieldset", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/FieldSet.php#L30-L45
225,620
SetBased/php-abc-form
src/Control/FieldSet.php
FieldSet.getHtmlLegend
protected function getHtmlLegend(): string { if ($this->legend) { $ret = $this->legend->getHtml(); } else { $ret = ''; } return $ret; }
php
protected function getHtmlLegend(): string { if ($this->legend) { $ret = $this->legend->getHtml(); } else { $ret = ''; } return $ret; }
[ "protected", "function", "getHtmlLegend", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "legend", ")", "{", "$", "ret", "=", "$", "this", "->", "legend", "->", "getHtml", "(", ")", ";", "}", "else", "{", "$", "ret", "=", "''", ";", "}", "return", "$", "ret", ";", "}" ]
Returns the legend for this fieldset. @return string @since 1.0.0 @api
[ "Returns", "the", "legend", "for", "this", "fieldset", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/FieldSet.php#L87-L99
225,621
edineibauer/entity
public/src/Entity/Validate.php
Validate.meta
public static function meta(Meta $m) { if ($m->getColumn() !== "id") { self::checkDefaultSet($m); if (!empty($m->getValue()) && !in_array($m->getKey(), ["extend", "extend_add", "list", "selecao", "checkbox_rel"])) { self::checkRegular($m); self::convertValues($m); self::checkType($m); self::checkSize($m); self::checkValidate($m); self::checkValues($m); } } }
php
public static function meta(Meta $m) { if ($m->getColumn() !== "id") { self::checkDefaultSet($m); if (!empty($m->getValue()) && !in_array($m->getKey(), ["extend", "extend_add", "list", "selecao", "checkbox_rel"])) { self::checkRegular($m); self::convertValues($m); self::checkType($m); self::checkSize($m); self::checkValidate($m); self::checkValues($m); } } }
[ "public", "static", "function", "meta", "(", "Meta", "$", "m", ")", "{", "if", "(", "$", "m", "->", "getColumn", "(", ")", "!==", "\"id\"", ")", "{", "self", "::", "checkDefaultSet", "(", "$", "m", ")", ";", "if", "(", "!", "empty", "(", "$", "m", "->", "getValue", "(", ")", ")", "&&", "!", "in_array", "(", "$", "m", "->", "getKey", "(", ")", ",", "[", "\"extend\"", ",", "\"extend_add\"", ",", "\"list\"", ",", "\"selecao\"", ",", "\"checkbox_rel\"", "]", ")", ")", "{", "self", "::", "checkRegular", "(", "$", "m", ")", ";", "self", "::", "convertValues", "(", "$", "m", ")", ";", "self", "::", "checkType", "(", "$", "m", ")", ";", "self", "::", "checkSize", "(", "$", "m", ")", ";", "self", "::", "checkValidate", "(", "$", "m", ")", ";", "self", "::", "checkValues", "(", "$", "m", ")", ";", "}", "}", "}" ]
Valida valor a ser inserido na meta @param Meta $m @param $value @return mixed
[ "Valida", "valor", "a", "ser", "inserido", "na", "meta" ]
8437f5531ed9cd5f75c4c69c7db27b31e31e02c2
https://github.com/edineibauer/entity/blob/8437f5531ed9cd5f75c4c69c7db27b31e31e02c2/public/src/Entity/Validate.php#L17-L30
225,622
matteosister/CompassElephant
src/CompassElephant/StalenessChecker/FinderStalenessChecker.php
FinderStalenessChecker.isClean
public function isClean() { if ($this->getConfigFileAge() > max($this->getSassMaxAge(), $this->getStylesheetsMaxAge())) { return false; } return $this->getSassMaxAge() <= $this->getStylesheetsMaxAge(); }
php
public function isClean() { if ($this->getConfigFileAge() > max($this->getSassMaxAge(), $this->getStylesheetsMaxAge())) { return false; } return $this->getSassMaxAge() <= $this->getStylesheetsMaxAge(); }
[ "public", "function", "isClean", "(", ")", "{", "if", "(", "$", "this", "->", "getConfigFileAge", "(", ")", ">", "max", "(", "$", "this", "->", "getSassMaxAge", "(", ")", ",", "$", "this", "->", "getStylesheetsMaxAge", "(", ")", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getSassMaxAge", "(", ")", "<=", "$", "this", "->", "getStylesheetsMaxAge", "(", ")", ";", "}" ]
return true if the project do not need to be recompiled @return boolean
[ "return", "true", "if", "the", "project", "do", "not", "need", "to", "be", "recompiled" ]
5d2dacca5e33405872219ea5b6297e8aed964cf3
https://github.com/matteosister/CompassElephant/blob/5d2dacca5e33405872219ea5b6297e8aed964cf3/src/CompassElephant/StalenessChecker/FinderStalenessChecker.php#L51-L58
225,623
matteosister/CompassElephant
src/CompassElephant/StalenessChecker/FinderStalenessChecker.php
FinderStalenessChecker.checkPaths
private function checkPaths() { if (!is_dir($this->sassPath)) { throw new \RuntimeException(sprintf('The path %s do not exists', $this->sassPath)); } if (!is_dir($this->cssPath)) { try { mkdir($this->cssPath); } catch (\Exception $e) { throw new \RuntimeException(sprintf('The path %s do not exists, and could not be created', $this->cssPath)); } } if (!is_writable($this->sassPath)) { throw new \RuntimeException(sprintf('The path %s should be writable (by the webserver user) for CompassElephant to compile the project', $this->sassPath)); } if (!is_writable($this->cssPath)) { throw new \RuntimeException(sprintf('The path %s should be writable (by the webserver user) for CompassElephant to compile the project', $this->cssPath)); } }
php
private function checkPaths() { if (!is_dir($this->sassPath)) { throw new \RuntimeException(sprintf('The path %s do not exists', $this->sassPath)); } if (!is_dir($this->cssPath)) { try { mkdir($this->cssPath); } catch (\Exception $e) { throw new \RuntimeException(sprintf('The path %s do not exists, and could not be created', $this->cssPath)); } } if (!is_writable($this->sassPath)) { throw new \RuntimeException(sprintf('The path %s should be writable (by the webserver user) for CompassElephant to compile the project', $this->sassPath)); } if (!is_writable($this->cssPath)) { throw new \RuntimeException(sprintf('The path %s should be writable (by the webserver user) for CompassElephant to compile the project', $this->cssPath)); } }
[ "private", "function", "checkPaths", "(", ")", "{", "if", "(", "!", "is_dir", "(", "$", "this", "->", "sassPath", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The path %s do not exists'", ",", "$", "this", "->", "sassPath", ")", ")", ";", "}", "if", "(", "!", "is_dir", "(", "$", "this", "->", "cssPath", ")", ")", "{", "try", "{", "mkdir", "(", "$", "this", "->", "cssPath", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The path %s do not exists, and could not be created'", ",", "$", "this", "->", "cssPath", ")", ")", ";", "}", "}", "if", "(", "!", "is_writable", "(", "$", "this", "->", "sassPath", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The path %s should be writable (by the webserver user) for CompassElephant to compile the project'", ",", "$", "this", "->", "sassPath", ")", ")", ";", "}", "if", "(", "!", "is_writable", "(", "$", "this", "->", "cssPath", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The path %s should be writable (by the webserver user) for CompassElephant to compile the project'", ",", "$", "this", "->", "cssPath", ")", ")", ";", "}", "}" ]
check if sass and stylesheets paths are writable @throws \RuntimeException
[ "check", "if", "sass", "and", "stylesheets", "paths", "are", "writable" ]
5d2dacca5e33405872219ea5b6297e8aed964cf3
https://github.com/matteosister/CompassElephant/blob/5d2dacca5e33405872219ea5b6297e8aed964cf3/src/CompassElephant/StalenessChecker/FinderStalenessChecker.php#L65-L83
225,624
matteosister/CompassElephant
src/CompassElephant/StalenessChecker/FinderStalenessChecker.php
FinderStalenessChecker.findPaths
private function findPaths() { $configFilename = $this->projectPath . DIRECTORY_SEPARATOR . $this->configFile; $handle = fopen($configFilename, 'r'); if (false === $handle) { throw new \FileNotFoundException($configFilename . ' could not be found'); } $contents = fread($handle, filesize($configFilename)); foreach (explode(PHP_EOL, $contents) as $line) { if (preg_match('/sass_dir ?= ?"(.*)"/', $line, $matches) !== 0) { $this->sassPath = $this->projectPath . DIRECTORY_SEPARATOR . $matches[1]; } if (preg_match('/css_dir ?= ?"(.*)"/', $line, $matches) !== 0) { $this->cssPath = $this->projectPath . DIRECTORY_SEPARATOR . $matches[1]; } } }
php
private function findPaths() { $configFilename = $this->projectPath . DIRECTORY_SEPARATOR . $this->configFile; $handle = fopen($configFilename, 'r'); if (false === $handle) { throw new \FileNotFoundException($configFilename . ' could not be found'); } $contents = fread($handle, filesize($configFilename)); foreach (explode(PHP_EOL, $contents) as $line) { if (preg_match('/sass_dir ?= ?"(.*)"/', $line, $matches) !== 0) { $this->sassPath = $this->projectPath . DIRECTORY_SEPARATOR . $matches[1]; } if (preg_match('/css_dir ?= ?"(.*)"/', $line, $matches) !== 0) { $this->cssPath = $this->projectPath . DIRECTORY_SEPARATOR . $matches[1]; } } }
[ "private", "function", "findPaths", "(", ")", "{", "$", "configFilename", "=", "$", "this", "->", "projectPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "configFile", ";", "$", "handle", "=", "fopen", "(", "$", "configFilename", ",", "'r'", ")", ";", "if", "(", "false", "===", "$", "handle", ")", "{", "throw", "new", "\\", "FileNotFoundException", "(", "$", "configFilename", ".", "' could not be found'", ")", ";", "}", "$", "contents", "=", "fread", "(", "$", "handle", ",", "filesize", "(", "$", "configFilename", ")", ")", ";", "foreach", "(", "explode", "(", "PHP_EOL", ",", "$", "contents", ")", "as", "$", "line", ")", "{", "if", "(", "preg_match", "(", "'/sass_dir ?= ?\"(.*)\"/'", ",", "$", "line", ",", "$", "matches", ")", "!==", "0", ")", "{", "$", "this", "->", "sassPath", "=", "$", "this", "->", "projectPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "matches", "[", "1", "]", ";", "}", "if", "(", "preg_match", "(", "'/css_dir ?= ?\"(.*)\"/'", ",", "$", "line", ",", "$", "matches", ")", "!==", "0", ")", "{", "$", "this", "->", "cssPath", "=", "$", "this", "->", "projectPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "matches", "[", "1", "]", ";", "}", "}", "}" ]
find sass and stylesheets files parsing the config file @throws \FileNotFoundException
[ "find", "sass", "and", "stylesheets", "files", "parsing", "the", "config", "file" ]
5d2dacca5e33405872219ea5b6297e8aed964cf3
https://github.com/matteosister/CompassElephant/blob/5d2dacca5e33405872219ea5b6297e8aed964cf3/src/CompassElephant/StalenessChecker/FinderStalenessChecker.php#L90-L106
225,625
matteosister/CompassElephant
src/CompassElephant/StalenessChecker/FinderStalenessChecker.php
FinderStalenessChecker.getStylesheetsMaxAge
private function getStylesheetsMaxAge() { if (is_null($this->cssPath)) { $this->findPaths(); $this->checkPaths(); } return $this->getFilesMaxAge($this->cssPath, array('*.css')); }
php
private function getStylesheetsMaxAge() { if (is_null($this->cssPath)) { $this->findPaths(); $this->checkPaths(); } return $this->getFilesMaxAge($this->cssPath, array('*.css')); }
[ "private", "function", "getStylesheetsMaxAge", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "cssPath", ")", ")", "{", "$", "this", "->", "findPaths", "(", ")", ";", "$", "this", "->", "checkPaths", "(", ")", ";", "}", "return", "$", "this", "->", "getFilesMaxAge", "(", "$", "this", "->", "cssPath", ",", "array", "(", "'*.css'", ")", ")", ";", "}" ]
Get the max_age of stylesheets files @return int
[ "Get", "the", "max_age", "of", "stylesheets", "files" ]
5d2dacca5e33405872219ea5b6297e8aed964cf3
https://github.com/matteosister/CompassElephant/blob/5d2dacca5e33405872219ea5b6297e8aed964cf3/src/CompassElephant/StalenessChecker/FinderStalenessChecker.php#L113-L120
225,626
cmsgears/module-cms
common/models/entities/Content.php
Content.getParent
public function getParent() { $pageClass = Yii::$app->cms->getPageClass( $this->type ); return $this->hasOne( $pageClass, [ 'id' => 'parentId' ] ); }
php
public function getParent() { $pageClass = Yii::$app->cms->getPageClass( $this->type ); return $this->hasOne( $pageClass, [ 'id' => 'parentId' ] ); }
[ "public", "function", "getParent", "(", ")", "{", "$", "pageClass", "=", "Yii", "::", "$", "app", "->", "cms", "->", "getPageClass", "(", "$", "this", "->", "type", ")", ";", "return", "$", "this", "->", "hasOne", "(", "$", "pageClass", ",", "[", "'id'", "=>", "'parentId'", "]", ")", ";", "}" ]
Returns the immediate parent. @return Content
[ "Returns", "the", "immediate", "parent", "." ]
ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8
https://github.com/cmsgears/module-cms/blob/ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8/common/models/entities/Content.php#L306-L311
225,627
stubbles/stubbles-input
src/main/php/filter/ReusableFilter.php
ReusableFilter.instance
public static function instance(): Filter { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
php
public static function instance(): Filter { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
[ "public", "static", "function", "instance", "(", ")", ":", "Filter", "{", "if", "(", "null", "===", "self", "::", "$", "instance", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", ")", ";", "}", "return", "self", "::", "$", "instance", ";", "}" ]
returns reusable filter instance @return \stubbles\input\Filter
[ "returns", "reusable", "filter", "instance" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/filter/ReusableFilter.php#L32-L39
225,628
GFG/dto-context
src/DTOContext/Factory/Base.php
Base.getMappedContext
protected function getMappedContext($contextName) { $this->checkMappedContext($contextName); $mappingList = $this->getMappingList(); return $mappingList[$contextName]; }
php
protected function getMappedContext($contextName) { $this->checkMappedContext($contextName); $mappingList = $this->getMappingList(); return $mappingList[$contextName]; }
[ "protected", "function", "getMappedContext", "(", "$", "contextName", ")", "{", "$", "this", "->", "checkMappedContext", "(", "$", "contextName", ")", ";", "$", "mappingList", "=", "$", "this", "->", "getMappingList", "(", ")", ";", "return", "$", "mappingList", "[", "$", "contextName", "]", ";", "}" ]
Return the mapped context class @param string $contextName @return string
[ "Return", "the", "mapped", "context", "class" ]
c1a47273d3dc2704bfd3f90c2560726688d54558
https://github.com/GFG/dto-context/blob/c1a47273d3dc2704bfd3f90c2560726688d54558/src/DTOContext/Factory/Base.php#L56-L62
225,629
spiral/translator
src/Indexer.php
Indexer.registerMessage
public function registerMessage(string $domain, string $string, bool $resolveDomain = true) { if ($resolveDomain) { $domain = $this->config->resolveDomain($domain); } //Automatically registering $this->catalogue->set($domain, $string, $string); $this->getLogger()->debug( sprintf("[%s]: `%s`", $domain, $string), compact('domain', 'string') ); }
php
public function registerMessage(string $domain, string $string, bool $resolveDomain = true) { if ($resolveDomain) { $domain = $this->config->resolveDomain($domain); } //Automatically registering $this->catalogue->set($domain, $string, $string); $this->getLogger()->debug( sprintf("[%s]: `%s`", $domain, $string), compact('domain', 'string') ); }
[ "public", "function", "registerMessage", "(", "string", "$", "domain", ",", "string", "$", "string", ",", "bool", "$", "resolveDomain", "=", "true", ")", "{", "if", "(", "$", "resolveDomain", ")", "{", "$", "domain", "=", "$", "this", "->", "config", "->", "resolveDomain", "(", "$", "domain", ")", ";", "}", "//Automatically registering", "$", "this", "->", "catalogue", "->", "set", "(", "$", "domain", ",", "$", "string", ",", "$", "string", ")", ";", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "sprintf", "(", "\"[%s]: `%s`\"", ",", "$", "domain", ",", "$", "string", ")", ",", "compact", "(", "'domain'", ",", "'string'", ")", ")", ";", "}" ]
Register string in active translator. @param string $domain @param string $string @param bool $resolveDomain
[ "Register", "string", "in", "active", "translator", "." ]
dde0f3d3db7960c22a36b9e781fe30ab51656424
https://github.com/spiral/translator/blob/dde0f3d3db7960c22a36b9e781fe30ab51656424/src/Indexer.php#L60-L73
225,630
spiral/translator
src/Indexer.php
Indexer.indexClasses
public function indexClasses(ClassesInterface $locator) { foreach ($locator->getClasses(TranslatorTrait::class) as $class) { $strings = $this->fetchMessages($class, true); foreach ($strings as $string) { $this->registerMessage($class->getName(), $string); } } }
php
public function indexClasses(ClassesInterface $locator) { foreach ($locator->getClasses(TranslatorTrait::class) as $class) { $strings = $this->fetchMessages($class, true); foreach ($strings as $string) { $this->registerMessage($class->getName(), $string); } } }
[ "public", "function", "indexClasses", "(", "ClassesInterface", "$", "locator", ")", "{", "foreach", "(", "$", "locator", "->", "getClasses", "(", "TranslatorTrait", "::", "class", ")", "as", "$", "class", ")", "{", "$", "strings", "=", "$", "this", "->", "fetchMessages", "(", "$", "class", ",", "true", ")", ";", "foreach", "(", "$", "strings", "as", "$", "string", ")", "{", "$", "this", "->", "registerMessage", "(", "$", "class", "->", "getName", "(", ")", ",", "$", "string", ")", ";", "}", "}", "}" ]
Index and register i18n string located in default properties which belongs to TranslatorTrait classes. @param ClassesInterface $locator
[ "Index", "and", "register", "i18n", "string", "located", "in", "default", "properties", "which", "belongs", "to", "TranslatorTrait", "classes", "." ]
dde0f3d3db7960c22a36b9e781fe30ab51656424
https://github.com/spiral/translator/blob/dde0f3d3db7960c22a36b9e781fe30ab51656424/src/Indexer.php#L81-L89
225,631
spiral/translator
src/Indexer.php
Indexer.registerInvocations
private function registerInvocations(array $invocations) { foreach ($invocations as $invocation) { if ($invocation->getArgument(0)->getType() != ReflectionArgument::STRING) { //We can only index invocations with constant string arguments continue; } $string = $invocation->getArgument(0)->stringValue(); $string = $this->prepareMessage($string); $this->registerMessage($this->invocationDomain($invocation), $string, false); } }
php
private function registerInvocations(array $invocations) { foreach ($invocations as $invocation) { if ($invocation->getArgument(0)->getType() != ReflectionArgument::STRING) { //We can only index invocations with constant string arguments continue; } $string = $invocation->getArgument(0)->stringValue(); $string = $this->prepareMessage($string); $this->registerMessage($this->invocationDomain($invocation), $string, false); } }
[ "private", "function", "registerInvocations", "(", "array", "$", "invocations", ")", "{", "foreach", "(", "$", "invocations", "as", "$", "invocation", ")", "{", "if", "(", "$", "invocation", "->", "getArgument", "(", "0", ")", "->", "getType", "(", ")", "!=", "ReflectionArgument", "::", "STRING", ")", "{", "//We can only index invocations with constant string arguments", "continue", ";", "}", "$", "string", "=", "$", "invocation", "->", "getArgument", "(", "0", ")", "->", "stringValue", "(", ")", ";", "$", "string", "=", "$", "this", "->", "prepareMessage", "(", "$", "string", ")", ";", "$", "this", "->", "registerMessage", "(", "$", "this", "->", "invocationDomain", "(", "$", "invocation", ")", ",", "$", "string", ",", "false", ")", ";", "}", "}" ]
Register found invocations in translator bundles. @param ReflectionInvocation[] $invocations
[ "Register", "found", "invocations", "in", "translator", "bundles", "." ]
dde0f3d3db7960c22a36b9e781fe30ab51656424
https://github.com/spiral/translator/blob/dde0f3d3db7960c22a36b9e781fe30ab51656424/src/Indexer.php#L117-L130
225,632
spiral/translator
src/Indexer.php
Indexer.fetchMessages
private function fetchMessages(\ReflectionClass $reflection, bool $inherit = false) { $target = $reflection->getDefaultProperties() + $reflection->getConstants(); foreach ($reflection->getProperties() as $property) { if (is_string($property->getDocComment()) && strpos($property->getDocComment(), "@do-not-index")) { unset($target[$property->getName()]); } } $strings = []; array_walk_recursive($target, function ($value) use (&$strings) { if (is_string($value) && Translator::isMessage($value)) { $strings[] = $this->prepareMessage($value); } }); if ($inherit && $reflection->getParentClass()) { //Joining strings data with parent class values (inheritance ON) - resolved into same //domain on export $strings = array_merge( $strings, $this->fetchMessages($reflection->getParentClass(), true) ); } return $strings; }
php
private function fetchMessages(\ReflectionClass $reflection, bool $inherit = false) { $target = $reflection->getDefaultProperties() + $reflection->getConstants(); foreach ($reflection->getProperties() as $property) { if (is_string($property->getDocComment()) && strpos($property->getDocComment(), "@do-not-index")) { unset($target[$property->getName()]); } } $strings = []; array_walk_recursive($target, function ($value) use (&$strings) { if (is_string($value) && Translator::isMessage($value)) { $strings[] = $this->prepareMessage($value); } }); if ($inherit && $reflection->getParentClass()) { //Joining strings data with parent class values (inheritance ON) - resolved into same //domain on export $strings = array_merge( $strings, $this->fetchMessages($reflection->getParentClass(), true) ); } return $strings; }
[ "private", "function", "fetchMessages", "(", "\\", "ReflectionClass", "$", "reflection", ",", "bool", "$", "inherit", "=", "false", ")", "{", "$", "target", "=", "$", "reflection", "->", "getDefaultProperties", "(", ")", "+", "$", "reflection", "->", "getConstants", "(", ")", ";", "foreach", "(", "$", "reflection", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "if", "(", "is_string", "(", "$", "property", "->", "getDocComment", "(", ")", ")", "&&", "strpos", "(", "$", "property", "->", "getDocComment", "(", ")", ",", "\"@do-not-index\"", ")", ")", "{", "unset", "(", "$", "target", "[", "$", "property", "->", "getName", "(", ")", "]", ")", ";", "}", "}", "$", "strings", "=", "[", "]", ";", "array_walk_recursive", "(", "$", "target", ",", "function", "(", "$", "value", ")", "use", "(", "&", "$", "strings", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", "&&", "Translator", "::", "isMessage", "(", "$", "value", ")", ")", "{", "$", "strings", "[", "]", "=", "$", "this", "->", "prepareMessage", "(", "$", "value", ")", ";", "}", "}", ")", ";", "if", "(", "$", "inherit", "&&", "$", "reflection", "->", "getParentClass", "(", ")", ")", "{", "//Joining strings data with parent class values (inheritance ON) - resolved into same", "//domain on export", "$", "strings", "=", "array_merge", "(", "$", "strings", ",", "$", "this", "->", "fetchMessages", "(", "$", "reflection", "->", "getParentClass", "(", ")", ",", "true", ")", ")", ";", "}", "return", "$", "strings", ";", "}" ]
Fetch default string values from class and merge it with parent strings if requested. @param \ReflectionClass $reflection @param bool $inherit @return array
[ "Fetch", "default", "string", "values", "from", "class", "and", "merge", "it", "with", "parent", "strings", "if", "requested", "." ]
dde0f3d3db7960c22a36b9e781fe30ab51656424
https://github.com/spiral/translator/blob/dde0f3d3db7960c22a36b9e781fe30ab51656424/src/Indexer.php#L139-L166
225,633
spiral/translator
src/Indexer.php
Indexer.invocationDomain
private function invocationDomain(ReflectionInvocation $invocation): string { //Translation using default bundle $domain = $this->config->getDefaultDomain(); if ($invocation->getName() === 'say') { //Let's try to confirm domain $domain = $this->config->resolveDomain($invocation->getClass()); } //`l` and `p`, `say` functions $argument = null; switch (strtolower($invocation->getName())) { case 'say': case 'l': if ($invocation->countArguments() >= 3) { $argument = $invocation->getArgument(2); } break; case 'p': if ($invocation->countArguments() >= 4) { $argument = $invocation->getArgument(3); } } if (!empty($argument) && $argument->getType() === ReflectionArgument::STRING) { //Domain specified in arguments $domain = $this->config->resolveDomain($argument->stringValue()); } return $domain; }
php
private function invocationDomain(ReflectionInvocation $invocation): string { //Translation using default bundle $domain = $this->config->getDefaultDomain(); if ($invocation->getName() === 'say') { //Let's try to confirm domain $domain = $this->config->resolveDomain($invocation->getClass()); } //`l` and `p`, `say` functions $argument = null; switch (strtolower($invocation->getName())) { case 'say': case 'l': if ($invocation->countArguments() >= 3) { $argument = $invocation->getArgument(2); } break; case 'p': if ($invocation->countArguments() >= 4) { $argument = $invocation->getArgument(3); } } if (!empty($argument) && $argument->getType() === ReflectionArgument::STRING) { //Domain specified in arguments $domain = $this->config->resolveDomain($argument->stringValue()); } return $domain; }
[ "private", "function", "invocationDomain", "(", "ReflectionInvocation", "$", "invocation", ")", ":", "string", "{", "//Translation using default bundle", "$", "domain", "=", "$", "this", "->", "config", "->", "getDefaultDomain", "(", ")", ";", "if", "(", "$", "invocation", "->", "getName", "(", ")", "===", "'say'", ")", "{", "//Let's try to confirm domain", "$", "domain", "=", "$", "this", "->", "config", "->", "resolveDomain", "(", "$", "invocation", "->", "getClass", "(", ")", ")", ";", "}", "//`l` and `p`, `say` functions", "$", "argument", "=", "null", ";", "switch", "(", "strtolower", "(", "$", "invocation", "->", "getName", "(", ")", ")", ")", "{", "case", "'say'", ":", "case", "'l'", ":", "if", "(", "$", "invocation", "->", "countArguments", "(", ")", ">=", "3", ")", "{", "$", "argument", "=", "$", "invocation", "->", "getArgument", "(", "2", ")", ";", "}", "break", ";", "case", "'p'", ":", "if", "(", "$", "invocation", "->", "countArguments", "(", ")", ">=", "4", ")", "{", "$", "argument", "=", "$", "invocation", "->", "getArgument", "(", "3", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "argument", ")", "&&", "$", "argument", "->", "getType", "(", ")", "===", "ReflectionArgument", "::", "STRING", ")", "{", "//Domain specified in arguments", "$", "domain", "=", "$", "this", "->", "config", "->", "resolveDomain", "(", "$", "argument", "->", "stringValue", "(", ")", ")", ";", "}", "return", "$", "domain", ";", "}" ]
Get associated domain. @param ReflectionInvocation $invocation @return string
[ "Get", "associated", "domain", "." ]
dde0f3d3db7960c22a36b9e781fe30ab51656424
https://github.com/spiral/translator/blob/dde0f3d3db7960c22a36b9e781fe30ab51656424/src/Indexer.php#L174-L205
225,634
SetBased/php-abc-table-detail
src/TableRow/IntegerTableRow.php
IntegerTableRow.addRow
public static function addRow(DetailTable $table, $header, ?int $value): void { if ($value!==null && $value!=='') { $table->addRow($header, ['class' => 'integer'], Cast::toOptString($value)); } else { $table->addRow($header); } }
php
public static function addRow(DetailTable $table, $header, ?int $value): void { if ($value!==null && $value!=='') { $table->addRow($header, ['class' => 'integer'], Cast::toOptString($value)); } else { $table->addRow($header); } }
[ "public", "static", "function", "addRow", "(", "DetailTable", "$", "table", ",", "$", "header", ",", "?", "int", "$", "value", ")", ":", "void", "{", "if", "(", "$", "value", "!==", "null", "&&", "$", "value", "!==", "''", ")", "{", "$", "table", "->", "addRow", "(", "$", "header", ",", "[", "'class'", "=>", "'integer'", "]", ",", "Cast", "::", "toOptString", "(", "$", "value", ")", ")", ";", "}", "else", "{", "$", "table", "->", "addRow", "(", "$", "header", ")", ";", "}", "}" ]
Adds a row with an integer value to a detail table. @param DetailTable $table The detail table. @param string|int|null $header The header text of this table row. @param int|null $value The integer value.
[ "Adds", "a", "row", "with", "an", "integer", "value", "to", "a", "detail", "table", "." ]
1f786174ccb10800f9c07bfd497b0ab35940a8ea
https://github.com/SetBased/php-abc-table-detail/blob/1f786174ccb10800f9c07bfd497b0ab35940a8ea/src/TableRow/IntegerTableRow.php#L22-L32
225,635
Everest/Everest-Filesystem
src/classes/Everest/Filesystem/FolderCollection.php
FolderCollection.delete
public function delete(bool $recursive = true): bool { $this->each(function (Folder $item) use ($recursive) { $item->delete($recursive); }); return true; }
php
public function delete(bool $recursive = true): bool { $this->each(function (Folder $item) use ($recursive) { $item->delete($recursive); }); return true; }
[ "public", "function", "delete", "(", "bool", "$", "recursive", "=", "true", ")", ":", "bool", "{", "$", "this", "->", "each", "(", "function", "(", "Folder", "$", "item", ")", "use", "(", "$", "recursive", ")", "{", "$", "item", "->", "delete", "(", "$", "recursive", ")", ";", "}", ")", ";", "return", "true", ";", "}" ]
Delete all folders. @param bool $recursive Set FALSE to prevent recursive deleting all files and sub folders @return bool
[ "Delete", "all", "folders", "." ]
67782256e4b09adc7f761944b88ea317a194d677
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/FolderCollection.php#L30-L37
225,636
n2n/n2n-log4php
src/app/n2n/log4php/LoggerRoot.php
LoggerRoot.setLevel
public function setLevel(\n2n\log4php\LoggerLevel $level = null) { if (isset($level)) { parent::setLevel($level); } else { throw new \n2n\log4php\LoggerException("log4php: Cannot set LoggerRoot level to null.", E_USER_WARNING); } }
php
public function setLevel(\n2n\log4php\LoggerLevel $level = null) { if (isset($level)) { parent::setLevel($level); } else { throw new \n2n\log4php\LoggerException("log4php: Cannot set LoggerRoot level to null.", E_USER_WARNING); } }
[ "public", "function", "setLevel", "(", "\\", "n2n", "\\", "log4php", "\\", "LoggerLevel", "$", "level", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "level", ")", ")", "{", "parent", "::", "setLevel", "(", "$", "level", ")", ";", "}", "else", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Cannot set LoggerRoot level to null.\"", ",", "E_USER_WARNING", ")", ";", "}", "}" ]
Override level setter to prevent setting the root logger's level to null. Root logger must always have a level. @param \n2n\log4php\LoggerLevel $level
[ "Override", "level", "setter", "to", "prevent", "setting", "the", "root", "logger", "s", "level", "to", "null", ".", "Root", "logger", "must", "always", "have", "a", "level", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/LoggerRoot.php#L57-L63
225,637
SlayerBirden/dataflow
src/Writer/Dbal/Write.php
Write.pass
public function pass(DataBagInterface $dataBag): DataBagInterface { $dataToInsert = $this->getDataToInsert($dataBag); if ($this->recordExists($dataBag)) { $this->updateRecord($dataToInsert, $dataBag); } else { $this->insertRecord($dataToInsert, $dataBag); } return $dataBag; }
php
public function pass(DataBagInterface $dataBag): DataBagInterface { $dataToInsert = $this->getDataToInsert($dataBag); if ($this->recordExists($dataBag)) { $this->updateRecord($dataToInsert, $dataBag); } else { $this->insertRecord($dataToInsert, $dataBag); } return $dataBag; }
[ "public", "function", "pass", "(", "DataBagInterface", "$", "dataBag", ")", ":", "DataBagInterface", "{", "$", "dataToInsert", "=", "$", "this", "->", "getDataToInsert", "(", "$", "dataBag", ")", ";", "if", "(", "$", "this", "->", "recordExists", "(", "$", "dataBag", ")", ")", "{", "$", "this", "->", "updateRecord", "(", "$", "dataToInsert", ",", "$", "dataBag", ")", ";", "}", "else", "{", "$", "this", "->", "insertRecord", "(", "$", "dataToInsert", ",", "$", "dataBag", ")", ";", "}", "return", "$", "dataBag", ";", "}" ]
DBAL Insert statement. Inserts data into a table using DBAL. {@inheritdoc}
[ "DBAL", "Insert", "statement", ".", "Inserts", "data", "into", "a", "table", "using", "DBAL", "." ]
a9cb826b106e882e43523d39fea319adc4893e00
https://github.com/SlayerBirden/dataflow/blob/a9cb826b106e882e43523d39fea319adc4893e00/src/Writer/Dbal/Write.php#L73-L83
225,638
SlayerBirden/dataflow
src/Writer/Dbal/Write.php
Write.getRecordId
public function getRecordId(array $identifier, string $autoIncrementColumn): int { if (isset($identifier[$autoIncrementColumn])) { return (int)$identifier[$autoIncrementColumn]; } $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder->select($autoIncrementColumn) ->from($this->table) ->setParameters($identifier); foreach (array_keys($identifier) as $key) { $queryBuilder->andWhere("$key = :$key"); } $stmt = $this->connection->prepare($queryBuilder->getSQL()); $stmt->execute($identifier); return (int)$stmt->fetchColumn(); }
php
public function getRecordId(array $identifier, string $autoIncrementColumn): int { if (isset($identifier[$autoIncrementColumn])) { return (int)$identifier[$autoIncrementColumn]; } $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder->select($autoIncrementColumn) ->from($this->table) ->setParameters($identifier); foreach (array_keys($identifier) as $key) { $queryBuilder->andWhere("$key = :$key"); } $stmt = $this->connection->prepare($queryBuilder->getSQL()); $stmt->execute($identifier); return (int)$stmt->fetchColumn(); }
[ "public", "function", "getRecordId", "(", "array", "$", "identifier", ",", "string", "$", "autoIncrementColumn", ")", ":", "int", "{", "if", "(", "isset", "(", "$", "identifier", "[", "$", "autoIncrementColumn", "]", ")", ")", "{", "return", "(", "int", ")", "$", "identifier", "[", "$", "autoIncrementColumn", "]", ";", "}", "$", "queryBuilder", "=", "$", "this", "->", "connection", "->", "createQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "select", "(", "$", "autoIncrementColumn", ")", "->", "from", "(", "$", "this", "->", "table", ")", "->", "setParameters", "(", "$", "identifier", ")", ";", "foreach", "(", "array_keys", "(", "$", "identifier", ")", "as", "$", "key", ")", "{", "$", "queryBuilder", "->", "andWhere", "(", "\"$key = :$key\"", ")", ";", "}", "$", "stmt", "=", "$", "this", "->", "connection", "->", "prepare", "(", "$", "queryBuilder", "->", "getSQL", "(", ")", ")", ";", "$", "stmt", "->", "execute", "(", "$", "identifier", ")", ";", "return", "(", "int", ")", "$", "stmt", "->", "fetchColumn", "(", ")", ";", "}" ]
Get auto-increment field value of the record using given id. @param array $identifier @param string $autoIncrementColumn @return int @throws DBALException
[ "Get", "auto", "-", "increment", "field", "value", "of", "the", "record", "using", "given", "id", "." ]
a9cb826b106e882e43523d39fea319adc4893e00
https://github.com/SlayerBirden/dataflow/blob/a9cb826b106e882e43523d39fea319adc4893e00/src/Writer/Dbal/Write.php#L159-L174
225,639
SlayerBirden/dataflow
src/Writer/Dbal/Write.php
Write.recordExists
private function recordExists(DataBagInterface $dataBag): bool { $id = $this->updateStrategy->getRecordIdentifier($dataBag); if (!empty($id)) { $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder->select('count(*)') ->from($this->table) ->setParameters($id); foreach (array_keys($id) as $key) { $queryBuilder->andWhere("$key = :$key"); } $stmt = $this->connection->prepare($queryBuilder->getSQL()); $stmt->execute($id); $count = (int)$stmt->fetchColumn(); if ($count > 1) { throw new InvalidIdentificationException( sprintf('Could not narrow results to 1 entry using given predicate: %s', json_encode($id)) ); } return $count === 1; } return false; }
php
private function recordExists(DataBagInterface $dataBag): bool { $id = $this->updateStrategy->getRecordIdentifier($dataBag); if (!empty($id)) { $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder->select('count(*)') ->from($this->table) ->setParameters($id); foreach (array_keys($id) as $key) { $queryBuilder->andWhere("$key = :$key"); } $stmt = $this->connection->prepare($queryBuilder->getSQL()); $stmt->execute($id); $count = (int)$stmt->fetchColumn(); if ($count > 1) { throw new InvalidIdentificationException( sprintf('Could not narrow results to 1 entry using given predicate: %s', json_encode($id)) ); } return $count === 1; } return false; }
[ "private", "function", "recordExists", "(", "DataBagInterface", "$", "dataBag", ")", ":", "bool", "{", "$", "id", "=", "$", "this", "->", "updateStrategy", "->", "getRecordIdentifier", "(", "$", "dataBag", ")", ";", "if", "(", "!", "empty", "(", "$", "id", ")", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "connection", "->", "createQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "select", "(", "'count(*)'", ")", "->", "from", "(", "$", "this", "->", "table", ")", "->", "setParameters", "(", "$", "id", ")", ";", "foreach", "(", "array_keys", "(", "$", "id", ")", "as", "$", "key", ")", "{", "$", "queryBuilder", "->", "andWhere", "(", "\"$key = :$key\"", ")", ";", "}", "$", "stmt", "=", "$", "this", "->", "connection", "->", "prepare", "(", "$", "queryBuilder", "->", "getSQL", "(", ")", ")", ";", "$", "stmt", "->", "execute", "(", "$", "id", ")", ";", "$", "count", "=", "(", "int", ")", "$", "stmt", "->", "fetchColumn", "(", ")", ";", "if", "(", "$", "count", ">", "1", ")", "{", "throw", "new", "InvalidIdentificationException", "(", "sprintf", "(", "'Could not narrow results to 1 entry using given predicate: %s'", ",", "json_encode", "(", "$", "id", ")", ")", ")", ";", "}", "return", "$", "count", "===", "1", ";", "}", "return", "false", ";", "}" ]
Checks if record already exists in the DB. @param DataBagInterface $dataBag @return bool @throws DBALException
[ "Checks", "if", "record", "already", "exists", "in", "the", "DB", "." ]
a9cb826b106e882e43523d39fea319adc4893e00
https://github.com/SlayerBirden/dataflow/blob/a9cb826b106e882e43523d39fea319adc4893e00/src/Writer/Dbal/Write.php#L183-L206
225,640
railken/amethyst-api
src/Api/Concerns/ApiTransformerTrait.php
ApiTransformerTrait.transform
public function transform(EntityContract $entity) { return $this->manager->getSerializer()->serialize($entity, Collection::make(array_merge($this->getSelectedAttributes(), $this->getAuthorizedAttributes())))->toArray(); }
php
public function transform(EntityContract $entity) { return $this->manager->getSerializer()->serialize($entity, Collection::make(array_merge($this->getSelectedAttributes(), $this->getAuthorizedAttributes())))->toArray(); }
[ "public", "function", "transform", "(", "EntityContract", "$", "entity", ")", "{", "return", "$", "this", "->", "manager", "->", "getSerializer", "(", ")", "->", "serialize", "(", "$", "entity", ",", "Collection", "::", "make", "(", "array_merge", "(", "$", "this", "->", "getSelectedAttributes", "(", ")", ",", "$", "this", "->", "getAuthorizedAttributes", "(", ")", ")", ")", ")", "->", "toArray", "(", ")", ";", "}" ]
Turn this item object into a generic array. @return array
[ "Turn", "this", "item", "object", "into", "a", "generic", "array", "." ]
00b78540b05dac59e6ef9367f1c37623a5754b89
https://github.com/railken/amethyst-api/blob/00b78540b05dac59e6ef9367f1c37623a5754b89/src/Api/Concerns/ApiTransformerTrait.php#L42-L45
225,641
sopinetchat/SopinetChatBundle
Entity/Message.php
Message.getMyType
public function getMyType() { $className = get_class($this); $classParts = explode("\\", $className); $classSingle = $classParts[count($classParts) - 1]; $classLowSingle = strtolower($classSingle); $type = str_replace("message", "", $classLowSingle); if (!$type) { return "unknown"; } else { return $type; } }
php
public function getMyType() { $className = get_class($this); $classParts = explode("\\", $className); $classSingle = $classParts[count($classParts) - 1]; $classLowSingle = strtolower($classSingle); $type = str_replace("message", "", $classLowSingle); if (!$type) { return "unknown"; } else { return $type; } }
[ "public", "function", "getMyType", "(", ")", "{", "$", "className", "=", "get_class", "(", "$", "this", ")", ";", "$", "classParts", "=", "explode", "(", "\"\\\\\"", ",", "$", "className", ")", ";", "$", "classSingle", "=", "$", "classParts", "[", "count", "(", "$", "classParts", ")", "-", "1", "]", ";", "$", "classLowSingle", "=", "strtolower", "(", "$", "classSingle", ")", ";", "$", "type", "=", "str_replace", "(", "\"message\"", ",", "\"\"", ",", "$", "classLowSingle", ")", ";", "if", "(", "!", "$", "type", ")", "{", "return", "\"unknown\"", ";", "}", "else", "{", "return", "$", "type", ";", "}", "}" ]
Return type data @return string
[ "Return", "type", "data" ]
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Entity/Message.php#L324-L336
225,642
Finesse/MiniDB
src/Parts/RawStatementsTrait.php
RawStatementsTrait.insert
public function insert(string $query, array $values = []): int { try { return $this->connection->insert($query, $values); } catch (\Throwable $exception) { return $this->handleException($exception); } }
php
public function insert(string $query, array $values = []): int { try { return $this->connection->insert($query, $values); } catch (\Throwable $exception) { return $this->handleException($exception); } }
[ "public", "function", "insert", "(", "string", "$", "query", ",", "array", "$", "values", "=", "[", "]", ")", ":", "int", "{", "try", "{", "return", "$", "this", "->", "connection", "->", "insert", "(", "$", "query", ",", "$", "values", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "exception", ")", "{", "return", "$", "this", "->", "handleException", "(", "$", "exception", ")", ";", "}", "}" ]
Performs a insert query and returns the number of inserted rows. @param string $query Full SQL query (tables are not prefixed here) @param array $values Values to bind. The indexes are the names or numbers of the values. @return int @throws InvalidArgumentException @throws DatabaseException
[ "Performs", "a", "insert", "query", "and", "returns", "the", "number", "of", "inserted", "rows", "." ]
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/RawStatementsTrait.php#L67-L74
225,643
Finesse/MiniDB
src/Parts/RawStatementsTrait.php
RawStatementsTrait.insertGetId
public function insertGetId(string $query, array $values = [], string $sequence = null) { try { return $this->connection->insertGetId($query, $values, $sequence); } catch (\Throwable $exception) { return $this->handleException($exception); } }
php
public function insertGetId(string $query, array $values = [], string $sequence = null) { try { return $this->connection->insertGetId($query, $values, $sequence); } catch (\Throwable $exception) { return $this->handleException($exception); } }
[ "public", "function", "insertGetId", "(", "string", "$", "query", ",", "array", "$", "values", "=", "[", "]", ",", "string", "$", "sequence", "=", "null", ")", "{", "try", "{", "return", "$", "this", "->", "connection", "->", "insertGetId", "(", "$", "query", ",", "$", "values", ",", "$", "sequence", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "exception", ")", "{", "return", "$", "this", "->", "handleException", "(", "$", "exception", ")", ";", "}", "}" ]
Performs a insert query and returns the identifier of the last inserted row. @param string $query Full SQL query (tables are not prefixed here) @param array $values Values to bind. The indexes are the names or numbers of the values. @param string|null $sequence Name of the sequence object from which the ID should be returned @return int|string @throws InvalidArgumentException @throws DatabaseException
[ "Performs", "a", "insert", "query", "and", "returns", "the", "identifier", "of", "the", "last", "inserted", "row", "." ]
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/RawStatementsTrait.php#L86-L93
225,644
bytic/Common
src/Controllers/Traits/Models/HasModelFinder.php
HasModelFinder.getForeignModelFromRequest
protected function getForeignModelFromRequest($name) { $this->checkForeignModelFromRequest($name); $requestKey = $this->getRequestKeyFromString($name); return $this->getRequest()->attributes->get($requestKey); }
php
protected function getForeignModelFromRequest($name) { $this->checkForeignModelFromRequest($name); $requestKey = $this->getRequestKeyFromString($name); return $this->getRequest()->attributes->get($requestKey); }
[ "protected", "function", "getForeignModelFromRequest", "(", "$", "name", ")", "{", "$", "this", "->", "checkForeignModelFromRequest", "(", "$", "name", ")", ";", "$", "requestKey", "=", "$", "this", "->", "getRequestKeyFromString", "(", "$", "name", ")", ";", "return", "$", "this", "->", "getRequest", "(", ")", "->", "attributes", "->", "get", "(", "$", "requestKey", ")", ";", "}" ]
Gets Foreign model from Request @param string $name @return Record|null
[ "Gets", "Foreign", "model", "from", "Request" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Controllers/Traits/Models/HasModelFinder.php#L192-L198
225,645
froq/froq-logger
src/Logger.php
Logger.checkDirectory
public function checkDirectory(): bool { if ($this->directory == null) { throw new LoggerException('Log directory is not defined yet'); } self::$directoryChecked = self::$directoryChecked ?: is_dir($this->directory); if (!self::$directoryChecked) { self::$directoryChecked = (bool) @mkdir($this->directory, 0644, true); if (self::$directoryChecked === false) { throw new LoggerException(sprintf('Cannot make directory, error[%s]', error_get_last()['message'] ?? 'Unknown')); } } return self::$directoryChecked; }
php
public function checkDirectory(): bool { if ($this->directory == null) { throw new LoggerException('Log directory is not defined yet'); } self::$directoryChecked = self::$directoryChecked ?: is_dir($this->directory); if (!self::$directoryChecked) { self::$directoryChecked = (bool) @mkdir($this->directory, 0644, true); if (self::$directoryChecked === false) { throw new LoggerException(sprintf('Cannot make directory, error[%s]', error_get_last()['message'] ?? 'Unknown')); } } return self::$directoryChecked; }
[ "public", "function", "checkDirectory", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "directory", "==", "null", ")", "{", "throw", "new", "LoggerException", "(", "'Log directory is not defined yet'", ")", ";", "}", "self", "::", "$", "directoryChecked", "=", "self", "::", "$", "directoryChecked", "?", ":", "is_dir", "(", "$", "this", "->", "directory", ")", ";", "if", "(", "!", "self", "::", "$", "directoryChecked", ")", "{", "self", "::", "$", "directoryChecked", "=", "(", "bool", ")", "@", "mkdir", "(", "$", "this", "->", "directory", ",", "0644", ",", "true", ")", ";", "if", "(", "self", "::", "$", "directoryChecked", "===", "false", ")", "{", "throw", "new", "LoggerException", "(", "sprintf", "(", "'Cannot make directory, error[%s]'", ",", "error_get_last", "(", ")", "[", "'message'", "]", "??", "'Unknown'", ")", ")", ";", "}", "}", "return", "self", "::", "$", "directoryChecked", ";", "}" ]
Check directory. @return bool @throws froq\logger\LoggerException
[ "Check", "directory", "." ]
7b04a012375828bec556bd93e2d023dd58a9fe74
https://github.com/froq/froq-logger/blob/7b04a012375828bec556bd93e2d023dd58a9fe74/src/Logger.php#L119-L135
225,646
froq/froq-logger
src/Logger.php
Logger.logAny
public function logAny($message, bool $separate = false): ?bool { return $this->log(self::ANY, $message, $separate); }
php
public function logAny($message, bool $separate = false): ?bool { return $this->log(self::ANY, $message, $separate); }
[ "public", "function", "logAny", "(", "$", "message", ",", "bool", "$", "separate", "=", "false", ")", ":", "?", "bool", "{", "return", "$", "this", "->", "log", "(", "self", "::", "ANY", ",", "$", "message", ",", "$", "separate", ")", ";", "}" ]
Log any. @param any $message @param bool $separate @return ?bool @since 3.2
[ "Log", "any", "." ]
7b04a012375828bec556bd93e2d023dd58a9fe74
https://github.com/froq/froq-logger/blob/7b04a012375828bec556bd93e2d023dd58a9fe74/src/Logger.php#L211-L214
225,647
froq/froq-logger
src/Logger.php
Logger.logFail
public function logFail($message, bool $separate = false): ?bool { return $this->log(self::FAIL, $message, $separate); }
php
public function logFail($message, bool $separate = false): ?bool { return $this->log(self::FAIL, $message, $separate); }
[ "public", "function", "logFail", "(", "$", "message", ",", "bool", "$", "separate", "=", "false", ")", ":", "?", "bool", "{", "return", "$", "this", "->", "log", "(", "self", "::", "FAIL", ",", "$", "message", ",", "$", "separate", ")", ";", "}" ]
Log fail. @param any $message @param bool $separate @return ?bool
[ "Log", "fail", "." ]
7b04a012375828bec556bd93e2d023dd58a9fe74
https://github.com/froq/froq-logger/blob/7b04a012375828bec556bd93e2d023dd58a9fe74/src/Logger.php#L222-L225
225,648
froq/froq-logger
src/Logger.php
Logger.logWarn
public function logWarn($message, bool $separate = false): ?bool { return $this->log(self::WARN, $message, $separate); }
php
public function logWarn($message, bool $separate = false): ?bool { return $this->log(self::WARN, $message, $separate); }
[ "public", "function", "logWarn", "(", "$", "message", ",", "bool", "$", "separate", "=", "false", ")", ":", "?", "bool", "{", "return", "$", "this", "->", "log", "(", "self", "::", "WARN", ",", "$", "message", ",", "$", "separate", ")", ";", "}" ]
Log warn. @param any $message @param bool $separate @return ?bool
[ "Log", "warn", "." ]
7b04a012375828bec556bd93e2d023dd58a9fe74
https://github.com/froq/froq-logger/blob/7b04a012375828bec556bd93e2d023dd58a9fe74/src/Logger.php#L233-L236
225,649
froq/froq-logger
src/Logger.php
Logger.logInfo
public function logInfo($message, bool $separate = false): ?bool { return $this->log(self::INFO, $message, $separate); }
php
public function logInfo($message, bool $separate = false): ?bool { return $this->log(self::INFO, $message, $separate); }
[ "public", "function", "logInfo", "(", "$", "message", ",", "bool", "$", "separate", "=", "false", ")", ":", "?", "bool", "{", "return", "$", "this", "->", "log", "(", "self", "::", "INFO", ",", "$", "message", ",", "$", "separate", ")", ";", "}" ]
Log info. @param any $message @param bool $separate @return ?bool
[ "Log", "info", "." ]
7b04a012375828bec556bd93e2d023dd58a9fe74
https://github.com/froq/froq-logger/blob/7b04a012375828bec556bd93e2d023dd58a9fe74/src/Logger.php#L244-L247
225,650
froq/froq-logger
src/Logger.php
Logger.logDebug
public function logDebug($message, bool $separate = false): ?bool { return $this->log(self::DEBUG, $message, $separate); }
php
public function logDebug($message, bool $separate = false): ?bool { return $this->log(self::DEBUG, $message, $separate); }
[ "public", "function", "logDebug", "(", "$", "message", ",", "bool", "$", "separate", "=", "false", ")", ":", "?", "bool", "{", "return", "$", "this", "->", "log", "(", "self", "::", "DEBUG", ",", "$", "message", ",", "$", "separate", ")", ";", "}" ]
Log debug. @param any $message @param bool $separate @return ?bool
[ "Log", "debug", "." ]
7b04a012375828bec556bd93e2d023dd58a9fe74
https://github.com/froq/froq-logger/blob/7b04a012375828bec556bd93e2d023dd58a9fe74/src/Logger.php#L255-L258
225,651
interserver/myadmin-plugin-installer
src/Loader.php
Loader.get_routes
public function get_routes($include_admin = false) { //if ($include_admin === FALSE && $GLOBALS['tf']->ima === 'admin') //$include_admin = TRUE; $routes = array_merge($this->public_routes, $this->routes); if ($include_admin === true) { $routes = array_merge($this->admin_routes, $routes); } uksort($routes, function ($a, $b) { if (strlen($a) == strlen($b)) { if ($a == $b) { return 0; } return ($a > $b) ? -1 : 1; } else { return (strlen($a) > strlen($b)) ? -1 : 1; } }); //myadmin_log('route', 'debug', json_encode($routes), __LINE__, __FILE__); return $routes; }
php
public function get_routes($include_admin = false) { //if ($include_admin === FALSE && $GLOBALS['tf']->ima === 'admin') //$include_admin = TRUE; $routes = array_merge($this->public_routes, $this->routes); if ($include_admin === true) { $routes = array_merge($this->admin_routes, $routes); } uksort($routes, function ($a, $b) { if (strlen($a) == strlen($b)) { if ($a == $b) { return 0; } return ($a > $b) ? -1 : 1; } else { return (strlen($a) > strlen($b)) ? -1 : 1; } }); //myadmin_log('route', 'debug', json_encode($routes), __LINE__, __FILE__); return $routes; }
[ "public", "function", "get_routes", "(", "$", "include_admin", "=", "false", ")", "{", "//if ($include_admin === FALSE && $GLOBALS['tf']->ima === 'admin')", "//$include_admin = TRUE;", "$", "routes", "=", "array_merge", "(", "$", "this", "->", "public_routes", ",", "$", "this", "->", "routes", ")", ";", "if", "(", "$", "include_admin", "===", "true", ")", "{", "$", "routes", "=", "array_merge", "(", "$", "this", "->", "admin_routes", ",", "$", "routes", ")", ";", "}", "uksort", "(", "$", "routes", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "strlen", "(", "$", "a", ")", "==", "strlen", "(", "$", "b", ")", ")", "{", "if", "(", "$", "a", "==", "$", "b", ")", "{", "return", "0", ";", "}", "return", "(", "$", "a", ">", "$", "b", ")", "?", "-", "1", ":", "1", ";", "}", "else", "{", "return", "(", "strlen", "(", "$", "a", ")", ">", "strlen", "(", "$", "b", ")", ")", "?", "-", "1", ":", "1", ";", "}", "}", ")", ";", "//myadmin_log('route', 'debug', json_encode($routes), __LINE__, __FILE__);", "return", "$", "routes", ";", "}" ]
gets the page routes @param bool $include_admin @return array of routes
[ "gets", "the", "page", "routes" ]
128efde0b61f5623b094cbb399e66ab4aa0dba3f
https://github.com/interserver/myadmin-plugin-installer/blob/128efde0b61f5623b094cbb399e66ab4aa0dba3f/src/Loader.php#L38-L58
225,652
SetBased/php-abc-form
src/Cleaner/DateCleaner.php
DateCleaner.clean
public function clean($value) { // First prune whitespace. $value = PruneWhitespaceCleaner::get()->clean($value); // If the value is empty return immediately. if ($value==='' || $value===null || $value===false) { return $this->openDate; } // First validate against ISO 8601. $match = preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value, $parts); $valid = ($match && checkdate((int)$parts[2], (int)$parts[3], (int)$parts[1])); if ($valid) { $date = new \DateTime($value); return $date->format('Y-m-d'); } // Replace alternative separators with the expected separator. if ($this->separator!==null && $this->alternativeSeparators!==null) { $value = strtr($value, $this->alternativeSeparators, str_repeat($this->separator[0], strlen($this->alternativeSeparators))); } // Validate against $format. $date = \DateTime::createFromFormat($this->format, $value); if ($date) { // Note: String '2000-02-30' will transformed to date '2000-03-01' with a warning. We consider this as an // invalid date. $tmp = $date::getLastErrors(); if ($tmp['warning_count']==0) return $date->format('Y-m-d'); } return $value; }
php
public function clean($value) { // First prune whitespace. $value = PruneWhitespaceCleaner::get()->clean($value); // If the value is empty return immediately. if ($value==='' || $value===null || $value===false) { return $this->openDate; } // First validate against ISO 8601. $match = preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value, $parts); $valid = ($match && checkdate((int)$parts[2], (int)$parts[3], (int)$parts[1])); if ($valid) { $date = new \DateTime($value); return $date->format('Y-m-d'); } // Replace alternative separators with the expected separator. if ($this->separator!==null && $this->alternativeSeparators!==null) { $value = strtr($value, $this->alternativeSeparators, str_repeat($this->separator[0], strlen($this->alternativeSeparators))); } // Validate against $format. $date = \DateTime::createFromFormat($this->format, $value); if ($date) { // Note: String '2000-02-30' will transformed to date '2000-03-01' with a warning. We consider this as an // invalid date. $tmp = $date::getLastErrors(); if ($tmp['warning_count']==0) return $date->format('Y-m-d'); } return $value; }
[ "public", "function", "clean", "(", "$", "value", ")", "{", "// First prune whitespace.", "$", "value", "=", "PruneWhitespaceCleaner", "::", "get", "(", ")", "->", "clean", "(", "$", "value", ")", ";", "// If the value is empty return immediately.", "if", "(", "$", "value", "===", "''", "||", "$", "value", "===", "null", "||", "$", "value", "===", "false", ")", "{", "return", "$", "this", "->", "openDate", ";", "}", "// First validate against ISO 8601.", "$", "match", "=", "preg_match", "(", "'/^(\\d{4})-(\\d{1,2})-(\\d{1,2})$/'", ",", "$", "value", ",", "$", "parts", ")", ";", "$", "valid", "=", "(", "$", "match", "&&", "checkdate", "(", "(", "int", ")", "$", "parts", "[", "2", "]", ",", "(", "int", ")", "$", "parts", "[", "3", "]", ",", "(", "int", ")", "$", "parts", "[", "1", "]", ")", ")", ";", "if", "(", "$", "valid", ")", "{", "$", "date", "=", "new", "\\", "DateTime", "(", "$", "value", ")", ";", "return", "$", "date", "->", "format", "(", "'Y-m-d'", ")", ";", "}", "// Replace alternative separators with the expected separator.", "if", "(", "$", "this", "->", "separator", "!==", "null", "&&", "$", "this", "->", "alternativeSeparators", "!==", "null", ")", "{", "$", "value", "=", "strtr", "(", "$", "value", ",", "$", "this", "->", "alternativeSeparators", ",", "str_repeat", "(", "$", "this", "->", "separator", "[", "0", "]", ",", "strlen", "(", "$", "this", "->", "alternativeSeparators", ")", ")", ")", ";", "}", "// Validate against $format.", "$", "date", "=", "\\", "DateTime", "::", "createFromFormat", "(", "$", "this", "->", "format", ",", "$", "value", ")", ";", "if", "(", "$", "date", ")", "{", "// Note: String '2000-02-30' will transformed to date '2000-03-01' with a warning. We consider this as an", "// invalid date.", "$", "tmp", "=", "$", "date", "::", "getLastErrors", "(", ")", ";", "if", "(", "$", "tmp", "[", "'warning_count'", "]", "==", "0", ")", "return", "$", "date", "->", "format", "(", "'Y-m-d'", ")", ";", "}", "return", "$", "value", ";", "}" ]
Cleans a submitted date and returns the date in ISO 8601 machine format if the date is a valid date. Otherwise returns the original submitted value. @param string|null $value The submitted date. @return string|null @since 1.0.0 @api
[ "Cleans", "a", "submitted", "date", "and", "returns", "the", "date", "in", "ISO", "8601", "machine", "format", "if", "the", "date", "is", "a", "valid", "date", ".", "Otherwise", "returns", "the", "original", "submitted", "value", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Cleaner/DateCleaner.php#L72-L112
225,653
DrNixx/yii2-onix
src/collections/ArrayList.php
ArrayList.addAll
public function addAll($elements) { if ($elements instanceof CollectionInterface) { $elements = $elements->toArray(); } else { $elements = array_values($elements); } $this->elements = array_merge($this->elements, $elements); return $this; }
php
public function addAll($elements) { if ($elements instanceof CollectionInterface) { $elements = $elements->toArray(); } else { $elements = array_values($elements); } $this->elements = array_merge($this->elements, $elements); return $this; }
[ "public", "function", "addAll", "(", "$", "elements", ")", "{", "if", "(", "$", "elements", "instanceof", "CollectionInterface", ")", "{", "$", "elements", "=", "$", "elements", "->", "toArray", "(", ")", ";", "}", "else", "{", "$", "elements", "=", "array_values", "(", "$", "elements", ")", ";", "}", "$", "this", "->", "elements", "=", "array_merge", "(", "$", "this", "->", "elements", ",", "$", "elements", ")", ";", "return", "$", "this", ";", "}" ]
Adds elements to the end of the list. @param CollectionInterface|array $elements Elements to add to the list. @return ArrayList A reference to the list. @see add
[ "Adds", "elements", "to", "the", "end", "of", "the", "list", "." ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/ArrayList.php#L40-L49
225,654
DrNixx/yii2-onix
src/collections/ArrayList.php
ArrayList.insert
public function insert($index, $element) { if (0 < $index && $this->count() < $index) { throw new \OutOfBoundsException(); } array_splice($this->elements, $index, 0, $element); foreach ($this->subLists as $subList) { $subList->insert($index, $element, true); } return $this; }
php
public function insert($index, $element) { if (0 < $index && $this->count() < $index) { throw new \OutOfBoundsException(); } array_splice($this->elements, $index, 0, $element); foreach ($this->subLists as $subList) { $subList->insert($index, $element, true); } return $this; }
[ "public", "function", "insert", "(", "$", "index", ",", "$", "element", ")", "{", "if", "(", "0", "<", "$", "index", "&&", "$", "this", "->", "count", "(", ")", "<", "$", "index", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", ")", ";", "}", "array_splice", "(", "$", "this", "->", "elements", ",", "$", "index", ",", "0", ",", "$", "element", ")", ";", "foreach", "(", "$", "this", "->", "subLists", "as", "$", "subList", ")", "{", "$", "subList", "->", "insert", "(", "$", "index", ",", "$", "element", ",", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Inserts the element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). @param int $index Index to insert at. @param mixed $element Element to insert. @return ArrayList A reference to the list. @throws \OutOfBoundsException If the index is out of range. @see insertAll, add
[ "Inserts", "the", "element", "at", "the", "specified", "position", "in", "this", "list", "." ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/ArrayList.php#L66-L78
225,655
DrNixx/yii2-onix
src/collections/ArrayList.php
ArrayList.insertAll
public function insertAll($index, $elements) { if (0 < $index && $this->count() < $index) { throw new \OutOfBoundsException(); } if ($elements instanceof CollectionInterface) { $elements = $elements->toArray(); } else { $elements = array_values($elements); } array_splice($this->elements, $index, 0, $elements); foreach ($this->subLists as $subList) { $subList->insertAll($index, $elements, true); } return $this; }
php
public function insertAll($index, $elements) { if (0 < $index && $this->count() < $index) { throw new \OutOfBoundsException(); } if ($elements instanceof CollectionInterface) { $elements = $elements->toArray(); } else { $elements = array_values($elements); } array_splice($this->elements, $index, 0, $elements); foreach ($this->subLists as $subList) { $subList->insertAll($index, $elements, true); } return $this; }
[ "public", "function", "insertAll", "(", "$", "index", ",", "$", "elements", ")", "{", "if", "(", "0", "<", "$", "index", "&&", "$", "this", "->", "count", "(", ")", "<", "$", "index", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", ")", ";", "}", "if", "(", "$", "elements", "instanceof", "CollectionInterface", ")", "{", "$", "elements", "=", "$", "elements", "->", "toArray", "(", ")", ";", "}", "else", "{", "$", "elements", "=", "array_values", "(", "$", "elements", ")", ";", "}", "array_splice", "(", "$", "this", "->", "elements", ",", "$", "index", ",", "0", ",", "$", "elements", ")", ";", "foreach", "(", "$", "this", "->", "subLists", "as", "$", "subList", ")", "{", "$", "subList", "->", "insertAll", "(", "$", "index", ",", "$", "elements", ",", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Inserts all of the elements into this list at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. @param int $index Index at insert at. @param CollectionInterface|array $elements Elements to insert. @return ArrayList A reference to the list. @throws \OutOfBoundsException If the index is out of range. @see insert, addAll
[ "Inserts", "all", "of", "the", "elements", "into", "this", "list", "at", "the", "specified", "position", "." ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/ArrayList.php#L95-L110
225,656
DrNixx/yii2-onix
src/collections/ArrayList.php
ArrayList.set
public function set($index, $element) { if (false === array_key_exists($index, $this->elements)) { throw new \OutOfBoundsException(); } $this->elements[$index] = $element; foreach ($this->subLists as $subList) { $subList->set($index, $element, true); } return $this; }
php
public function set($index, $element) { if (false === array_key_exists($index, $this->elements)) { throw new \OutOfBoundsException(); } $this->elements[$index] = $element; foreach ($this->subLists as $subList) { $subList->set($index, $element, true); } return $this; }
[ "public", "function", "set", "(", "$", "index", ",", "$", "element", ")", "{", "if", "(", "false", "===", "array_key_exists", "(", "$", "index", ",", "$", "this", "->", "elements", ")", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", ")", ";", "}", "$", "this", "->", "elements", "[", "$", "index", "]", "=", "$", "element", ";", "foreach", "(", "$", "this", "->", "subLists", "as", "$", "subList", ")", "{", "$", "subList", "->", "set", "(", "$", "index", ",", "$", "element", ",", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Replaces the element at the specified position in this list with the specified element. @param int $index Index of the element to replace. @param mixed $element Element to replace. @return ArrayList A reference to the list. @throws \OutOfBoundsException If the index is out of range.
[ "Replaces", "the", "element", "at", "the", "specified", "position", "in", "this", "list", "with", "the", "specified", "element", "." ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/ArrayList.php#L123-L133
225,657
DrNixx/yii2-onix
src/collections/ArrayList.php
ArrayList.remove
public function remove($element) { $key = array_search($element, $this->elements, true); if (false !== $key) { unset($this->elements[$key]); $this->elements = array_values($this->elements); } foreach ($this->subLists as $subList) { $subList->drop($key, true); } return $this; }
php
public function remove($element) { $key = array_search($element, $this->elements, true); if (false !== $key) { unset($this->elements[$key]); $this->elements = array_values($this->elements); } foreach ($this->subLists as $subList) { $subList->drop($key, true); } return $this; }
[ "public", "function", "remove", "(", "$", "element", ")", "{", "$", "key", "=", "array_search", "(", "$", "element", ",", "$", "this", "->", "elements", ",", "true", ")", ";", "if", "(", "false", "!==", "$", "key", ")", "{", "unset", "(", "$", "this", "->", "elements", "[", "$", "key", "]", ")", ";", "$", "this", "->", "elements", "=", "array_values", "(", "$", "this", "->", "elements", ")", ";", "}", "foreach", "(", "$", "this", "->", "subLists", "as", "$", "subList", ")", "{", "$", "subList", "->", "drop", "(", "$", "key", ",", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes the first instance of the element from the list, if it is present. @param mixed $element Element to be removed from the list. @return ArrayList A reference to the list. @see removeAll
[ "Removes", "the", "first", "instance", "of", "the", "element", "from", "the", "list", "if", "it", "is", "present", "." ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/ArrayList.php#L144-L155
225,658
DrNixx/yii2-onix
src/collections/ArrayList.php
ArrayList.removeAll
public function removeAll($elements) { if ($elements instanceof CollectionInterface) { $elements = $elements->toArray(); } $this->elements = array_values( array_udiff( $this->elements, $elements, function ($a, $b) { if ($a === $b) { return 0; } elseif (is_int($a) && is_object($b)) { return -1; } elseif (is_object($a) && is_int($b)) { return 1; } elseif ($a < $b) { return -1; } else { return 1; } } ) ); foreach ($this->subLists as $subList) { $subList->removeAll($elements, true); } return $this; }
php
public function removeAll($elements) { if ($elements instanceof CollectionInterface) { $elements = $elements->toArray(); } $this->elements = array_values( array_udiff( $this->elements, $elements, function ($a, $b) { if ($a === $b) { return 0; } elseif (is_int($a) && is_object($b)) { return -1; } elseif (is_object($a) && is_int($b)) { return 1; } elseif ($a < $b) { return -1; } else { return 1; } } ) ); foreach ($this->subLists as $subList) { $subList->removeAll($elements, true); } return $this; }
[ "public", "function", "removeAll", "(", "$", "elements", ")", "{", "if", "(", "$", "elements", "instanceof", "CollectionInterface", ")", "{", "$", "elements", "=", "$", "elements", "->", "toArray", "(", ")", ";", "}", "$", "this", "->", "elements", "=", "array_values", "(", "array_udiff", "(", "$", "this", "->", "elements", ",", "$", "elements", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "$", "a", "===", "$", "b", ")", "{", "return", "0", ";", "}", "elseif", "(", "is_int", "(", "$", "a", ")", "&&", "is_object", "(", "$", "b", ")", ")", "{", "return", "-", "1", ";", "}", "elseif", "(", "is_object", "(", "$", "a", ")", "&&", "is_int", "(", "$", "b", ")", ")", "{", "return", "1", ";", "}", "elseif", "(", "$", "a", "<", "$", "b", ")", "{", "return", "-", "1", ";", "}", "else", "{", "return", "1", ";", "}", "}", ")", ")", ";", "foreach", "(", "$", "this", "->", "subLists", "as", "$", "subList", ")", "{", "$", "subList", "->", "removeAll", "(", "$", "elements", ",", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes all instances of the elements from the list, if they are present. @param CollectionInterface|array $elements Elements to be removed from the list, if present. @return ArrayList A reference to the list. @see remove
[ "Removes", "all", "instances", "of", "the", "elements", "from", "the", "list", "if", "they", "are", "present", "." ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/ArrayList.php#L166-L194
225,659
DrNixx/yii2-onix
src/collections/ArrayList.php
ArrayList.drop
public function drop($index) { if (false === array_key_exists($index, $this->elements)) { throw new \OutOfBoundsException(); } unset($this->elements[$index]); $this->elements = array_values($this->elements); foreach ($this->subLists as $subList) { $subList->drop($index, true); } return $this; }
php
public function drop($index) { if (false === array_key_exists($index, $this->elements)) { throw new \OutOfBoundsException(); } unset($this->elements[$index]); $this->elements = array_values($this->elements); foreach ($this->subLists as $subList) { $subList->drop($index, true); } return $this; }
[ "public", "function", "drop", "(", "$", "index", ")", "{", "if", "(", "false", "===", "array_key_exists", "(", "$", "index", ",", "$", "this", "->", "elements", ")", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", ")", ";", "}", "unset", "(", "$", "this", "->", "elements", "[", "$", "index", "]", ")", ";", "$", "this", "->", "elements", "=", "array_values", "(", "$", "this", "->", "elements", ")", ";", "foreach", "(", "$", "this", "->", "subLists", "as", "$", "subList", ")", "{", "$", "subList", "->", "drop", "(", "$", "index", ",", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). @param int $index Index of the element to be removed. @return ArrayList A reference to the list. @throws \OutOfBoundsException If the index is out of range.
[ "Removes", "the", "element", "at", "the", "specified", "position", "in", "this", "list", "." ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/ArrayList.php#L208-L219
225,660
DrNixx/yii2-onix
src/collections/ArrayList.php
ArrayList.clear
public function clear() { $this->elements = array(); foreach ($this->subLists as $subList) { $subList->clear(true); } return $this; }
php
public function clear() { $this->elements = array(); foreach ($this->subLists as $subList) { $subList->clear(true); } return $this; }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "elements", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "subLists", "as", "$", "subList", ")", "{", "$", "subList", "->", "clear", "(", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes all elements from the list. @return ArrayList A reference to the list.
[ "Removes", "all", "elements", "from", "the", "list", "." ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/ArrayList.php#L226-L233
225,661
DrNixx/yii2-onix
src/collections/ArrayList.php
ArrayList.retainAll
public function retainAll($elements) { if ($elements instanceof CollectionInterface) { $elements = $elements->toArray(); } $this->elements = array_values( array_uintersect( $this->elements, $elements, function ($a, $b) { if ($a === $b) { return 0; } elseif (is_int($a) && is_object($b)) { return -1; } elseif (is_object($a) && is_int($b)) { return 1; } elseif ($a < $b) { return -1; } else { return 1; } } ) ); return $this; }
php
public function retainAll($elements) { if ($elements instanceof CollectionInterface) { $elements = $elements->toArray(); } $this->elements = array_values( array_uintersect( $this->elements, $elements, function ($a, $b) { if ($a === $b) { return 0; } elseif (is_int($a) && is_object($b)) { return -1; } elseif (is_object($a) && is_int($b)) { return 1; } elseif ($a < $b) { return -1; } else { return 1; } } ) ); return $this; }
[ "public", "function", "retainAll", "(", "$", "elements", ")", "{", "if", "(", "$", "elements", "instanceof", "CollectionInterface", ")", "{", "$", "elements", "=", "$", "elements", "->", "toArray", "(", ")", ";", "}", "$", "this", "->", "elements", "=", "array_values", "(", "array_uintersect", "(", "$", "this", "->", "elements", ",", "$", "elements", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "$", "a", "===", "$", "b", ")", "{", "return", "0", ";", "}", "elseif", "(", "is_int", "(", "$", "a", ")", "&&", "is_object", "(", "$", "b", ")", ")", "{", "return", "-", "1", ";", "}", "elseif", "(", "is_object", "(", "$", "a", ")", "&&", "is_int", "(", "$", "b", ")", ")", "{", "return", "1", ";", "}", "elseif", "(", "$", "a", "<", "$", "b", ")", "{", "return", "-", "1", ";", "}", "else", "{", "return", "1", ";", "}", "}", ")", ")", ";", "return", "$", "this", ";", "}" ]
Retains only the elements in the list that are contained in the specified collection. In other words, removes from the list all of its elements that are not contained in the specified collection. @param CollectionInterface|array $elements Elements to be retained in the list. @return ArrayList A reference to the list.
[ "Retains", "only", "the", "elements", "in", "the", "list", "that", "are", "contained", "in", "the", "specified", "collection", "." ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/ArrayList.php#L246-L271
225,662
n2n/n2n-log4php
src/app/n2n/log4php/pattern/PatternParser.php
PatternParser.parse
public function parse() { // Skip parsing if the pattern is empty if (empty($this->pattern)) { $this->addLiteral(''); return $this->head; } // Find all conversion words in the conversion pattern $count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE); if ($count === false) { $error = error_get_last(); throw new \n2n\log4php\LoggerException("Failed parsing layotut pattern: {$error['message']}"); } $prevEnd = 0; foreach($matches[0] as $key => $item) { // Locate where the conversion command starts and ends $length = strlen($item[0]); $start = $item[1]; $end = $item[1] + $length; // Find any literal expressions between matched commands if ($start > $prevEnd) { $literal = substr($this->pattern, $prevEnd, $start - $prevEnd); $this->addLiteral($literal); } // Extract the data from the matched command $word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null; $modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null; $option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null; // Create a converter and add it to the chain $this->addConverter($word, $modifiers, $option); $prevEnd = $end; } // Add any trailing literals if ($end < strlen($this->pattern)) { $literal = substr($this->pattern, $end); $this->addLiteral($literal); } return $this->head; }
php
public function parse() { // Skip parsing if the pattern is empty if (empty($this->pattern)) { $this->addLiteral(''); return $this->head; } // Find all conversion words in the conversion pattern $count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE); if ($count === false) { $error = error_get_last(); throw new \n2n\log4php\LoggerException("Failed parsing layotut pattern: {$error['message']}"); } $prevEnd = 0; foreach($matches[0] as $key => $item) { // Locate where the conversion command starts and ends $length = strlen($item[0]); $start = $item[1]; $end = $item[1] + $length; // Find any literal expressions between matched commands if ($start > $prevEnd) { $literal = substr($this->pattern, $prevEnd, $start - $prevEnd); $this->addLiteral($literal); } // Extract the data from the matched command $word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null; $modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null; $option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null; // Create a converter and add it to the chain $this->addConverter($word, $modifiers, $option); $prevEnd = $end; } // Add any trailing literals if ($end < strlen($this->pattern)) { $literal = substr($this->pattern, $end); $this->addLiteral($literal); } return $this->head; }
[ "public", "function", "parse", "(", ")", "{", "// Skip parsing if the pattern is empty\r", "if", "(", "empty", "(", "$", "this", "->", "pattern", ")", ")", "{", "$", "this", "->", "addLiteral", "(", "''", ")", ";", "return", "$", "this", "->", "head", ";", "}", "// Find all conversion words in the conversion pattern\r", "$", "count", "=", "preg_match_all", "(", "$", "this", "->", "regex", ",", "$", "this", "->", "pattern", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", ")", ";", "if", "(", "$", "count", "===", "false", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"Failed parsing layotut pattern: {$error['message']}\"", ")", ";", "}", "$", "prevEnd", "=", "0", ";", "foreach", "(", "$", "matches", "[", "0", "]", "as", "$", "key", "=>", "$", "item", ")", "{", "// Locate where the conversion command starts and ends\r", "$", "length", "=", "strlen", "(", "$", "item", "[", "0", "]", ")", ";", "$", "start", "=", "$", "item", "[", "1", "]", ";", "$", "end", "=", "$", "item", "[", "1", "]", "+", "$", "length", ";", "// Find any literal expressions between matched commands\r", "if", "(", "$", "start", ">", "$", "prevEnd", ")", "{", "$", "literal", "=", "substr", "(", "$", "this", "->", "pattern", ",", "$", "prevEnd", ",", "$", "start", "-", "$", "prevEnd", ")", ";", "$", "this", "->", "addLiteral", "(", "$", "literal", ")", ";", "}", "// Extract the data from the matched command\r", "$", "word", "=", "!", "empty", "(", "$", "matches", "[", "'word'", "]", "[", "$", "key", "]", ")", "?", "$", "matches", "[", "'word'", "]", "[", "$", "key", "]", "[", "0", "]", ":", "null", ";", "$", "modifiers", "=", "!", "empty", "(", "$", "matches", "[", "'modifiers'", "]", "[", "$", "key", "]", ")", "?", "$", "matches", "[", "'modifiers'", "]", "[", "$", "key", "]", "[", "0", "]", ":", "null", ";", "$", "option", "=", "!", "empty", "(", "$", "matches", "[", "'option'", "]", "[", "$", "key", "]", ")", "?", "$", "matches", "[", "'option'", "]", "[", "$", "key", "]", "[", "0", "]", ":", "null", ";", "// Create a converter and add it to the chain\r", "$", "this", "->", "addConverter", "(", "$", "word", ",", "$", "modifiers", ",", "$", "option", ")", ";", "$", "prevEnd", "=", "$", "end", ";", "}", "// Add any trailing literals\r", "if", "(", "$", "end", "<", "strlen", "(", "$", "this", "->", "pattern", ")", ")", "{", "$", "literal", "=", "substr", "(", "$", "this", "->", "pattern", ",", "$", "end", ")", ";", "$", "this", "->", "addLiteral", "(", "$", "literal", ")", ";", "}", "return", "$", "this", "->", "head", ";", "}" ]
Parses the conversion pattern string, converts it to a chain of pattern converters and returns the first converter in the chain. @return \n2n\log4php\pattern\PatternConverter
[ "Parses", "the", "conversion", "pattern", "string", "converts", "it", "to", "a", "chain", "of", "pattern", "converters", "and", "returns", "the", "first", "converter", "in", "the", "chain", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/pattern/PatternParser.php#L78-L126
225,663
n2n/n2n-log4php
src/app/n2n/log4php/pattern/PatternParser.php
PatternParser.addLiteral
private function addLiteral($string) { $converter = new \n2n\log4php\pattern\converter\ConverterLiteral($string); $this->addToChain($converter); }
php
private function addLiteral($string) { $converter = new \n2n\log4php\pattern\converter\ConverterLiteral($string); $this->addToChain($converter); }
[ "private", "function", "addLiteral", "(", "$", "string", ")", "{", "$", "converter", "=", "new", "\\", "n2n", "\\", "log4php", "\\", "pattern", "\\", "converter", "\\", "ConverterLiteral", "(", "$", "string", ")", ";", "$", "this", "->", "addToChain", "(", "$", "converter", ")", ";", "}" ]
Adds a literal converter to the converter chain. @param string $string The string for the literal converter.
[ "Adds", "a", "literal", "converter", "to", "the", "converter", "chain", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/pattern/PatternParser.php#L132-L135
225,664
n2n/n2n-log4php
src/app/n2n/log4php/pattern/PatternParser.php
PatternParser.addConverter
private function addConverter($word, $modifiers, $option) { $formattingInfo = $this->parseModifiers($modifiers); $option = trim($option, "{} "); if (isset($this->converterMap[$word])) { $converter = $this->getConverter($word, $formattingInfo, $option); $this->addToChain($converter); } else { throw new \n2n\log4php\LoggerException("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING); } }
php
private function addConverter($word, $modifiers, $option) { $formattingInfo = $this->parseModifiers($modifiers); $option = trim($option, "{} "); if (isset($this->converterMap[$word])) { $converter = $this->getConverter($word, $formattingInfo, $option); $this->addToChain($converter); } else { throw new \n2n\log4php\LoggerException("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING); } }
[ "private", "function", "addConverter", "(", "$", "word", ",", "$", "modifiers", ",", "$", "option", ")", "{", "$", "formattingInfo", "=", "$", "this", "->", "parseModifiers", "(", "$", "modifiers", ")", ";", "$", "option", "=", "trim", "(", "$", "option", ",", "\"{} \"", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "converterMap", "[", "$", "word", "]", ")", ")", "{", "$", "converter", "=", "$", "this", "->", "getConverter", "(", "$", "word", ",", "$", "formattingInfo", ",", "$", "option", ")", ";", "$", "this", "->", "addToChain", "(", "$", "converter", ")", ";", "}", "else", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.\"", ",", "E_USER_WARNING", ")", ";", "}", "}" ]
Adds a non-literal converter to the converter chain. @param string $word The conversion word, used to determine which converter will be used. @param string $modifiers Formatting modifiers. @param string $option Option to pass to the converter.
[ "Adds", "a", "non", "-", "literal", "converter", "to", "the", "converter", "chain", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/pattern/PatternParser.php#L145-L155
225,665
n2n/n2n-log4php
src/app/n2n/log4php/pattern/PatternParser.php
PatternParser.getConverter
private function getConverter($word, $info, $option) { if (!isset($this->converterMap[$word])) { throw new \n2n\log4php\LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword."); } $converterClass = $this->converterMap[$word]; if(!class_exists($converterClass)) { throw new \n2n\log4php\LoggerException("Class '$converterClass' does not exist."); } $converter = new $converterClass($info, $option); if(!($converter instanceof \n2n\log4php\pattern\PatternConverter)) { throw new \n2n\log4php\LoggerException("Class '$converterClass' is not an instance of \n2n\log4php\pattern\PatternConverter."); } return $converter; }
php
private function getConverter($word, $info, $option) { if (!isset($this->converterMap[$word])) { throw new \n2n\log4php\LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword."); } $converterClass = $this->converterMap[$word]; if(!class_exists($converterClass)) { throw new \n2n\log4php\LoggerException("Class '$converterClass' does not exist."); } $converter = new $converterClass($info, $option); if(!($converter instanceof \n2n\log4php\pattern\PatternConverter)) { throw new \n2n\log4php\LoggerException("Class '$converterClass' is not an instance of \n2n\log4php\pattern\PatternConverter."); } return $converter; }
[ "private", "function", "getConverter", "(", "$", "word", ",", "$", "info", ",", "$", "option", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "converterMap", "[", "$", "word", "]", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"Invalid keyword '%$word' in converison pattern. Ignoring keyword.\"", ")", ";", "}", "$", "converterClass", "=", "$", "this", "->", "converterMap", "[", "$", "word", "]", ";", "if", "(", "!", "class_exists", "(", "$", "converterClass", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"Class '$converterClass' does not exist.\"", ")", ";", "}", "$", "converter", "=", "new", "$", "converterClass", "(", "$", "info", ",", "$", "option", ")", ";", "if", "(", "!", "(", "$", "converter", "instanceof", "\\", "n2n", "\\", "log4php", "\\", "pattern", "\\", "PatternConverter", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"Class '$converterClass' is not an instance of \\n2n\\log4php\\pattern\\PatternConverter.\"", ")", ";", "}", "return", "$", "converter", ";", "}" ]
Determines which converter to use based on the conversion word. Creates an instance of the converter using the provided formatting info and option and returns it. @param string $word The conversion word. @param \n2n\log4php\formatting\FormattingInfo $info Formatting info. @param string $option Converter option. @throws \n2n\log4php\LoggerException @return \n2n\log4php\pattern\PatternConverter
[ "Determines", "which", "converter", "to", "use", "based", "on", "the", "conversion", "word", ".", "Creates", "an", "instance", "of", "the", "converter", "using", "the", "provided", "formatting", "info", "and", "option", "and", "returns", "it", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/pattern/PatternParser.php#L170-L186
225,666
n2n/n2n-log4php
src/app/n2n/log4php/pattern/PatternParser.php
PatternParser.parseModifiers
private function parseModifiers($modifiers) { $info = new \n2n\log4php\formatting\FormattingInfo(); // If no modifiers are given, return default values if (empty($modifiers)) { return $info; } // Validate $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/'; if (!preg_match($pattern, $modifiers)) { throw new \n2n\log4php\LoggerException("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING); return $info; } $parts = explode('.', $modifiers); if (!empty($parts[0])) { $minPart = (integer) $parts[0]; $info->min = abs($minPart); $info->padLeft = ($minPart > 0); } if (!empty($parts[1])) { $maxPart = (integer) $parts[1]; $info->max = abs($maxPart); $info->trimLeft = ($maxPart < 0); } return $info; }
php
private function parseModifiers($modifiers) { $info = new \n2n\log4php\formatting\FormattingInfo(); // If no modifiers are given, return default values if (empty($modifiers)) { return $info; } // Validate $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/'; if (!preg_match($pattern, $modifiers)) { throw new \n2n\log4php\LoggerException("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING); return $info; } $parts = explode('.', $modifiers); if (!empty($parts[0])) { $minPart = (integer) $parts[0]; $info->min = abs($minPart); $info->padLeft = ($minPart > 0); } if (!empty($parts[1])) { $maxPart = (integer) $parts[1]; $info->max = abs($maxPart); $info->trimLeft = ($maxPart < 0); } return $info; }
[ "private", "function", "parseModifiers", "(", "$", "modifiers", ")", "{", "$", "info", "=", "new", "\\", "n2n", "\\", "log4php", "\\", "formatting", "\\", "FormattingInfo", "(", ")", ";", "// If no modifiers are given, return default values\r", "if", "(", "empty", "(", "$", "modifiers", ")", ")", "{", "return", "$", "info", ";", "}", "// Validate\r", "$", "pattern", "=", "'/^(-?[0-9]+)?\\.?-?[0-9]+$/'", ";", "if", "(", "!", "preg_match", "(", "$", "pattern", ",", "$", "modifiers", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.\"", ",", "E_USER_WARNING", ")", ";", "return", "$", "info", ";", "}", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "modifiers", ")", ";", "if", "(", "!", "empty", "(", "$", "parts", "[", "0", "]", ")", ")", "{", "$", "minPart", "=", "(", "integer", ")", "$", "parts", "[", "0", "]", ";", "$", "info", "->", "min", "=", "abs", "(", "$", "minPart", ")", ";", "$", "info", "->", "padLeft", "=", "(", "$", "minPart", ">", "0", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "parts", "[", "1", "]", ")", ")", "{", "$", "maxPart", "=", "(", "integer", ")", "$", "parts", "[", "1", "]", ";", "$", "info", "->", "max", "=", "abs", "(", "$", "maxPart", ")", ";", "$", "info", "->", "trimLeft", "=", "(", "$", "maxPart", "<", "0", ")", ";", "}", "return", "$", "info", ";", "}" ]
Parses the formatting modifiers and produces the corresponding \n2n\log4php\formatting\FormattingInfo object. @param string $modifier @return \n2n\log4php\formatting\FormattingInfo @throws \n2n\log4php\LoggerException
[ "Parses", "the", "formatting", "modifiers", "and", "produces", "the", "corresponding", "\\", "n2n", "\\", "log4php", "\\", "formatting", "\\", "FormattingInfo", "object", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/pattern/PatternParser.php#L207-L237
225,667
sopinetchat/SopinetChatBundle
Service/ChatHelper.php
ChatHelper.getMyChats
public function getMyChats(Request $request){ /** @var LoginHelper $loginHelper */ $loginHelper = $this->container->get('sopinet_login_helper'); try { $user = $loginHelper->getUser($request); } catch(Exception $e) { throw new Exception($e->getMessage()); } $em = $this->container->get('doctrine.orm.default_entity_manager'); /** @var ChatRepository $reChat */ $reChat = $em->getRepository('SopinetChatBundle:Chat'); $all = $reChat->findAll(); $chats = array(); /** @var Chat $chat */ foreach ($all as $chat){ if($chat->getChatMembers()->contains($user)){ $chats [] = $chat; } } return $chats; }
php
public function getMyChats(Request $request){ /** @var LoginHelper $loginHelper */ $loginHelper = $this->container->get('sopinet_login_helper'); try { $user = $loginHelper->getUser($request); } catch(Exception $e) { throw new Exception($e->getMessage()); } $em = $this->container->get('doctrine.orm.default_entity_manager'); /** @var ChatRepository $reChat */ $reChat = $em->getRepository('SopinetChatBundle:Chat'); $all = $reChat->findAll(); $chats = array(); /** @var Chat $chat */ foreach ($all as $chat){ if($chat->getChatMembers()->contains($user)){ $chats [] = $chat; } } return $chats; }
[ "public", "function", "getMyChats", "(", "Request", "$", "request", ")", "{", "/** @var LoginHelper $loginHelper */", "$", "loginHelper", "=", "$", "this", "->", "container", "->", "get", "(", "'sopinet_login_helper'", ")", ";", "try", "{", "$", "user", "=", "$", "loginHelper", "->", "getUser", "(", "$", "request", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine.orm.default_entity_manager'", ")", ";", "/** @var ChatRepository $reChat */", "$", "reChat", "=", "$", "em", "->", "getRepository", "(", "'SopinetChatBundle:Chat'", ")", ";", "$", "all", "=", "$", "reChat", "->", "findAll", "(", ")", ";", "$", "chats", "=", "array", "(", ")", ";", "/** @var Chat $chat */", "foreach", "(", "$", "all", "as", "$", "chat", ")", "{", "if", "(", "$", "chat", "->", "getChatMembers", "(", ")", "->", "contains", "(", "$", "user", ")", ")", "{", "$", "chats", "[", "]", "=", "$", "chat", ";", "}", "}", "return", "$", "chats", ";", "}" ]
Funcion para obtener mis chats @param Request $request @return array
[ "Funcion", "para", "obtener", "mis", "chats" ]
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/ChatHelper.php#L129-L157
225,668
SetBased/php-helper-code-store-php
src/PhpCodeStore.php
PhpCodeStore.indentationModeBlock
private function indentationModeBlock(string $line): int { $mode = 0; if (substr($line, -1, 1)=='{') { $mode |= self::C_INDENT_INCREMENT_AFTER; $this->defaultLevelIncrement(); } if (substr($line, 0, 1)=='}') { $this->defaultLevelDecrement(); if ($this->defaultLevelIsZero()) { $mode |= self::C_INDENT_DECREMENT_BEFORE_DOUBLE; array_pop($this->defaultLevel); } else { $mode |= self::C_INDENT_DECREMENT_BEFORE; } } return $mode; }
php
private function indentationModeBlock(string $line): int { $mode = 0; if (substr($line, -1, 1)=='{') { $mode |= self::C_INDENT_INCREMENT_AFTER; $this->defaultLevelIncrement(); } if (substr($line, 0, 1)=='}') { $this->defaultLevelDecrement(); if ($this->defaultLevelIsZero()) { $mode |= self::C_INDENT_DECREMENT_BEFORE_DOUBLE; array_pop($this->defaultLevel); } else { $mode |= self::C_INDENT_DECREMENT_BEFORE; } } return $mode; }
[ "private", "function", "indentationModeBlock", "(", "string", "$", "line", ")", ":", "int", "{", "$", "mode", "=", "0", ";", "if", "(", "substr", "(", "$", "line", ",", "-", "1", ",", "1", ")", "==", "'{'", ")", "{", "$", "mode", "|=", "self", "::", "C_INDENT_INCREMENT_AFTER", ";", "$", "this", "->", "defaultLevelIncrement", "(", ")", ";", "}", "if", "(", "substr", "(", "$", "line", ",", "0", ",", "1", ")", "==", "'}'", ")", "{", "$", "this", "->", "defaultLevelDecrement", "(", ")", ";", "if", "(", "$", "this", "->", "defaultLevelIsZero", "(", ")", ")", "{", "$", "mode", "|=", "self", "::", "C_INDENT_DECREMENT_BEFORE_DOUBLE", ";", "array_pop", "(", "$", "this", "->", "defaultLevel", ")", ";", "}", "else", "{", "$", "mode", "|=", "self", "::", "C_INDENT_DECREMENT_BEFORE", ";", "}", "}", "return", "$", "mode", ";", "}" ]
Returns the indentation mode based blocks of code. @param string $line The line of code. @return int
[ "Returns", "the", "indentation", "mode", "based", "blocks", "of", "code", "." ]
954f8dcc47e12e5c2878ba7473f9feb9c3aaa643
https://github.com/SetBased/php-helper-code-store-php/blob/954f8dcc47e12e5c2878ba7473f9feb9c3aaa643/src/PhpCodeStore.php#L92-L120
225,669
SetBased/php-helper-code-store-php
src/PhpCodeStore.php
PhpCodeStore.indentationModeSwitch
private function indentationModeSwitch(string $line): int { $mode = 0; if (substr($line, 0, 5)=='case ') { $mode |= self::C_INDENT_INCREMENT_AFTER; } if (substr($line, 0, 8)=='default:') { $this->defaultLevel[] = 0; $mode |= self::C_INDENT_INCREMENT_AFTER; } if (substr($line, 0, 6)=='break;') { $mode |= self::C_INDENT_DECREMENT_AFTER; } return $mode; }
php
private function indentationModeSwitch(string $line): int { $mode = 0; if (substr($line, 0, 5)=='case ') { $mode |= self::C_INDENT_INCREMENT_AFTER; } if (substr($line, 0, 8)=='default:') { $this->defaultLevel[] = 0; $mode |= self::C_INDENT_INCREMENT_AFTER; } if (substr($line, 0, 6)=='break;') { $mode |= self::C_INDENT_DECREMENT_AFTER; } return $mode; }
[ "private", "function", "indentationModeSwitch", "(", "string", "$", "line", ")", ":", "int", "{", "$", "mode", "=", "0", ";", "if", "(", "substr", "(", "$", "line", ",", "0", ",", "5", ")", "==", "'case '", ")", "{", "$", "mode", "|=", "self", "::", "C_INDENT_INCREMENT_AFTER", ";", "}", "if", "(", "substr", "(", "$", "line", ",", "0", ",", "8", ")", "==", "'default:'", ")", "{", "$", "this", "->", "defaultLevel", "[", "]", "=", "0", ";", "$", "mode", "|=", "self", "::", "C_INDENT_INCREMENT_AFTER", ";", "}", "if", "(", "substr", "(", "$", "line", ",", "0", ",", "6", ")", "==", "'break;'", ")", "{", "$", "mode", "|=", "self", "::", "C_INDENT_DECREMENT_AFTER", ";", "}", "return", "$", "mode", ";", "}" ]
Returns the indentation mode based on a line of code for switch statements. @param string $line The line of code. @return int
[ "Returns", "the", "indentation", "mode", "based", "on", "a", "line", "of", "code", "for", "switch", "statements", "." ]
954f8dcc47e12e5c2878ba7473f9feb9c3aaa643
https://github.com/SetBased/php-helper-code-store-php/blob/954f8dcc47e12e5c2878ba7473f9feb9c3aaa643/src/PhpCodeStore.php#L130-L152
225,670
SetBased/php-abc-form
src/Control/SimpleControl.php
SimpleControl.setLabelAttribute
public function setLabelAttribute(string $name, ?string $value) { if ($value==='' || $value===null) { unset($this->labelAttributes[$name]); } else { if ($name=='class' && isset($this->labelAttributes[$name])) { $this->labelAttributes[$name] .= ' '; $this->labelAttributes[$name] .= $value; } else { $this->labelAttributes[$name] = $value; } } }
php
public function setLabelAttribute(string $name, ?string $value) { if ($value==='' || $value===null) { unset($this->labelAttributes[$name]); } else { if ($name=='class' && isset($this->labelAttributes[$name])) { $this->labelAttributes[$name] .= ' '; $this->labelAttributes[$name] .= $value; } else { $this->labelAttributes[$name] = $value; } } }
[ "public", "function", "setLabelAttribute", "(", "string", "$", "name", ",", "?", "string", "$", "value", ")", "{", "if", "(", "$", "value", "===", "''", "||", "$", "value", "===", "null", ")", "{", "unset", "(", "$", "this", "->", "labelAttributes", "[", "$", "name", "]", ")", ";", "}", "else", "{", "if", "(", "$", "name", "==", "'class'", "&&", "isset", "(", "$", "this", "->", "labelAttributes", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "labelAttributes", "[", "$", "name", "]", ".=", "' '", ";", "$", "this", "->", "labelAttributes", "[", "$", "name", "]", ".=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "labelAttributes", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "}" ]
Sets the value of an attribute the label for this form control. The attribute is unset when the value is one of: <ul> <li> null <li> false <li> ''. </ul> If attribute name is 'class' then the value is appended to the space separated list of classes. @param string $name The name of the attribute. @param string|null $value The value for the attribute. @since 1.0.0 @api
[ "Sets", "the", "value", "of", "an", "attribute", "the", "label", "for", "this", "form", "control", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/SimpleControl.php#L375-L393
225,671
SetBased/php-abc-form
src/Control/SimpleControl.php
SimpleControl.getHtmlPrefixLabel
protected function getHtmlPrefixLabel(): string { // If a label must be generated make sure the form control and the label have matching 'id' and 'for' attributes. if (isset($this->labelPosition)) { if (!isset($this->attributes['id'])) { $id = Html::getAutoId(); $this->attributes['id'] = $id; $this->labelAttributes['for'] = $id; } else { $this->labelAttributes['for'] = $this->attributes['id']; } } // Generate a prefix label, if required. if ($this->labelPosition=='pre') { $ret = $this->getHtmlLabel(); } else { $ret = ''; } return $ret; }
php
protected function getHtmlPrefixLabel(): string { // If a label must be generated make sure the form control and the label have matching 'id' and 'for' attributes. if (isset($this->labelPosition)) { if (!isset($this->attributes['id'])) { $id = Html::getAutoId(); $this->attributes['id'] = $id; $this->labelAttributes['for'] = $id; } else { $this->labelAttributes['for'] = $this->attributes['id']; } } // Generate a prefix label, if required. if ($this->labelPosition=='pre') { $ret = $this->getHtmlLabel(); } else { $ret = ''; } return $ret; }
[ "protected", "function", "getHtmlPrefixLabel", "(", ")", ":", "string", "{", "// If a label must be generated make sure the form control and the label have matching 'id' and 'for' attributes.", "if", "(", "isset", "(", "$", "this", "->", "labelPosition", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "attributes", "[", "'id'", "]", ")", ")", "{", "$", "id", "=", "Html", "::", "getAutoId", "(", ")", ";", "$", "this", "->", "attributes", "[", "'id'", "]", "=", "$", "id", ";", "$", "this", "->", "labelAttributes", "[", "'for'", "]", "=", "$", "id", ";", "}", "else", "{", "$", "this", "->", "labelAttributes", "[", "'for'", "]", "=", "$", "this", "->", "attributes", "[", "'id'", "]", ";", "}", "}", "// Generate a prefix label, if required.", "if", "(", "$", "this", "->", "labelPosition", "==", "'pre'", ")", "{", "$", "ret", "=", "$", "this", "->", "getHtmlLabel", "(", ")", ";", "}", "else", "{", "$", "ret", "=", "''", ";", "}", "return", "$", "ret", ";", "}" ]
Returns HTML code for a label for this form control te be inserted before the HTML code of this form control. @return string @since 1.0.0 @api
[ "Returns", "HTML", "code", "for", "a", "label", "for", "this", "form", "control", "te", "be", "inserted", "before", "the", "HTML", "code", "of", "this", "form", "control", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/SimpleControl.php#L513-L541
225,672
nails/module-currency
src/Service/Currency.php
Currency.getByIsoCode
public function getByIsoCode($sCode) { if (array_key_exists($sCode, $this->aSupportedCurrencies)) { return $this->aSupportedCurrencies[$sCode]; } else { throw new CurrencyException('"' . $sCode . '" is not a valid currency code.'); } }
php
public function getByIsoCode($sCode) { if (array_key_exists($sCode, $this->aSupportedCurrencies)) { return $this->aSupportedCurrencies[$sCode]; } else { throw new CurrencyException('"' . $sCode . '" is not a valid currency code.'); } }
[ "public", "function", "getByIsoCode", "(", "$", "sCode", ")", "{", "if", "(", "array_key_exists", "(", "$", "sCode", ",", "$", "this", "->", "aSupportedCurrencies", ")", ")", "{", "return", "$", "this", "->", "aSupportedCurrencies", "[", "$", "sCode", "]", ";", "}", "else", "{", "throw", "new", "CurrencyException", "(", "'\"'", ".", "$", "sCode", ".", "'\" is not a valid currency code.'", ")", ";", "}", "}" ]
Returns a currency by it's ISO 4217 code @param string $sCode The currency to get @return \stdClass @throws CurrencyException
[ "Returns", "a", "currency", "by", "it", "s", "ISO", "4217", "code" ]
c2dc3ade2e03bc3a6cee749eceea84ca7ee5f1c6
https://github.com/nails/module-currency/blob/c2dc3ade2e03bc3a6cee749eceea84ca7ee5f1c6/src/Service/Currency.php#L76-L83
225,673
nails/module-currency
src/Service/Currency.php
Currency.format
public function format($sCode, $nValue, $bIncludeSymbol = true) { try { $oCurrency = $this->getByIsoCode($sCode); $sOut = number_format( $nValue, $oCurrency->decimal_precision, $oCurrency->decimal_symbol, $oCurrency->thousands_separator ); if ($bIncludeSymbol) { if ($oCurrency->symbol_position == 'BEFORE') { $sOut = $oCurrency->symbol . $sOut; } else { $sOut = $sOut . $oCurrency->symbol; } } return $sOut; } catch (\Exception $e) { return '[CURRENCY FORMATTING FAILED: ' . $e->getMessage() . ']'; } }
php
public function format($sCode, $nValue, $bIncludeSymbol = true) { try { $oCurrency = $this->getByIsoCode($sCode); $sOut = number_format( $nValue, $oCurrency->decimal_precision, $oCurrency->decimal_symbol, $oCurrency->thousands_separator ); if ($bIncludeSymbol) { if ($oCurrency->symbol_position == 'BEFORE') { $sOut = $oCurrency->symbol . $sOut; } else { $sOut = $sOut . $oCurrency->symbol; } } return $sOut; } catch (\Exception $e) { return '[CURRENCY FORMATTING FAILED: ' . $e->getMessage() . ']'; } }
[ "public", "function", "format", "(", "$", "sCode", ",", "$", "nValue", ",", "$", "bIncludeSymbol", "=", "true", ")", "{", "try", "{", "$", "oCurrency", "=", "$", "this", "->", "getByIsoCode", "(", "$", "sCode", ")", ";", "$", "sOut", "=", "number_format", "(", "$", "nValue", ",", "$", "oCurrency", "->", "decimal_precision", ",", "$", "oCurrency", "->", "decimal_symbol", ",", "$", "oCurrency", "->", "thousands_separator", ")", ";", "if", "(", "$", "bIncludeSymbol", ")", "{", "if", "(", "$", "oCurrency", "->", "symbol_position", "==", "'BEFORE'", ")", "{", "$", "sOut", "=", "$", "oCurrency", "->", "symbol", ".", "$", "sOut", ";", "}", "else", "{", "$", "sOut", "=", "$", "sOut", ".", "$", "oCurrency", "->", "symbol", ";", "}", "}", "return", "$", "sOut", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "'[CURRENCY FORMATTING FAILED: '", ".", "$", "e", "->", "getMessage", "(", ")", ".", "']'", ";", "}", "}" ]
Formats a currency @param string $sCode The currency to get @param number $nValue The value @param boolean $bIncludeSymbol Include the currency symbol @return string
[ "Formats", "a", "currency" ]
c2dc3ade2e03bc3a6cee749eceea84ca7ee5f1c6
https://github.com/nails/module-currency/blob/c2dc3ade2e03bc3a6cee749eceea84ca7ee5f1c6/src/Service/Currency.php#L94-L119
225,674
bytic/Common
src/Controllers/Traits/HasView.php
HasView.initViewVars
protected function initViewVars($view) { $view->set('controller', $this->getName()); $view->set('action', $this->getAction()); if (method_exists($view, 'setRequest')) { $view->setRequest($this->getRequest()); } return $view; }
php
protected function initViewVars($view) { $view->set('controller', $this->getName()); $view->set('action', $this->getAction()); if (method_exists($view, 'setRequest')) { $view->setRequest($this->getRequest()); } return $view; }
[ "protected", "function", "initViewVars", "(", "$", "view", ")", "{", "$", "view", "->", "set", "(", "'controller'", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "$", "view", "->", "set", "(", "'action'", ",", "$", "this", "->", "getAction", "(", ")", ")", ";", "if", "(", "method_exists", "(", "$", "view", ",", "'setRequest'", ")", ")", "{", "$", "view", "->", "setRequest", "(", "$", "this", "->", "getRequest", "(", ")", ")", ";", "}", "return", "$", "view", ";", "}" ]
Init View variables @param View $view View Instance @return View
[ "Init", "View", "variables" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Controllers/Traits/HasView.php#L97-L107
225,675
bytic/Common
src/Controllers/Traits/HasView.php
HasView.initViewContentBlocks
protected function initViewContentBlocks($view) { $view->setBlock( 'content', $this->getRequest()->getControllerName() . '/' . $this->getRequest()->getActionName() ); return $view; }
php
protected function initViewContentBlocks($view) { $view->setBlock( 'content', $this->getRequest()->getControllerName() . '/' . $this->getRequest()->getActionName() ); return $view; }
[ "protected", "function", "initViewContentBlocks", "(", "$", "view", ")", "{", "$", "view", "->", "setBlock", "(", "'content'", ",", "$", "this", "->", "getRequest", "(", ")", "->", "getControllerName", "(", ")", ".", "'/'", ".", "$", "this", "->", "getRequest", "(", ")", "->", "getActionName", "(", ")", ")", ";", "return", "$", "view", ";", "}" ]
Init View Content block @param View $view View instance @return View
[ "Init", "View", "Content", "block" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Controllers/Traits/HasView.php#L123-L131
225,676
SetBased/php-abc-table-detail
src/TableRow/NumericTableRow.php
NumericTableRow.addRow
public static function addRow(DetailTable $table, $header, ?string $value, string $format): void { if ($value!==null && $value!=='') { $table->addRow($header, ['class' => 'number'], sprintf($format, $value)); } else { $table->addRow($header); } }
php
public static function addRow(DetailTable $table, $header, ?string $value, string $format): void { if ($value!==null && $value!=='') { $table->addRow($header, ['class' => 'number'], sprintf($format, $value)); } else { $table->addRow($header); } }
[ "public", "static", "function", "addRow", "(", "DetailTable", "$", "table", ",", "$", "header", ",", "?", "string", "$", "value", ",", "string", "$", "format", ")", ":", "void", "{", "if", "(", "$", "value", "!==", "null", "&&", "$", "value", "!==", "''", ")", "{", "$", "table", "->", "addRow", "(", "$", "header", ",", "[", "'class'", "=>", "'number'", "]", ",", "sprintf", "(", "$", "format", ",", "$", "value", ")", ")", ";", "}", "else", "{", "$", "table", "->", "addRow", "(", "$", "header", ")", ";", "}", "}" ]
Adds a row with a numeric value to a detail table. @param DetailTable $table The detail table. @param string|int|null $header The header text of this table row. @param string|null $value The value. @param string $format The formatting string (see sprintf).
[ "Adds", "a", "row", "with", "a", "numeric", "value", "to", "a", "detail", "table", "." ]
1f786174ccb10800f9c07bfd497b0ab35940a8ea
https://github.com/SetBased/php-abc-table-detail/blob/1f786174ccb10800f9c07bfd497b0ab35940a8ea/src/TableRow/NumericTableRow.php#L21-L31
225,677
czogori/Dami
src/Dami/Migration/MigrationNameParser.php
MigrationNameParser.setMigrationName
public function setMigrationName($migrationName) { $this->migrationName = $migrationName; $migrationNameAsUnderscoreSrtring = S::underscored($migrationName); $items = explode('_', $migrationNameAsUnderscoreSrtring); if (count($items) >= 3) { $this->action = in_array($items[0], $this->validActions) ? $items[0] : null; $this->actionObject = in_array($items[1], $this->validActionObjects) ? $items[1] : null; $this->model = str_replace($items[0] . '_' . $items[1] . '_', '', $migrationNameAsUnderscoreSrtring); } }
php
public function setMigrationName($migrationName) { $this->migrationName = $migrationName; $migrationNameAsUnderscoreSrtring = S::underscored($migrationName); $items = explode('_', $migrationNameAsUnderscoreSrtring); if (count($items) >= 3) { $this->action = in_array($items[0], $this->validActions) ? $items[0] : null; $this->actionObject = in_array($items[1], $this->validActionObjects) ? $items[1] : null; $this->model = str_replace($items[0] . '_' . $items[1] . '_', '', $migrationNameAsUnderscoreSrtring); } }
[ "public", "function", "setMigrationName", "(", "$", "migrationName", ")", "{", "$", "this", "->", "migrationName", "=", "$", "migrationName", ";", "$", "migrationNameAsUnderscoreSrtring", "=", "S", "::", "underscored", "(", "$", "migrationName", ")", ";", "$", "items", "=", "explode", "(", "'_'", ",", "$", "migrationNameAsUnderscoreSrtring", ")", ";", "if", "(", "count", "(", "$", "items", ")", ">=", "3", ")", "{", "$", "this", "->", "action", "=", "in_array", "(", "$", "items", "[", "0", "]", ",", "$", "this", "->", "validActions", ")", "?", "$", "items", "[", "0", "]", ":", "null", ";", "$", "this", "->", "actionObject", "=", "in_array", "(", "$", "items", "[", "1", "]", ",", "$", "this", "->", "validActionObjects", ")", "?", "$", "items", "[", "1", "]", ":", "null", ";", "$", "this", "->", "model", "=", "str_replace", "(", "$", "items", "[", "0", "]", ".", "'_'", ".", "$", "items", "[", "1", "]", ".", "'_'", ",", "''", ",", "$", "migrationNameAsUnderscoreSrtring", ")", ";", "}", "}" ]
Sets a migration name. @param string $migrationName A migration name. @return void
[ "Sets", "a", "migration", "name", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/MigrationNameParser.php#L23-L37
225,678
n2n/n2n-log4php
src/app/n2n/log4php/appender/AppenderSyslog.php
AppenderSyslog.append
public function append(\n2n\log4php\logging\LoggingEvent $event) { $priority = $this->getSyslogPriority($event->getLevel()); $message = $this->layout->format($event); openlog($this->ident, $this->intOption, $this->intFacility); syslog($priority, $message); closelog(); }
php
public function append(\n2n\log4php\logging\LoggingEvent $event) { $priority = $this->getSyslogPriority($event->getLevel()); $message = $this->layout->format($event); openlog($this->ident, $this->intOption, $this->intFacility); syslog($priority, $message); closelog(); }
[ "public", "function", "append", "(", "\\", "n2n", "\\", "log4php", "\\", "logging", "\\", "LoggingEvent", "$", "event", ")", "{", "$", "priority", "=", "$", "this", "->", "getSyslogPriority", "(", "$", "event", "->", "getLevel", "(", ")", ")", ";", "$", "message", "=", "$", "this", "->", "layout", "->", "format", "(", "$", "event", ")", ";", "openlog", "(", "$", "this", "->", "ident", ",", "$", "this", "->", "intOption", ",", "$", "this", "->", "intFacility", ")", ";", "syslog", "(", "$", "priority", ",", "$", "message", ")", ";", "closelog", "(", ")", ";", "}" ]
Appends the event to syslog. Log is opened and closed each time because if it is not closed, it can cause the Apache httpd server to log to whatever ident/facility was used in openlog(). @see http://www.php.net/manual/en/function.syslog.php#97843
[ "Appends", "the", "event", "to", "syslog", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderSyslog.php#L246-L253
225,679
n2n/n2n-log4php
src/app/n2n/log4php/appender/AppenderSyslog.php
AppenderSyslog.getSyslogPriority
private function getSyslogPriority(\n2n\log4php\LoggerLevel $level) { if($this->overridePriority) { return $this->intPriority; } return $level->getSyslogEquivalent(); }
php
private function getSyslogPriority(\n2n\log4php\LoggerLevel $level) { if($this->overridePriority) { return $this->intPriority; } return $level->getSyslogEquivalent(); }
[ "private", "function", "getSyslogPriority", "(", "\\", "n2n", "\\", "log4php", "\\", "LoggerLevel", "$", "level", ")", "{", "if", "(", "$", "this", "->", "overridePriority", ")", "{", "return", "$", "this", "->", "intPriority", ";", "}", "return", "$", "level", "->", "getSyslogEquivalent", "(", ")", ";", "}" ]
Determines which syslog priority to use based on the given level.
[ "Determines", "which", "syslog", "priority", "to", "use", "based", "on", "the", "given", "level", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderSyslog.php#L256-L261
225,680
n2n/n2n-log4php
src/app/n2n/log4php/appender/AppenderSyslog.php
AppenderSyslog.parseOption
private function parseOption() { $value = 0; $options = explode('|', $this->option); foreach($options as $option) { if (!empty($option)) { $constant = "LOG_" . trim($option); if (defined($constant)) { $value |= constant($constant); } else { throw new \n2n\log4php\LoggerException("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING); } } } return $value; }
php
private function parseOption() { $value = 0; $options = explode('|', $this->option); foreach($options as $option) { if (!empty($option)) { $constant = "LOG_" . trim($option); if (defined($constant)) { $value |= constant($constant); } else { throw new \n2n\log4php\LoggerException("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING); } } } return $value; }
[ "private", "function", "parseOption", "(", ")", "{", "$", "value", "=", "0", ";", "$", "options", "=", "explode", "(", "'|'", ",", "$", "this", "->", "option", ")", ";", "foreach", "(", "$", "options", "as", "$", "option", ")", "{", "if", "(", "!", "empty", "(", "$", "option", ")", ")", "{", "$", "constant", "=", "\"LOG_\"", ".", "trim", "(", "$", "option", ")", ";", "if", "(", "defined", "(", "$", "constant", ")", ")", "{", "$", "value", "|=", "constant", "(", "$", "constant", ")", ";", "}", "else", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.\"", ",", "E_USER_WARNING", ")", ";", "}", "}", "}", "return", "$", "value", ";", "}" ]
Parses a syslog option string and returns the correspodning int value.
[ "Parses", "a", "syslog", "option", "string", "and", "returns", "the", "correspodning", "int", "value", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderSyslog.php#L264-L279
225,681
n2n/n2n-log4php
src/app/n2n/log4php/appender/AppenderSyslog.php
AppenderSyslog.parseFacility
private function parseFacility() { if (!empty($this->facility)) { $constant = "LOG_" . trim($this->facility); if (defined($constant)) { return constant($constant); } else { throw new \n2n\log4php\LoggerException("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING); } } }
php
private function parseFacility() { if (!empty($this->facility)) { $constant = "LOG_" . trim($this->facility); if (defined($constant)) { return constant($constant); } else { throw new \n2n\log4php\LoggerException("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING); } } }
[ "private", "function", "parseFacility", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "facility", ")", ")", "{", "$", "constant", "=", "\"LOG_\"", ".", "trim", "(", "$", "this", "->", "facility", ")", ";", "if", "(", "defined", "(", "$", "constant", ")", ")", "{", "return", "constant", "(", "$", "constant", ")", ";", "}", "else", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Invalid syslog facility provided: {$this->facility}.\"", ",", "E_USER_WARNING", ")", ";", "}", "}", "}" ]
Parses the facility string and returns the corresponding int value.
[ "Parses", "the", "facility", "string", "and", "returns", "the", "corresponding", "int", "value", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderSyslog.php#L282-L291
225,682
n2n/n2n-log4php
src/app/n2n/log4php/appender/AppenderSyslog.php
AppenderSyslog.parsePriority
private function parsePriority() { if (!empty($this->priority)) { $constant = "LOG_" . trim($this->priority); if (defined($constant)) { return constant($constant); } else { throw new \n2n\log4php\LoggerException("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING); } } }
php
private function parsePriority() { if (!empty($this->priority)) { $constant = "LOG_" . trim($this->priority); if (defined($constant)) { return constant($constant); } else { throw new \n2n\log4php\LoggerException("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING); } } }
[ "private", "function", "parsePriority", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "priority", ")", ")", "{", "$", "constant", "=", "\"LOG_\"", ".", "trim", "(", "$", "this", "->", "priority", ")", ";", "if", "(", "defined", "(", "$", "constant", ")", ")", "{", "return", "constant", "(", "$", "constant", ")", ";", "}", "else", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Invalid syslog priority provided: {$this->priority}.\"", ",", "E_USER_WARNING", ")", ";", "}", "}", "}" ]
Parses the priority string and returns the corresponding int value.
[ "Parses", "the", "priority", "string", "and", "returns", "the", "corresponding", "int", "value", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderSyslog.php#L294-L303
225,683
fxpio/fxp-default-value
ObjectConfigBuilder.php
ObjectConfigBuilder.findProperties
protected function findProperties(\ReflectionClass $reflection): void { if (false !== $reflection->getParentClass()) { $this->findProperties($reflection->getParentClass()); } $this->properties = array_unique(array_merge($this->properties, array_keys($reflection->getDefaultProperties()))); }
php
protected function findProperties(\ReflectionClass $reflection): void { if (false !== $reflection->getParentClass()) { $this->findProperties($reflection->getParentClass()); } $this->properties = array_unique(array_merge($this->properties, array_keys($reflection->getDefaultProperties()))); }
[ "protected", "function", "findProperties", "(", "\\", "ReflectionClass", "$", "reflection", ")", ":", "void", "{", "if", "(", "false", "!==", "$", "reflection", "->", "getParentClass", "(", ")", ")", "{", "$", "this", "->", "findProperties", "(", "$", "reflection", "->", "getParentClass", "(", ")", ")", ";", "}", "$", "this", "->", "properties", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "properties", ",", "array_keys", "(", "$", "reflection", "->", "getDefaultProperties", "(", ")", ")", ")", ")", ";", "}" ]
Finds all properties in class. @param \ReflectionClass $reflection
[ "Finds", "all", "properties", "in", "class", "." ]
c045f5c7e3078377a092f197f8e5c633f5084091
https://github.com/fxpio/fxp-default-value/blob/c045f5c7e3078377a092f197f8e5c633f5084091/ObjectConfigBuilder.php#L261-L268
225,684
fxpio/fxp-default-value
ObjectConfigBuilder.php
ObjectConfigBuilder.findReflectionProperty
protected function findReflectionProperty($property, \ReflectionClass $reflection) { if ($reflection->hasProperty($property)) { $refProp = $reflection->getProperty($property); $refProp->setAccessible(true); return $refProp; } if (false !== $reflection->getParentClass()) { return $this->findReflectionProperty($property, $reflection->getParentClass()); } throw new InvalidArgumentException(sprintf('The "%s" property is not found in "%s" class.', $property, $this->getDataClass())); }
php
protected function findReflectionProperty($property, \ReflectionClass $reflection) { if ($reflection->hasProperty($property)) { $refProp = $reflection->getProperty($property); $refProp->setAccessible(true); return $refProp; } if (false !== $reflection->getParentClass()) { return $this->findReflectionProperty($property, $reflection->getParentClass()); } throw new InvalidArgumentException(sprintf('The "%s" property is not found in "%s" class.', $property, $this->getDataClass())); }
[ "protected", "function", "findReflectionProperty", "(", "$", "property", ",", "\\", "ReflectionClass", "$", "reflection", ")", "{", "if", "(", "$", "reflection", "->", "hasProperty", "(", "$", "property", ")", ")", "{", "$", "refProp", "=", "$", "reflection", "->", "getProperty", "(", "$", "property", ")", ";", "$", "refProp", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "refProp", ";", "}", "if", "(", "false", "!==", "$", "reflection", "->", "getParentClass", "(", ")", ")", "{", "return", "$", "this", "->", "findReflectionProperty", "(", "$", "property", ",", "$", "reflection", "->", "getParentClass", "(", ")", ")", ";", "}", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The \"%s\" property is not found in \"%s\" class.'", ",", "$", "property", ",", "$", "this", "->", "getDataClass", "(", ")", ")", ")", ";", "}" ]
Finds the reflection property. @param string $property @param \ReflectionClass $reflection @throws InvalidArgumentException When the property is not found @return \ReflectionProperty
[ "Finds", "the", "reflection", "property", "." ]
c045f5c7e3078377a092f197f8e5c633f5084091
https://github.com/fxpio/fxp-default-value/blob/c045f5c7e3078377a092f197f8e5c633f5084091/ObjectConfigBuilder.php#L280-L294
225,685
Eve-PHP/Framework
src/Action/Json.php
Json.fail
protected function fail($message = null, $validation = null) { $this->trigger('json-fail', $this, $message, $validation); $this->trigger('response-fail', $this, $message, $validation); $json = array('error' => true); if($message) { $json['message'] = $message; } if($validation) { $json['validation'] = $validation; } $body = json_encode($json, JSON_PRETTY_PRINT); $this->response ->set('headers', 'Content-Type', 'text/json') ->set('body', $body); return $body; }
php
protected function fail($message = null, $validation = null) { $this->trigger('json-fail', $this, $message, $validation); $this->trigger('response-fail', $this, $message, $validation); $json = array('error' => true); if($message) { $json['message'] = $message; } if($validation) { $json['validation'] = $validation; } $body = json_encode($json, JSON_PRETTY_PRINT); $this->response ->set('headers', 'Content-Type', 'text/json') ->set('body', $body); return $body; }
[ "protected", "function", "fail", "(", "$", "message", "=", "null", ",", "$", "validation", "=", "null", ")", "{", "$", "this", "->", "trigger", "(", "'json-fail'", ",", "$", "this", ",", "$", "message", ",", "$", "validation", ")", ";", "$", "this", "->", "trigger", "(", "'response-fail'", ",", "$", "this", ",", "$", "message", ",", "$", "validation", ")", ";", "$", "json", "=", "array", "(", "'error'", "=>", "true", ")", ";", "if", "(", "$", "message", ")", "{", "$", "json", "[", "'message'", "]", "=", "$", "message", ";", "}", "if", "(", "$", "validation", ")", "{", "$", "json", "[", "'validation'", "]", "=", "$", "validation", ";", "}", "$", "body", "=", "json_encode", "(", "$", "json", ",", "JSON_PRETTY_PRINT", ")", ";", "$", "this", "->", "response", "->", "set", "(", "'headers'", ",", "'Content-Type'", ",", "'text/json'", ")", "->", "set", "(", "'body'", ",", "$", "body", ")", ";", "return", "$", "body", ";", "}" ]
Sets a fail format @param string|null $message Any message to pass to the page @param mixed $validation Field specific errors @return string
[ "Sets", "a", "fail", "format" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Action/Json.php#L32-L54
225,686
Eve-PHP/Framework
src/Action/Json.php
Json.success
protected function success($results = null) { $this->trigger('json-success', $this, $results); $this->trigger('response-success', $this, $results); $json = array('error' => false); if($results) { $json['results'] = $results; } $body = json_encode($json, JSON_PRETTY_PRINT); $this->response ->set('headers', 'Content-Type', 'text/json') ->set('body', $body); return $body; }
php
protected function success($results = null) { $this->trigger('json-success', $this, $results); $this->trigger('response-success', $this, $results); $json = array('error' => false); if($results) { $json['results'] = $results; } $body = json_encode($json, JSON_PRETTY_PRINT); $this->response ->set('headers', 'Content-Type', 'text/json') ->set('body', $body); return $body; }
[ "protected", "function", "success", "(", "$", "results", "=", "null", ")", "{", "$", "this", "->", "trigger", "(", "'json-success'", ",", "$", "this", ",", "$", "results", ")", ";", "$", "this", "->", "trigger", "(", "'response-success'", ",", "$", "this", ",", "$", "results", ")", ";", "$", "json", "=", "array", "(", "'error'", "=>", "false", ")", ";", "if", "(", "$", "results", ")", "{", "$", "json", "[", "'results'", "]", "=", "$", "results", ";", "}", "$", "body", "=", "json_encode", "(", "$", "json", ",", "JSON_PRETTY_PRINT", ")", ";", "$", "this", "->", "response", "->", "set", "(", "'headers'", ",", "'Content-Type'", ",", "'text/json'", ")", "->", "set", "(", "'body'", ",", "$", "body", ")", ";", "return", "$", "body", ";", "}" ]
Sets a success format @param mixed $results Data to be included in the success packet @return string
[ "Sets", "a", "success", "format" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Action/Json.php#L63-L81
225,687
jeffreyguo/SS-Behat-quicksetup
src/SilverStripe/BehatExtension/Console/Processor/InitProcessor.php
InitProcessor.initBundleDirectoryStructure
protected function initBundleDirectoryStructure(InputInterface $input, OutputInterface $output) { // Bootstrap SS so we can use module listing $frameworkPath = $this->container->getParameter('behat.silverstripe_extension.framework_path'); $_GET['flush'] = 1; require_once $frameworkPath . '/core/Core.php'; unset($_GET['flush']); $featuresPath = $input->getArgument('features'); if(!$featuresPath) { throw new \InvalidArgumentException('Please specify a module name (e.g. "@mymodule")'); } // Can't use 'behat.paths.base' since that's locked at this point to base folder (not module) $pathSuffix = $this->container->getParameter('behat.silverstripe_extension.context.path_suffix'); $currentModuleName = null; $modules = \SS_ClassLoader::instance()->getManifest()->getModules(); $currentModuleName = $this->container->getParameter('behat.silverstripe_extension.module'); // get module from short notation if path starts from @ if (preg_match('/^\@([^\/\\\\]+)(.*)$/', $featuresPath, $matches)) { $currentModuleName = $matches[1]; // TODO Replace with proper module loader once AJShort's changes are merged into core if (!array_key_exists($currentModuleName, $modules)) { throw new \InvalidArgumentException(sprintf('Module "%s" not found', $currentModuleName)); } $currentModulePath = $modules[$currentModuleName]; } if (!$currentModuleName) { throw new \InvalidArgumentException('Can not find module to initialize suite.'); } // TODO Retrieve from module definition once that's implemented if($input->getOption('namespace')) { $namespace = $input->getOption('namespace'); } else { $namespace = ucfirst($currentModuleName); } $namespace .= '\\' . $this->container->getParameter('behat.silverstripe_extension.context.namespace_suffix'); $featuresPath = rtrim($currentModulePath.DIRECTORY_SEPARATOR.$pathSuffix,DIRECTORY_SEPARATOR); $basePath = $this->container->getParameter('behat.paths.base').DIRECTORY_SEPARATOR; $bootstrapPath = $featuresPath.DIRECTORY_SEPARATOR.'bootstrap'; $contextPath = $bootstrapPath.DIRECTORY_SEPARATOR.'Context'; if (!is_dir($featuresPath)) { mkdir($featuresPath, 0777, true); mkdir($bootstrapPath, 0777, true); // touch($bootstrapPath.DIRECTORY_SEPARATOR.'_manifest_exclude'); $output->writeln( '<info>+d</info> ' . str_replace($basePath, '', realpath($featuresPath)) . ' <comment>- place your *.feature files here</comment>' ); } if (!is_dir($contextPath)) { mkdir($contextPath, 0777, true); $className = $this->container->getParameter('behat.context.class'); file_put_contents( $contextPath . DIRECTORY_SEPARATOR . $className . '.php', strtr($this->getFeatureContextSkelet(), array( '%NAMESPACE%' => $namespace )) ); $output->writeln( '<info>+f</info> ' . str_replace($basePath, '', realpath($contextPath)) . DIRECTORY_SEPARATOR . 'FeatureContext.php <comment>- place your feature related code here</comment>' ); } }
php
protected function initBundleDirectoryStructure(InputInterface $input, OutputInterface $output) { // Bootstrap SS so we can use module listing $frameworkPath = $this->container->getParameter('behat.silverstripe_extension.framework_path'); $_GET['flush'] = 1; require_once $frameworkPath . '/core/Core.php'; unset($_GET['flush']); $featuresPath = $input->getArgument('features'); if(!$featuresPath) { throw new \InvalidArgumentException('Please specify a module name (e.g. "@mymodule")'); } // Can't use 'behat.paths.base' since that's locked at this point to base folder (not module) $pathSuffix = $this->container->getParameter('behat.silverstripe_extension.context.path_suffix'); $currentModuleName = null; $modules = \SS_ClassLoader::instance()->getManifest()->getModules(); $currentModuleName = $this->container->getParameter('behat.silverstripe_extension.module'); // get module from short notation if path starts from @ if (preg_match('/^\@([^\/\\\\]+)(.*)$/', $featuresPath, $matches)) { $currentModuleName = $matches[1]; // TODO Replace with proper module loader once AJShort's changes are merged into core if (!array_key_exists($currentModuleName, $modules)) { throw new \InvalidArgumentException(sprintf('Module "%s" not found', $currentModuleName)); } $currentModulePath = $modules[$currentModuleName]; } if (!$currentModuleName) { throw new \InvalidArgumentException('Can not find module to initialize suite.'); } // TODO Retrieve from module definition once that's implemented if($input->getOption('namespace')) { $namespace = $input->getOption('namespace'); } else { $namespace = ucfirst($currentModuleName); } $namespace .= '\\' . $this->container->getParameter('behat.silverstripe_extension.context.namespace_suffix'); $featuresPath = rtrim($currentModulePath.DIRECTORY_SEPARATOR.$pathSuffix,DIRECTORY_SEPARATOR); $basePath = $this->container->getParameter('behat.paths.base').DIRECTORY_SEPARATOR; $bootstrapPath = $featuresPath.DIRECTORY_SEPARATOR.'bootstrap'; $contextPath = $bootstrapPath.DIRECTORY_SEPARATOR.'Context'; if (!is_dir($featuresPath)) { mkdir($featuresPath, 0777, true); mkdir($bootstrapPath, 0777, true); // touch($bootstrapPath.DIRECTORY_SEPARATOR.'_manifest_exclude'); $output->writeln( '<info>+d</info> ' . str_replace($basePath, '', realpath($featuresPath)) . ' <comment>- place your *.feature files here</comment>' ); } if (!is_dir($contextPath)) { mkdir($contextPath, 0777, true); $className = $this->container->getParameter('behat.context.class'); file_put_contents( $contextPath . DIRECTORY_SEPARATOR . $className . '.php', strtr($this->getFeatureContextSkelet(), array( '%NAMESPACE%' => $namespace )) ); $output->writeln( '<info>+f</info> ' . str_replace($basePath, '', realpath($contextPath)) . DIRECTORY_SEPARATOR . 'FeatureContext.php <comment>- place your feature related code here</comment>' ); } }
[ "protected", "function", "initBundleDirectoryStructure", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// Bootstrap SS so we can use module listing", "$", "frameworkPath", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'behat.silverstripe_extension.framework_path'", ")", ";", "$", "_GET", "[", "'flush'", "]", "=", "1", ";", "require_once", "$", "frameworkPath", ".", "'/core/Core.php'", ";", "unset", "(", "$", "_GET", "[", "'flush'", "]", ")", ";", "$", "featuresPath", "=", "$", "input", "->", "getArgument", "(", "'features'", ")", ";", "if", "(", "!", "$", "featuresPath", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Please specify a module name (e.g. \"@mymodule\")'", ")", ";", "}", "// Can't use 'behat.paths.base' since that's locked at this point to base folder (not module)", "$", "pathSuffix", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'behat.silverstripe_extension.context.path_suffix'", ")", ";", "$", "currentModuleName", "=", "null", ";", "$", "modules", "=", "\\", "SS_ClassLoader", "::", "instance", "(", ")", "->", "getManifest", "(", ")", "->", "getModules", "(", ")", ";", "$", "currentModuleName", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'behat.silverstripe_extension.module'", ")", ";", "// get module from short notation if path starts from @", "if", "(", "preg_match", "(", "'/^\\@([^\\/\\\\\\\\]+)(.*)$/'", ",", "$", "featuresPath", ",", "$", "matches", ")", ")", "{", "$", "currentModuleName", "=", "$", "matches", "[", "1", "]", ";", "// TODO Replace with proper module loader once AJShort's changes are merged into core", "if", "(", "!", "array_key_exists", "(", "$", "currentModuleName", ",", "$", "modules", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Module \"%s\" not found'", ",", "$", "currentModuleName", ")", ")", ";", "}", "$", "currentModulePath", "=", "$", "modules", "[", "$", "currentModuleName", "]", ";", "}", "if", "(", "!", "$", "currentModuleName", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Can not find module to initialize suite.'", ")", ";", "}", "// TODO Retrieve from module definition once that's implemented", "if", "(", "$", "input", "->", "getOption", "(", "'namespace'", ")", ")", "{", "$", "namespace", "=", "$", "input", "->", "getOption", "(", "'namespace'", ")", ";", "}", "else", "{", "$", "namespace", "=", "ucfirst", "(", "$", "currentModuleName", ")", ";", "}", "$", "namespace", ".=", "'\\\\'", ".", "$", "this", "->", "container", "->", "getParameter", "(", "'behat.silverstripe_extension.context.namespace_suffix'", ")", ";", "$", "featuresPath", "=", "rtrim", "(", "$", "currentModulePath", ".", "DIRECTORY_SEPARATOR", ".", "$", "pathSuffix", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "basePath", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'behat.paths.base'", ")", ".", "DIRECTORY_SEPARATOR", ";", "$", "bootstrapPath", "=", "$", "featuresPath", ".", "DIRECTORY_SEPARATOR", ".", "'bootstrap'", ";", "$", "contextPath", "=", "$", "bootstrapPath", ".", "DIRECTORY_SEPARATOR", ".", "'Context'", ";", "if", "(", "!", "is_dir", "(", "$", "featuresPath", ")", ")", "{", "mkdir", "(", "$", "featuresPath", ",", "0777", ",", "true", ")", ";", "mkdir", "(", "$", "bootstrapPath", ",", "0777", ",", "true", ")", ";", "// touch($bootstrapPath.DIRECTORY_SEPARATOR.'_manifest_exclude');", "$", "output", "->", "writeln", "(", "'<info>+d</info> '", ".", "str_replace", "(", "$", "basePath", ",", "''", ",", "realpath", "(", "$", "featuresPath", ")", ")", ".", "' <comment>- place your *.feature files here</comment>'", ")", ";", "}", "if", "(", "!", "is_dir", "(", "$", "contextPath", ")", ")", "{", "mkdir", "(", "$", "contextPath", ",", "0777", ",", "true", ")", ";", "$", "className", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'behat.context.class'", ")", ";", "file_put_contents", "(", "$", "contextPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "className", ".", "'.php'", ",", "strtr", "(", "$", "this", "->", "getFeatureContextSkelet", "(", ")", ",", "array", "(", "'%NAMESPACE%'", "=>", "$", "namespace", ")", ")", ")", ";", "$", "output", "->", "writeln", "(", "'<info>+f</info> '", ".", "str_replace", "(", "$", "basePath", ",", "''", ",", "realpath", "(", "$", "contextPath", ")", ")", ".", "DIRECTORY_SEPARATOR", ".", "'FeatureContext.php <comment>- place your feature related code here</comment>'", ")", ";", "}", "}" ]
Inits bundle directory structure @param InputInterface $input @param OutputInterface $output
[ "Inits", "bundle", "directory", "structure" ]
a5172f3a94dc2b364df5c2758a8a1df4f026168e
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Console/Processor/InitProcessor.php#L62-L136
225,688
Finesse/MiniDB
src/Parts/InsertTrait.php
InsertTrait.insert
public function insert(array $rows): int { try { $query = (clone $this)->addInsert($rows)->apply($this->database->getTablePrefixer()); $statements = $this->database->getGrammar()->compileInsert($query); $count = 0; foreach ($statements as $statement) { $count += $this->database->insert($statement->getSQL(), $statement->getBindings()); } return $count; } catch (\Throwable $exception) { return $this->handleException($exception); } }
php
public function insert(array $rows): int { try { $query = (clone $this)->addInsert($rows)->apply($this->database->getTablePrefixer()); $statements = $this->database->getGrammar()->compileInsert($query); $count = 0; foreach ($statements as $statement) { $count += $this->database->insert($statement->getSQL(), $statement->getBindings()); } return $count; } catch (\Throwable $exception) { return $this->handleException($exception); } }
[ "public", "function", "insert", "(", "array", "$", "rows", ")", ":", "int", "{", "try", "{", "$", "query", "=", "(", "clone", "$", "this", ")", "->", "addInsert", "(", "$", "rows", ")", "->", "apply", "(", "$", "this", "->", "database", "->", "getTablePrefixer", "(", ")", ")", ";", "$", "statements", "=", "$", "this", "->", "database", "->", "getGrammar", "(", ")", "->", "compileInsert", "(", "$", "query", ")", ";", "$", "count", "=", "0", ";", "foreach", "(", "$", "statements", "as", "$", "statement", ")", "{", "$", "count", "+=", "$", "this", "->", "database", "->", "insert", "(", "$", "statement", "->", "getSQL", "(", ")", ",", "$", "statement", "->", "getBindings", "(", ")", ")", ";", "}", "return", "$", "count", ";", "}", "catch", "(", "\\", "Throwable", "$", "exception", ")", "{", "return", "$", "this", "->", "handleException", "(", "$", "exception", ")", ";", "}", "}" ]
Inserts rows to a table. Doesn't modify itself. @param mixed[][]|\Closure[][]|Query[][]|StatementInterface[][] $rows An array of rows. Each row is an associative array where indexes are column names and values are cell values. Rows indexes must be strings. @return int Number of inserted rows @throws DatabaseException @throws IncorrectQueryException @throws InvalidArgumentException
[ "Inserts", "rows", "to", "a", "table", ".", "Doesn", "t", "modify", "itself", "." ]
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/InsertTrait.php#L36-L51
225,689
Finesse/MiniDB
src/Parts/InsertTrait.php
InsertTrait.insertGetId
public function insertGetId(array $row, string $sequence = null) { try { $query = (clone $this)->addInsert([$row])->apply($this->database->getTablePrefixer()); $statements = $this->database->getGrammar()->compileInsert($query); $id = null; foreach ($statements as $statement) { $id = $this->database->insertGetId($statement->getSQL(), $statement->getBindings(), $sequence); } return $id; } catch (\Throwable $exception) { return $this->handleException($exception); } }
php
public function insertGetId(array $row, string $sequence = null) { try { $query = (clone $this)->addInsert([$row])->apply($this->database->getTablePrefixer()); $statements = $this->database->getGrammar()->compileInsert($query); $id = null; foreach ($statements as $statement) { $id = $this->database->insertGetId($statement->getSQL(), $statement->getBindings(), $sequence); } return $id; } catch (\Throwable $exception) { return $this->handleException($exception); } }
[ "public", "function", "insertGetId", "(", "array", "$", "row", ",", "string", "$", "sequence", "=", "null", ")", "{", "try", "{", "$", "query", "=", "(", "clone", "$", "this", ")", "->", "addInsert", "(", "[", "$", "row", "]", ")", "->", "apply", "(", "$", "this", "->", "database", "->", "getTablePrefixer", "(", ")", ")", ";", "$", "statements", "=", "$", "this", "->", "database", "->", "getGrammar", "(", ")", "->", "compileInsert", "(", "$", "query", ")", ";", "$", "id", "=", "null", ";", "foreach", "(", "$", "statements", "as", "$", "statement", ")", "{", "$", "id", "=", "$", "this", "->", "database", "->", "insertGetId", "(", "$", "statement", "->", "getSQL", "(", ")", ",", "$", "statement", "->", "getBindings", "(", ")", ",", "$", "sequence", ")", ";", "}", "return", "$", "id", ";", "}", "catch", "(", "\\", "Throwable", "$", "exception", ")", "{", "return", "$", "this", "->", "handleException", "(", "$", "exception", ")", ";", "}", "}" ]
Inserts a row to a table and returns the inserted row identifier. Doesn't modify itself. @param mixed[]|\Closure[]|Query[]|StatementInterface[] $rows Row. Associative array where indexes are column names and values are cell values. Rows indexes must be strings. @param string|null $sequence Name of the sequence object from which the ID should be returned @return int|string @throws DatabaseException @throws IncorrectQueryException @throws InvalidArgumentException
[ "Inserts", "a", "row", "to", "a", "table", "and", "returns", "the", "inserted", "row", "identifier", ".", "Doesn", "t", "modify", "itself", "." ]
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/InsertTrait.php#L64-L79
225,690
Finesse/MiniDB
src/Parts/InsertTrait.php
InsertTrait.insertFromSelect
public function insertFromSelect($columns, $selectQuery = null): int { return (clone $this)->addInsertFromSelect($columns, $selectQuery)->insert([]); }
php
public function insertFromSelect($columns, $selectQuery = null): int { return (clone $this)->addInsertFromSelect($columns, $selectQuery)->insert([]); }
[ "public", "function", "insertFromSelect", "(", "$", "columns", ",", "$", "selectQuery", "=", "null", ")", ":", "int", "{", "return", "(", "clone", "$", "this", ")", "->", "addInsertFromSelect", "(", "$", "columns", ",", "$", "selectQuery", ")", "->", "insert", "(", "[", "]", ")", ";", "}" ]
Inserts rows to a table from a select query. Doesn't modify itself. @param string[]|\Closure|Query|StatementInterface $columns The list of the columns to which the selected values should be inserted. You may omit this argument and pass the $selectQuery argument instead. @param \Closure|self|StatementInterface|null $selectQuery @return int Number of inserted rows @throws DatabaseException @throws IncorrectQueryException @throws InvalidArgumentException
[ "Inserts", "rows", "to", "a", "table", "from", "a", "select", "query", ".", "Doesn", "t", "modify", "itself", "." ]
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/InsertTrait.php#L92-L95
225,691
chEbba/LogStock
src/Che/LogStock/Loader/HierarchicalNameLoader.php
HierarchicalNameLoader.getParentName
protected function getParentName($name) { return (string) substr($name, 0, (int) strrpos($name, $this->separator)); }
php
protected function getParentName($name) { return (string) substr($name, 0, (int) strrpos($name, $this->separator)); }
[ "protected", "function", "getParentName", "(", "$", "name", ")", "{", "return", "(", "string", ")", "substr", "(", "$", "name", ",", "0", ",", "(", "int", ")", "strrpos", "(", "$", "name", ",", "$", "this", "->", "separator", ")", ")", ";", "}" ]
Get name for parent loader @param string $name Child logger name @return string Parent name, an empty string is the top level parent
[ "Get", "name", "for", "parent", "loader" ]
206ee26ed937b0f8857b63a527dd1a6020f52168
https://github.com/chEbba/LogStock/blob/206ee26ed937b0f8857b63a527dd1a6020f52168/src/Che/LogStock/Loader/HierarchicalNameLoader.php#L90-L93
225,692
stubbles/stubbles-input
src/main/php/broker/TargetMethod.php
TargetMethod.invoke
public function invoke($object, $value) { if (null !== $value) { $this->method->invoke($object, $value); } }
php
public function invoke($object, $value) { if (null !== $value) { $this->method->invoke($object, $value); } }
[ "public", "function", "invoke", "(", "$", "object", ",", "$", "value", ")", "{", "if", "(", "null", "!==", "$", "value", ")", "{", "$", "this", "->", "method", "->", "invoke", "(", "$", "object", ",", "$", "value", ")", ";", "}", "}" ]
passes procured value to the instance @api @param object $object instance to invoke the method on @param mixed $value value to pass to the method
[ "passes", "procured", "value", "to", "the", "instance" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/TargetMethod.php#L140-L145
225,693
railken/amethyst-user
src/Repositories/UserRepository.php
UserRepository.findAllToRefreshToken
public function findAllToRefreshToken(bool $force = false) { $query = $this->newQuery(); return $force ? $query->get() : $query->whereNull('token')->get(); }
php
public function findAllToRefreshToken(bool $force = false) { $query = $this->newQuery(); return $force ? $query->get() : $query->whereNull('token')->get(); }
[ "public", "function", "findAllToRefreshToken", "(", "bool", "$", "force", "=", "false", ")", "{", "$", "query", "=", "$", "this", "->", "newQuery", "(", ")", ";", "return", "$", "force", "?", "$", "query", "->", "get", "(", ")", ":", "$", "query", "->", "whereNull", "(", "'token'", ")", "->", "get", "(", ")", ";", "}" ]
Find all user that have a null token. @param bool $force @return \Illuminate\Support\Collection
[ "Find", "all", "user", "that", "have", "a", "null", "token", "." ]
ab95c6298219fe17bc69c719adf0eeb6c304e401
https://github.com/railken/amethyst-user/blob/ab95c6298219fe17bc69c719adf0eeb6c304e401/src/Repositories/UserRepository.php#L42-L47
225,694
kaystrobach/FLOW.Custom
Classes/ViewHelpers/SurfReleaseViewHelper.php
SurfReleaseViewHelper.render
public function render($format = 'd.m.Y H:i:s') { $output = $this->getContext() . ': '; $date = $this->extractDateFromRevisionFile(); if ($date === null) { $date = $this->extractDateFromSurfPath(); } if ($date === null) { $date = new \DateTime('now'); } $output.= $date->format($format); $output.= $this->extractRevisionFileContent(); return $output; }
php
public function render($format = 'd.m.Y H:i:s') { $output = $this->getContext() . ': '; $date = $this->extractDateFromRevisionFile(); if ($date === null) { $date = $this->extractDateFromSurfPath(); } if ($date === null) { $date = new \DateTime('now'); } $output.= $date->format($format); $output.= $this->extractRevisionFileContent(); return $output; }
[ "public", "function", "render", "(", "$", "format", "=", "'d.m.Y H:i:s'", ")", "{", "$", "output", "=", "$", "this", "->", "getContext", "(", ")", ".", "': '", ";", "$", "date", "=", "$", "this", "->", "extractDateFromRevisionFile", "(", ")", ";", "if", "(", "$", "date", "===", "null", ")", "{", "$", "date", "=", "$", "this", "->", "extractDateFromSurfPath", "(", ")", ";", "}", "if", "(", "$", "date", "===", "null", ")", "{", "$", "date", "=", "new", "\\", "DateTime", "(", "'now'", ")", ";", "}", "$", "output", ".=", "$", "date", "->", "format", "(", "$", "format", ")", ";", "$", "output", ".=", "$", "this", "->", "extractRevisionFileContent", "(", ")", ";", "return", "$", "output", ";", "}" ]
Show release string based on symlink @param string $format @return string @throws \Exception
[ "Show", "release", "string", "based", "on", "symlink" ]
873001a46fa0dfbc426edd74af1841cfa7bcf1b9
https://github.com/kaystrobach/FLOW.Custom/blob/873001a46fa0dfbc426edd74af1841cfa7bcf1b9/Classes/ViewHelpers/SurfReleaseViewHelper.php#L17-L31
225,695
cmsgears/module-cms
common/models/traits/resources/PageContentTrait.php
PageContentTrait.isPublished
public function isPublished() { $user = Yii::$app->core->getUser(); if( isset( $user ) ) { // Always published for owner if( $this->createdBy == $user->id ) { return true; } // TODO: Add code for secured visibility with password match // Visible to logged in users in strictly protected mode if( $this->isPublic() && $this->isVisibilityProtected() ) { return true; } } // Status(Active or Frozen) with public visibility return $this->isPublic() && $this->isVisibilityPublic( false ); }
php
public function isPublished() { $user = Yii::$app->core->getUser(); if( isset( $user ) ) { // Always published for owner if( $this->createdBy == $user->id ) { return true; } // TODO: Add code for secured visibility with password match // Visible to logged in users in strictly protected mode if( $this->isPublic() && $this->isVisibilityProtected() ) { return true; } } // Status(Active or Frozen) with public visibility return $this->isPublic() && $this->isVisibilityPublic( false ); }
[ "public", "function", "isPublished", "(", ")", "{", "$", "user", "=", "Yii", "::", "$", "app", "->", "core", "->", "getUser", "(", ")", ";", "if", "(", "isset", "(", "$", "user", ")", ")", "{", "// Always published for owner", "if", "(", "$", "this", "->", "createdBy", "==", "$", "user", "->", "id", ")", "{", "return", "true", ";", "}", "// TODO: Add code for secured visibility with password match", "// Visible to logged in users in strictly protected mode", "if", "(", "$", "this", "->", "isPublic", "(", ")", "&&", "$", "this", "->", "isVisibilityProtected", "(", ")", ")", "{", "return", "true", ";", "}", "}", "// Status(Active or Frozen) with public visibility", "return", "$", "this", "->", "isPublic", "(", ")", "&&", "$", "this", "->", "isVisibilityPublic", "(", "false", ")", ";", "}" ]
Check whether content is published. To consider a model as published, it must be publicly visible in either active or frozen status. @return boolean
[ "Check", "whether", "content", "is", "published", ".", "To", "consider", "a", "model", "as", "published", "it", "must", "be", "publicly", "visible", "in", "either", "active", "or", "frozen", "status", "." ]
ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8
https://github.com/cmsgears/module-cms/blob/ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8/common/models/traits/resources/PageContentTrait.php#L68-L91
225,696
SetBased/php-abc-form
src/Cleaner/AmbiguityCleaner.php
AmbiguityCleaner.clean
public function clean($value) { // Return null for empty strings. if ($value==='' || $value===null || $value===false) { return null; } // Replace all ambiguous characters. $tmp = $value; foreach ($this->ambiguities as $unambiguity => $ambiguities) { foreach ($ambiguities as $ambiguity) { // Note: str_replace works fine with multi byte characters like UTF-8. $tmp = str_replace($ambiguity, $unambiguity, $tmp); } } // Restore EOL for DOS users. if (PHP_EOL!="\n") $tmp = str_replace("\n", PHP_EOL, $tmp); // Return null for empty strings. if ($tmp==='') $tmp = null; return $tmp; }
php
public function clean($value) { // Return null for empty strings. if ($value==='' || $value===null || $value===false) { return null; } // Replace all ambiguous characters. $tmp = $value; foreach ($this->ambiguities as $unambiguity => $ambiguities) { foreach ($ambiguities as $ambiguity) { // Note: str_replace works fine with multi byte characters like UTF-8. $tmp = str_replace($ambiguity, $unambiguity, $tmp); } } // Restore EOL for DOS users. if (PHP_EOL!="\n") $tmp = str_replace("\n", PHP_EOL, $tmp); // Return null for empty strings. if ($tmp==='') $tmp = null; return $tmp; }
[ "public", "function", "clean", "(", "$", "value", ")", "{", "// Return null for empty strings.", "if", "(", "$", "value", "===", "''", "||", "$", "value", "===", "null", "||", "$", "value", "===", "false", ")", "{", "return", "null", ";", "}", "// Replace all ambiguous characters.", "$", "tmp", "=", "$", "value", ";", "foreach", "(", "$", "this", "->", "ambiguities", "as", "$", "unambiguity", "=>", "$", "ambiguities", ")", "{", "foreach", "(", "$", "ambiguities", "as", "$", "ambiguity", ")", "{", "// Note: str_replace works fine with multi byte characters like UTF-8.", "$", "tmp", "=", "str_replace", "(", "$", "ambiguity", ",", "$", "unambiguity", ",", "$", "tmp", ")", ";", "}", "}", "// Restore EOL for DOS users.", "if", "(", "PHP_EOL", "!=", "\"\\n\"", ")", "$", "tmp", "=", "str_replace", "(", "\"\\n\"", ",", "PHP_EOL", ",", "$", "tmp", ")", ";", "// Return null for empty strings.", "if", "(", "$", "tmp", "===", "''", ")", "$", "tmp", "=", "null", ";", "return", "$", "tmp", ";", "}" ]
Replaces all ambiguous characters in a submitted values with the intended characters. @param string|null $value The submitted value. @return string|null @since 1.0.0 @api
[ "Replaces", "all", "ambiguous", "characters", "in", "a", "submitted", "values", "with", "the", "intended", "characters", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Cleaner/AmbiguityCleaner.php#L158-L184
225,697
fxpio/fxp-default-value
ResolvedObjectType.php
ResolvedObjectType.doActionObject
protected function doActionObject($method, ObjectBuilderInterface $builder, array $options): void { if (null !== $this->parent) { $this->parent->{$method}($builder, $options); } $this->innerType->{$method}($builder, $options); foreach ($this->typeExtensions as $extension) { /* @var ObjectTypeExtensionInterface $extension */ $extension->{$method}($builder, $options); } }
php
protected function doActionObject($method, ObjectBuilderInterface $builder, array $options): void { if (null !== $this->parent) { $this->parent->{$method}($builder, $options); } $this->innerType->{$method}($builder, $options); foreach ($this->typeExtensions as $extension) { /* @var ObjectTypeExtensionInterface $extension */ $extension->{$method}($builder, $options); } }
[ "protected", "function", "doActionObject", "(", "$", "method", ",", "ObjectBuilderInterface", "$", "builder", ",", "array", "$", "options", ")", ":", "void", "{", "if", "(", "null", "!==", "$", "this", "->", "parent", ")", "{", "$", "this", "->", "parent", "->", "{", "$", "method", "}", "(", "$", "builder", ",", "$", "options", ")", ";", "}", "$", "this", "->", "innerType", "->", "{", "$", "method", "}", "(", "$", "builder", ",", "$", "options", ")", ";", "foreach", "(", "$", "this", "->", "typeExtensions", "as", "$", "extension", ")", "{", "/* @var ObjectTypeExtensionInterface $extension */", "$", "extension", "->", "{", "$", "method", "}", "(", "$", "builder", ",", "$", "options", ")", ";", "}", "}" ]
Build or finish the object. @param string $method The buildObject or finishObject method name @param ObjectBuilderInterface $builder @param array $options
[ "Build", "or", "finish", "the", "object", "." ]
c045f5c7e3078377a092f197f8e5c633f5084091
https://github.com/fxpio/fxp-default-value/blob/c045f5c7e3078377a092f197f8e5c633f5084091/ResolvedObjectType.php#L180-L192
225,698
peterkahl/Chinese-Master
src/ChineseMaster.php
ChineseMaster.isTraditional
public static function isTraditional($str) { if (empty($str)) { throw new Exception('Argument str cannot be empty'); } $ords = self::utf8ToUnicode($str); foreach ($ords as $val) { if (!empty($val) && array_key_exists($val, self::$trad2simple)) { return true; } } return false; }
php
public static function isTraditional($str) { if (empty($str)) { throw new Exception('Argument str cannot be empty'); } $ords = self::utf8ToUnicode($str); foreach ($ords as $val) { if (!empty($val) && array_key_exists($val, self::$trad2simple)) { return true; } } return false; }
[ "public", "static", "function", "isTraditional", "(", "$", "str", ")", "{", "if", "(", "empty", "(", "$", "str", ")", ")", "{", "throw", "new", "Exception", "(", "'Argument str cannot be empty'", ")", ";", "}", "$", "ords", "=", "self", "::", "utf8ToUnicode", "(", "$", "str", ")", ";", "foreach", "(", "$", "ords", "as", "$", "val", ")", "{", "if", "(", "!", "empty", "(", "$", "val", ")", "&&", "array_key_exists", "(", "$", "val", ",", "self", "::", "$", "trad2simple", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Is string made up of traditional Chinese characters? At least one character. @param string
[ "Is", "string", "made", "up", "of", "traditional", "Chinese", "characters?", "At", "least", "one", "character", "." ]
31e82bbcddcd9e2e5fa12db8d2e1026a1a0dbe9c
https://github.com/peterkahl/Chinese-Master/blob/31e82bbcddcd9e2e5fa12db8d2e1026a1a0dbe9c/src/ChineseMaster.php#L37-L48
225,699
peterkahl/Chinese-Master
src/ChineseMaster.php
ChineseMaster.trad2simp
public static function trad2simp($str) { if (empty($str)) { throw new Exception('Argument str cannot be empty'); } $ords = self::utf8ToUnicode($str); foreach ($ords as $k => $val) { if ($val !== false && array_key_exists($val, self::$trad2simple)) { $ords[$k] = self::$trad2simple[$val]; } else { $ords[$k] = $val; } } return self::unicodeToUtf8($ords); }
php
public static function trad2simp($str) { if (empty($str)) { throw new Exception('Argument str cannot be empty'); } $ords = self::utf8ToUnicode($str); foreach ($ords as $k => $val) { if ($val !== false && array_key_exists($val, self::$trad2simple)) { $ords[$k] = self::$trad2simple[$val]; } else { $ords[$k] = $val; } } return self::unicodeToUtf8($ords); }
[ "public", "static", "function", "trad2simp", "(", "$", "str", ")", "{", "if", "(", "empty", "(", "$", "str", ")", ")", "{", "throw", "new", "Exception", "(", "'Argument str cannot be empty'", ")", ";", "}", "$", "ords", "=", "self", "::", "utf8ToUnicode", "(", "$", "str", ")", ";", "foreach", "(", "$", "ords", "as", "$", "k", "=>", "$", "val", ")", "{", "if", "(", "$", "val", "!==", "false", "&&", "array_key_exists", "(", "$", "val", ",", "self", "::", "$", "trad2simple", ")", ")", "{", "$", "ords", "[", "$", "k", "]", "=", "self", "::", "$", "trad2simple", "[", "$", "val", "]", ";", "}", "else", "{", "$", "ords", "[", "$", "k", "]", "=", "$", "val", ";", "}", "}", "return", "self", "::", "unicodeToUtf8", "(", "$", "ords", ")", ";", "}" ]
Converts traditional to simplified. @param string
[ "Converts", "traditional", "to", "simplified", "." ]
31e82bbcddcd9e2e5fa12db8d2e1026a1a0dbe9c
https://github.com/peterkahl/Chinese-Master/blob/31e82bbcddcd9e2e5fa12db8d2e1026a1a0dbe9c/src/ChineseMaster.php#L56-L70