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
partition
stringclasses
1 value
JBZoo/JBDump
class.jbdump.php
JBDump._errorHandler
function _errorHandler($errNo, $errMsg, $errFile, $errLine, $errCont) { $errType = $this->_getErrorTypes(); $errorMessage = $errType[$errNo] . "\t\"" . trim($errMsg) . "\"\t" . $errFile . ' ' . 'Line:' . $errLine; if (self::$_config['errors']['logAll']) { error_log('JBDump:' . $errorMessage); } if (!(error_reporting() & $errNo) || error_reporting() == 0 || (int)ini_get('display_errors') == 0) { if (self::$_config['errors']['logHidden']) { $errorMessage = date(self::DATE_FORMAT, time()) . ' ' . $errorMessage . PHP_EOL; $logPath = self::$_config['log']['path'] . '/' . self::$_config['log']['file'] . '_error_' . date('Y.m.d') . '.log'; error_log($errorMessage, 3, $logPath); } return false; } $errFile = $this->_getRalativePath($errFile); $result = array( 'file' => $errFile . ' : ' . $errLine, 'type' => $errType[$errNo] . ' (' . $errNo . ')', 'message' => $errMsg, ); if (self::$_config['errors']['context']) { $result['context'] = $errCont; } if (self::$_config['errors']['errorBacktrace']) { $trace = debug_backtrace(); unset($trace[0]); $result['backtrace'] = $this->convertTrace($trace); } if ($this->_isLiteMode()) { $errorInfo = array( 'message' => $result['type'] . ' / ' . $result['message'], 'file' => $result['file'] ); $this->_dumpRenderLite($errorInfo, '* ' . $errType[$errNo]); } else { $desc = '<b style="color:red;">*</b> ' . $errType[$errNo] . ' / ' . $this->_htmlChars($result['message']); $this->dump($result, $desc); } return true; }
php
function _errorHandler($errNo, $errMsg, $errFile, $errLine, $errCont) { $errType = $this->_getErrorTypes(); $errorMessage = $errType[$errNo] . "\t\"" . trim($errMsg) . "\"\t" . $errFile . ' ' . 'Line:' . $errLine; if (self::$_config['errors']['logAll']) { error_log('JBDump:' . $errorMessage); } if (!(error_reporting() & $errNo) || error_reporting() == 0 || (int)ini_get('display_errors') == 0) { if (self::$_config['errors']['logHidden']) { $errorMessage = date(self::DATE_FORMAT, time()) . ' ' . $errorMessage . PHP_EOL; $logPath = self::$_config['log']['path'] . '/' . self::$_config['log']['file'] . '_error_' . date('Y.m.d') . '.log'; error_log($errorMessage, 3, $logPath); } return false; } $errFile = $this->_getRalativePath($errFile); $result = array( 'file' => $errFile . ' : ' . $errLine, 'type' => $errType[$errNo] . ' (' . $errNo . ')', 'message' => $errMsg, ); if (self::$_config['errors']['context']) { $result['context'] = $errCont; } if (self::$_config['errors']['errorBacktrace']) { $trace = debug_backtrace(); unset($trace[0]); $result['backtrace'] = $this->convertTrace($trace); } if ($this->_isLiteMode()) { $errorInfo = array( 'message' => $result['type'] . ' / ' . $result['message'], 'file' => $result['file'] ); $this->_dumpRenderLite($errorInfo, '* ' . $errType[$errNo]); } else { $desc = '<b style="color:red;">*</b> ' . $errType[$errNo] . ' / ' . $this->_htmlChars($result['message']); $this->dump($result, $desc); } return true; }
[ "function", "_errorHandler", "(", "$", "errNo", ",", "$", "errMsg", ",", "$", "errFile", ",", "$", "errLine", ",", "$", "errCont", ")", "{", "$", "errType", "=", "$", "this", "->", "_getErrorTypes", "(", ")", ";", "$", "errorMessage", "=", "$", "errT...
Error handler for PHP errors @param integer $errNo @param string $errMsg @param string $errFile @param integer $errLine @param array $errCont @return bool
[ "Error", "handler", "for", "PHP", "errors" ]
2129dd19755c031361d4ec7699521c5df9d5e433
https://github.com/JBZoo/JBDump/blob/2129dd19755c031361d4ec7699521c5df9d5e433/class.jbdump.php#L3306-L3361
train
JBZoo/JBDump
class.jbdump.php
JBDump.errors
public static function errors() { $result = array(); $result['error_reporting'] = error_reporting(); $errTypes = self::_getErrorTypes(); foreach ($errTypes as $errTypeKey => $errTypeName) { if ($result['error_reporting'] & $errTypeKey) { $result['show_types'][] = $errTypeName . ' (' . $errTypeKey . ')'; } } return self::i()->dump($result, '! errors info !'); }
php
public static function errors() { $result = array(); $result['error_reporting'] = error_reporting(); $errTypes = self::_getErrorTypes(); foreach ($errTypes as $errTypeKey => $errTypeName) { if ($result['error_reporting'] & $errTypeKey) { $result['show_types'][] = $errTypeName . ' (' . $errTypeKey . ')'; } } return self::i()->dump($result, '! errors info !'); }
[ "public", "static", "function", "errors", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'error_reporting'", "]", "=", "error_reporting", "(", ")", ";", "$", "errTypes", "=", "self", "::", "_getErrorTypes", "(", ")", ";...
Information about current PHP reporting @return JBDump
[ "Information", "about", "current", "PHP", "reporting" ]
2129dd19755c031361d4ec7699521c5df9d5e433
https://github.com/JBZoo/JBDump/blob/2129dd19755c031361d4ec7699521c5df9d5e433/class.jbdump.php#L3394-L3407
train
JBZoo/JBDump
class.jbdump.php
JBDump.isAjax
public static function isAjax() { if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) { return true; } elseif (self::isCli()) { return true; } elseif (function_exists('apache_request_headers')) { $headers = apache_request_headers(); foreach ($headers as $key => $value) { if (strtolower($key) == 'x-requested-with' && strtolower($value) == 'xmlhttprequest') { return true; } } } elseif (isset($_REQUEST['ajax']) && $_REQUEST['ajax']) { return true; } elseif (isset($_REQUEST['AJAX']) && $_REQUEST['AJAX']) { return true; } return false; }
php
public static function isAjax() { if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) { return true; } elseif (self::isCli()) { return true; } elseif (function_exists('apache_request_headers')) { $headers = apache_request_headers(); foreach ($headers as $key => $value) { if (strtolower($key) == 'x-requested-with' && strtolower($value) == 'xmlhttprequest') { return true; } } } elseif (isset($_REQUEST['ajax']) && $_REQUEST['ajax']) { return true; } elseif (isset($_REQUEST['AJAX']) && $_REQUEST['AJAX']) { return true; } return false; }
[ "public", "static", "function", "isAjax", "(", ")", "{", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_X_REQUESTED_WITH'", "]", ")", "&&", "strtolower", "(", "$", "_SERVER", "[", "'HTTP_X_REQUESTED_WITH'", "]", ")", "==", "'xmlhttprequest'", ")", "{",...
Check is current HTTP request is ajax @return bool
[ "Check", "is", "current", "HTTP", "request", "is", "ajax" ]
2129dd19755c031361d4ec7699521c5df9d5e433
https://github.com/JBZoo/JBDump/blob/2129dd19755c031361d4ec7699521c5df9d5e433/class.jbdump.php#L3426-L3453
train
JBZoo/JBDump
class.jbdump.php
JBDump.mail
public static function mail($text, $subject = null, $to = null) { if (!self::isDebug()) { return false; } $_this = self::i(); if (empty($subject)) { $subject = self::$_config['mail']['subject']; } if (empty($to)) { $to = isset(self::$_config['mail']['to']) ? self::$_config['mail']['to'] : 'jbdump@' . $_SERVER['HTTP_HOST']; } if (is_array($to)) { $to = implode(', ', $to); } // message $message = array(); $message[] = '<html><body>'; $message[] = '<p><b>JBDump mail from ' . '<a href="http://' . $_SERVER['HTTP_HOST'] . '">' . $_SERVER['HTTP_HOST'] . '</a>' . '</b></p>'; $message[] = '<p><b>Date</b>: ' . date(DATE_RFC822, time()) . '</p>'; $message[] = '<p><b>IP</b>: ' . self::getClientIP() . '</p>'; $message[] = '<b>Debug message</b>: <pre>' . print_r($text, true) . '</pre>'; $message[] = '</body></html>'; $message = wordwrap(implode(PHP_EOL, $message), 70); // To send HTML mail, the Content-type header must be set $headers = array(); $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=utf-8'; $headers[] = 'To: ' . $to; $headers[] = 'From: JBDump debug <jbdump@' . $_SERVER['HTTP_HOST'] . '>'; $headers[] = 'X-Mailer: JBDump v' . self::VERSION; $headers = implode("\r\n", $headers); $result = mail($to, $subject, $message, $headers); if (self::$_config['mail']['log']) { $_this->log( array( 'email' => $to, 'subject' => $subject, 'message' => $message, 'headers' => $headers, 'result' => $result ), 'JBDump::mail' ); } return $result; }
php
public static function mail($text, $subject = null, $to = null) { if (!self::isDebug()) { return false; } $_this = self::i(); if (empty($subject)) { $subject = self::$_config['mail']['subject']; } if (empty($to)) { $to = isset(self::$_config['mail']['to']) ? self::$_config['mail']['to'] : 'jbdump@' . $_SERVER['HTTP_HOST']; } if (is_array($to)) { $to = implode(', ', $to); } // message $message = array(); $message[] = '<html><body>'; $message[] = '<p><b>JBDump mail from ' . '<a href="http://' . $_SERVER['HTTP_HOST'] . '">' . $_SERVER['HTTP_HOST'] . '</a>' . '</b></p>'; $message[] = '<p><b>Date</b>: ' . date(DATE_RFC822, time()) . '</p>'; $message[] = '<p><b>IP</b>: ' . self::getClientIP() . '</p>'; $message[] = '<b>Debug message</b>: <pre>' . print_r($text, true) . '</pre>'; $message[] = '</body></html>'; $message = wordwrap(implode(PHP_EOL, $message), 70); // To send HTML mail, the Content-type header must be set $headers = array(); $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=utf-8'; $headers[] = 'To: ' . $to; $headers[] = 'From: JBDump debug <jbdump@' . $_SERVER['HTTP_HOST'] . '>'; $headers[] = 'X-Mailer: JBDump v' . self::VERSION; $headers = implode("\r\n", $headers); $result = mail($to, $subject, $message, $headers); if (self::$_config['mail']['log']) { $_this->log( array( 'email' => $to, 'subject' => $subject, 'message' => $message, 'headers' => $headers, 'result' => $result ), 'JBDump::mail' ); } return $result; }
[ "public", "static", "function", "mail", "(", "$", "text", ",", "$", "subject", "=", "null", ",", "$", "to", "=", "null", ")", "{", "if", "(", "!", "self", "::", "isDebug", "(", ")", ")", "{", "return", "false", ";", "}", "$", "_this", "=", "sel...
Send message mail @param mixed $text @param string $subject @param string $to @return bool
[ "Send", "message", "mail" ]
2129dd19755c031361d4ec7699521c5df9d5e433
https://github.com/JBZoo/JBDump/blob/2129dd19755c031361d4ec7699521c5df9d5e433/class.jbdump.php#L3471-L3530
train
JBZoo/JBDump
class.jbdump.php
JBDump.sql
public static function sql($query, $sqlName = 'SQL Query', $nl2br = false) { // Joomla hack if (defined('_JEXEC')) { $config = new JConfig(); $prefix = $config->dbprefix; $query = str_replace('#__', $prefix, $query); } if (class_exists('JBDump_SqlFormatter')) { $sqlHtml = JBDump_SqlFormatter::format($query); return self::i()->dump($sqlHtml, $sqlName . '::html'); } return self::i()->dump($query, $sqlName . '::html'); }
php
public static function sql($query, $sqlName = 'SQL Query', $nl2br = false) { // Joomla hack if (defined('_JEXEC')) { $config = new JConfig(); $prefix = $config->dbprefix; $query = str_replace('#__', $prefix, $query); } if (class_exists('JBDump_SqlFormatter')) { $sqlHtml = JBDump_SqlFormatter::format($query); return self::i()->dump($sqlHtml, $sqlName . '::html'); } return self::i()->dump($query, $sqlName . '::html'); }
[ "public", "static", "function", "sql", "(", "$", "query", ",", "$", "sqlName", "=", "'SQL Query'", ",", "$", "nl2br", "=", "false", ")", "{", "// Joomla hack\r", "if", "(", "defined", "(", "'_JEXEC'", ")", ")", "{", "$", "config", "=", "new", "JConfig"...
Highlight SQL query @param $query @param string $sqlName @param bool $nl2br @return JBDump
[ "Highlight", "SQL", "query" ]
2129dd19755c031361d4ec7699521c5df9d5e433
https://github.com/JBZoo/JBDump/blob/2129dd19755c031361d4ec7699521c5df9d5e433/class.jbdump.php#L3602-L3617
train
JBZoo/JBDump
class.jbdump.php
JBDump._jsonEncode
protected function _jsonEncode($in, $indent = 0) { $out = ''; foreach ($in as $key => $value) { $out .= str_repeat(" ", $indent + 1); $out .= json_encode((string)$key) . ': '; if (is_object($value) || is_array($value)) { $out .= $this->_jsonEncode($value, $indent + 1); } else { $out .= json_encode($value); } $out .= "," . PHP_EOL; } if (!empty($out)) { $out = substr($out, 0, -2); } $out = "{" . PHP_EOL . $out . PHP_EOL . str_repeat(" ", $indent) . "}"; return $out; }
php
protected function _jsonEncode($in, $indent = 0) { $out = ''; foreach ($in as $key => $value) { $out .= str_repeat(" ", $indent + 1); $out .= json_encode((string)$key) . ': '; if (is_object($value) || is_array($value)) { $out .= $this->_jsonEncode($value, $indent + 1); } else { $out .= json_encode($value); } $out .= "," . PHP_EOL; } if (!empty($out)) { $out = substr($out, 0, -2); } $out = "{" . PHP_EOL . $out . PHP_EOL . str_repeat(" ", $indent) . "}"; return $out; }
[ "protected", "function", "_jsonEncode", "(", "$", "in", ",", "$", "indent", "=", "0", ")", "{", "$", "out", "=", "''", ";", "foreach", "(", "$", "in", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "out", ".=", "str_repeat", "(", "\" \""...
Do the real json encoding adding human readability. Supports automatic indenting with tabs @param array|object $in The array or object to encode in json @param int $indent The indentation level. Adds $indent tabs to the string @return string
[ "Do", "the", "real", "json", "encoding", "adding", "human", "readability", ".", "Supports", "automatic", "indenting", "with", "tabs" ]
2129dd19755c031361d4ec7699521c5df9d5e433
https://github.com/JBZoo/JBDump/blob/2129dd19755c031361d4ec7699521c5df9d5e433/class.jbdump.php#L3625-L3650
train
aimeos/ai-typo3
lib/custom/setup/CustomerAddVatidTypo3.php
CustomerAddVatidTypo3.process
protected function process( array $stmts ) { $this->msg( 'Adding "vatid" column to fe_users tables', 0 ); $this->status( '' ); foreach( $stmts as $table => $stmt ) { $this->msg( sprintf( 'Checking "%1$s" table', $table ), 1 ); if( $this->schema->tableExists( $table ) === true && $this->schema->columnExists( $table, 'vatid' ) === false ) { $this->execute( $stmt ); $this->status( 'added' ); } else { $this->status( 'OK' ); } } }
php
protected function process( array $stmts ) { $this->msg( 'Adding "vatid" column to fe_users tables', 0 ); $this->status( '' ); foreach( $stmts as $table => $stmt ) { $this->msg( sprintf( 'Checking "%1$s" table', $table ), 1 ); if( $this->schema->tableExists( $table ) === true && $this->schema->columnExists( $table, 'vatid' ) === false ) { $this->execute( $stmt ); $this->status( 'added' ); } else { $this->status( 'OK' ); } } }
[ "protected", "function", "process", "(", "array", "$", "stmts", ")", "{", "$", "this", "->", "msg", "(", "'Adding \"vatid\" column to fe_users tables'", ",", "0", ")", ";", "$", "this", "->", "status", "(", "''", ")", ";", "foreach", "(", "$", "stmts", "...
Add column vatid to fe_users tables. @param array $stmts Associative array of tables names and lists of SQL statements to execute.
[ "Add", "column", "vatid", "to", "fe_users", "tables", "." ]
74902c312900c8c5659acd4e85fea61ed1cd7c9a
https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/setup/CustomerAddVatidTypo3.php#L48-L65
train
soosyze/framework
src/Components/Util/Util.php
Util.getJson
public static function getJson($file, $assoc = true) { // @codeCoverageIgnoreStart if (!extension_loaded('json')) { throw new \Exception('The JSON extension is not loaded.'); } // @codeCoverageIgnoreEnd if (!file_exists($file)) { throw new \InvalidArgumentException(htmlspecialchars("The $file file is missing.")); } if (strrchr($file, '.') != '.json') { throw new \InvalidArgumentException(htmlspecialchars("The $file is not in JSON format.")); } if (($json = file_get_contents($file)) === null) { throw new \Exception(htmlspecialchars("The $file file is not readable.")); } if (($return = json_decode($json, $assoc)) === null) { throw new \Exception(htmlspecialchars("The JSON $file file is invalid.")); } return $return; }
php
public static function getJson($file, $assoc = true) { // @codeCoverageIgnoreStart if (!extension_loaded('json')) { throw new \Exception('The JSON extension is not loaded.'); } // @codeCoverageIgnoreEnd if (!file_exists($file)) { throw new \InvalidArgumentException(htmlspecialchars("The $file file is missing.")); } if (strrchr($file, '.') != '.json') { throw new \InvalidArgumentException(htmlspecialchars("The $file is not in JSON format.")); } if (($json = file_get_contents($file)) === null) { throw new \Exception(htmlspecialchars("The $file file is not readable.")); } if (($return = json_decode($json, $assoc)) === null) { throw new \Exception(htmlspecialchars("The JSON $file file is invalid.")); } return $return; }
[ "public", "static", "function", "getJson", "(", "$", "file", ",", "$", "assoc", "=", "true", ")", "{", "// @codeCoverageIgnoreStart", "if", "(", "!", "extension_loaded", "(", "'json'", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'The JSON extensi...
Lit un fichier de type JSON et retourne un tableau associatif. @param string $file Chemin + nom du fichier + extension. @param bool $assoc Si true l'objet retourné sera converti en un tableau associatif. @throws \Exception L'extension JSON n'est pas chargé. @throws \InvalidArgumentException Le fichier est manquant. @throws \InvalidArgumentException L'extension du fichier n'est pas au format JSON. @throws \Exception Le fichier JSON n'est pas accessible en lecture. @throws \Exception Le fichier JSON est invalide. @return array|object
[ "Lit", "un", "fichier", "de", "type", "JSON", "et", "retourne", "un", "tableau", "associatif", "." ]
d8dec2155bf9bc1d8ded176b4b65c183e2082049
https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Util/Util.php#L35-L56
train
nextras/link-factory
src/LinkFactory.php
LinkFactory.link
public function link($destination, array $params = array()) { if (($pos = strrpos($destination, '#')) !== FALSE) { $fragment = substr($destination, $pos); $destination = substr($destination, 0, $pos); } else { $fragment = ''; } if (strncmp($destination, '//', 2) === 0) { $absoluteUrl = TRUE; $destination = substr($destination, 2); } else { $absoluteUrl = FALSE; } $pos = strrpos($destination, ':'); $presenter = substr($destination, 0, $pos); if ($pos + 1 < strlen($destination)) { $params['action'] = substr($destination, $pos + 1); } $request = new Nette\Application\Request($presenter, 'GET', $params); $url = $this->router->constructUrl($request, $this->refUrl); if ($url === NULL) { throw new InvalidLinkException("Router failed to create link to '$destination'."); } if (!$absoluteUrl && strncmp($url, $this->refUrlHost, strlen($this->refUrlHost)) === 0) { $url = substr($url, strlen($this->refUrlHost)); } if ($fragment) { $url .= $fragment; } return $url; }
php
public function link($destination, array $params = array()) { if (($pos = strrpos($destination, '#')) !== FALSE) { $fragment = substr($destination, $pos); $destination = substr($destination, 0, $pos); } else { $fragment = ''; } if (strncmp($destination, '//', 2) === 0) { $absoluteUrl = TRUE; $destination = substr($destination, 2); } else { $absoluteUrl = FALSE; } $pos = strrpos($destination, ':'); $presenter = substr($destination, 0, $pos); if ($pos + 1 < strlen($destination)) { $params['action'] = substr($destination, $pos + 1); } $request = new Nette\Application\Request($presenter, 'GET', $params); $url = $this->router->constructUrl($request, $this->refUrl); if ($url === NULL) { throw new InvalidLinkException("Router failed to create link to '$destination'."); } if (!$absoluteUrl && strncmp($url, $this->refUrlHost, strlen($this->refUrlHost)) === 0) { $url = substr($url, strlen($this->refUrlHost)); } if ($fragment) { $url .= $fragment; } return $url; }
[ "public", "function", "link", "(", "$", "destination", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "(", "$", "pos", "=", "strrpos", "(", "$", "destination", ",", "'#'", ")", ")", "!==", "FALSE", ")", "{", "$", "fragm...
Creates link. Destination syntax: - 'Presenter:action' - creates relative link - '//Presenter:action' - creates absolute link - 'Presenter:action#fragment' - may contain optional fragment @param string 'Presenter:action' (creates relative link) or '//Presenter:action' (creates absolute link) @param array @return string @throws InvalidLinkException if router returns NULL
[ "Creates", "link", "." ]
9ed0e9df82951096114a40d1e4a35b0b645614a4
https://github.com/nextras/link-factory/blob/9ed0e9df82951096114a40d1e4a35b0b645614a4/src/LinkFactory.php#L45-L82
train
dreamfactorysoftware/azure-documentdb-php-sdk
src/Client.php
Client.generateRequestHeaders
protected function generateRequestHeaders( $verb, $resourceType, $resourceId, $isQuery = false, $contentLength = 0, array $extraHeaders = [] ){ $xMsDate = gmdate('D, d M Y H:i:s T'); $headers = [ 'Accept: application/json', 'User-Agent: ' . static::USER_AGENT, 'Cache-Control: no-cache', 'x-ms-date: ' . $xMsDate, 'x-ms-version: ' . $this->apiVersion, 'Authorization: ' . $this->generateAuthHeader($verb, $xMsDate, $resourceType, $resourceId) ]; if (in_array($verb, [Verbs::POST, Verbs::PUT])) { $headers[] = 'Content-Length: ' . $contentLength; if ($isQuery === true) { $headers[] = 'Content-Type: application/query+json'; $headers[] = 'x-ms-documentdb-isquery: True'; } else { $headers[] = 'Content-Type: application/json'; } } return array_merge($headers, $extraHeaders); }
php
protected function generateRequestHeaders( $verb, $resourceType, $resourceId, $isQuery = false, $contentLength = 0, array $extraHeaders = [] ){ $xMsDate = gmdate('D, d M Y H:i:s T'); $headers = [ 'Accept: application/json', 'User-Agent: ' . static::USER_AGENT, 'Cache-Control: no-cache', 'x-ms-date: ' . $xMsDate, 'x-ms-version: ' . $this->apiVersion, 'Authorization: ' . $this->generateAuthHeader($verb, $xMsDate, $resourceType, $resourceId) ]; if (in_array($verb, [Verbs::POST, Verbs::PUT])) { $headers[] = 'Content-Length: ' . $contentLength; if ($isQuery === true) { $headers[] = 'Content-Type: application/query+json'; $headers[] = 'x-ms-documentdb-isquery: True'; } else { $headers[] = 'Content-Type: application/json'; } } return array_merge($headers, $extraHeaders); }
[ "protected", "function", "generateRequestHeaders", "(", "$", "verb", ",", "$", "resourceType", ",", "$", "resourceId", ",", "$", "isQuery", "=", "false", ",", "$", "contentLength", "=", "0", ",", "array", "$", "extraHeaders", "=", "[", "]", ")", "{", "$"...
Generates request headers based on request options. @param string $verb Request Method (HEAD, GET, POST, PUT, DELETE) @param string $resourceType Requested resource type @param string $resourceId Requested resource id @param bool $isQuery Indicates if the request is query or not @param int $contentLength Content length of posted data @param array $extraHeaders Additional request headers @return array Array of request headers
[ "Generates", "request", "headers", "based", "on", "request", "options", "." ]
73152d23284e9501332a307cfc3411cb3de57245
https://github.com/dreamfactorysoftware/azure-documentdb-php-sdk/blob/73152d23284e9501332a307cfc3411cb3de57245/src/Client.php#L157-L187
train
dreamfactorysoftware/azure-documentdb-php-sdk
src/Client.php
Client.generateAuthHeader
private function generateAuthHeader($verb, $xMsDate, $resourceType, $resourceId) { $master = 'master'; $token = '1.0'; $key = base64_decode($this->key); $stringToSign = strtolower($verb) . "\n" . strtolower($resourceType) . "\n" . $resourceId . "\n" . strtolower($xMsDate) . "\n" . "\n"; $sig = base64_encode(hash_hmac('sha256', $stringToSign, $key, true)); return urlencode("type=$master&ver=$token&sig=$sig"); }
php
private function generateAuthHeader($verb, $xMsDate, $resourceType, $resourceId) { $master = 'master'; $token = '1.0'; $key = base64_decode($this->key); $stringToSign = strtolower($verb) . "\n" . strtolower($resourceType) . "\n" . $resourceId . "\n" . strtolower($xMsDate) . "\n" . "\n"; $sig = base64_encode(hash_hmac('sha256', $stringToSign, $key, true)); return urlencode("type=$master&ver=$token&sig=$sig"); }
[ "private", "function", "generateAuthHeader", "(", "$", "verb", ",", "$", "xMsDate", ",", "$", "resourceType", ",", "$", "resourceId", ")", "{", "$", "master", "=", "'master'", ";", "$", "token", "=", "'1.0'", ";", "$", "key", "=", "base64_decode", "(", ...
Generates the request Authorization header. @link http://msdn.microsoft.com/en-us/library/azure/dn783368.aspx @param string $verb Request Method (HEAD, GET, POST, PUT, DELETE) @param string $xMsDate Request date/time string @param string $resourceType Requested resource Type @param string $resourceId Requested resource ID @return string Authorization string
[ "Generates", "the", "request", "Authorization", "header", "." ]
73152d23284e9501332a307cfc3411cb3de57245
https://github.com/dreamfactorysoftware/azure-documentdb-php-sdk/blob/73152d23284e9501332a307cfc3411cb3de57245/src/Client.php#L201-L215
train
mapbender/data-source
Component/DataStore.php
DataStore.getParent
public function getParent($id) { /** @var Statement $statement */ $dataItem = $this->get($id); $queryBuilder = $this->driver->getSelectQueryBuilder(); $queryBuilder->andWhere($this->driver->getUniqueId() . " = " . $dataItem->getAttribute($this->getParentField())); $statement = $queryBuilder->execute(); $rows = array($statement->fetch()); $hasResults = count($rows) > 0; $parent = null; if ($hasResults) { $this->driver->prepareResults($rows); $parent = $rows[0]; } return $parent; }
php
public function getParent($id) { /** @var Statement $statement */ $dataItem = $this->get($id); $queryBuilder = $this->driver->getSelectQueryBuilder(); $queryBuilder->andWhere($this->driver->getUniqueId() . " = " . $dataItem->getAttribute($this->getParentField())); $statement = $queryBuilder->execute(); $rows = array($statement->fetch()); $hasResults = count($rows) > 0; $parent = null; if ($hasResults) { $this->driver->prepareResults($rows); $parent = $rows[0]; } return $parent; }
[ "public", "function", "getParent", "(", "$", "id", ")", "{", "/** @var Statement $statement */", "$", "dataItem", "=", "$", "this", "->", "get", "(", "$", "id", ")", ";", "$", "queryBuilder", "=", "$", "this", "->", "driver", "->", "getSelectQueryBuilder", ...
Get parent by child ID @param $id @return DataItem|null
[ "Get", "parent", "by", "child", "ID" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/DataStore.php#L143-L160
train
mapbender/data-source
Component/DataStore.php
DataStore.save
public function save($item, $autoUpdate = true) { $result = null; $this->allowSave = true; if (isset($this->events[ self::EVENT_ON_BEFORE_SAVE ])) { $this->secureEval($this->events[ self::EVENT_ON_BEFORE_SAVE ], array( 'item' => &$item )); } if ($this->allowSave) { $result = $this->getDriver()->save($item, $autoUpdate); } if (isset($this->events[ self::EVENT_ON_AFTER_SAVE ])) { $this->secureEval($this->events[ self::EVENT_ON_AFTER_SAVE ], array( 'item' => &$item )); } return $result; }
php
public function save($item, $autoUpdate = true) { $result = null; $this->allowSave = true; if (isset($this->events[ self::EVENT_ON_BEFORE_SAVE ])) { $this->secureEval($this->events[ self::EVENT_ON_BEFORE_SAVE ], array( 'item' => &$item )); } if ($this->allowSave) { $result = $this->getDriver()->save($item, $autoUpdate); } if (isset($this->events[ self::EVENT_ON_AFTER_SAVE ])) { $this->secureEval($this->events[ self::EVENT_ON_AFTER_SAVE ], array( 'item' => &$item )); } return $result; }
[ "public", "function", "save", "(", "$", "item", ",", "$", "autoUpdate", "=", "true", ")", "{", "$", "result", "=", "null", ";", "$", "this", "->", "allowSave", "=", "true", ";", "if", "(", "isset", "(", "$", "this", "->", "events", "[", "self", "...
Save data item @param DataItem|array $item Data item @param bool $autoUpdate Create item if doesn't exists @return DataItem @throws \Exception
[ "Save", "data", "item" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/DataStore.php#L215-L234
train
mapbender/data-source
Component/DataStore.php
DataStore.isOracle
public function isOracle() { static $r; if (is_null($r)) { $r = $this->driver->getPlatformName() == self::ORACLE_PLATFORM; } return $r; }
php
public function isOracle() { static $r; if (is_null($r)) { $r = $this->driver->getPlatformName() == self::ORACLE_PLATFORM; } return $r; }
[ "public", "function", "isOracle", "(", ")", "{", "static", "$", "r", ";", "if", "(", "is_null", "(", "$", "r", ")", ")", "{", "$", "r", "=", "$", "this", "->", "driver", "->", "getPlatformName", "(", ")", "==", "self", "::", "ORACLE_PLATFORM", ";",...
Is oralce platform @return bool
[ "Is", "oralce", "platform" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/DataStore.php#L297-L304
train
mapbender/data-source
Component/DataStore.php
DataStore.isSqlite
public function isSqlite() { static $r; if (is_null($r)) { $r = $this->driver->getPlatformName() == self::SQLITE_PLATFORM; } return $r; }
php
public function isSqlite() { static $r; if (is_null($r)) { $r = $this->driver->getPlatformName() == self::SQLITE_PLATFORM; } return $r; }
[ "public", "function", "isSqlite", "(", ")", "{", "static", "$", "r", ";", "if", "(", "is_null", "(", "$", "r", ")", ")", "{", "$", "r", "=", "$", "this", "->", "driver", "->", "getPlatformName", "(", ")", "==", "self", "::", "SQLITE_PLATFORM", ";",...
Is SQLite platform @return bool
[ "Is", "SQLite", "platform" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/DataStore.php#L322-L329
train
mapbender/data-source
Component/DataStore.php
DataStore.isPostgres
public function isPostgres() { static $r; if (is_null($r)) { $r = $this->driver->getPlatformName() == self::POSTGRESQL_PLATFORM; } return $r; }
php
public function isPostgres() { static $r; if (is_null($r)) { $r = $this->driver->getPlatformName() == self::POSTGRESQL_PLATFORM; } return $r; }
[ "public", "function", "isPostgres", "(", ")", "{", "static", "$", "r", ";", "if", "(", "is_null", "(", "$", "r", ")", ")", "{", "$", "r", "=", "$", "this", "->", "driver", "->", "getPlatformName", "(", ")", "==", "self", "::", "POSTGRESQL_PLATFORM", ...
Is postgres platform @return bool
[ "Is", "postgres", "platform" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/DataStore.php#L336-L343
train
mapbender/data-source
Component/DataStore.php
DataStore.getTypes
public function getTypes() { $list = array(); $reflectionClass = new \ReflectionClass(__CLASS__); foreach ($reflectionClass->getConstants() as $k => $v) { if (strrpos($k, "_PLATFORM") > 0) { $list[] = $v; } } return $list; }
php
public function getTypes() { $list = array(); $reflectionClass = new \ReflectionClass(__CLASS__); foreach ($reflectionClass->getConstants() as $k => $v) { if (strrpos($k, "_PLATFORM") > 0) { $list[] = $v; } } return $list; }
[ "public", "function", "getTypes", "(", ")", "{", "$", "list", "=", "array", "(", ")", ";", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "__CLASS__", ")", ";", "foreach", "(", "$", "reflectionClass", "->", "getConstants", "(", ")", "a...
Get driver types @return array
[ "Get", "driver", "types" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/DataStore.php#L350-L360
train
mapbender/data-source
Component/DataStore.php
DataStore.getTroughMapping
public function getTroughMapping($mappingId, $id) { $config = $this->mapping[ $mappingId ]; $dataStoreService = $this->container->get("data.source"); $externalDataStore = $dataStoreService->get($config["externalDataStore"]); $externalDriver = $externalDataStore->getDriver(); $internalFieldName = null; $externalFieldName = null; if (isset($config['internalId'])) { $internalFieldName = $config['internalId']; } if (isset($config['externalId'])) { $externalFieldName = $config['externalId']; } if (isset($config['internalFieldName'])) { $internalFieldName = $config['internalFieldName']; } if (isset($config['relatedFieldName'])) { $externalFieldName = $config['relatedFieldName']; } if (!$externalDriver instanceof DoctrineBaseDriver) { throw new Exception('This kind of externalDriver can\'t get relations'); } $criteria = $this->get($id)->getAttribute($internalFieldName); return $externalDriver->getByCriteria($criteria, $externalFieldName); }
php
public function getTroughMapping($mappingId, $id) { $config = $this->mapping[ $mappingId ]; $dataStoreService = $this->container->get("data.source"); $externalDataStore = $dataStoreService->get($config["externalDataStore"]); $externalDriver = $externalDataStore->getDriver(); $internalFieldName = null; $externalFieldName = null; if (isset($config['internalId'])) { $internalFieldName = $config['internalId']; } if (isset($config['externalId'])) { $externalFieldName = $config['externalId']; } if (isset($config['internalFieldName'])) { $internalFieldName = $config['internalFieldName']; } if (isset($config['relatedFieldName'])) { $externalFieldName = $config['relatedFieldName']; } if (!$externalDriver instanceof DoctrineBaseDriver) { throw new Exception('This kind of externalDriver can\'t get relations'); } $criteria = $this->get($id)->getAttribute($internalFieldName); return $externalDriver->getByCriteria($criteria, $externalFieldName); }
[ "public", "function", "getTroughMapping", "(", "$", "mappingId", ",", "$", "id", ")", "{", "$", "config", "=", "$", "this", "->", "mapping", "[", "$", "mappingId", "]", ";", "$", "dataStoreService", "=", "$", "this", "->", "container", "->", "get", "("...
Get related objects through mapping @param $mappingId @param $id @return DataItem[]
[ "Get", "related", "objects", "through", "mapping" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/DataStore.php#L481-L513
train
aimeos/ai-typo3
lib/custom/src/MW/Cache/Typo3.php
Typo3.deleteMultiple
public function deleteMultiple( $keys ) { foreach( $keys as $key ) { $this->object->remove( $this->prefix . $key ); } }
php
public function deleteMultiple( $keys ) { foreach( $keys as $key ) { $this->object->remove( $this->prefix . $key ); } }
[ "public", "function", "deleteMultiple", "(", "$", "keys", ")", "{", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "this", "->", "object", "->", "remove", "(", "$", "this", "->", "prefix", ".", "$", "key", ")", ";", "}", "}" ]
Removes the cache entries identified by the given keys. @inheritDoc @param \Traversable|array $keys List of key strings that identify the cache entries that should be removed
[ "Removes", "the", "cache", "entries", "identified", "by", "the", "given", "keys", "." ]
74902c312900c8c5659acd4e85fea61ed1cd7c9a
https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/src/MW/Cache/Typo3.php#L63-L68
train
aimeos/ai-typo3
lib/custom/src/MW/Cache/Typo3.php
Typo3.deleteByTags
public function deleteByTags( array $tags ) { foreach( $tags as $tag ) { $this->object->flushByTag( $this->prefix . $tag ); } }
php
public function deleteByTags( array $tags ) { foreach( $tags as $tag ) { $this->object->flushByTag( $this->prefix . $tag ); } }
[ "public", "function", "deleteByTags", "(", "array", "$", "tags", ")", "{", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "this", "->", "object", "->", "flushByTag", "(", "$", "this", "->", "prefix", ".", "$", "tag", ")", ";", "}", ...
Removes the cache entries identified by the given tags. @inheritDoc @param string[] $tags List of tag strings that are associated to one or more cache entries that should be removed
[ "Removes", "the", "cache", "entries", "identified", "by", "the", "given", "tags", "." ]
74902c312900c8c5659acd4e85fea61ed1cd7c9a
https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/src/MW/Cache/Typo3.php#L79-L84
train
aimeos/ai-typo3
lib/custom/src/MW/Cache/Typo3.php
Typo3.clear
public function clear() { if( $this->prefix ) { $this->object->flushByTag( $this->prefix . 'siteid' ); } else { $this->object->flush(); } }
php
public function clear() { if( $this->prefix ) { $this->object->flushByTag( $this->prefix . 'siteid' ); } else { $this->object->flush(); } }
[ "public", "function", "clear", "(", ")", "{", "if", "(", "$", "this", "->", "prefix", ")", "{", "$", "this", "->", "object", "->", "flushByTag", "(", "$", "this", "->", "prefix", ".", "'siteid'", ")", ";", "}", "else", "{", "$", "this", "->", "ob...
Removes all entries for the current site from the cache. @inheritDoc
[ "Removes", "all", "entries", "for", "the", "current", "site", "from", "the", "cache", "." ]
74902c312900c8c5659acd4e85fea61ed1cd7c9a
https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/src/MW/Cache/Typo3.php#L92-L99
train
SplashSync/Php-Core
Components/FileManager.php
FileManager.getFile
public function getFile($file = null, $md5 = null) { //====================================================================// // Stack Trace Splash::log()->trace(); //====================================================================// // PHPUNIT Exception => Look First in Local FileSystem //====================================================================// if (defined('SPLASH_DEBUG') && !empty(SPLASH_DEBUG)) { $filePath = dirname(__DIR__)."/Resources/files/".$file; if (is_file($filePath)) { $file = $this->readFile($filePath, $md5); return is_array($file) ? $file : false; } $imgPath = dirname(__DIR__)."/Resources/img/".$file; if (is_file($imgPath)) { $file = $this->readFile($imgPath, $md5); return is_array($file) ? $file : false; } } //====================================================================// // Initiate Tasks parameters array $params = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $params->file = $file; $params->md5 = $md5; //====================================================================// // Add Task to Ws Task List Splash::ws()->addTask(SPL_F_GETFILE, $params, Splash::trans("MsgSchRemoteReadFile", (string) $file)); //====================================================================// // Execute Task $response = Splash::ws()->call(SPL_S_FILE); //====================================================================// // Return First Task Result return Splash::ws()->getNextResult($response); }
php
public function getFile($file = null, $md5 = null) { //====================================================================// // Stack Trace Splash::log()->trace(); //====================================================================// // PHPUNIT Exception => Look First in Local FileSystem //====================================================================// if (defined('SPLASH_DEBUG') && !empty(SPLASH_DEBUG)) { $filePath = dirname(__DIR__)."/Resources/files/".$file; if (is_file($filePath)) { $file = $this->readFile($filePath, $md5); return is_array($file) ? $file : false; } $imgPath = dirname(__DIR__)."/Resources/img/".$file; if (is_file($imgPath)) { $file = $this->readFile($imgPath, $md5); return is_array($file) ? $file : false; } } //====================================================================// // Initiate Tasks parameters array $params = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $params->file = $file; $params->md5 = $md5; //====================================================================// // Add Task to Ws Task List Splash::ws()->addTask(SPL_F_GETFILE, $params, Splash::trans("MsgSchRemoteReadFile", (string) $file)); //====================================================================// // Execute Task $response = Splash::ws()->call(SPL_S_FILE); //====================================================================// // Return First Task Result return Splash::ws()->getNextResult($response); }
[ "public", "function", "getFile", "(", "$", "file", "=", "null", ",", "$", "md5", "=", "null", ")", "{", "//====================================================================//", "// Stack Trace", "Splash", "::", "log", "(", ")", "->", "trace", "(", ")", ";", "...
Read a file from Splash Server @param string $file File Identifier (Given by Splash Server) @param string $md5 Local FileName @return array|false $file False if not found, else file contents array
[ "Read", "a", "file", "from", "Splash", "Server" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FileManager.php#L41-L81
train
SplashSync/Php-Core
Components/FileManager.php
FileManager.isFile
public function isFile($path = null, $md5 = null) { //====================================================================// // Safety Checks if (empty($path)) { return Splash::log()->err("ErrFileFileMissing", __FUNCTION__); } if (empty(dirname($path))) { return Splash::log()->err("ErrFileDirMissing", __FUNCTION__); } if (empty($md5)) { return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__); } //====================================================================// // Check if folder exists if (!is_dir(dirname($path))) { return Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($path)); } //====================================================================// // Check if file exists if (!is_file($path)) { return Splash::log()->war("ErrFileNoExists", __FUNCTION__, $path); } //====================================================================// // Check File CheckSum => No Diff with Previous Error for Higher Safety Level if (md5_file($path) != $md5) { return Splash::log()->war("ErrFileNoExists", __FUNCTION__, $path); } //====================================================================// // Read file Informations Splash::log()->deb("Splash - Get File Infos : File ".$path." exists."); $infos = array(); $owner = posix_getpwuid((int) fileowner($path)); $infos["owner"] = $owner["name"]; $infos["readable"] = is_readable($path); $infos["writable"] = is_writable($path); $infos["mtime"] = filemtime($path); $infos["modified"] = date("F d Y H:i:s.", (int) $infos["mtime"]); $infos["md5"] = md5_file($path); $infos["size"] = filesize($path); return $infos; }
php
public function isFile($path = null, $md5 = null) { //====================================================================// // Safety Checks if (empty($path)) { return Splash::log()->err("ErrFileFileMissing", __FUNCTION__); } if (empty(dirname($path))) { return Splash::log()->err("ErrFileDirMissing", __FUNCTION__); } if (empty($md5)) { return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__); } //====================================================================// // Check if folder exists if (!is_dir(dirname($path))) { return Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($path)); } //====================================================================// // Check if file exists if (!is_file($path)) { return Splash::log()->war("ErrFileNoExists", __FUNCTION__, $path); } //====================================================================// // Check File CheckSum => No Diff with Previous Error for Higher Safety Level if (md5_file($path) != $md5) { return Splash::log()->war("ErrFileNoExists", __FUNCTION__, $path); } //====================================================================// // Read file Informations Splash::log()->deb("Splash - Get File Infos : File ".$path." exists."); $infos = array(); $owner = posix_getpwuid((int) fileowner($path)); $infos["owner"] = $owner["name"]; $infos["readable"] = is_readable($path); $infos["writable"] = is_writable($path); $infos["mtime"] = filemtime($path); $infos["modified"] = date("F d Y H:i:s.", (int) $infos["mtime"]); $infos["md5"] = md5_file($path); $infos["size"] = filesize($path); return $infos; }
[ "public", "function", "isFile", "(", "$", "path", "=", "null", ",", "$", "md5", "=", "null", ")", "{", "//====================================================================//", "// Safety Checks", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "return", ...
Check whether if a file exists or not @param string $path Full Path to Local File @param string $md5 Local File Checksum @return array|bool $infos 0 if not found, else file informations array File Information Array Structure $infos["owner"] => File Owner Name (Human Readable); $infos["readable"] => File is Readable; $infos["writable"] => File is writable; $infos["mtime"] => Last Modification TimeStamp; $infos["modified"] => Last Modification Date (Human Readable); $infos["md5"] => File MD5 Checksum $infos["size"] => File Size in bytes @remark For all file access functions, File Checksumm is used to ensure the server who send request was allowed by local server to read the specified file.
[ "Check", "whether", "if", "a", "file", "exists", "or", "not" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FileManager.php#L104-L148
train
SplashSync/Php-Core
Components/FileManager.php
FileManager.readFile
public function readFile($path = null, $md5 = null) { //====================================================================// // Safety Checks if (empty($path)) { return Splash::log()->err("ErrFileFileMissing", __FUNCTION__); } if (empty(dirname($path))) { return Splash::log()->err("ErrFileDirMissing", __FUNCTION__); } if (empty($md5)) { return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__); } //====================================================================// // Check if folder exists if (!is_dir(dirname($path))) { return Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($path)); } //====================================================================// // Check if file exists if (!is_file($path) || !is_readable($path)) { return Splash::log()->war("ErrFileReadable", __FUNCTION__, $path); } //====================================================================// // Check File CheckSum => No Diff with Previous Error for Higher Safety Level if (md5_file($path) != $md5) { return Splash::log()->war("ErrFileNoExists", __FUNCTION__, $path); } //====================================================================// // Open File $filehandle = fopen($path, "rb"); if (false == $filehandle) { return Splash::log()->err("ErrFileRead", __FUNCTION__, $path); } //====================================================================// // Fill file Informations $infos = array(); $infos["filename"] = basename($path); $infos["raw"] = base64_encode((string) fread($filehandle, (int) filesize($path))); fclose($filehandle); $infos["md5"] = md5_file($path); $infos["size"] = filesize($path); Splash::log()->deb("MsgFileRead", __FUNCTION__, basename($path)); return $infos; }
php
public function readFile($path = null, $md5 = null) { //====================================================================// // Safety Checks if (empty($path)) { return Splash::log()->err("ErrFileFileMissing", __FUNCTION__); } if (empty(dirname($path))) { return Splash::log()->err("ErrFileDirMissing", __FUNCTION__); } if (empty($md5)) { return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__); } //====================================================================// // Check if folder exists if (!is_dir(dirname($path))) { return Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($path)); } //====================================================================// // Check if file exists if (!is_file($path) || !is_readable($path)) { return Splash::log()->war("ErrFileReadable", __FUNCTION__, $path); } //====================================================================// // Check File CheckSum => No Diff with Previous Error for Higher Safety Level if (md5_file($path) != $md5) { return Splash::log()->war("ErrFileNoExists", __FUNCTION__, $path); } //====================================================================// // Open File $filehandle = fopen($path, "rb"); if (false == $filehandle) { return Splash::log()->err("ErrFileRead", __FUNCTION__, $path); } //====================================================================// // Fill file Informations $infos = array(); $infos["filename"] = basename($path); $infos["raw"] = base64_encode((string) fread($filehandle, (int) filesize($path))); fclose($filehandle); $infos["md5"] = md5_file($path); $infos["size"] = filesize($path); Splash::log()->deb("MsgFileRead", __FUNCTION__, basename($path)); return $infos; }
[ "public", "function", "readFile", "(", "$", "path", "=", "null", ",", "$", "md5", "=", "null", ")", "{", "//====================================================================//", "// Safety Checks", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "return", ...
Read a file from local filesystem @param string $path Full Path to Local File @param string $md5 Local File Checksum @return array|bool $file 0 if not found, else file contents array File Information Array Structure $infos["filename"] => File Name $infos["raw"] => Raw File Contents $infos["md5"] => File MD5 Checksum $infos["size"] => File Size in bytes @remark For all file access functions, File Checksumm is used to ensure the server who send request was allowed by local server to read the specified file.
[ "Read", "a", "file", "from", "local", "filesystem" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FileManager.php#L168-L216
train
SplashSync/Php-Core
Components/FileManager.php
FileManager.readFileContents
public function readFileContents($fileName = null) { //====================================================================// // Safety Checks if (empty($fileName)) { return Splash::log()->err("ErrFileFileMissing"); } //====================================================================// // Check if file exists if (!is_file($fileName)) { return Splash::log()->err("ErrFileNoExists", $fileName); } //====================================================================// // Check if file is readable if (!is_readable($fileName)) { return Splash::log()->err("ErrFileReadable", $fileName); } Splash::log()->deb("MsgFileRead", $fileName); //====================================================================// // Read File Contents return base64_encode((string) file_get_contents($fileName)); }
php
public function readFileContents($fileName = null) { //====================================================================// // Safety Checks if (empty($fileName)) { return Splash::log()->err("ErrFileFileMissing"); } //====================================================================// // Check if file exists if (!is_file($fileName)) { return Splash::log()->err("ErrFileNoExists", $fileName); } //====================================================================// // Check if file is readable if (!is_readable($fileName)) { return Splash::log()->err("ErrFileReadable", $fileName); } Splash::log()->deb("MsgFileRead", $fileName); //====================================================================// // Read File Contents return base64_encode((string) file_get_contents($fileName)); }
[ "public", "function", "readFileContents", "(", "$", "fileName", "=", "null", ")", "{", "//====================================================================//", "// Safety Checks", "if", "(", "empty", "(", "$", "fileName", ")", ")", "{", "return", "Splash", "::", "l...
Read a file contents from local filesystem & encode it to base64 format @param string $fileName Full path local FileName @return false|string Base64 encoded raw file
[ "Read", "a", "file", "contents", "from", "local", "filesystem", "&", "encode", "it", "to", "base64", "format" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FileManager.php#L225-L246
train
SplashSync/Php-Core
Components/FileManager.php
FileManager.writeFile
public function writeFile($dir = null, $file = null, $md5 = null, $raw = null) { //====================================================================// // Safety Checks if (!$this->isWriteValidInputs($dir, $file, $md5, $raw)) { return false; } //====================================================================// // Assemble full Filename $fullpath = $dir.$file; //====================================================================// // Check if folder exists or create it if (!is_dir((string) $dir)) { mkdir((string) $dir, 0775, true); } //====================================================================// // Check if folder exists if (!is_dir((string) $dir)) { Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, $dir); } //====================================================================// // Check if file exists if (is_file($fullpath)) { Splash::log()->deb("MsgFileExists", __FUNCTION__, $file); //====================================================================// // Check if file is different if ($md5 === md5_file($fullpath)) { return true; } //====================================================================// // Check if file is writable if (!is_writable((string) $fullpath)) { return Splash::log()->err("ErrFileWriteable", __FUNCTION__, $file); } } //====================================================================// // Open File $filehandle = fopen($fullpath, 'w'); if (false == $filehandle) { return Splash::log()->war("ErrFileOpen", __FUNCTION__, $fullpath); } //====================================================================// // Write file fwrite($filehandle, (string) base64_decode((string) $raw, true)); fclose($filehandle); clearstatcache(); //====================================================================// // Verify file checksum if ($md5 !== md5_file($fullpath)) { return Splash::log()->err("ErrFileWrite", __FUNCTION__, $file); } return true; }
php
public function writeFile($dir = null, $file = null, $md5 = null, $raw = null) { //====================================================================// // Safety Checks if (!$this->isWriteValidInputs($dir, $file, $md5, $raw)) { return false; } //====================================================================// // Assemble full Filename $fullpath = $dir.$file; //====================================================================// // Check if folder exists or create it if (!is_dir((string) $dir)) { mkdir((string) $dir, 0775, true); } //====================================================================// // Check if folder exists if (!is_dir((string) $dir)) { Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, $dir); } //====================================================================// // Check if file exists if (is_file($fullpath)) { Splash::log()->deb("MsgFileExists", __FUNCTION__, $file); //====================================================================// // Check if file is different if ($md5 === md5_file($fullpath)) { return true; } //====================================================================// // Check if file is writable if (!is_writable((string) $fullpath)) { return Splash::log()->err("ErrFileWriteable", __FUNCTION__, $file); } } //====================================================================// // Open File $filehandle = fopen($fullpath, 'w'); if (false == $filehandle) { return Splash::log()->war("ErrFileOpen", __FUNCTION__, $fullpath); } //====================================================================// // Write file fwrite($filehandle, (string) base64_decode((string) $raw, true)); fclose($filehandle); clearstatcache(); //====================================================================// // Verify file checksum if ($md5 !== md5_file($fullpath)) { return Splash::log()->err("ErrFileWrite", __FUNCTION__, $file); } return true; }
[ "public", "function", "writeFile", "(", "$", "dir", "=", "null", ",", "$", "file", "=", "null", ",", "$", "md5", "=", "null", ",", "$", "raw", "=", "null", ")", "{", "//====================================================================//", "// Safety Checks", ...
Write a file on local filesystem @remark For all function used remotly, all parameters have default predefined values in order to avoid remote execution errors. @param string $dir Local File Directory @param string $file Local FileName @param string $md5 File MD5 Checksum @param string $raw Raw File Contents (base64 Encoded) @return bool
[ "Write", "a", "file", "on", "local", "filesystem" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FileManager.php#L261-L316
train
SplashSync/Php-Core
Components/FileManager.php
FileManager.deleteFile
public function deleteFile($path = null, $md5 = null) { $fPath = (string) $path; //====================================================================// // Safety Checks if (empty(dirname($fPath))) { return Splash::log()->err("ErrFileDirMissing", __FUNCTION__); } if (empty(basename($fPath))) { return Splash::log()->err("ErrFileFileMissing", __FUNCTION__); } if (empty($md5)) { return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__); } //====================================================================// // Check if folder exists if (!is_dir(dirname($fPath))) { Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($fPath)); } //====================================================================// // Check if file exists if (is_file($fPath) && (md5_file($fPath) === $md5)) { Splash::log()->deb("MsgFileExists", __FUNCTION__, basename($fPath)); //====================================================================// // Delete File if (unlink($fPath)) { return Splash::log()->deb("MsgFileDeleted", __FUNCTION__, basename($fPath)); } return Splash::log()->err("ErrFileDeleted", __FUNCTION__, basename($fPath)); } return true; }
php
public function deleteFile($path = null, $md5 = null) { $fPath = (string) $path; //====================================================================// // Safety Checks if (empty(dirname($fPath))) { return Splash::log()->err("ErrFileDirMissing", __FUNCTION__); } if (empty(basename($fPath))) { return Splash::log()->err("ErrFileFileMissing", __FUNCTION__); } if (empty($md5)) { return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__); } //====================================================================// // Check if folder exists if (!is_dir(dirname($fPath))) { Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($fPath)); } //====================================================================// // Check if file exists if (is_file($fPath) && (md5_file($fPath) === $md5)) { Splash::log()->deb("MsgFileExists", __FUNCTION__, basename($fPath)); //====================================================================// // Delete File if (unlink($fPath)) { return Splash::log()->deb("MsgFileDeleted", __FUNCTION__, basename($fPath)); } return Splash::log()->err("ErrFileDeleted", __FUNCTION__, basename($fPath)); } return true; }
[ "public", "function", "deleteFile", "(", "$", "path", "=", "null", ",", "$", "md5", "=", "null", ")", "{", "$", "fPath", "=", "(", "string", ")", "$", "path", ";", "//====================================================================//", "// Safety Checks", "if"...
Delete a file exists or not @param string $path Full Path to Local File @param string $md5 Local File Checksum @return bool @remark For all file access functions, File Checksumm is used to ensure the server who send request was allowed by local server to read the specified file.
[ "Delete", "a", "file", "exists", "or", "not" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FileManager.php#L330-L363
train
SplashSync/Php-Core
Components/FileManager.php
FileManager.isWriteValidInputs
private function isWriteValidInputs($dir = null, $file = null, $md5 = null, $raw = null) { //====================================================================// // Safety Checks if (empty($dir)) { return Splash::log()->err("ErrFileDirMissing", __FUNCTION__); } if (empty($file)) { return Splash::log()->err("ErrFileFileMissing", __FUNCTION__); } if (empty($md5)) { return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__); } if (empty($raw)) { return Splash::log()->err("ErrFileRawMissing", __FUNCTION__); } return true; }
php
private function isWriteValidInputs($dir = null, $file = null, $md5 = null, $raw = null) { //====================================================================// // Safety Checks if (empty($dir)) { return Splash::log()->err("ErrFileDirMissing", __FUNCTION__); } if (empty($file)) { return Splash::log()->err("ErrFileFileMissing", __FUNCTION__); } if (empty($md5)) { return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__); } if (empty($raw)) { return Splash::log()->err("ErrFileRawMissing", __FUNCTION__); } return true; }
[ "private", "function", "isWriteValidInputs", "(", "$", "dir", "=", "null", ",", "$", "file", "=", "null", ",", "$", "md5", "=", "null", ",", "$", "raw", "=", "null", ")", "{", "//====================================================================//", "// Safety C...
Verify Write Inputs are Conform to Expected @param string $dir @param string $file @param string $md5 @param string $raw @return boolean
[ "Verify", "Write", "Inputs", "are", "Conform", "to", "Expected" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FileManager.php#L375-L393
train
payneteasy/php-library-payneteasy-api
source/PaynetEasy/PaynetEasyApi/Query/CreateCardRefQuery.php
CreateCardRefQuery.checkPaymentTransactionStatus
protected function checkPaymentTransactionStatus(PaymentTransaction $paymentTransaction) { if (!$paymentTransaction->isFinished()) { throw new ValidationException('Only finished payment transaction can be used for create-card-ref-id'); } if (!$paymentTransaction->getPayment()->isPaid()) { throw new ValidationException("Can not use new payment for create-card-ref-id. Execute 'sale' or 'preauth' query first"); } }
php
protected function checkPaymentTransactionStatus(PaymentTransaction $paymentTransaction) { if (!$paymentTransaction->isFinished()) { throw new ValidationException('Only finished payment transaction can be used for create-card-ref-id'); } if (!$paymentTransaction->getPayment()->isPaid()) { throw new ValidationException("Can not use new payment for create-card-ref-id. Execute 'sale' or 'preauth' query first"); } }
[ "protected", "function", "checkPaymentTransactionStatus", "(", "PaymentTransaction", "$", "paymentTransaction", ")", "{", "if", "(", "!", "$", "paymentTransaction", "->", "isFinished", "(", ")", ")", "{", "throw", "new", "ValidationException", "(", "'Only finished pay...
Check, if payment transaction is finished and payment is not new. @param PaymentTransaction $paymentTransaction Payment transaction for checking
[ "Check", "if", "payment", "transaction", "is", "finished", "and", "payment", "is", "not", "new", "." ]
e3484aa37b6594231f59b1f43523603aa704f093
https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/CreateCardRefQuery.php#L88-L99
train
payneteasy/php-library-payneteasy-api
source/PaynetEasy/PaynetEasyApi/Transport/GatewayClient.php
GatewayClient.parseReponse
protected function parseReponse($response) { if(empty($response)) { throw new ResponseException('PaynetEasy response is empty'); } $responseFields = array(); parse_str($response, $responseFields); return new Response($responseFields); }
php
protected function parseReponse($response) { if(empty($response)) { throw new ResponseException('PaynetEasy response is empty'); } $responseFields = array(); parse_str($response, $responseFields); return new Response($responseFields); }
[ "protected", "function", "parseReponse", "(", "$", "response", ")", "{", "if", "(", "empty", "(", "$", "response", ")", ")", "{", "throw", "new", "ResponseException", "(", "'PaynetEasy response is empty'", ")", ";", "}", "$", "responseFields", "=", "array", ...
Parse PaynetEasy response from string to Response object @param string $response PaynetEasy response as string @return Response PaynetEasy response as object @throws ResponseException Error while parsing
[ "Parse", "PaynetEasy", "response", "from", "string", "to", "Response", "object" ]
e3484aa37b6594231f59b1f43523603aa704f093
https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Transport/GatewayClient.php#L89-L101
train
payneteasy/php-library-payneteasy-api
source/PaynetEasy/PaynetEasyApi/Transport/GatewayClient.php
GatewayClient.getUrl
protected function getUrl(Request $request) { if (strpos($request->getApiMethod(), 'sync-') === 0) { $apiMethod = 'sync/' . substr($request->getApiMethod(), strlen('sync-')); } else { $apiMethod = $request->getApiMethod(); } if (strlen($request->getEndPointGroup()) > 0) { $endPoint = "group/{$request->getEndPointGroup()}"; } else { $endPoint = (string) $request->getEndPoint(); } return "{$request->getGatewayUrl()}/{$apiMethod}/{$endPoint}"; }
php
protected function getUrl(Request $request) { if (strpos($request->getApiMethod(), 'sync-') === 0) { $apiMethod = 'sync/' . substr($request->getApiMethod(), strlen('sync-')); } else { $apiMethod = $request->getApiMethod(); } if (strlen($request->getEndPointGroup()) > 0) { $endPoint = "group/{$request->getEndPointGroup()}"; } else { $endPoint = (string) $request->getEndPoint(); } return "{$request->getGatewayUrl()}/{$apiMethod}/{$endPoint}"; }
[ "protected", "function", "getUrl", "(", "Request", "$", "request", ")", "{", "if", "(", "strpos", "(", "$", "request", "->", "getApiMethod", "(", ")", ",", "'sync-'", ")", "===", "0", ")", "{", "$", "apiMethod", "=", "'sync/'", ".", "substr", "(", "$...
Returns url for payment method, based on request data @param Request $request Request for url creation @return string Url
[ "Returns", "url", "for", "payment", "method", "based", "on", "request", "data" ]
e3484aa37b6594231f59b1f43523603aa704f093
https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Transport/GatewayClient.php#L153-L174
train
tokenly/token-generator
src/TokenGenerator.php
TokenGenerator.generateToken
public function generateToken($token_length=30, $prefix='') { $token_length = $token_length - strlen($prefix); if ($token_length < 0) { throw new Exception("Prefix is too long", 1); } $token = ""; while (($len = strlen($token)) < $token_length) { $remaining_len = $token_length - $len; $bytes = random_bytes($remaining_len); $token .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $remaining_len); } return $prefix.$token; }
php
public function generateToken($token_length=30, $prefix='') { $token_length = $token_length - strlen($prefix); if ($token_length < 0) { throw new Exception("Prefix is too long", 1); } $token = ""; while (($len = strlen($token)) < $token_length) { $remaining_len = $token_length - $len; $bytes = random_bytes($remaining_len); $token .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $remaining_len); } return $prefix.$token; }
[ "public", "function", "generateToken", "(", "$", "token_length", "=", "30", ",", "$", "prefix", "=", "''", ")", "{", "$", "token_length", "=", "$", "token_length", "-", "strlen", "(", "$", "prefix", ")", ";", "if", "(", "$", "token_length", "<", "0", ...
generates a secure random string @param integer $token_length The number of characters including the prefix @param string $prefix A prefix for the random string @return string The random string starting with prefix
[ "generates", "a", "secure", "random", "string" ]
a0fff2db10325416ea2bbe1a11b729e97cc6f86c
https://github.com/tokenly/token-generator/blob/a0fff2db10325416ea2bbe1a11b729e97cc6f86c/src/TokenGenerator.php#L19-L31
train
payneteasy/php-library-payneteasy-api
source/PaynetEasy/PaynetEasyApi/Util/Validator.php
Validator.validateByRule
static public function validateByRule($value, $rule, $failOnError = true) { $valid = false; switch ($rule) { case self::EMAIL: { $valid = filter_var($value, FILTER_VALIDATE_EMAIL); break; } case self::IP: { $valid = filter_var($value, FILTER_VALIDATE_IP); break; } case self::URL: { $valid = filter_var($value, FILTER_VALIDATE_URL); break; } case self::MONTH: { $valid = in_array($value, range(1, 12)); break; } case self::COUNTRY: { $valid = RegionFinder::hasCountryByCode($value); break; } case self::STATE: { $valid = RegionFinder::hasStateByCode($value); break; } default: { if (isset(static::$ruleRegExps[$rule])) { $valid = static::validateByRegExp($value, static::$ruleRegExps[$rule], $failOnError); } else { $valid = static::validateByRegExp($value, $rule, $failOnError); } } } if ($valid !== false) { return true; } elseif ($failOnError === true) { throw new ValidationException("Value '{$value}' does not match rule '{$rule}'"); } else { return false; } }
php
static public function validateByRule($value, $rule, $failOnError = true) { $valid = false; switch ($rule) { case self::EMAIL: { $valid = filter_var($value, FILTER_VALIDATE_EMAIL); break; } case self::IP: { $valid = filter_var($value, FILTER_VALIDATE_IP); break; } case self::URL: { $valid = filter_var($value, FILTER_VALIDATE_URL); break; } case self::MONTH: { $valid = in_array($value, range(1, 12)); break; } case self::COUNTRY: { $valid = RegionFinder::hasCountryByCode($value); break; } case self::STATE: { $valid = RegionFinder::hasStateByCode($value); break; } default: { if (isset(static::$ruleRegExps[$rule])) { $valid = static::validateByRegExp($value, static::$ruleRegExps[$rule], $failOnError); } else { $valid = static::validateByRegExp($value, $rule, $failOnError); } } } if ($valid !== false) { return true; } elseif ($failOnError === true) { throw new ValidationException("Value '{$value}' does not match rule '{$rule}'"); } else { return false; } }
[ "static", "public", "function", "validateByRule", "(", "$", "value", ",", "$", "rule", ",", "$", "failOnError", "=", "true", ")", "{", "$", "valid", "=", "false", ";", "switch", "(", "$", "rule", ")", "{", "case", "self", "::", "EMAIL", ":", "{", "...
Validates value by given rule. Rule can be one of Validator constants or regExp. @param string $value Value for validation @param string $rule Rule for validation @param boolean $failOnError Throw exception on invalid value or not @return boolean Validation result @throws ValidationException Value does not match rule (if $failOnError == true)
[ "Validates", "value", "by", "given", "rule", ".", "Rule", "can", "be", "one", "of", "Validator", "constants", "or", "regExp", "." ]
e3484aa37b6594231f59b1f43523603aa704f093
https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Util/Validator.php#L133-L194
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.create
public function create($fieldType, $fieldId = null, $fieldName = null) { //====================================================================// // Commit Last Created if not already done if (!empty($this->new)) { $this->commit(); } //====================================================================// // Unset Current $this->new = null; //====================================================================// // Create new empty field $this->new = new ArrayObject($this->empty, ArrayObject::ARRAY_AS_PROPS); //====================================================================// // Set Field Type $this->new->type = $fieldType; //====================================================================// // Set Field Identifier if (!is_null($fieldId)) { $this->identifier($fieldId); } //====================================================================// // Set Field Name if (!is_null($fieldName)) { $this->name($fieldName); } return $this; }
php
public function create($fieldType, $fieldId = null, $fieldName = null) { //====================================================================// // Commit Last Created if not already done if (!empty($this->new)) { $this->commit(); } //====================================================================// // Unset Current $this->new = null; //====================================================================// // Create new empty field $this->new = new ArrayObject($this->empty, ArrayObject::ARRAY_AS_PROPS); //====================================================================// // Set Field Type $this->new->type = $fieldType; //====================================================================// // Set Field Identifier if (!is_null($fieldId)) { $this->identifier($fieldId); } //====================================================================// // Set Field Name if (!is_null($fieldName)) { $this->name($fieldName); } return $this; }
[ "public", "function", "create", "(", "$", "fieldType", ",", "$", "fieldId", "=", "null", ",", "$", "fieldName", "=", "null", ")", "{", "//====================================================================//", "// Commit Last Created if not already done", "if", "(", "!",...
Create a new Field Definition with default parameters @param string $fieldType Standard Data Type (Refer Splash.Inc.php) @param string $fieldId Local Data Identifier (Shall be unik on local machine) @param string $fieldName Data Name (Will Be Translated by Splash if Possible) @return $this
[ "Create", "a", "new", "Field", "Definition", "with", "default", "parameters" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L146-L174
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.identifier
public function identifier($fieldId) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->id = $fieldId; } return $this; }
php
public function identifier($fieldId) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->id = $fieldId; } return $this; }
[ "public", "function", "identifier", "(", "$", "fieldId", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{", "Splash", "::...
Set Current New Field Identifier @param string $fieldId Local Data Identifier (Shall be unik on local machine) @return $this
[ "Set", "Current", "New", "Field", "Identifier" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L183-L196
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.inList
public function inList($listName) { //====================================================================// // Safety Checks ==> Verify List Name Not Empty if (empty($listName)) { return $this; } //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field Identifier $this->new->id = $this->new->id.LISTSPLIT.$listName; //====================================================================// // Update New Field Type $this->new->type = $this->new->type.LISTSPLIT.SPL_T_LIST; } return $this; }
php
public function inList($listName) { //====================================================================// // Safety Checks ==> Verify List Name Not Empty if (empty($listName)) { return $this; } //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field Identifier $this->new->id = $this->new->id.LISTSPLIT.$listName; //====================================================================// // Update New Field Type $this->new->type = $this->new->type.LISTSPLIT.SPL_T_LIST; } return $this; }
[ "public", "function", "inList", "(", "$", "listName", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify List Name Not Empty", "if", "(", "empty", "(", "$", "listName", ")", ")", "{", "return", "$", "this", "...
Update Current New Field set as it inside a list @param string $listName Name of List @return $this
[ "Update", "Current", "New", "Field", "set", "as", "it", "inside", "a", "list" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L205-L227
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.isReadOnly
public function isReadOnly($isReadOnly = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } elseif ($isReadOnly) { //====================================================================// // Update New Field structure $this->new->read = true; $this->new->write = false; } return $this; }
php
public function isReadOnly($isReadOnly = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } elseif ($isReadOnly) { //====================================================================// // Update New Field structure $this->new->read = true; $this->new->write = false; } return $this; }
[ "public", "function", "isReadOnly", "(", "$", "isReadOnly", "=", "true", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{...
Update Current New Field set as Read Only Field @param null|bool $isReadOnly @return $this
[ "Update", "Current", "New", "Field", "set", "as", "Read", "Only", "Field" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L305-L319
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.isWriteOnly
public function isWriteOnly($isWriteOnly = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } elseif ($isWriteOnly) { //====================================================================// // Update New Field structure $this->new->read = false; $this->new->write = true; } return $this; }
php
public function isWriteOnly($isWriteOnly = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } elseif ($isWriteOnly) { //====================================================================// // Update New Field structure $this->new->read = false; $this->new->write = true; } return $this; }
[ "public", "function", "isWriteOnly", "(", "$", "isWriteOnly", "=", "true", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", ...
Update Current New Field set as Write Only Field @param null|bool $isWriteOnly @return $this
[ "Update", "Current", "New", "Field", "set", "as", "Write", "Only", "Field" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L328-L342
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.isRequired
public function isRequired($isRequired = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->required = (bool) $isRequired; } return $this; }
php
public function isRequired($isRequired = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->required = (bool) $isRequired; } return $this; }
[ "public", "function", "isRequired", "(", "$", "isRequired", "=", "true", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{...
Update Current New Field set as required for creation @param null|bool $isRequired @return $this
[ "Update", "Current", "New", "Field", "set", "as", "required", "for", "creation" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L351-L364
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.setPreferRead
public function setPreferRead() { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->syncmode = self::MODE_READ; } return $this; }
php
public function setPreferRead() { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->syncmode = self::MODE_READ; } return $this; }
[ "public", "function", "setPreferRead", "(", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{", "Splash", "::", "log", "("...
Signify Server Current New Field Prefer ReadOnly Mode @return $this
[ "Signify", "Server", "Current", "New", "Field", "Prefer", "ReadOnly", "Mode" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L371-L384
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.setPreferWrite
public function setPreferWrite() { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->syncmode = self::MODE_WRITE; } return $this; }
php
public function setPreferWrite() { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->syncmode = self::MODE_WRITE; } return $this; }
[ "public", "function", "setPreferWrite", "(", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{", "Splash", "::", "log", "(...
Signify Server Current New Field Prefer WriteOnly Mode @return $this
[ "Signify", "Server", "Current", "New", "Field", "Prefer", "WriteOnly", "Mode" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L391-L404
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.setPreferNone
public function setPreferNone() { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->syncmode = self::MODE_NONE; } return $this; }
php
public function setPreferNone() { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->syncmode = self::MODE_NONE; } return $this; }
[ "public", "function", "setPreferNone", "(", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{", "Splash", "::", "log", "("...
Signify Server Current New Field Prefer No Sync Mode @return $this
[ "Signify", "Server", "Current", "New", "Field", "Prefer", "No", "Sync", "Mode" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L411-L424
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.association
public function association() { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Field Clear Fields Associations if (!empty($this->new->asso)) { $this->new->asso = null; } //====================================================================// // Set New Field Associations if (!empty(func_get_args())) { $this->new->asso = func_get_args(); } } return $this; }
php
public function association() { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Field Clear Fields Associations if (!empty($this->new->asso)) { $this->new->asso = null; } //====================================================================// // Set New Field Associations if (!empty(func_get_args())) { $this->new->asso = func_get_args(); } } return $this; }
[ "public", "function", "association", "(", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{", "Splash", "::", "log", "(", ...
Update Current New Field set list of associated fields @return $this
[ "Update", "Current", "New", "Field", "set", "list", "of", "associated", "fields" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L431-L452
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.isListed
public function isListed($isListed = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->inlist = (bool) $isListed; } return $this; }
php
public function isListed($isListed = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->inlist = (bool) $isListed; } return $this; }
[ "public", "function", "isListed", "(", "$", "isListed", "=", "true", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{", ...
Update Current New Field set as available in objects list @param null|bool $isListed @return $this
[ "Update", "Current", "New", "Field", "set", "as", "available", "in", "objects", "list" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L461-L474
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.isLogged
public function isLogged($isLogged = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->log = (bool) $isLogged; } return $this; }
php
public function isLogged($isLogged = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->log = (bool) $isLogged; } return $this; }
[ "public", "function", "isLogged", "(", "$", "isLogged", "=", "true", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{", ...
Update Current New Field set as recommended for logging @param null|bool $isLogged @return $this
[ "Update", "Current", "New", "Field", "set", "as", "recommended", "for", "logging" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L483-L496
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.microData
public function microData($itemType, $itemProp) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->itemtype = $itemType; $this->new->itemprop = $itemProp; $this->setTag($itemProp.IDSPLIT.$itemType); } return $this; }
php
public function microData($itemType, $itemProp) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->itemtype = $itemType; $this->new->itemprop = $itemProp; $this->setTag($itemProp.IDSPLIT.$itemType); } return $this; }
[ "public", "function", "microData", "(", "$", "itemType", ",", "$", "itemProp", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", "...
Update Current New Field set its meta informations for autolinking @param string $itemType Field Microdata Type Url @param string $itemProp Field Microdata Property Name @return $this
[ "Update", "Current", "New", "Field", "set", "its", "meta", "informations", "for", "autolinking" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L506-L521
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.addOptions
public function addOptions($fieldOptions) { foreach ($fieldOptions as $type => $value) { $this->addOption($type, $value); } return $this; }
php
public function addOptions($fieldOptions) { foreach ($fieldOptions as $type => $value) { $this->addOption($type, $value); } return $this; }
[ "public", "function", "addOptions", "(", "$", "fieldOptions", ")", "{", "foreach", "(", "$", "fieldOptions", "as", "$", "type", "=>", "$", "value", ")", "{", "$", "this", "->", "addOption", "(", "$", "type", ",", "$", "value", ")", ";", "}", "return"...
Add New Options Array for Current Field @param array $fieldOptions Array of Options (Type => Value) @return $this
[ "Add", "New", "Options", "Array", "for", "Current", "Field" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L592-L599
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.addOption
public function addOption($type, $value = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } elseif (empty($type)) { Splash::log()->err("Field Option Type Cannot be Empty"); } else { //====================================================================// // Update New Field structure $this->new->options[$type] = $value; } return $this; }
php
public function addOption($type, $value = true) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } elseif (empty($type)) { Splash::log()->err("Field Option Type Cannot be Empty"); } else { //====================================================================// // Update New Field structure $this->new->options[$type] = $value; } return $this; }
[ "public", "function", "addOption", "(", "$", "type", ",", "$", "value", "=", "true", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ...
Add New Option for Current Field @param string $type Constrain Type @param bool|string $value Constrain Value @return $this
[ "Add", "New", "Option", "for", "Current", "Field" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L609-L624
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.setDefaultLanguage
public function setDefaultLanguage($isoCode) { //====================================================================// // Safety Checks ==> Verify Language ISO Code if (!is_string($isoCode) || (strlen($isoCode) < 2)) { Splash::log()->err("Default Language ISO Code is Invalid"); return $this; } //====================================================================// // Store Default Language ISO Code $this->dfLanguage = $isoCode; return $this; }
php
public function setDefaultLanguage($isoCode) { //====================================================================// // Safety Checks ==> Verify Language ISO Code if (!is_string($isoCode) || (strlen($isoCode) < 2)) { Splash::log()->err("Default Language ISO Code is Invalid"); return $this; } //====================================================================// // Store Default Language ISO Code $this->dfLanguage = $isoCode; return $this; }
[ "public", "function", "setDefaultLanguage", "(", "$", "isoCode", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify Language ISO Code", "if", "(", "!", "is_string", "(", "$", "isoCode", ")", "||", "(", "strlen", ...
Select Default Language for Field List @param null|string $isoCode Language ISO Code (i.e en_US | fr_FR) @return $this
[ "Select", "Default", "Language", "for", "Field", "List" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L633-L647
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.setMultilang
public function setMultilang($isoCode) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); return $this; } //====================================================================// // Safety Checks ==> Verify Language ISO Code if (!is_string($isoCode) || (strlen($isoCode) < 2)) { Splash::log()->err("Language ISO Code is Invalid"); return $this; } //====================================================================// // Safety Checks ==> Verify Field Type is Allowed if (!in_array($this->new->type, array(SPL_T_VARCHAR, SPL_T_TEXT), true)) { Splash::log()->err("ErrFieldsWrongLang"); Splash::log()->err("Received: ".$this->new->type); return $this; } //====================================================================// // Default Language ==> Only Setup Language Option $this->addOption("language", $isoCode); //====================================================================// // Other Language ==> Complete Field Setup if ($isoCode != $this->dfLanguage) { $this->identifier($this->new->id."_".$isoCode); if (!empty($this->new->itemtype)) { $this->microData($this->new->itemtype."/".$isoCode, $this->new->itemprop); } } return $this; }
php
public function setMultilang($isoCode) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); return $this; } //====================================================================// // Safety Checks ==> Verify Language ISO Code if (!is_string($isoCode) || (strlen($isoCode) < 2)) { Splash::log()->err("Language ISO Code is Invalid"); return $this; } //====================================================================// // Safety Checks ==> Verify Field Type is Allowed if (!in_array($this->new->type, array(SPL_T_VARCHAR, SPL_T_TEXT), true)) { Splash::log()->err("ErrFieldsWrongLang"); Splash::log()->err("Received: ".$this->new->type); return $this; } //====================================================================// // Default Language ==> Only Setup Language Option $this->addOption("language", $isoCode); //====================================================================// // Other Language ==> Complete Field Setup if ($isoCode != $this->dfLanguage) { $this->identifier($this->new->id."_".$isoCode); if (!empty($this->new->itemtype)) { $this->microData($this->new->itemtype."/".$isoCode, $this->new->itemprop); } } return $this; }
[ "public", "function", "setMultilang", "(", "$", "isoCode", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{", "Splash", "...
Configure Current Field with Multilangual Options @param null|string $isoCode Language ISO Code (i.e en_US | fr_FR) @return $this
[ "Configure", "Current", "Field", "with", "Multilangual", "Options" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L656-L694
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.seachtByTag
public function seachtByTag($fieldList, $fieldTag) { //====================================================================// // Safety Checks if (!count($fieldList)) { return false; } if (empty($fieldTag)) { return false; } //====================================================================// // Walk Through List and select by Tag foreach ($fieldList as $field) { if ($field["tag"] == $fieldTag) { return $field; } } return false; }
php
public function seachtByTag($fieldList, $fieldTag) { //====================================================================// // Safety Checks if (!count($fieldList)) { return false; } if (empty($fieldTag)) { return false; } //====================================================================// // Walk Through List and select by Tag foreach ($fieldList as $field) { if ($field["tag"] == $fieldTag) { return $field; } } return false; }
[ "public", "function", "seachtByTag", "(", "$", "fieldList", ",", "$", "fieldTag", ")", "{", "//====================================================================//", "// Safety Checks", "if", "(", "!", "count", "(", "$", "fieldList", ")", ")", "{", "return", "false"...
Seach for a Field by unik tag @param array $fieldList Array Of Field definition @param string $fieldTag Field Unik Tag @return ArrayObject|false
[ "Seach", "for", "a", "Field", "by", "unik", "tag" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L733-L752
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.seachtById
public function seachtById($fieldList, $fieldId) { //====================================================================// // Safety Checks if (!count($fieldList)) { return false; } if (empty($fieldId)) { return false; } //====================================================================// // Walk Through List and select by Tag foreach ($fieldList as $field) { if ($field["id"] == $fieldId) { return $field; } } return false; }
php
public function seachtById($fieldList, $fieldId) { //====================================================================// // Safety Checks if (!count($fieldList)) { return false; } if (empty($fieldId)) { return false; } //====================================================================// // Walk Through List and select by Tag foreach ($fieldList as $field) { if ($field["id"] == $fieldId) { return $field; } } return false; }
[ "public", "function", "seachtById", "(", "$", "fieldList", ",", "$", "fieldId", ")", "{", "//====================================================================//", "// Safety Checks", "if", "(", "!", "count", "(", "$", "fieldList", ")", ")", "{", "return", "false", ...
Seach for a Field by id @param array $fieldList Array Of Field definition @param string $fieldId Field Identifier @return ArrayObject|false
[ "Seach", "for", "a", "Field", "by", "id" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L762-L781
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.setTag
private function setTag($fieldTag) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->tag = md5($fieldTag); } return $this; }
php
private function setTag($fieldTag) { //====================================================================// // Safety Checks ==> Verify a new Field Exists if (empty($this->new)) { Splash::log()->err("ErrFieldsNoNew"); } else { //====================================================================// // Update New Field structure $this->new->tag = md5($fieldTag); } return $this; }
[ "private", "function", "setTag", "(", "$", "fieldTag", ")", "{", "//====================================================================//", "// Safety Checks ==> Verify a new Field Exists", "if", "(", "empty", "(", "$", "this", "->", "new", ")", ")", "{", "Splash", "::",...
Update Current New Field set its unik tag for autolinking @param string $fieldTag Field Unik Tag @return $this
[ "Update", "Current", "New", "Field", "set", "its", "unik", "tag", "for", "autolinking" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L790-L803
train
SplashSync/Php-Core
Components/FieldsFactory.php
FieldsFactory.validate
private function validate($field) { //====================================================================// // Verify - Field Type is Not Empty if (empty($field->type) || !is_string($field->type)) { return Splash::log()->err("ErrFieldsNoType"); } //====================================================================// // Verify - Field Id is Not Empty if (empty($field->id) || !is_string($field->id)) { return Splash::log()->err("ErrFieldsNoId"); } //====================================================================// // Verify - Field Id No Spacial Chars if ($field->id !== preg_replace('/[^a-zA-Z0-9-_@]/u', '', $field->id)) { Splash::log()->war("ErrFieldsInvalidId", $field->id); return false; } //====================================================================// // Verify - Field Name is Not Empty if (empty($field->name) || !is_string($field->name)) { return Splash::log()->err("ErrFieldsNoName"); } //====================================================================// // Verify - Field Desc is Not Empty if (empty($field->desc) || !is_string($field->desc)) { return Splash::log()->err("ErrFieldsNoDesc"); } return true; }
php
private function validate($field) { //====================================================================// // Verify - Field Type is Not Empty if (empty($field->type) || !is_string($field->type)) { return Splash::log()->err("ErrFieldsNoType"); } //====================================================================// // Verify - Field Id is Not Empty if (empty($field->id) || !is_string($field->id)) { return Splash::log()->err("ErrFieldsNoId"); } //====================================================================// // Verify - Field Id No Spacial Chars if ($field->id !== preg_replace('/[^a-zA-Z0-9-_@]/u', '', $field->id)) { Splash::log()->war("ErrFieldsInvalidId", $field->id); return false; } //====================================================================// // Verify - Field Name is Not Empty if (empty($field->name) || !is_string($field->name)) { return Splash::log()->err("ErrFieldsNoName"); } //====================================================================// // Verify - Field Desc is Not Empty if (empty($field->desc) || !is_string($field->desc)) { return Splash::log()->err("ErrFieldsNoDesc"); } return true; }
[ "private", "function", "validate", "(", "$", "field", ")", "{", "//====================================================================//", "// Verify - Field Type is Not Empty", "if", "(", "empty", "(", "$", "field", "->", "type", ")", "||", "!", "is_string", "(", "$",...
Validate Field Definition @param ArrayObject $field @return boolean @SuppressWarnings(PHPMD.CyclomaticComplexity)
[ "Validate", "Field", "Definition" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/FieldsFactory.php#L830-L861
train
BootstrapCMS/Contact
src/Http/Controllers/ContactController.php
ContactController.postSubmit
public function postSubmit() { $rules = [ 'first_name' => 'required', 'last_name' => 'required', 'email' => 'required', 'message' => 'required', ]; $input = Binput::only(array_keys($rules)); $val = Validator::make($input, $rules); if ($val->fails()) { return Redirect::to($this->path)->withInput()->withErrors($val); } $this->throttler->hit(); Mailer::send($input['first_name'], $input['last_name'], $input['email'], $input['message']); return Redirect::to('/')->with('success', 'Your message was sent successfully. Thank you for contacting us.'); }
php
public function postSubmit() { $rules = [ 'first_name' => 'required', 'last_name' => 'required', 'email' => 'required', 'message' => 'required', ]; $input = Binput::only(array_keys($rules)); $val = Validator::make($input, $rules); if ($val->fails()) { return Redirect::to($this->path)->withInput()->withErrors($val); } $this->throttler->hit(); Mailer::send($input['first_name'], $input['last_name'], $input['email'], $input['message']); return Redirect::to('/')->with('success', 'Your message was sent successfully. Thank you for contacting us.'); }
[ "public", "function", "postSubmit", "(", ")", "{", "$", "rules", "=", "[", "'first_name'", "=>", "'required'", ",", "'last_name'", "=>", "'required'", ",", "'email'", "=>", "'required'", ",", "'message'", "=>", "'required'", ",", "]", ";", "$", "input", "=...
Submit the contact form. @return \Illuminate\Http\Response
[ "Submit", "the", "contact", "form", "." ]
299cc7f8a724348406a030ca138d9e25b49c4337
https://github.com/BootstrapCMS/Contact/blob/299cc7f8a724348406a030ca138d9e25b49c4337/src/Http/Controllers/ContactController.php#L63-L85
train
wangxian/ephp
src/Email/Email.php
PHPMailer.EncodeString
public function EncodeString($str, $encoding = 'base64') { $encoded = ''; switch (strtolower($encoding)) { case 'base64': $encoded = chunk_split(base64_encode($str), 76, $this->LE); break; case '7bit': case '8bit': $encoded = $this->FixEOL($str); //Make sure it ends with a line break if (substr($encoded, -(strlen($this->LE))) != $this->LE) { $encoded .= $this->LE; } break; case 'binary': $encoded = $str; break; case 'quoted-printable': $encoded = $this->EncodeQP($str); break; default: $this->SetError($this->Lang('encoding') . $encoding); break; } return $encoded; }
php
public function EncodeString($str, $encoding = 'base64') { $encoded = ''; switch (strtolower($encoding)) { case 'base64': $encoded = chunk_split(base64_encode($str), 76, $this->LE); break; case '7bit': case '8bit': $encoded = $this->FixEOL($str); //Make sure it ends with a line break if (substr($encoded, -(strlen($this->LE))) != $this->LE) { $encoded .= $this->LE; } break; case 'binary': $encoded = $str; break; case 'quoted-printable': $encoded = $this->EncodeQP($str); break; default: $this->SetError($this->Lang('encoding') . $encoding); break; } return $encoded; }
[ "public", "function", "EncodeString", "(", "$", "str", ",", "$", "encoding", "=", "'base64'", ")", "{", "$", "encoded", "=", "''", ";", "switch", "(", "strtolower", "(", "$", "encoding", ")", ")", "{", "case", "'base64'", ":", "$", "encoded", "=", "c...
Encodes string to requested format. Returns an empty string on failure. @param string $str The text to encode @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' @access public @return string
[ "Encodes", "string", "to", "requested", "format", ".", "Returns", "an", "empty", "string", "on", "failure", "." ]
697248ab098d8dc352de31ab0c64ea0fee1d7132
https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Email/Email.php#L1384-L1411
train
wangxian/ephp
src/Email/Email.php
PHPMailer._mime_types
public static function _mime_types($ext = '') { $mimes = array( 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/macbinary', 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'class' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'so' => 'application/octet-stream', 'sea' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'gtar' => 'application/x-gtar', 'php' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'js' => 'application/x-javascript', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', 'tgz' => 'application/x-tar', 'xhtml' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml', 'zip' => 'application/zip', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mpga' => 'audio/mpeg', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'rv' => 'video/vnd.rn-realvideo', 'wav' => 'audio/x-wav', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html', 'txt' => 'text/plain', 'text' => 'text/plain', 'log' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'xml' => 'text/xml', 'xsl' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'doc' => 'application/msword', 'word' => 'application/msword', 'xl' => 'application/excel', 'eml' => 'message/rfc822', ); return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; }
php
public static function _mime_types($ext = '') { $mimes = array( 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/macbinary', 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'class' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'so' => 'application/octet-stream', 'sea' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'gtar' => 'application/x-gtar', 'php' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'js' => 'application/x-javascript', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', 'tgz' => 'application/x-tar', 'xhtml' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml', 'zip' => 'application/zip', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mpga' => 'audio/mpeg', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'rv' => 'video/vnd.rn-realvideo', 'wav' => 'audio/x-wav', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html', 'txt' => 'text/plain', 'text' => 'text/plain', 'log' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'xml' => 'text/xml', 'xsl' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'doc' => 'application/msword', 'word' => 'application/msword', 'xl' => 'application/excel', 'eml' => 'message/rfc822', ); return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; }
[ "public", "static", "function", "_mime_types", "(", "$", "ext", "=", "''", ")", "{", "$", "mimes", "=", "array", "(", "'hqx'", "=>", "'application/mac-binhex40'", ",", "'cpt'", "=>", "'application/mac-compactpro'", ",", "'doc'", "=>", "'application/msword'", ","...
Gets the MIME type of the embedded or inline image @param string File extension @access public @return string MIME type of ext @static
[ "Gets", "the", "MIME", "type", "of", "the", "embedded", "or", "inline", "image" ]
697248ab098d8dc352de31ab0c64ea0fee1d7132
https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Email/Email.php#L1969-L2061
train
wangxian/ephp
src/Email/Email.php
SMTP.StartTLS
public function StartTLS() { $this->error = null; # to avoid confusion if (!$this->connected()) { $this->error = array("error" => "Called StartTLS() without being connected"); return false; } fputs($this->smtp_conn, "STARTTLS" . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply, 0, 3); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; } if ($code != 220) { $this->error = array("error" => "STARTTLS not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply, 4)); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } // Begin encrypted connection if (!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { return false; } return true; }
php
public function StartTLS() { $this->error = null; # to avoid confusion if (!$this->connected()) { $this->error = array("error" => "Called StartTLS() without being connected"); return false; } fputs($this->smtp_conn, "STARTTLS" . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply, 0, 3); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; } if ($code != 220) { $this->error = array("error" => "STARTTLS not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply, 4)); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } // Begin encrypted connection if (!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { return false; } return true; }
[ "public", "function", "StartTLS", "(", ")", "{", "$", "this", "->", "error", "=", "null", ";", "# to avoid confusion", "if", "(", "!", "$", "this", "->", "connected", "(", ")", ")", "{", "$", "this", "->", "error", "=", "array", "(", "\"error\"", "=>...
Initiate a TLS communication with the server. SMTP CODE 220 Ready to start TLS SMTP CODE 501 Syntax error (no parameters allowed) SMTP CODE 454 TLS not available due to temporary reason @access public @return bool success
[ "Initiate", "a", "TLS", "communication", "with", "the", "server", "." ]
697248ab098d8dc352de31ab0c64ea0fee1d7132
https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Email/Email.php#L2256-L2291
train
wangxian/ephp
src/Email/Email.php
SMTP.Close
public function Close() { $this->error = null; // so there is no confusion $this->helo_rply = null; if (!empty($this->smtp_conn)) { // close the connection and cleanup fclose($this->smtp_conn); $this->smtp_conn = 0; } }
php
public function Close() { $this->error = null; // so there is no confusion $this->helo_rply = null; if (!empty($this->smtp_conn)) { // close the connection and cleanup fclose($this->smtp_conn); $this->smtp_conn = 0; } }
[ "public", "function", "Close", "(", ")", "{", "$", "this", "->", "error", "=", "null", ";", "// so there is no confusion", "$", "this", "->", "helo_rply", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "smtp_conn", ")", ")", "{", ...
Closes the socket and cleans up the state of the class. It is not considered good to use this function without first trying to use QUIT. @access public @return void
[ "Closes", "the", "socket", "and", "cleans", "up", "the", "state", "of", "the", "class", ".", "It", "is", "not", "considered", "good", "to", "use", "this", "function", "without", "first", "trying", "to", "use", "QUIT", "." ]
697248ab098d8dc352de31ab0c64ea0fee1d7132
https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Email/Email.php#L2384-L2393
train
mikemirten/JsonApi
src/Mapper/Definition/AnnotationProcessor/AbstractProcessor.php
AbstractProcessor.registerAnnotations
static protected function registerAnnotations() { if (self::$annotationsRegistered === false) { AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/ResourceIdentifier.php'); AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/Relationship.php'); AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/Attribute.php'); AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/Link.php'); self::$annotationsRegistered = true; } }
php
static protected function registerAnnotations() { if (self::$annotationsRegistered === false) { AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/ResourceIdentifier.php'); AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/Relationship.php'); AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/Attribute.php'); AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/Link.php'); self::$annotationsRegistered = true; } }
[ "static", "protected", "function", "registerAnnotations", "(", ")", "{", "if", "(", "self", "::", "$", "annotationsRegistered", "===", "false", ")", "{", "AnnotationRegistry", "::", "registerFile", "(", "__DIR__", ".", "'/../Annotation/ResourceIdentifier.php'", ")", ...
Register annotation classes. Supports a medieval-aged way of "autoloading" for the Doctrine Annotation library.
[ "Register", "annotation", "classes", ".", "Supports", "a", "medieval", "-", "aged", "way", "of", "autoloading", "for", "the", "Doctrine", "Annotation", "library", "." ]
a3c1baf8f753c040f24e4522495b7d34565e6560
https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/AbstractProcessor.php#L54-L64
train
mikemirten/JsonApi
src/Mapper/Definition/AnnotationProcessor/AbstractProcessor.php
AbstractProcessor.createLink
protected function createLink(LinkAnnotation $annotation): Link { if (! preg_match(self::RESOURCE_PATTERN, $annotation->resource, $matches)) { throw new \LogicException(sprintf('Invalid resource definition: "%s"', $annotation->resource)); } $link = new Link( $annotation->name, $matches['repository'], $matches['link'] ); $link->setParameters($annotation->parameters); $link->setMetadata($annotation->metadata); return $link; }
php
protected function createLink(LinkAnnotation $annotation): Link { if (! preg_match(self::RESOURCE_PATTERN, $annotation->resource, $matches)) { throw new \LogicException(sprintf('Invalid resource definition: "%s"', $annotation->resource)); } $link = new Link( $annotation->name, $matches['repository'], $matches['link'] ); $link->setParameters($annotation->parameters); $link->setMetadata($annotation->metadata); return $link; }
[ "protected", "function", "createLink", "(", "LinkAnnotation", "$", "annotation", ")", ":", "Link", "{", "if", "(", "!", "preg_match", "(", "self", "::", "RESOURCE_PATTERN", ",", "$", "annotation", "->", "resource", ",", "$", "matches", ")", ")", "{", "thro...
Create link by link's annotation @param LinkAnnotation $annotation @return Link
[ "Create", "link", "by", "link", "s", "annotation" ]
a3c1baf8f753c040f24e4522495b7d34565e6560
https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/AbstractProcessor.php#L72-L88
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidLocalClass
public function isValidLocalClass() { $className = SPLASH_CLASS_PREFIX.'\\Local'; //====================================================================// // Verify Results in Cache if (isset($this->ValidLocalClass[$className])) { return $this->ValidLocalClass[$className]; } $this->ValidLocalClass[$className] = false; //====================================================================// // Verify Splash Local Core Class Exists if (false == class_exists($className)) { return Splash::log()->err(Splash::trans('ErrLocalClass', $className)); } //====================================================================// // Verify Splash Local Core Extends LocalClassInterface try { $class = new $className(); if (!($class instanceof LocalClassInterface)) { return Splash::log()->err(Splash::trans('ErrLocalInterface', $className, LocalClassInterface::class)); } } catch (Exception $exc) { echo $exc->getMessage(); return Splash::log()->err($exc->getMessage()); } $this->ValidLocalClass[$className] = true; return $this->ValidLocalClass[$className]; }
php
public function isValidLocalClass() { $className = SPLASH_CLASS_PREFIX.'\\Local'; //====================================================================// // Verify Results in Cache if (isset($this->ValidLocalClass[$className])) { return $this->ValidLocalClass[$className]; } $this->ValidLocalClass[$className] = false; //====================================================================// // Verify Splash Local Core Class Exists if (false == class_exists($className)) { return Splash::log()->err(Splash::trans('ErrLocalClass', $className)); } //====================================================================// // Verify Splash Local Core Extends LocalClassInterface try { $class = new $className(); if (!($class instanceof LocalClassInterface)) { return Splash::log()->err(Splash::trans('ErrLocalInterface', $className, LocalClassInterface::class)); } } catch (Exception $exc) { echo $exc->getMessage(); return Splash::log()->err($exc->getMessage()); } $this->ValidLocalClass[$className] = true; return $this->ValidLocalClass[$className]; }
[ "public", "function", "isValidLocalClass", "(", ")", "{", "$", "className", "=", "SPLASH_CLASS_PREFIX", ".", "'\\\\Local'", ";", "//====================================================================//", "// Verify Results in Cache", "if", "(", "isset", "(", "$", "this", "...
Verify Local Core Class Exists & Is Valid @return bool
[ "Verify", "Local", "Core", "Class", "Exists", "&", "Is", "Valid" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L58-L91
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidLocalParameterArray
public function isValidLocalParameterArray($input) { //====================================================================// // Verify Array Given if (!is_array($input)) { return Splash::log()->err(Splash::trans('ErrorCfgNotAnArray', get_class($input))); } //====================================================================// // Required Parameters are Available //====================================================================// if (!array_key_exists('WsIdentifier', $input)) { return Splash::log()->err(Splash::trans('ErrWsNoId')); } if (!array_key_exists('WsEncryptionKey', $input)) { return Splash::log()->err(Splash::trans('ErrWsNoKey')); } return true; }
php
public function isValidLocalParameterArray($input) { //====================================================================// // Verify Array Given if (!is_array($input)) { return Splash::log()->err(Splash::trans('ErrorCfgNotAnArray', get_class($input))); } //====================================================================// // Required Parameters are Available //====================================================================// if (!array_key_exists('WsIdentifier', $input)) { return Splash::log()->err(Splash::trans('ErrWsNoId')); } if (!array_key_exists('WsEncryptionKey', $input)) { return Splash::log()->err(Splash::trans('ErrWsNoKey')); } return true; }
[ "public", "function", "isValidLocalParameterArray", "(", "$", "input", ")", "{", "//====================================================================//", "// Verify Array Given", "if", "(", "!", "is_array", "(", "$", "input", ")", ")", "{", "return", "Splash", "::", ...
Verify Local Core Parameters are Valid @param mixed $input @return bool
[ "Verify", "Local", "Core", "Parameters", "are", "Valid" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L100-L120
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidServerInfos
public function isValidServerInfos() { $infos = Splash::ws()->getServerInfos(); //====================================================================// // Verify Array Given if (!is_a($infos, 'ArrayObject')) { return Splash::log()->err(Splash::trans('ErrInfosNotArrayObject', get_class($infos))); } if (defined('SPLASH_DEBUG') && !empty(SPLASH_DEBUG)) { Splash::log()->war('Host : '.$infos['ServerHost']); Splash::log()->war('Path : '.$infos['ServerPath']); } //====================================================================// // Required Parameters are Available //====================================================================// if (!isset($infos['ServerHost']) || empty($infos['ServerHost'])) { Splash::log()->err(Splash::trans('ErrEmptyServerHost')); return Splash::log()->err(Splash::trans('ErrEmptyServerHostDesc')); } if (!isset($infos['ServerPath']) || empty($infos['ServerPath'])) { Splash::log()->err(Splash::trans('ErrEmptyServerPath')); return Splash::log()->err(Splash::trans('ErrEmptyServerPathDesc')); } //====================================================================// // Detect Local Installations //====================================================================// $this->isLocalInstallation($infos); return true; }
php
public function isValidServerInfos() { $infos = Splash::ws()->getServerInfos(); //====================================================================// // Verify Array Given if (!is_a($infos, 'ArrayObject')) { return Splash::log()->err(Splash::trans('ErrInfosNotArrayObject', get_class($infos))); } if (defined('SPLASH_DEBUG') && !empty(SPLASH_DEBUG)) { Splash::log()->war('Host : '.$infos['ServerHost']); Splash::log()->war('Path : '.$infos['ServerPath']); } //====================================================================// // Required Parameters are Available //====================================================================// if (!isset($infos['ServerHost']) || empty($infos['ServerHost'])) { Splash::log()->err(Splash::trans('ErrEmptyServerHost')); return Splash::log()->err(Splash::trans('ErrEmptyServerHostDesc')); } if (!isset($infos['ServerPath']) || empty($infos['ServerPath'])) { Splash::log()->err(Splash::trans('ErrEmptyServerPath')); return Splash::log()->err(Splash::trans('ErrEmptyServerPathDesc')); } //====================================================================// // Detect Local Installations //====================================================================// $this->isLocalInstallation($infos); return true; }
[ "public", "function", "isValidServerInfos", "(", ")", "{", "$", "infos", "=", "Splash", "::", "ws", "(", ")", "->", "getServerInfos", "(", ")", ";", "//====================================================================//", "// Verify Array Given", "if", "(", "!", "i...
Verify Webserver Informations are Valid @return bool
[ "Verify", "Webserver", "Informations", "are", "Valid" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L145-L181
train
SplashSync/Php-Core
Components/Validator.php
Validator.isLocalInstallation
public function isLocalInstallation($infos) { if (false !== strpos($infos['ServerHost'], 'localhost')) { Splash::log()->war(Splash::trans('WarIsLocalhostServer')); } elseif (false !== strpos($infos['ServerIP'], '127.0.0.1')) { Splash::log()->war(Splash::trans('WarIsLocalhostServer')); } if ('https' === Splash::input('REQUEST_SCHEME')) { Splash::log()->war(Splash::trans('WarIsHttpsServer')); } }
php
public function isLocalInstallation($infos) { if (false !== strpos($infos['ServerHost'], 'localhost')) { Splash::log()->war(Splash::trans('WarIsLocalhostServer')); } elseif (false !== strpos($infos['ServerIP'], '127.0.0.1')) { Splash::log()->war(Splash::trans('WarIsLocalhostServer')); } if ('https' === Splash::input('REQUEST_SCHEME')) { Splash::log()->war(Splash::trans('WarIsHttpsServer')); } }
[ "public", "function", "isLocalInstallation", "(", "$", "infos", ")", "{", "if", "(", "false", "!==", "strpos", "(", "$", "infos", "[", "'ServerHost'", "]", ",", "'localhost'", ")", ")", "{", "Splash", "::", "log", "(", ")", "->", "war", "(", "Splash", ...
Verify Webserver is a LocalHost @param mixed $infos
[ "Verify", "Webserver", "is", "a", "LocalHost" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L188-L199
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidObject
public function isValidObject($objectType) { //====================================================================// // Verify Result in Cache if (isset($this->ValidLocalObject[$objectType])) { return $this->ValidLocalObject[$objectType]; } $this->ValidLocalObject[$objectType] = false; //====================================================================// // Verify Local Core Class Exist & Is Valid if (!$this->isValidLocalClass()) { return false; } //====================================================================// // Check if Object Manager is NOT Overriden if (!(Splash::local() instanceof ObjectsProviderInterface)) { //====================================================================// // Verify Object File Exist & is Valid if (!$this->isValidObjectFile($objectType)) { return false; } } //====================================================================// // Verify Object Class Exist & is Valid if (!$this->isValidObjectClass($objectType)) { return false; } $this->ValidLocalObject[$objectType] = true; return true; }
php
public function isValidObject($objectType) { //====================================================================// // Verify Result in Cache if (isset($this->ValidLocalObject[$objectType])) { return $this->ValidLocalObject[$objectType]; } $this->ValidLocalObject[$objectType] = false; //====================================================================// // Verify Local Core Class Exist & Is Valid if (!$this->isValidLocalClass()) { return false; } //====================================================================// // Check if Object Manager is NOT Overriden if (!(Splash::local() instanceof ObjectsProviderInterface)) { //====================================================================// // Verify Object File Exist & is Valid if (!$this->isValidObjectFile($objectType)) { return false; } } //====================================================================// // Verify Object Class Exist & is Valid if (!$this->isValidObjectClass($objectType)) { return false; } $this->ValidLocalObject[$objectType] = true; return true; }
[ "public", "function", "isValidObject", "(", "$", "objectType", ")", "{", "//====================================================================//", "// Verify Result in Cache", "if", "(", "isset", "(", "$", "this", "->", "ValidLocalObject", "[", "$", "objectType", "]", "...
Verify this parameter is a valid object type name @param string $objectType Object Class/Type Name @return bool
[ "Verify", "this", "parameter", "is", "a", "valid", "object", "type", "name" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L214-L247
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidObjectId
public function isValidObjectId($objectId) { //====================================================================// // Checks Id is not Null if (is_null($objectId)) { return Splash::log()->err('ErrEmptyObjectId'); } //====================================================================// // Checks Id is String or Int if (!is_string($objectId) && !is_numeric($objectId)) { return Splash::log()->err('ErrWrongObjectId'); } //====================================================================// // Checks List Not Empty if (is_numeric($objectId) && ($objectId < 0)) { return Splash::log()->err('ErrNegObjectId'); } return Splash::log()->deb('MsgObjectIdOk'); }
php
public function isValidObjectId($objectId) { //====================================================================// // Checks Id is not Null if (is_null($objectId)) { return Splash::log()->err('ErrEmptyObjectId'); } //====================================================================// // Checks Id is String or Int if (!is_string($objectId) && !is_numeric($objectId)) { return Splash::log()->err('ErrWrongObjectId'); } //====================================================================// // Checks List Not Empty if (is_numeric($objectId) && ($objectId < 0)) { return Splash::log()->err('ErrNegObjectId'); } return Splash::log()->deb('MsgObjectIdOk'); }
[ "public", "function", "isValidObjectId", "(", "$", "objectId", ")", "{", "//====================================================================//", "// Checks Id is not Null", "if", "(", "is_null", "(", "$", "objectId", ")", ")", "{", "return", "Splash", "::", "log", "...
Verify Object Identifier @param mixed $objectId Object Identifier @return bool
[ "Verify", "Object", "Identifier" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L276-L295
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidObjectFieldsList
public function isValidObjectFieldsList($fieldsList) { //====================================================================// // Checks List Type if (!is_array($fieldsList) && !($fieldsList instanceof ArrayObject)) { return Splash::log()->err('ErrWrongFieldList'); } //====================================================================// // Checks List Not Empty if (empty($fieldsList)) { return Splash::log()->err('ErrEmptyFieldList'); } return Splash::log()->deb('MsgFieldListOk'); }
php
public function isValidObjectFieldsList($fieldsList) { //====================================================================// // Checks List Type if (!is_array($fieldsList) && !($fieldsList instanceof ArrayObject)) { return Splash::log()->err('ErrWrongFieldList'); } //====================================================================// // Checks List Not Empty if (empty($fieldsList)) { return Splash::log()->err('ErrEmptyFieldList'); } return Splash::log()->deb('MsgFieldListOk'); }
[ "public", "function", "isValidObjectFieldsList", "(", "$", "fieldsList", ")", "{", "//====================================================================//", "// Checks List Type", "if", "(", "!", "is_array", "(", "$", "fieldsList", ")", "&&", "!", "(", "$", "fieldsList"...
Verify Object Field List @param null|array|ArrayObject $fieldsList Object Field List @return bool
[ "Verify", "Object", "Field", "List" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L304-L318
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidWidget
public function isValidWidget($widgetType) { //====================================================================// // Verify Result in Cache if (isset($this->ValidLocalWidget[$widgetType])) { return $this->ValidLocalWidget[$widgetType]; } $this->ValidLocalWidget[$widgetType] = false; //====================================================================// // Verify Local Core Class Exist & Is Valid if (!$this->isValidLocalClass()) { return false; } //====================================================================// // Check if Widget Manager is NOT Overriden if (!(Splash::local() instanceof WidgetsProviderInterface)) { //====================================================================// // Verify Widget File Exist & is Valid if (!$this->isValidWidgetFile($widgetType)) { return false; } } //====================================================================// // Verify Widget Class Exist & is Valid if (!$this->isValidWidgetClass($widgetType)) { return false; } $this->ValidLocalWidget[$widgetType] = true; return true; }
php
public function isValidWidget($widgetType) { //====================================================================// // Verify Result in Cache if (isset($this->ValidLocalWidget[$widgetType])) { return $this->ValidLocalWidget[$widgetType]; } $this->ValidLocalWidget[$widgetType] = false; //====================================================================// // Verify Local Core Class Exist & Is Valid if (!$this->isValidLocalClass()) { return false; } //====================================================================// // Check if Widget Manager is NOT Overriden if (!(Splash::local() instanceof WidgetsProviderInterface)) { //====================================================================// // Verify Widget File Exist & is Valid if (!$this->isValidWidgetFile($widgetType)) { return false; } } //====================================================================// // Verify Widget Class Exist & is Valid if (!$this->isValidWidgetClass($widgetType)) { return false; } $this->ValidLocalWidget[$widgetType] = true; return true; }
[ "public", "function", "isValidWidget", "(", "$", "widgetType", ")", "{", "//====================================================================//", "// Verify Result in Cache", "if", "(", "isset", "(", "$", "this", "->", "ValidLocalWidget", "[", "$", "widgetType", "]", "...
Verify this parameter is a valid widget type name @param string $widgetType Widget Class/Type Name @return bool
[ "Verify", "this", "parameter", "is", "a", "valid", "widget", "type", "name" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L333-L365
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidLocalPath
public function isValidLocalPath() { //====================================================================// // Verify no result in Cache if (!isset($this->ValidLocalPath)) { $path = Splash::getLocalPath(); //====================================================================// // Verify Local Path Exist if (is_null($path) || !is_dir($path)) { $this->ValidLocalPath = false; return Splash::log()->err(Splash::trans('ErrLocalPath', (string) $path)); } $this->ValidLocalPath = true; } return $this->ValidLocalPath; }
php
public function isValidLocalPath() { //====================================================================// // Verify no result in Cache if (!isset($this->ValidLocalPath)) { $path = Splash::getLocalPath(); //====================================================================// // Verify Local Path Exist if (is_null($path) || !is_dir($path)) { $this->ValidLocalPath = false; return Splash::log()->err(Splash::trans('ErrLocalPath', (string) $path)); } $this->ValidLocalPath = true; } return $this->ValidLocalPath; }
[ "public", "function", "isValidLocalPath", "(", ")", "{", "//====================================================================//", "// Verify no result in Cache", "if", "(", "!", "isset", "(", "$", "this", "->", "ValidLocalPath", ")", ")", "{", "$", "path", "=", "Spla...
Verify Local Path Exists @return bool
[ "Verify", "Local", "Path", "Exists" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L378-L396
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidPHPVersion
public function isValidPHPVersion() { if (version_compare(PHP_VERSION, '5.6.0') < 0) { return Splash::log()->err( 'PHP : Your PHP version is too low to use Splash ('.PHP_VERSION.'). PHP >5.6 is Requiered.' ); } return Splash::log()->msg( 'PHP : Your PHP version is compatible with Splash ('.PHP_VERSION.')' ); }
php
public function isValidPHPVersion() { if (version_compare(PHP_VERSION, '5.6.0') < 0) { return Splash::log()->err( 'PHP : Your PHP version is too low to use Splash ('.PHP_VERSION.'). PHP >5.6 is Requiered.' ); } return Splash::log()->msg( 'PHP : Your PHP version is compatible with Splash ('.PHP_VERSION.')' ); }
[ "public", "function", "isValidPHPVersion", "(", ")", "{", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.6.0'", ")", "<", "0", ")", "{", "return", "Splash", "::", "log", "(", ")", "->", "err", "(", "'PHP : Your PHP version is too low to use Splash ('...
Verify PHP Version is Compatible. @return bool
[ "Verify", "PHP", "Version", "is", "Compatible", "." ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L443-L454
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidPHPExtensions
public function isValidPHPExtensions() { $extensions = array('xml', 'soap', 'curl'); foreach ($extensions as $extension) { if (!extension_loaded($extension)) { return Splash::log()->err( 'PHP :'.$extension.' PHP Extension is required to use Splash PHP Module.' ); } } return Splash::log()->msg( 'PHP : Required PHP Extension are installed ('.implode(', ', $extensions).')' ); }
php
public function isValidPHPExtensions() { $extensions = array('xml', 'soap', 'curl'); foreach ($extensions as $extension) { if (!extension_loaded($extension)) { return Splash::log()->err( 'PHP :'.$extension.' PHP Extension is required to use Splash PHP Module.' ); } } return Splash::log()->msg( 'PHP : Required PHP Extension are installed ('.implode(', ', $extensions).')' ); }
[ "public", "function", "isValidPHPExtensions", "(", ")", "{", "$", "extensions", "=", "array", "(", "'xml'", ",", "'soap'", ",", "'curl'", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "if", "(", "!", "extension_loaded", "...
Verify PHP Required are Installed & Active @return bool
[ "Verify", "PHP", "Required", "are", "Installed", "&", "Active" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L461-L475
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidSOAPMethod
public function isValidSOAPMethod() { if (!in_array(Splash::configuration()->WsMethod, array('SOAP', 'NuSOAP'), true)) { return Splash::log()->err( 'Config : Your selected an unknown SOAP Method ('.Splash::configuration()->WsMethod.').' ); } return Splash::log()->msg( 'Config : SOAP Method is Ok ('.Splash::configuration()->WsMethod.').' ); }
php
public function isValidSOAPMethod() { if (!in_array(Splash::configuration()->WsMethod, array('SOAP', 'NuSOAP'), true)) { return Splash::log()->err( 'Config : Your selected an unknown SOAP Method ('.Splash::configuration()->WsMethod.').' ); } return Splash::log()->msg( 'Config : SOAP Method is Ok ('.Splash::configuration()->WsMethod.').' ); }
[ "public", "function", "isValidSOAPMethod", "(", ")", "{", "if", "(", "!", "in_array", "(", "Splash", "::", "configuration", "(", ")", "->", "WsMethod", ",", "array", "(", "'SOAP'", ",", "'NuSOAP'", ")", ",", "true", ")", ")", "{", "return", "Splash", "...
Verify WebService Library is Valid. @return bool
[ "Verify", "WebService", "Library", "is", "Valid", "." ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L482-L493
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidConfigurator
public function isValidConfigurator($className) { //====================================================================// // Verify Class Exists if (false == class_exists($className)) { return Splash::log()->err('Configurator Class Not Found: '.$className); } //====================================================================// // Verify Configurator Class Extends ConfiguratorInterface try { $class = new $className(); if (!($class instanceof ConfiguratorInterface)) { return Splash::log()->err(Splash::trans('ErrLocalInterface', $className, ConfiguratorInterface::class)); } } catch (Exception $exc) { echo $exc->getMessage(); return Splash::log()->err($exc->getMessage()); } return true; }
php
public function isValidConfigurator($className) { //====================================================================// // Verify Class Exists if (false == class_exists($className)) { return Splash::log()->err('Configurator Class Not Found: '.$className); } //====================================================================// // Verify Configurator Class Extends ConfiguratorInterface try { $class = new $className(); if (!($class instanceof ConfiguratorInterface)) { return Splash::log()->err(Splash::trans('ErrLocalInterface', $className, ConfiguratorInterface::class)); } } catch (Exception $exc) { echo $exc->getMessage(); return Splash::log()->err($exc->getMessage()); } return true; }
[ "public", "function", "isValidConfigurator", "(", "$", "className", ")", "{", "//====================================================================//", "// Verify Class Exists", "if", "(", "false", "==", "class_exists", "(", "$", "className", ")", ")", "{", "return", "S...
Verify Given Class Is a Valid Splash Configurator @param string $className Configurator Class Name @return bool
[ "Verify", "Given", "Class", "Is", "a", "Valid", "Splash", "Configurator" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L508-L530
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidObjectFile
private function isValidObjectFile($objectType) { //====================================================================// // Verify Local Path Exist if (false == $this->isValidLocalPath()) { return false; } //====================================================================// // Verify Object File Exist $filename = Splash::getLocalPath().'/Objects/'.$objectType.'.php'; if (false == file_exists($filename)) { $msg = 'Local Object File Not Found.</br>'; $msg .= 'Current Filename : '.$filename.''; return Splash::log()->err($msg); } return true; }
php
private function isValidObjectFile($objectType) { //====================================================================// // Verify Local Path Exist if (false == $this->isValidLocalPath()) { return false; } //====================================================================// // Verify Object File Exist $filename = Splash::getLocalPath().'/Objects/'.$objectType.'.php'; if (false == file_exists($filename)) { $msg = 'Local Object File Not Found.</br>'; $msg .= 'Current Filename : '.$filename.''; return Splash::log()->err($msg); } return true; }
[ "private", "function", "isValidObjectFile", "(", "$", "objectType", ")", "{", "//====================================================================//", "// Verify Local Path Exist", "if", "(", "false", "==", "$", "this", "->", "isValidLocalPath", "(", ")", ")", "{", "re...
Verify a Local Object File is Valid. @param string $objectType Object Type Name @return bool
[ "Verify", "a", "Local", "Object", "File", "is", "Valid", "." ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L545-L564
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidObjectClass
private function isValidObjectClass($objectType) { //====================================================================// // Check if Object Manager is Overriden if (Splash::local() instanceof ObjectsProviderInterface) { //====================================================================// // Retrieve Object Manager ClassName $className = get_class(Splash::local()->object($objectType)); } else { $className = SPLASH_CLASS_PREFIX.'\\Objects\\'.$objectType; } //====================================================================// // Verify Splash Local Core Class Exists if (false == class_exists($className)) { return Splash::log()->err(Splash::trans('ErrLocalClass', $objectType)); } //====================================================================// // Verify Local Object Core Class Functions Exists //====================================================================// //====================================================================// // Read Object Disable Flag if (false == $this->isValidLocalFunction('getIsDisabled', $className)) { return false; } if (Splash::configurator()->isDisabled($objectType, $className::getIsDisabled())) { return false; } //====================================================================// // Verify Local Object Class Implements ObjectInterface return is_subclass_of($className, ObjectInterface::class); }
php
private function isValidObjectClass($objectType) { //====================================================================// // Check if Object Manager is Overriden if (Splash::local() instanceof ObjectsProviderInterface) { //====================================================================// // Retrieve Object Manager ClassName $className = get_class(Splash::local()->object($objectType)); } else { $className = SPLASH_CLASS_PREFIX.'\\Objects\\'.$objectType; } //====================================================================// // Verify Splash Local Core Class Exists if (false == class_exists($className)) { return Splash::log()->err(Splash::trans('ErrLocalClass', $objectType)); } //====================================================================// // Verify Local Object Core Class Functions Exists //====================================================================// //====================================================================// // Read Object Disable Flag if (false == $this->isValidLocalFunction('getIsDisabled', $className)) { return false; } if (Splash::configurator()->isDisabled($objectType, $className::getIsDisabled())) { return false; } //====================================================================// // Verify Local Object Class Implements ObjectInterface return is_subclass_of($className, ObjectInterface::class); }
[ "private", "function", "isValidObjectClass", "(", "$", "objectType", ")", "{", "//====================================================================//", "// Check if Object Manager is Overriden", "if", "(", "Splash", "::", "local", "(", ")", "instanceof", "ObjectsProviderInterf...
Verify Availability of a Local Object Class. @param string $objectType Object Type Name @return bool
[ "Verify", "Availability", "of", "a", "Local", "Object", "Class", "." ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L573-L606
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidWidgetFile
private function isValidWidgetFile($widgetType) { //====================================================================// // Verify Local Path Exist if (false == $this->isValidLocalPath()) { return false; } //====================================================================// // Verify Object File Exist $filename = Splash::getLocalPath().'/Widgets/'.$widgetType.'.php'; if (false == file_exists($filename)) { $msg = 'Local Widget File Not Found.</br>'; $msg .= 'Current Filename : '.$filename.''; return Splash::log()->err($msg); } return true; }
php
private function isValidWidgetFile($widgetType) { //====================================================================// // Verify Local Path Exist if (false == $this->isValidLocalPath()) { return false; } //====================================================================// // Verify Object File Exist $filename = Splash::getLocalPath().'/Widgets/'.$widgetType.'.php'; if (false == file_exists($filename)) { $msg = 'Local Widget File Not Found.</br>'; $msg .= 'Current Filename : '.$filename.''; return Splash::log()->err($msg); } return true; }
[ "private", "function", "isValidWidgetFile", "(", "$", "widgetType", ")", "{", "//====================================================================//", "// Verify Local Path Exist", "if", "(", "false", "==", "$", "this", "->", "isValidLocalPath", "(", ")", ")", "{", "re...
Verify a Local Widget File is Valid. @param string $widgetType Widget Type Name @return bool
[ "Verify", "a", "Local", "Widget", "File", "is", "Valid", "." ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L615-L633
train
SplashSync/Php-Core
Components/Validator.php
Validator.isValidWidgetClass
private function isValidWidgetClass($widgetType) { //====================================================================// // Check if Widget Manager is Overriden if (Splash::local() instanceof WidgetsProviderInterface) { //====================================================================// // Retrieve Widget Manager ClassName $className = get_class(Splash::local()->widget($widgetType)); } else { $className = SPLASH_CLASS_PREFIX.'\\Widgets\\'.$widgetType; } //====================================================================// // Verify Splash Local Core Class Exists if (false == class_exists($className)) { return Splash::log()->err(Splash::trans('ErrLocalClass', $widgetType)); } //====================================================================// // Verify Local Widget Core Class Functions Exists //====================================================================// //====================================================================// // Read Object Disable Flag if (false == $this->isValidLocalFunction('getIsDisabled', $className)) { $this->ValidLocalWidget[$widgetType] = false; return false; } if ($className::getIsDisabled()) { $this->ValidLocalWidget[$widgetType] = false; return false; } //====================================================================// // Verify Local Object Class Implements WidgetInterface return is_subclass_of($className, WidgetInterface::class); }
php
private function isValidWidgetClass($widgetType) { //====================================================================// // Check if Widget Manager is Overriden if (Splash::local() instanceof WidgetsProviderInterface) { //====================================================================// // Retrieve Widget Manager ClassName $className = get_class(Splash::local()->widget($widgetType)); } else { $className = SPLASH_CLASS_PREFIX.'\\Widgets\\'.$widgetType; } //====================================================================// // Verify Splash Local Core Class Exists if (false == class_exists($className)) { return Splash::log()->err(Splash::trans('ErrLocalClass', $widgetType)); } //====================================================================// // Verify Local Widget Core Class Functions Exists //====================================================================// //====================================================================// // Read Object Disable Flag if (false == $this->isValidLocalFunction('getIsDisabled', $className)) { $this->ValidLocalWidget[$widgetType] = false; return false; } if ($className::getIsDisabled()) { $this->ValidLocalWidget[$widgetType] = false; return false; } //====================================================================// // Verify Local Object Class Implements WidgetInterface return is_subclass_of($className, WidgetInterface::class); }
[ "private", "function", "isValidWidgetClass", "(", "$", "widgetType", ")", "{", "//====================================================================//", "// Check if Widget Manager is Overriden", "if", "(", "Splash", "::", "local", "(", ")", "instanceof", "WidgetsProviderInterf...
Verify Availability of a Local Widget Class. @param string $widgetType Widget Type Name @return bool
[ "Verify", "Availability", "of", "a", "Local", "Widget", "Class", "." ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Validator.php#L642-L680
train
payneteasy/php-library-payneteasy-api
source/PaynetEasy/PaynetEasyApi/Callback/CallbackFactory.php
CallbackFactory.instantiateCallback
protected function instantiateCallback($callbackClass, $callbackType) { if (!is_a($callbackClass, static::$callbackInterface, true)) { throw new RuntimeException("Callback class '{$callbackClass}' does not implements '" . static::$callbackInterface . "' interface."); } return new $callbackClass($callbackType); }
php
protected function instantiateCallback($callbackClass, $callbackType) { if (!is_a($callbackClass, static::$callbackInterface, true)) { throw new RuntimeException("Callback class '{$callbackClass}' does not implements '" . static::$callbackInterface . "' interface."); } return new $callbackClass($callbackType); }
[ "protected", "function", "instantiateCallback", "(", "$", "callbackClass", ",", "$", "callbackType", ")", "{", "if", "(", "!", "is_a", "(", "$", "callbackClass", ",", "static", "::", "$", "callbackInterface", ",", "true", ")", ")", "{", "throw", "new", "Ru...
Method check callback class and return new callback object @param string $callbackClass Callback class @param string $callbackType Callback type @return CallbackInterface New callback object @throws RuntimeException Callback does not implements CallbackInterface
[ "Method", "check", "callback", "class", "and", "return", "new", "callback", "object" ]
e3484aa37b6594231f59b1f43523603aa704f093
https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Callback/CallbackFactory.php#L59-L68
train
mapbender/data-source
Component/Drivers/PostgreSQL.php
PostgreSQL.getTableGeomType
public function getTableGeomType($tableName, $schema = null) { $connection = $this->connection; if (strpos($tableName, '.')) { list($schema, $tableName) = explode('.', $tableName); } $_schema = $schema ? $connection->quote($schema) : 'current_schema()'; $type = $connection->query("SELECT \"type\" FROM geometry_columns WHERE f_table_schema = " . $_schema . " AND f_table_name = " . $connection->quote($tableName))->fetchColumn(); return $type; }
php
public function getTableGeomType($tableName, $schema = null) { $connection = $this->connection; if (strpos($tableName, '.')) { list($schema, $tableName) = explode('.', $tableName); } $_schema = $schema ? $connection->quote($schema) : 'current_schema()'; $type = $connection->query("SELECT \"type\" FROM geometry_columns WHERE f_table_schema = " . $_schema . " AND f_table_name = " . $connection->quote($tableName))->fetchColumn(); return $type; }
[ "public", "function", "getTableGeomType", "(", "$", "tableName", ",", "$", "schema", "=", "null", ")", "{", "$", "connection", "=", "$", "this", "->", "connection", ";", "if", "(", "strpos", "(", "$", "tableName", ",", "'.'", ")", ")", "{", "list", "...
Get table geom type @param string $tableName Table name. The name can contains schema name splited by dot. @param string $schema @return string @throws \Doctrine\DBAL\DBALException
[ "Get", "table", "geom", "type" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/Drivers/PostgreSQL.php#L137-L149
train
mapbender/data-source
Component/Drivers/PostgreSQL.php
PostgreSQL.getLastInsertId
public function getLastInsertId() { $connection = $this->getConnection(); $id = $connection->lastInsertId(); if ($id < 1) { $fullTableName = $this->tableName; $fullUniqueIdName = $connection->quoteIdentifier($this->getUniqueId()); $sql = /** @lang PostgreSQL */ "SELECT $fullUniqueIdName FROM $fullTableName LIMIT 1 OFFSET (SELECT count($fullUniqueIdName)-1 FROM $fullTableName )"; $id = $connection->fetchColumn($sql); } return $id; }
php
public function getLastInsertId() { $connection = $this->getConnection(); $id = $connection->lastInsertId(); if ($id < 1) { $fullTableName = $this->tableName; $fullUniqueIdName = $connection->quoteIdentifier($this->getUniqueId()); $sql = /** @lang PostgreSQL */ "SELECT $fullUniqueIdName FROM $fullTableName LIMIT 1 OFFSET (SELECT count($fullUniqueIdName)-1 FROM $fullTableName )"; $id = $connection->fetchColumn($sql); } return $id; }
[ "public", "function", "getLastInsertId", "(", ")", "{", "$", "connection", "=", "$", "this", "->", "getConnection", "(", ")", ";", "$", "id", "=", "$", "connection", "->", "lastInsertId", "(", ")", ";", "if", "(", "$", "id", "<", "1", ")", "{", "$"...
Get last insert id @return int
[ "Get", "last", "insert", "id" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/Drivers/PostgreSQL.php#L156-L172
train
mapbender/data-source
Component/Drivers/PostgreSQL.php
PostgreSQL.getNodeFromGeom
public function getNodeFromGeom($waysVerticesTableName, $waysGeomFieldName, $ewkt, $transformTo = null, $idKey = "id") { $db = $this->getConnection(); $geom = "ST_GeometryFromText('" . $db->quote($ewkt) . "')"; if ($transformTo) { $geom = "ST_TRANSFORM($geom, $transformTo)"; } return $db->fetchColumn(/** @lang PostgreSQL */ "SELECT {$db->quoteIdentifier($idKey)}, ST_Distance({$db->quoteIdentifier($waysGeomFieldName)}, $geom) AS distance FROM {$db->quoteIdentifier($waysVerticesTableName)} ORDER BY distance ASC LIMIT 1"); }
php
public function getNodeFromGeom($waysVerticesTableName, $waysGeomFieldName, $ewkt, $transformTo = null, $idKey = "id") { $db = $this->getConnection(); $geom = "ST_GeometryFromText('" . $db->quote($ewkt) . "')"; if ($transformTo) { $geom = "ST_TRANSFORM($geom, $transformTo)"; } return $db->fetchColumn(/** @lang PostgreSQL */ "SELECT {$db->quoteIdentifier($idKey)}, ST_Distance({$db->quoteIdentifier($waysGeomFieldName)}, $geom) AS distance FROM {$db->quoteIdentifier($waysVerticesTableName)} ORDER BY distance ASC LIMIT 1"); }
[ "public", "function", "getNodeFromGeom", "(", "$", "waysVerticesTableName", ",", "$", "waysGeomFieldName", ",", "$", "ewkt", ",", "$", "transformTo", "=", "null", ",", "$", "idKey", "=", "\"id\"", ")", "{", "$", "db", "=", "$", "this", "->", "getConnection...
Get nearest node to given geometry Important: <-> operator works not well!! @param $waysVerticesTableName @param $waysGeomFieldName @param string $ewkt EWKT @param null $transformTo @param string $idKey @return int Node ID
[ "Get", "nearest", "node", "to", "given", "geometry" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/Drivers/PostgreSQL.php#L186-L204
train
mapbender/data-source
Component/Drivers/PostgreSQL.php
PostgreSQL.routeBetweenNodes
public function routeBetweenNodes( $waysTableName, $waysGeomFieldName, $startNodeId, $endNodeId, $srid, $directedGraph = false, $hasReverseCost = false) { /** @var Connection $db */ $db = $this->getConnection(); $waysTableName = $db->quoteIdentifier($waysTableName); $geomFieldName = $db->quoteIdentifier($waysGeomFieldName); $directedGraph = $directedGraph ? 'TRUE' : 'FALSE'; // directed graph [true|false] $hasReverseCost = $hasReverseCost && $directedGraph ? 'TRUE' : 'FALSE'; // directed graph [true|false] $results = $db->query("SELECT route.seq as orderId, route.id1 as startNodeId, route.id2 as endNodeId, route.cost as distance, ST_AsEWKT ($waysTableName.$geomFieldName) AS geom FROM pgr_dijkstra ( 'SELECT gid AS id, source, target, length AS cost FROM $waysTableName', $startNodeId, $endNodeId, $directedGraph, $hasReverseCost ) AS route LEFT JOIN $waysTableName ON route.id2 = $waysTableName.gid")->fetchAll(); return $this->prepareResults($results, $srid); }
php
public function routeBetweenNodes( $waysTableName, $waysGeomFieldName, $startNodeId, $endNodeId, $srid, $directedGraph = false, $hasReverseCost = false) { /** @var Connection $db */ $db = $this->getConnection(); $waysTableName = $db->quoteIdentifier($waysTableName); $geomFieldName = $db->quoteIdentifier($waysGeomFieldName); $directedGraph = $directedGraph ? 'TRUE' : 'FALSE'; // directed graph [true|false] $hasReverseCost = $hasReverseCost && $directedGraph ? 'TRUE' : 'FALSE'; // directed graph [true|false] $results = $db->query("SELECT route.seq as orderId, route.id1 as startNodeId, route.id2 as endNodeId, route.cost as distance, ST_AsEWKT ($waysTableName.$geomFieldName) AS geom FROM pgr_dijkstra ( 'SELECT gid AS id, source, target, length AS cost FROM $waysTableName', $startNodeId, $endNodeId, $directedGraph, $hasReverseCost ) AS route LEFT JOIN $waysTableName ON route.id2 = $waysTableName.gid")->fetchAll(); return $this->prepareResults($results, $srid); }
[ "public", "function", "routeBetweenNodes", "(", "$", "waysTableName", ",", "$", "waysGeomFieldName", ",", "$", "startNodeId", ",", "$", "endNodeId", ",", "$", "srid", ",", "$", "directedGraph", "=", "false", ",", "$", "hasReverseCost", "=", "false", ")", "{"...
Route between nodes @param $waysTableName @param $waysGeomFieldName @param int $startNodeId @param int $endNodeId @param $srid @param bool $directedGraph directed graph @param bool $hasReverseCost Has reverse cost, only can be true, if directed graph=true @return \Mapbender\DataSourceBundle\Entity\Feature[]
[ "Route", "between", "nodes" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/Drivers/PostgreSQL.php#L218-L249
train
katsana/katsana-sdk-php
src/One/Insurer.php
Insurer.all
public function all(string $country = 'MY', ?Query $query = null): Response { return $this->send( 'GET', "insurer/{$country}", $this->getApiHeaders(), $this->buildHttpQuery($query) ); }
php
public function all(string $country = 'MY', ?Query $query = null): Response { return $this->send( 'GET', "insurer/{$country}", $this->getApiHeaders(), $this->buildHttpQuery($query) ); }
[ "public", "function", "all", "(", "string", "$", "country", "=", "'MY'", ",", "?", "Query", "$", "query", "=", "null", ")", ":", "Response", "{", "return", "$", "this", "->", "send", "(", "'GET'", ",", "\"insurer/{$country}\"", ",", "$", "this", "->", ...
Get all available insurer by country. @param string $country @param \Katsana\Sdk\Query|null $query @return \Laravie\Codex\Contracts\Response
[ "Get", "all", "available", "insurer", "by", "country", "." ]
3266401639acd31c8f8cc0dea348085e3c59cb4d
https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/One/Insurer.php#L18-L23
train
mapbender/data-source
Component/FeatureType.php
FeatureType.getById
public function getById($id, $srid = null) { $rows = $this->getSelectQueryBuilder($srid) ->where($this->getUniqueId() . " = :id") ->setParameter('id', $id) ->execute() ->fetchAll(); $this->prepareResults($rows, $srid); return reset($rows); }
php
public function getById($id, $srid = null) { $rows = $this->getSelectQueryBuilder($srid) ->where($this->getUniqueId() . " = :id") ->setParameter('id', $id) ->execute() ->fetchAll(); $this->prepareResults($rows, $srid); return reset($rows); }
[ "public", "function", "getById", "(", "$", "id", ",", "$", "srid", "=", "null", ")", "{", "$", "rows", "=", "$", "this", "->", "getSelectQueryBuilder", "(", "$", "srid", ")", "->", "where", "(", "$", "this", "->", "getUniqueId", "(", ")", ".", "\" ...
Get feature by ID and SRID @param int $id @param int $srid SRID @return Feature
[ "Get", "feature", "by", "ID", "and", "SRID" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L154-L163
train
mapbender/data-source
Component/FeatureType.php
FeatureType.search
public function search(array $criteria = array()) { /** @var Statement $statement */ /** @var Feature $feature */ $maxResults = isset($criteria['maxResults']) ? intval($criteria['maxResults']) : self::MAX_RESULTS; $intersect = isset($criteria['intersectGeometry']) ? $criteria['intersectGeometry'] : null; $returnType = isset($criteria['returnType']) ? $criteria['returnType'] : null; $srid = isset($criteria['srid']) ? $criteria['srid'] : $this->getSrid(); $where = isset($criteria['where']) ? $criteria['where'] : null; $queryBuilder = $this->getSelectQueryBuilder($srid); $connection = $queryBuilder->getConnection(); $whereConditions = array(); // add GEOM where condition if ($intersect) { $geometry = BaseDriver::roundGeometry($intersect, 2); $whereConditions[] = $this->getDriver()->getIntersectCondition($geometry, $this->geomField, $srid, $this->getSrid()); } // add filter (https://trac.wheregroup.com/cp/issues/3733) if (!empty($this->sqlFilter)) { $securityContext = $this->container->get("security.context"); $user = $securityContext->getUser(); $sqlFilter = strtr($this->sqlFilter, array( ':userName' => $user->getUsername() )); $whereConditions[] = $sqlFilter; } // add second filter (https://trac.wheregroup.com/cp/issues/4643) if ($where) { $whereConditions[] = $where; } if (isset($criteria["source"]) && isset($criteria["distance"])) { $whereConditions[] = "ST_DWithin(t." . $this->getGeomField() . "," . $connection->quote($criteria["source"]) . "," . $criteria['distance'] . ')'; } if (count($whereConditions)) { $queryBuilder->where(join(" AND ", $whereConditions)); } $queryBuilder->setMaxResults($maxResults); // $queryBuilder->setParameters($params); // $sql = $queryBuilder->getSQL(); $statement = $queryBuilder->execute(); $rows = $statement->fetchAll(); $hasResults = count($rows) > 0; // Convert to Feature object if ($hasResults) { $this->prepareResults($rows, $srid); } if ($returnType == "FeatureCollection") { $rows = $this->toFeatureCollection($rows); } return $rows; }
php
public function search(array $criteria = array()) { /** @var Statement $statement */ /** @var Feature $feature */ $maxResults = isset($criteria['maxResults']) ? intval($criteria['maxResults']) : self::MAX_RESULTS; $intersect = isset($criteria['intersectGeometry']) ? $criteria['intersectGeometry'] : null; $returnType = isset($criteria['returnType']) ? $criteria['returnType'] : null; $srid = isset($criteria['srid']) ? $criteria['srid'] : $this->getSrid(); $where = isset($criteria['where']) ? $criteria['where'] : null; $queryBuilder = $this->getSelectQueryBuilder($srid); $connection = $queryBuilder->getConnection(); $whereConditions = array(); // add GEOM where condition if ($intersect) { $geometry = BaseDriver::roundGeometry($intersect, 2); $whereConditions[] = $this->getDriver()->getIntersectCondition($geometry, $this->geomField, $srid, $this->getSrid()); } // add filter (https://trac.wheregroup.com/cp/issues/3733) if (!empty($this->sqlFilter)) { $securityContext = $this->container->get("security.context"); $user = $securityContext->getUser(); $sqlFilter = strtr($this->sqlFilter, array( ':userName' => $user->getUsername() )); $whereConditions[] = $sqlFilter; } // add second filter (https://trac.wheregroup.com/cp/issues/4643) if ($where) { $whereConditions[] = $where; } if (isset($criteria["source"]) && isset($criteria["distance"])) { $whereConditions[] = "ST_DWithin(t." . $this->getGeomField() . "," . $connection->quote($criteria["source"]) . "," . $criteria['distance'] . ')'; } if (count($whereConditions)) { $queryBuilder->where(join(" AND ", $whereConditions)); } $queryBuilder->setMaxResults($maxResults); // $queryBuilder->setParameters($params); // $sql = $queryBuilder->getSQL(); $statement = $queryBuilder->execute(); $rows = $statement->fetchAll(); $hasResults = count($rows) > 0; // Convert to Feature object if ($hasResults) { $this->prepareResults($rows, $srid); } if ($returnType == "FeatureCollection") { $rows = $this->toFeatureCollection($rows); } return $rows; }
[ "public", "function", "search", "(", "array", "$", "criteria", "=", "array", "(", ")", ")", "{", "/** @var Statement $statement */", "/** @var Feature $feature */", "$", "maxResults", "=", "isset", "(", "$", "criteria", "[", "'maxResults'", "]", ")", "?", "intva...
Search feature by criteria @param array $criteria @return Feature[]
[ "Search", "feature", "by", "criteria" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L323-L388
train
mapbender/data-source
Component/FeatureType.php
FeatureType.getTableSequenceName
public function getTableSequenceName() { $connection = $this->getConnection(); $result = $connection->fetchColumn("SELECT column_default from information_schema.columns where table_name='" . $this->getTableName() . "' and column_name='" . $this->getUniqueId() . "'"); $result = explode("'", $result); return $result[0]; }
php
public function getTableSequenceName() { $connection = $this->getConnection(); $result = $connection->fetchColumn("SELECT column_default from information_schema.columns where table_name='" . $this->getTableName() . "' and column_name='" . $this->getUniqueId() . "'"); $result = explode("'", $result); return $result[0]; }
[ "public", "function", "getTableSequenceName", "(", ")", "{", "$", "connection", "=", "$", "this", "->", "getConnection", "(", ")", ";", "$", "result", "=", "$", "connection", "->", "fetchColumn", "(", "\"SELECT column_default from information_schema.columns where tabl...
Get sequence name @return string sequence name @throws \Doctrine\DBAL\DBALException
[ "Get", "sequence", "name" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L613-L619
train
mapbender/data-source
Component/FeatureType.php
FeatureType.getFileUri
public function getFileUri($fieldName = null) { $path = self::UPLOAD_DIR_NAME . "/" . $this->getTableName(); if ($fieldName) { $path .= "/" . $fieldName; } foreach ($this->getFileInfo() as $fileInfo) { if (isset($fileInfo["field"]) && isset($fileInfo["uri"]) && $fieldName == $fileInfo["field"]) { $path = $fileInfo["uri"]; break; } } return $path; }
php
public function getFileUri($fieldName = null) { $path = self::UPLOAD_DIR_NAME . "/" . $this->getTableName(); if ($fieldName) { $path .= "/" . $fieldName; } foreach ($this->getFileInfo() as $fileInfo) { if (isset($fileInfo["field"]) && isset($fileInfo["uri"]) && $fieldName == $fileInfo["field"]) { $path = $fileInfo["uri"]; break; } } return $path; }
[ "public", "function", "getFileUri", "(", "$", "fieldName", "=", "null", ")", "{", "$", "path", "=", "self", "::", "UPLOAD_DIR_NAME", ".", "\"/\"", ".", "$", "this", "->", "getTableName", "(", ")", ";", "if", "(", "$", "fieldName", ")", "{", "$", "pat...
Get files directory, relative to base upload directory @param null $fieldName @return string
[ "Get", "files", "directory", "relative", "to", "base", "upload", "directory" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L639-L655
train
mapbender/data-source
Component/FeatureType.php
FeatureType.getFilePath
public function getFilePath($fieldName = null, $createPath = true) { $path = realpath(AppComponent::getUploadsDir($this->container)) . "/" . $this->getFileUri($fieldName); foreach ($this->getFileInfo() as $fileInfo) { if (isset($fileInfo["field"]) && isset($fileInfo["path"]) && $fieldName == $fileInfo["field"]) { $path = $fileInfo["path"]; break; } } if ($createPath && !is_dir($path)) { mkdir($path, 0775, true); } return $path; }
php
public function getFilePath($fieldName = null, $createPath = true) { $path = realpath(AppComponent::getUploadsDir($this->container)) . "/" . $this->getFileUri($fieldName); foreach ($this->getFileInfo() as $fileInfo) { if (isset($fileInfo["field"]) && isset($fileInfo["path"]) && $fieldName == $fileInfo["field"]) { $path = $fileInfo["path"]; break; } } if ($createPath && !is_dir($path)) { mkdir($path, 0775, true); } return $path; }
[ "public", "function", "getFilePath", "(", "$", "fieldName", "=", "null", ",", "$", "createPath", "=", "true", ")", "{", "$", "path", "=", "realpath", "(", "AppComponent", "::", "getUploadsDir", "(", "$", "this", "->", "container", ")", ")", ".", "\"/\"",...
Get files base path @param null $fieldName file field name @param bool $createPath check and create path? @return string
[ "Get", "files", "base", "path" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L664-L680
train
mapbender/data-source
Component/FeatureType.php
FeatureType.genFilePath
public function genFilePath($fieldName = null) { $id = $this->countFiles($fieldName) + 1; $src = null; $path = null; while (1) { $path = $id; //. "-" . System::generatePassword(12) ; $src = $this->getFilePath($fieldName) . "/" . $path; if (!file_exists($src)) { break; } $id++; } return array( "src" => $src, "path" => $path ); }
php
public function genFilePath($fieldName = null) { $id = $this->countFiles($fieldName) + 1; $src = null; $path = null; while (1) { $path = $id; //. "-" . System::generatePassword(12) ; $src = $this->getFilePath($fieldName) . "/" . $path; if (!file_exists($src)) { break; } $id++; } return array( "src" => $src, "path" => $path ); }
[ "public", "function", "genFilePath", "(", "$", "fieldName", "=", "null", ")", "{", "$", "id", "=", "$", "this", "->", "countFiles", "(", "$", "fieldName", ")", "+", "1", ";", "$", "src", "=", "null", ";", "$", "path", "=", "null", ";", "while", "...
Generate unique file name for a field. @param null $fieldName Field @return string @internal param string $extension File extension
[ "Generate", "unique", "file", "name", "for", "a", "field", "." ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L710-L729
train
mapbender/data-source
Component/FeatureType.php
FeatureType.countFiles
private function countFiles($fieldName = null) { $finder = new Finder(); $finder->files()->in($this->getFilePath($fieldName)); return count($finder); }
php
private function countFiles($fieldName = null) { $finder = new Finder(); $finder->files()->in($this->getFilePath($fieldName)); return count($finder); }
[ "private", "function", "countFiles", "(", "$", "fieldName", "=", "null", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "files", "(", ")", "->", "in", "(", "$", "this", "->", "getFilePath", "(", "$", "fieldName", ...
Count files in the field directory @param null $fieldName @return int
[ "Count", "files", "in", "the", "field", "directory" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L737-L742
train
mapbender/data-source
Component/FeatureType.php
FeatureType.routeBetweenGeom
public function routeBetweenGeom($sourceGeom, $targetGeom) { $driver = $this->getDriver(); $srid = $this->getSrid(); $sourceNode = $driver->getNodeFromGeom($this->waysVerticesTableName, $this->waysGeomFieldName, $sourceGeom, $srid, 'id'); $targetNode = $driver->getNodeFromGeom($this->waysVerticesTableName, $this->waysGeomFieldName, $targetGeom, $srid, 'id'); return $driver->routeBetweenNodes($this->waysVerticesTableName, $this->waysGeomFieldName, $sourceNode, $targetNode, $srid); }
php
public function routeBetweenGeom($sourceGeom, $targetGeom) { $driver = $this->getDriver(); $srid = $this->getSrid(); $sourceNode = $driver->getNodeFromGeom($this->waysVerticesTableName, $this->waysGeomFieldName, $sourceGeom, $srid, 'id'); $targetNode = $driver->getNodeFromGeom($this->waysVerticesTableName, $this->waysGeomFieldName, $targetGeom, $srid, 'id'); return $driver->routeBetweenNodes($this->waysVerticesTableName, $this->waysGeomFieldName, $sourceNode, $targetNode, $srid); }
[ "public", "function", "routeBetweenGeom", "(", "$", "sourceGeom", ",", "$", "targetGeom", ")", "{", "$", "driver", "=", "$", "this", "->", "getDriver", "(", ")", ";", "$", "srid", "=", "$", "this", "->", "getSrid", "(", ")", ";", "$", "sourceNode", "...
Get route nodes between geometries @param string $sourceGeom EWKT geometry @param string $targetGeom EWKT geometry @return Feature[]
[ "Get", "route", "nodes", "between", "geometries" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L796-L803
train
mapbender/data-source
Component/FeatureType.php
FeatureType.getByIds
public function getByIds($ids, $prepareResults = true) { $queryBuilder = $this->getSelectQueryBuilder(); $connection = $queryBuilder->getConnection(); $rows = $queryBuilder->where( $queryBuilder->expr()->in($this->getUniqueId(), array_map(function ($id) use ($connection) { return $connection->quote($id); }, $ids)) )->execute()->fetchAll(); if ($prepareResults) { $this->prepareResults($rows); } return $rows; }
php
public function getByIds($ids, $prepareResults = true) { $queryBuilder = $this->getSelectQueryBuilder(); $connection = $queryBuilder->getConnection(); $rows = $queryBuilder->where( $queryBuilder->expr()->in($this->getUniqueId(), array_map(function ($id) use ($connection) { return $connection->quote($id); }, $ids)) )->execute()->fetchAll(); if ($prepareResults) { $this->prepareResults($rows); } return $rows; }
[ "public", "function", "getByIds", "(", "$", "ids", ",", "$", "prepareResults", "=", "true", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "getSelectQueryBuilder", "(", ")", ";", "$", "connection", "=", "$", "queryBuilder", "->", "getConnection", "...
Get by ID list @param $ids
[ "Get", "by", "ID", "list" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L829-L844
train
mapbender/data-source
Component/FeatureType.php
FeatureType.getConfiguration
public function getConfiguration($key = null) { return isset($this->_args[ $key ]) ? $this->_args[ $key ] : null; }
php
public function getConfiguration($key = null) { return isset($this->_args[ $key ]) ? $this->_args[ $key ] : null; }
[ "public", "function", "getConfiguration", "(", "$", "key", "=", "null", ")", "{", "return", "isset", "(", "$", "this", "->", "_args", "[", "$", "key", "]", ")", "?", "$", "this", "->", "_args", "[", "$", "key", "]", ":", "null", ";", "}" ]
Get feature type configuration by key name @param string $key Key name @return array|mixed|null
[ "Get", "feature", "type", "configuration", "by", "key", "name" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L852-L855
train
mapbender/data-source
Component/FeatureType.php
FeatureType.export
public function export(array &$rows) { $config = $this->getConfiguration('export'); $fieldNames = isset($config['fields']) ? $config['fields'] : null; $result = array(); if ($fieldNames) { foreach ($rows as &$row) { $exportRow = array(); foreach ($fieldNames as $fieldName => $fieldCode) { $exportRow[ $fieldName ] = $this->evaluateField($row, $fieldCode); } $result[] = $exportRow; } } else { $result = &$rows; } return $result; }
php
public function export(array &$rows) { $config = $this->getConfiguration('export'); $fieldNames = isset($config['fields']) ? $config['fields'] : null; $result = array(); if ($fieldNames) { foreach ($rows as &$row) { $exportRow = array(); foreach ($fieldNames as $fieldName => $fieldCode) { $exportRow[ $fieldName ] = $this->evaluateField($row, $fieldCode); } $result[] = $exportRow; } } else { $result = &$rows; } return $result; }
[ "public", "function", "export", "(", "array", "&", "$", "rows", ")", "{", "$", "config", "=", "$", "this", "->", "getConfiguration", "(", "'export'", ")", ";", "$", "fieldNames", "=", "isset", "(", "$", "config", "[", "'fields'", "]", ")", "?", "$", ...
Export by ID's @param array $rows @return array @internal param array $features @internal param array $ids
[ "Export", "by", "ID", "s" ]
b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed
https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureType.php#L865-L884
train
SplashSync/Php-Core
Models/Logger/ConsoleExporterTrait.php
ConsoleExporterTrait.getConsoleLog
public function getConsoleLog($clean = false) { $result = null; //====================================================================// // Read All Messages as Html $result .= $this->getConsole($this->err, ' - Error => ', self::CMD_COLOR_ERR); $result .= $this->getConsole($this->war, ' - Warning => ', self::CMD_COLOR_WAR); $result .= $this->getConsole($this->msg, ' - Messages => ', self::CMD_COLOR_MSG); $result .= $this->getConsole($this->deb, ' - Debug => ', self::CMD_COLOR_DEB); $result .= "\e[0m"; //====================================================================// // Clear Log Buffer If Requiered if ($clean) { $this->cleanLog(); } return $result; }
php
public function getConsoleLog($clean = false) { $result = null; //====================================================================// // Read All Messages as Html $result .= $this->getConsole($this->err, ' - Error => ', self::CMD_COLOR_ERR); $result .= $this->getConsole($this->war, ' - Warning => ', self::CMD_COLOR_WAR); $result .= $this->getConsole($this->msg, ' - Messages => ', self::CMD_COLOR_MSG); $result .= $this->getConsole($this->deb, ' - Debug => ', self::CMD_COLOR_DEB); $result .= "\e[0m"; //====================================================================// // Clear Log Buffer If Requiered if ($clean) { $this->cleanLog(); } return $result; }
[ "public", "function", "getConsoleLog", "(", "$", "clean", "=", "false", ")", "{", "$", "result", "=", "null", ";", "//====================================================================//", "// Read All Messages as Html", "$", "result", ".=", "$", "this", "->", "getCon...
Return All WebServer current Log WebServer in Console Colored format @param bool $clean true if messages needs to be cleaned after reading @return string
[ "Return", "All", "WebServer", "current", "Log", "WebServer", "in", "Console", "Colored", "format" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Logger/ConsoleExporterTrait.php#L33-L50
train
SplashSync/Php-Core
Models/Logger/ConsoleExporterTrait.php
ConsoleExporterTrait.getConsole
private function getConsole($msgArray, $title = '', $color = 0) { $result = ''; if ((is_array($msgArray) || $msgArray instanceof Countable) && count($msgArray)) { //====================================================================// // Add Messages foreach ($msgArray as $txt) { $result .= self::getConsoleLine($txt, $title, $color); } } return $result; }
php
private function getConsole($msgArray, $title = '', $color = 0) { $result = ''; if ((is_array($msgArray) || $msgArray instanceof Countable) && count($msgArray)) { //====================================================================// // Add Messages foreach ($msgArray as $txt) { $result .= self::getConsoleLine($txt, $title, $color); } } return $result; }
[ "private", "function", "getConsole", "(", "$", "msgArray", ",", "$", "title", "=", "''", ",", "$", "color", "=", "0", ")", "{", "$", "result", "=", "''", ";", "if", "(", "(", "is_array", "(", "$", "msgArray", ")", "||", "$", "msgArray", "instanceof...
Return All WebServer current Log WebServer Console Colored format @param null|array|ArrayObject $msgArray @param string $title @param int $color @return string
[ "Return", "All", "WebServer", "current", "Log", "WebServer", "Console", "Colored", "format" ]
f69724117b979e10eb38e72f7fe38611b5c3f830
https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Logger/ConsoleExporterTrait.php#L75-L87
train
mikemirten/JsonApi
src/Mapper/Handler/AttributeHandler.php
AttributeHandler.processAttributeToResource
protected function processAttributeToResource($object, ResourceObject $resource, Attribute $definition) { $name = $definition->getName(); $getter = $definition->getGetter(); $value = $object->$getter(); if ($value === null && ! $definition->getProcessNull()) { return; } $value = $this->typeManager->toResource($definition, $value); $resource->setAttribute($name, $value); }
php
protected function processAttributeToResource($object, ResourceObject $resource, Attribute $definition) { $name = $definition->getName(); $getter = $definition->getGetter(); $value = $object->$getter(); if ($value === null && ! $definition->getProcessNull()) { return; } $value = $this->typeManager->toResource($definition, $value); $resource->setAttribute($name, $value); }
[ "protected", "function", "processAttributeToResource", "(", "$", "object", ",", "ResourceObject", "$", "resource", ",", "Attribute", "$", "definition", ")", "{", "$", "name", "=", "$", "definition", "->", "getName", "(", ")", ";", "$", "getter", "=", "$", ...
Process attribute to resource mapping @param mixed $object @param ResourceObject $resource @param Attribute $definition
[ "Process", "attribute", "to", "resource", "mapping" ]
a3c1baf8f753c040f24e4522495b7d34565e6560
https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Handler/AttributeHandler.php#L52-L66
train
mikemirten/JsonApi
src/Mapper/Handler/AttributeHandler.php
AttributeHandler.processResourceToAttribute
protected function processResourceToAttribute($object, ResourceObject $resource, Attribute $definition) { $name = $definition->getName(); if (! $resource->hasAttribute($name)) { return; } $value = $resource->getAttribute($name); if ($value === null && ! $definition->getProcessNull()) { return; } $value = $this->typeManager->fromResource($definition, $value); $setter = $definition->getSetter(); $object->$setter($value); }
php
protected function processResourceToAttribute($object, ResourceObject $resource, Attribute $definition) { $name = $definition->getName(); if (! $resource->hasAttribute($name)) { return; } $value = $resource->getAttribute($name); if ($value === null && ! $definition->getProcessNull()) { return; } $value = $this->typeManager->fromResource($definition, $value); $setter = $definition->getSetter(); $object->$setter($value); }
[ "protected", "function", "processResourceToAttribute", "(", "$", "object", ",", "ResourceObject", "$", "resource", ",", "Attribute", "$", "definition", ")", "{", "$", "name", "=", "$", "definition", "->", "getName", "(", ")", ";", "if", "(", "!", "$", "res...
Process resource to attribute mapping @param mixed $object @param ResourceObject $resource @param Attribute $definition
[ "Process", "resource", "to", "attribute", "mapping" ]
a3c1baf8f753c040f24e4522495b7d34565e6560
https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Handler/AttributeHandler.php#L92-L110
train
wangxian/ephp
src/Web/Html.php
Html._parse_form_attributes
private static function _parse_form_attributes($attributes, $default) { if (is_array($attributes)) { foreach ($default as $key => $val) { if (isset($attributes[$key])) { $default[$key] = $attributes[$key]; unset($attributes[$key]); } } if (count($attributes) > 0) { $default = array_merge($default, $attributes); } } $att = ''; foreach ($default as $key => $val) { if ($key == 'value') { $val = self::form_prep($val, $default['name']); } $att .= $key . '="' . $val . '" '; } return $att; }
php
private static function _parse_form_attributes($attributes, $default) { if (is_array($attributes)) { foreach ($default as $key => $val) { if (isset($attributes[$key])) { $default[$key] = $attributes[$key]; unset($attributes[$key]); } } if (count($attributes) > 0) { $default = array_merge($default, $attributes); } } $att = ''; foreach ($default as $key => $val) { if ($key == 'value') { $val = self::form_prep($val, $default['name']); } $att .= $key . '="' . $val . '" '; } return $att; }
[ "private", "static", "function", "_parse_form_attributes", "(", "$", "attributes", ",", "$", "default", ")", "{", "if", "(", "is_array", "(", "$", "attributes", ")", ")", "{", "foreach", "(", "$", "default", "as", "$", "key", "=>", "$", "val", ")", "{"...
Parse the form attributes @ignore @param mixed $attributes @param mixed $default @return string
[ "Parse", "the", "form", "attributes" ]
697248ab098d8dc352de31ab0c64ea0fee1d7132
https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Web/Html.php#L326-L352
train