id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
12,000
pletfix/core
src/Services/Process.php
Process.isRunning
public function isRunning() { if ($this->process === null) { return false; } $status = proc_get_status($this->process); if ($status && $status['running'] === false && $this->exitcode === null) { $this->exitcode = $status['exitcode']; // Note that you can not use proc_get_status to determine the PID because proc_open first launches a shell (sh) // whose PID is returned! } return $status && $status['running']; }
php
public function isRunning() { if ($this->process === null) { return false; } $status = proc_get_status($this->process); if ($status && $status['running'] === false && $this->exitcode === null) { $this->exitcode = $status['exitcode']; // Note that you can not use proc_get_status to determine the PID because proc_open first launches a shell (sh) // whose PID is returned! } return $status && $status['running']; }
[ "public", "function", "isRunning", "(", ")", "{", "if", "(", "$", "this", "->", "process", "===", "null", ")", "{", "return", "false", ";", "}", "$", "status", "=", "proc_get_status", "(", "$", "this", "->", "process", ")", ";", "if", "(", "$", "status", "&&", "$", "status", "[", "'running'", "]", "===", "false", "&&", "$", "this", "->", "exitcode", "===", "null", ")", "{", "$", "this", "->", "exitcode", "=", "$", "status", "[", "'exitcode'", "]", ";", "// Note that you can not use proc_get_status to determine the PID because proc_open first launches a shell (sh)", "// whose PID is returned!", "}", "return", "$", "status", "&&", "$", "status", "[", "'running'", "]", ";", "}" ]
Determine if the process is currently running. @return bool true if the process is currently running, false otherwise.
[ "Determine", "if", "the", "process", "is", "currently", "running", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Process.php#L248-L262
12,001
pletfix/core
src/Services/Process.php
Process.getExitCode
public function getExitCode() { if ($this->exitcode === null && $this->process !== null) { $status = proc_get_status($this->process); if ($status && $status['running'] === false) { $this->exitcode = $status['exitcode']; } } return $this->exitcode; }
php
public function getExitCode() { if ($this->exitcode === null && $this->process !== null) { $status = proc_get_status($this->process); if ($status && $status['running'] === false) { $this->exitcode = $status['exitcode']; } } return $this->exitcode; }
[ "public", "function", "getExitCode", "(", ")", "{", "if", "(", "$", "this", "->", "exitcode", "===", "null", "&&", "$", "this", "->", "process", "!==", "null", ")", "{", "$", "status", "=", "proc_get_status", "(", "$", "this", "->", "process", ")", ";", "if", "(", "$", "status", "&&", "$", "status", "[", "'running'", "]", "===", "false", ")", "{", "$", "this", "->", "exitcode", "=", "$", "status", "[", "'exitcode'", "]", ";", "}", "}", "return", "$", "this", "->", "exitcode", ";", "}" ]
Get the exit code returned by the process. @return null|int The exit status code, null if the Process is not terminated.
[ "Get", "the", "exit", "code", "returned", "by", "the", "process", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Process.php#L269-L279
12,002
becopay/Invoice_SDK_PHP
src/PaymentGateway.php
PaymentGateway.create
public function create($orderId, $price, $description = '', $currency = 'IRR', $merchantCur = 'IRR') { // Clear the error variable $this->error = ''; $orderId = (string)$orderId; /** * Check value is string * If validation functions return false, it will be set error message on error variable */ if ( !self::__validateString($orderId, 1, 50) || !self::__validateNumeric($price, 1, 20) || !self::__validateString($description, 0, 255) ) return false; $param = array( "apikey" => $this->apiKey, "mobile" => $this->mobile, "description" => $description, "orderId" => $orderId, "merchantCur" => $merchantCur, "currency" => $currency, "price" => (string)$price ); $result = self::__sendRequest('invoice', 'POST', $param); // if response code is 200 return the response value if ($result->code === 200) { if (isset($result->response->qr)) unset($result->response->qr); return $result->response; } else if ($result->code == 0) { // if response code is 0 return false and set error message $this->error = $result->response; return false; } else { //Get error massage and return false if (isset($result->response->description) && !is_null($result->response->description)) $this->error = $result->response->description; else if (isset($result->response->message) && !is_null($result->response->message)) $this->error = $result->response->message; return false; } }
php
public function create($orderId, $price, $description = '', $currency = 'IRR', $merchantCur = 'IRR') { // Clear the error variable $this->error = ''; $orderId = (string)$orderId; /** * Check value is string * If validation functions return false, it will be set error message on error variable */ if ( !self::__validateString($orderId, 1, 50) || !self::__validateNumeric($price, 1, 20) || !self::__validateString($description, 0, 255) ) return false; $param = array( "apikey" => $this->apiKey, "mobile" => $this->mobile, "description" => $description, "orderId" => $orderId, "merchantCur" => $merchantCur, "currency" => $currency, "price" => (string)$price ); $result = self::__sendRequest('invoice', 'POST', $param); // if response code is 200 return the response value if ($result->code === 200) { if (isset($result->response->qr)) unset($result->response->qr); return $result->response; } else if ($result->code == 0) { // if response code is 0 return false and set error message $this->error = $result->response; return false; } else { //Get error massage and return false if (isset($result->response->description) && !is_null($result->response->description)) $this->error = $result->response->description; else if (isset($result->response->message) && !is_null($result->response->message)) $this->error = $result->response->message; return false; } }
[ "public", "function", "create", "(", "$", "orderId", ",", "$", "price", ",", "$", "description", "=", "''", ",", "$", "currency", "=", "'IRR'", ",", "$", "merchantCur", "=", "'IRR'", ")", "{", "// Clear the error variable", "$", "this", "->", "error", "=", "''", ";", "$", "orderId", "=", "(", "string", ")", "$", "orderId", ";", "/**\n * Check value is string\n * If validation functions return false, it will be set error message on error variable\n */", "if", "(", "!", "self", "::", "__validateString", "(", "$", "orderId", ",", "1", ",", "50", ")", "||", "!", "self", "::", "__validateNumeric", "(", "$", "price", ",", "1", ",", "20", ")", "||", "!", "self", "::", "__validateString", "(", "$", "description", ",", "0", ",", "255", ")", ")", "return", "false", ";", "$", "param", "=", "array", "(", "\"apikey\"", "=>", "$", "this", "->", "apiKey", ",", "\"mobile\"", "=>", "$", "this", "->", "mobile", ",", "\"description\"", "=>", "$", "description", ",", "\"orderId\"", "=>", "$", "orderId", ",", "\"merchantCur\"", "=>", "$", "merchantCur", ",", "\"currency\"", "=>", "$", "currency", ",", "\"price\"", "=>", "(", "string", ")", "$", "price", ")", ";", "$", "result", "=", "self", "::", "__sendRequest", "(", "'invoice'", ",", "'POST'", ",", "$", "param", ")", ";", "// if response code is 200 return the response value", "if", "(", "$", "result", "->", "code", "===", "200", ")", "{", "if", "(", "isset", "(", "$", "result", "->", "response", "->", "qr", ")", ")", "unset", "(", "$", "result", "->", "response", "->", "qr", ")", ";", "return", "$", "result", "->", "response", ";", "}", "else", "if", "(", "$", "result", "->", "code", "==", "0", ")", "{", "// if response code is 0 return false and set error message", "$", "this", "->", "error", "=", "$", "result", "->", "response", ";", "return", "false", ";", "}", "else", "{", "//Get error massage and return false", "if", "(", "isset", "(", "$", "result", "->", "response", "->", "description", ")", "&&", "!", "is_null", "(", "$", "result", "->", "response", "->", "description", ")", ")", "$", "this", "->", "error", "=", "$", "result", "->", "response", "->", "description", ";", "else", "if", "(", "isset", "(", "$", "result", "->", "response", "->", "message", ")", "&&", "!", "is_null", "(", "$", "result", "->", "response", "->", "message", ")", ")", "$", "this", "->", "error", "=", "$", "result", "->", "response", "->", "message", ";", "return", "false", ";", "}", "}" ]
Create the payment invoice and return the gateway url @param string | integer $orderId @param integer $price @param string $description @param string $currency payer currency @param string $merchantCur merchant currency @return mixed false|response object @throws \Exception
[ "Create", "the", "payment", "invoice", "and", "return", "the", "gateway", "url" ]
f39df3cd9ffa72738f082ad303ac9841fb158313
https://github.com/becopay/Invoice_SDK_PHP/blob/f39df3cd9ffa72738f082ad303ac9841fb158313/src/PaymentGateway.php#L78-L128
12,003
becopay/Invoice_SDK_PHP
src/PaymentGateway.php
PaymentGateway.check
public function check($invoiceId) { // Clear the error variable $this->error = ''; /** * Check value is string * If string return false and set error message on error variable */ if ( !self::__validateString($invoiceId, 1, 50) ) return false; $param = array( "id" => $invoiceId, "apikey" => $this->apiKey, "mobile" => $this->mobile ); return self::__sendCheckRequest('invoice', $param); }
php
public function check($invoiceId) { // Clear the error variable $this->error = ''; /** * Check value is string * If string return false and set error message on error variable */ if ( !self::__validateString($invoiceId, 1, 50) ) return false; $param = array( "id" => $invoiceId, "apikey" => $this->apiKey, "mobile" => $this->mobile ); return self::__sendCheckRequest('invoice', $param); }
[ "public", "function", "check", "(", "$", "invoiceId", ")", "{", "// Clear the error variable", "$", "this", "->", "error", "=", "''", ";", "/**\n * Check value is string\n * If string return false and set error message on error variable\n */", "if", "(", "!", "self", "::", "__validateString", "(", "$", "invoiceId", ",", "1", ",", "50", ")", ")", "return", "false", ";", "$", "param", "=", "array", "(", "\"id\"", "=>", "$", "invoiceId", ",", "\"apikey\"", "=>", "$", "this", "->", "apiKey", ",", "\"mobile\"", "=>", "$", "this", "->", "mobile", ")", ";", "return", "self", "::", "__sendCheckRequest", "(", "'invoice'", ",", "$", "param", ")", ";", "}" ]
Check the payment status with invoice id @param string $invoiceId @return mixed false|response object @throws \Exception
[ "Check", "the", "payment", "status", "with", "invoice", "id" ]
f39df3cd9ffa72738f082ad303ac9841fb158313
https://github.com/becopay/Invoice_SDK_PHP/blob/f39df3cd9ffa72738f082ad303ac9841fb158313/src/PaymentGateway.php#L137-L158
12,004
becopay/Invoice_SDK_PHP
src/PaymentGateway.php
PaymentGateway.__sendCheckRequest
private function __sendCheckRequest($path, $param) { $result = self::__sendRequest($path, 'GET', $param); // if response code is 200 return the response value if ($result->code === 200) { if (isset($result->response->qr)) unset($result->response->qr); return $result->response; } else if ($result->code == 0) { // if response code is 0 return false and set error message $this->error = $result->response; return false; } else { //Get error massage and return false if (isset($result->response->description) && !is_null($result->response->description)) $this->error = $result->response->description; else if (isset($result->response->message) && !is_null($result->response->message)) $this->error = $result->response->message; return false; } }
php
private function __sendCheckRequest($path, $param) { $result = self::__sendRequest($path, 'GET', $param); // if response code is 200 return the response value if ($result->code === 200) { if (isset($result->response->qr)) unset($result->response->qr); return $result->response; } else if ($result->code == 0) { // if response code is 0 return false and set error message $this->error = $result->response; return false; } else { //Get error massage and return false if (isset($result->response->description) && !is_null($result->response->description)) $this->error = $result->response->description; else if (isset($result->response->message) && !is_null($result->response->message)) $this->error = $result->response->message; return false; } }
[ "private", "function", "__sendCheckRequest", "(", "$", "path", ",", "$", "param", ")", "{", "$", "result", "=", "self", "::", "__sendRequest", "(", "$", "path", ",", "'GET'", ",", "$", "param", ")", ";", "// if response code is 200 return the response value", "if", "(", "$", "result", "->", "code", "===", "200", ")", "{", "if", "(", "isset", "(", "$", "result", "->", "response", "->", "qr", ")", ")", "unset", "(", "$", "result", "->", "response", "->", "qr", ")", ";", "return", "$", "result", "->", "response", ";", "}", "else", "if", "(", "$", "result", "->", "code", "==", "0", ")", "{", "// if response code is 0 return false and set error message", "$", "this", "->", "error", "=", "$", "result", "->", "response", ";", "return", "false", ";", "}", "else", "{", "//Get error massage and return false", "if", "(", "isset", "(", "$", "result", "->", "response", "->", "description", ")", "&&", "!", "is_null", "(", "$", "result", "->", "response", "->", "description", ")", ")", "$", "this", "->", "error", "=", "$", "result", "->", "response", "->", "description", ";", "else", "if", "(", "isset", "(", "$", "result", "->", "response", "->", "message", ")", "&&", "!", "is_null", "(", "$", "result", "->", "response", "->", "message", ")", ")", "$", "this", "->", "error", "=", "$", "result", "->", "response", "->", "message", ";", "return", "false", ";", "}", "}" ]
Send Check invoice request @param $path @param $param @return bool @throws \Exception
[ "Send", "Check", "invoice", "request" ]
f39df3cd9ffa72738f082ad303ac9841fb158313
https://github.com/becopay/Invoice_SDK_PHP/blob/f39df3cd9ffa72738f082ad303ac9841fb158313/src/PaymentGateway.php#L200-L221
12,005
becopay/Invoice_SDK_PHP
src/PaymentGateway.php
PaymentGateway.__sendRequest
private function __sendRequest($urlPath, $method, $param) { // Check Curl function if is enabled to send request if (function_exists('curl_version')) return self::__sendCurl($urlPath, $method, $param); // Check file_get_contents function if is enabled to send request else if (ini_get('allow_url_fopen')) return self::__sendFileGetContents($urlPath, $method, $param); //throw exception if none of them is enable else throw new \Exception('file_get_content and curl are disabled. you must enabled one of them'); }
php
private function __sendRequest($urlPath, $method, $param) { // Check Curl function if is enabled to send request if (function_exists('curl_version')) return self::__sendCurl($urlPath, $method, $param); // Check file_get_contents function if is enabled to send request else if (ini_get('allow_url_fopen')) return self::__sendFileGetContents($urlPath, $method, $param); //throw exception if none of them is enable else throw new \Exception('file_get_content and curl are disabled. you must enabled one of them'); }
[ "private", "function", "__sendRequest", "(", "$", "urlPath", ",", "$", "method", ",", "$", "param", ")", "{", "// Check Curl function if is enabled to send request", "if", "(", "function_exists", "(", "'curl_version'", ")", ")", "return", "self", "::", "__sendCurl", "(", "$", "urlPath", ",", "$", "method", ",", "$", "param", ")", ";", "// Check file_get_contents function if is enabled to send request", "else", "if", "(", "ini_get", "(", "'allow_url_fopen'", ")", ")", "return", "self", "::", "__sendFileGetContents", "(", "$", "urlPath", ",", "$", "method", ",", "$", "param", ")", ";", "//throw exception if none of them is enable", "else", "throw", "new", "\\", "Exception", "(", "'file_get_content and curl are disabled. you must enabled one of them'", ")", ";", "}" ]
Send the request to payment server @param string $urlPath @param string $method request method type , POST|GET @param array $param request parameters @return object @throws \Exception
[ "Send", "the", "request", "to", "payment", "server" ]
f39df3cd9ffa72738f082ad303ac9841fb158313
https://github.com/becopay/Invoice_SDK_PHP/blob/f39df3cd9ffa72738f082ad303ac9841fb158313/src/PaymentGateway.php#L232-L245
12,006
becopay/Invoice_SDK_PHP
src/PaymentGateway.php
PaymentGateway.__sendCurl
private function __sendCurl($urlPath, $method, $param) { $url = trim($this->apiBaseUrl, '/') . '/' . trim($urlPath, '/'); if ($method == 'GET') { $query = http_build_query($param); $url = $url . '?' . $query; } $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_CUSTOMREQUEST => $method, CURLOPT_POSTFIELDS => $method == 'POST' ? json_encode($param) : '', CURLOPT_HTTPHEADER => array( "Cache-Control: no-cache", "Content-Type: application/json", ), )); $response = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $error = curl_error($curl); curl_close($curl); return (object)array( 'code' => $httpCode, 'response' => $error ? $error : json_decode($response), ); }
php
private function __sendCurl($urlPath, $method, $param) { $url = trim($this->apiBaseUrl, '/') . '/' . trim($urlPath, '/'); if ($method == 'GET') { $query = http_build_query($param); $url = $url . '?' . $query; } $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_CUSTOMREQUEST => $method, CURLOPT_POSTFIELDS => $method == 'POST' ? json_encode($param) : '', CURLOPT_HTTPHEADER => array( "Cache-Control: no-cache", "Content-Type: application/json", ), )); $response = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $error = curl_error($curl); curl_close($curl); return (object)array( 'code' => $httpCode, 'response' => $error ? $error : json_decode($response), ); }
[ "private", "function", "__sendCurl", "(", "$", "urlPath", ",", "$", "method", ",", "$", "param", ")", "{", "$", "url", "=", "trim", "(", "$", "this", "->", "apiBaseUrl", ",", "'/'", ")", ".", "'/'", ".", "trim", "(", "$", "urlPath", ",", "'/'", ")", ";", "if", "(", "$", "method", "==", "'GET'", ")", "{", "$", "query", "=", "http_build_query", "(", "$", "param", ")", ";", "$", "url", "=", "$", "url", ".", "'?'", ".", "$", "query", ";", "}", "$", "curl", "=", "curl_init", "(", ")", ";", "curl_setopt_array", "(", "$", "curl", ",", "array", "(", "CURLOPT_URL", "=>", "$", "url", ",", "CURLOPT_RETURNTRANSFER", "=>", "true", ",", "CURLOPT_MAXREDIRS", "=>", "10", ",", "CURLOPT_TIMEOUT", "=>", "30", ",", "CURLOPT_CUSTOMREQUEST", "=>", "$", "method", ",", "CURLOPT_POSTFIELDS", "=>", "$", "method", "==", "'POST'", "?", "json_encode", "(", "$", "param", ")", ":", "''", ",", "CURLOPT_HTTPHEADER", "=>", "array", "(", "\"Cache-Control: no-cache\"", ",", "\"Content-Type: application/json\"", ",", ")", ",", ")", ")", ";", "$", "response", "=", "curl_exec", "(", "$", "curl", ")", ";", "$", "httpCode", "=", "curl_getinfo", "(", "$", "curl", ",", "CURLINFO_HTTP_CODE", ")", ";", "$", "error", "=", "curl_error", "(", "$", "curl", ")", ";", "curl_close", "(", "$", "curl", ")", ";", "return", "(", "object", ")", "array", "(", "'code'", "=>", "$", "httpCode", ",", "'response'", "=>", "$", "error", "?", "$", "error", ":", "json_decode", "(", "$", "response", ")", ",", ")", ";", "}" ]
Use Curl function for Send request @param string $urlPath @param string $method request method type , POST|GET @param array $param request parameters @return object
[ "Use", "Curl", "function", "for", "Send", "request" ]
f39df3cd9ffa72738f082ad303ac9841fb158313
https://github.com/becopay/Invoice_SDK_PHP/blob/f39df3cd9ffa72738f082ad303ac9841fb158313/src/PaymentGateway.php#L255-L288
12,007
becopay/Invoice_SDK_PHP
src/PaymentGateway.php
PaymentGateway.__sendFileGetContents
private function __sendFileGetContents($urlPath, $method, $param) { $url = trim($this->apiBaseUrl, '/') . '/' . trim($urlPath, '/'); if ($method == 'GET') { $query = http_build_query($param); $url = $url . '?' . $query; } $opts = array('http' => array( 'method' => $method, 'timeout' => '30', 'max_redirects' => '10', 'ignore_errors' => '1', 'header' => 'Content-type: application/json', 'content' => $method == 'POST' ? json_encode($param) : '' ) ); $context = stream_context_create($opts); $result = file_get_contents($url, false, $context); //get http status code $response_header = explode(' ', $http_response_header[0]); $httpCode = (int)$response_header[1]; return (object)array( 'code' => $httpCode, 'response' => json_decode($result), ); }
php
private function __sendFileGetContents($urlPath, $method, $param) { $url = trim($this->apiBaseUrl, '/') . '/' . trim($urlPath, '/'); if ($method == 'GET') { $query = http_build_query($param); $url = $url . '?' . $query; } $opts = array('http' => array( 'method' => $method, 'timeout' => '30', 'max_redirects' => '10', 'ignore_errors' => '1', 'header' => 'Content-type: application/json', 'content' => $method == 'POST' ? json_encode($param) : '' ) ); $context = stream_context_create($opts); $result = file_get_contents($url, false, $context); //get http status code $response_header = explode(' ', $http_response_header[0]); $httpCode = (int)$response_header[1]; return (object)array( 'code' => $httpCode, 'response' => json_decode($result), ); }
[ "private", "function", "__sendFileGetContents", "(", "$", "urlPath", ",", "$", "method", ",", "$", "param", ")", "{", "$", "url", "=", "trim", "(", "$", "this", "->", "apiBaseUrl", ",", "'/'", ")", ".", "'/'", ".", "trim", "(", "$", "urlPath", ",", "'/'", ")", ";", "if", "(", "$", "method", "==", "'GET'", ")", "{", "$", "query", "=", "http_build_query", "(", "$", "param", ")", ";", "$", "url", "=", "$", "url", ".", "'?'", ".", "$", "query", ";", "}", "$", "opts", "=", "array", "(", "'http'", "=>", "array", "(", "'method'", "=>", "$", "method", ",", "'timeout'", "=>", "'30'", ",", "'max_redirects'", "=>", "'10'", ",", "'ignore_errors'", "=>", "'1'", ",", "'header'", "=>", "'Content-type: application/json'", ",", "'content'", "=>", "$", "method", "==", "'POST'", "?", "json_encode", "(", "$", "param", ")", ":", "''", ")", ")", ";", "$", "context", "=", "stream_context_create", "(", "$", "opts", ")", ";", "$", "result", "=", "file_get_contents", "(", "$", "url", ",", "false", ",", "$", "context", ")", ";", "//get http status code", "$", "response_header", "=", "explode", "(", "' '", ",", "$", "http_response_header", "[", "0", "]", ")", ";", "$", "httpCode", "=", "(", "int", ")", "$", "response_header", "[", "1", "]", ";", "return", "(", "object", ")", "array", "(", "'code'", "=>", "$", "httpCode", ",", "'response'", "=>", "json_decode", "(", "$", "result", ")", ",", ")", ";", "}" ]
Use file_get_contents function for Send request @param string $urlPath @param string $method request method type , POST|GET @param array $param request parameters @return object
[ "Use", "file_get_contents", "function", "for", "Send", "request" ]
f39df3cd9ffa72738f082ad303ac9841fb158313
https://github.com/becopay/Invoice_SDK_PHP/blob/f39df3cd9ffa72738f082ad303ac9841fb158313/src/PaymentGateway.php#L298-L330
12,008
becopay/Invoice_SDK_PHP
src/PaymentGateway.php
PaymentGateway.__validateUrl
private function __validateUrl($url) { if (empty($url) || !is_string($url) || strlen($url) > 512 || !preg_match('/^http(s)?:\/\/[a-z0-9-]+(.[a-z0-9-]+)+(:[0-9]+)?(\/.*)?$/i', $url) || !filter_var($url, FILTER_VALIDATE_URL) ) { $this->error = 'invalid url format'; return false; } return true; }
php
private function __validateUrl($url) { if (empty($url) || !is_string($url) || strlen($url) > 512 || !preg_match('/^http(s)?:\/\/[a-z0-9-]+(.[a-z0-9-]+)+(:[0-9]+)?(\/.*)?$/i', $url) || !filter_var($url, FILTER_VALIDATE_URL) ) { $this->error = 'invalid url format'; return false; } return true; }
[ "private", "function", "__validateUrl", "(", "$", "url", ")", "{", "if", "(", "empty", "(", "$", "url", ")", "||", "!", "is_string", "(", "$", "url", ")", "||", "strlen", "(", "$", "url", ")", ">", "512", "||", "!", "preg_match", "(", "'/^http(s)?:\\/\\/[a-z0-9-]+(.[a-z0-9-]+)+(:[0-9]+)?(\\/.*)?$/i'", ",", "$", "url", ")", "||", "!", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_URL", ")", ")", "{", "$", "this", "->", "error", "=", "'invalid url format'", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validate url If url is invalid throw the exception @param $url @return bool
[ "Validate", "url", "If", "url", "is", "invalid", "throw", "the", "exception" ]
f39df3cd9ffa72738f082ad303ac9841fb158313
https://github.com/becopay/Invoice_SDK_PHP/blob/f39df3cd9ffa72738f082ad303ac9841fb158313/src/PaymentGateway.php#L339-L349
12,009
becopay/Invoice_SDK_PHP
src/PaymentGateway.php
PaymentGateway.__validateString
private function __validateString($string, $minLength = 1, $maxLength = 0) { if (!is_string($string)) { $this->error = 'parameter is not string.'; return false; } else if ($maxLength > 0 && strlen($string) > $maxLength) { $this->error = 'parameter is too long. string:' . $string; return false; } else if (strlen($string) < $minLength) { $this->error = 'parameter is too short. string:' . $string; return false; } return true; }
php
private function __validateString($string, $minLength = 1, $maxLength = 0) { if (!is_string($string)) { $this->error = 'parameter is not string.'; return false; } else if ($maxLength > 0 && strlen($string) > $maxLength) { $this->error = 'parameter is too long. string:' . $string; return false; } else if (strlen($string) < $minLength) { $this->error = 'parameter is too short. string:' . $string; return false; } return true; }
[ "private", "function", "__validateString", "(", "$", "string", ",", "$", "minLength", "=", "1", ",", "$", "maxLength", "=", "0", ")", "{", "if", "(", "!", "is_string", "(", "$", "string", ")", ")", "{", "$", "this", "->", "error", "=", "'parameter is not string.'", ";", "return", "false", ";", "}", "else", "if", "(", "$", "maxLength", ">", "0", "&&", "strlen", "(", "$", "string", ")", ">", "$", "maxLength", ")", "{", "$", "this", "->", "error", "=", "'parameter is too long. string:'", ".", "$", "string", ";", "return", "false", ";", "}", "else", "if", "(", "strlen", "(", "$", "string", ")", "<", "$", "minLength", ")", "{", "$", "this", "->", "error", "=", "'parameter is too short. string:'", ".", "$", "string", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
validate the string @param $string @param $minLength @param $maxLength @return bool
[ "validate", "the", "string" ]
f39df3cd9ffa72738f082ad303ac9841fb158313
https://github.com/becopay/Invoice_SDK_PHP/blob/f39df3cd9ffa72738f082ad303ac9841fb158313/src/PaymentGateway.php#L359-L372
12,010
becopay/Invoice_SDK_PHP
src/PaymentGateway.php
PaymentGateway.__validateNumeric
private function __validateNumeric($int, $minLength = 1, $maxLength = 0) { if (!is_numeric($int)) { $this->error = 'parameter is not number'; return false; } else if ($maxLength > 0 && strlen($int) > $maxLength) { $this->error = 'parameter is too long. number:' . $int; return false; } else if (strlen($int) < $minLength) { $this->error = 'parameter is too short. number:' . $int; return false; } return true; }
php
private function __validateNumeric($int, $minLength = 1, $maxLength = 0) { if (!is_numeric($int)) { $this->error = 'parameter is not number'; return false; } else if ($maxLength > 0 && strlen($int) > $maxLength) { $this->error = 'parameter is too long. number:' . $int; return false; } else if (strlen($int) < $minLength) { $this->error = 'parameter is too short. number:' . $int; return false; } return true; }
[ "private", "function", "__validateNumeric", "(", "$", "int", ",", "$", "minLength", "=", "1", ",", "$", "maxLength", "=", "0", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "int", ")", ")", "{", "$", "this", "->", "error", "=", "'parameter is not number'", ";", "return", "false", ";", "}", "else", "if", "(", "$", "maxLength", ">", "0", "&&", "strlen", "(", "$", "int", ")", ">", "$", "maxLength", ")", "{", "$", "this", "->", "error", "=", "'parameter is too long. number:'", ".", "$", "int", ";", "return", "false", ";", "}", "else", "if", "(", "strlen", "(", "$", "int", ")", "<", "$", "minLength", ")", "{", "$", "this", "->", "error", "=", "'parameter is too short. number:'", ".", "$", "int", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
validate variable is a number or a numeric string @param $int @param $minLength @param $maxLength @return bool
[ "validate", "variable", "is", "a", "number", "or", "a", "numeric", "string" ]
f39df3cd9ffa72738f082ad303ac9841fb158313
https://github.com/becopay/Invoice_SDK_PHP/blob/f39df3cd9ffa72738f082ad303ac9841fb158313/src/PaymentGateway.php#L382-L395
12,011
bmdevel/php-index
classes/xml/XmlParser.php
XmlParser.parseKeys
public function parseKeys($data, $offset) { $element = \preg_quote($this->getIndex()->getElement()); $attribute = \preg_quote($this->getIndex()->getAttribute()); $pregExp = '/<' . $element . '\s([^>]*\s)?' . $attribute . '\s*=\s*([\'"])(.+?)\2[^>]*>/si'; \preg_match_all( $pregExp, $data, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER ); $keys = array(); foreach ($matches as $match) { $keys[] = new FoundKey($match[0][1], $match[3][0]); } return $keys; }
php
public function parseKeys($data, $offset) { $element = \preg_quote($this->getIndex()->getElement()); $attribute = \preg_quote($this->getIndex()->getAttribute()); $pregExp = '/<' . $element . '\s([^>]*\s)?' . $attribute . '\s*=\s*([\'"])(.+?)\2[^>]*>/si'; \preg_match_all( $pregExp, $data, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER ); $keys = array(); foreach ($matches as $match) { $keys[] = new FoundKey($match[0][1], $match[3][0]); } return $keys; }
[ "public", "function", "parseKeys", "(", "$", "data", ",", "$", "offset", ")", "{", "$", "element", "=", "\\", "preg_quote", "(", "$", "this", "->", "getIndex", "(", ")", "->", "getElement", "(", ")", ")", ";", "$", "attribute", "=", "\\", "preg_quote", "(", "$", "this", "->", "getIndex", "(", ")", "->", "getAttribute", "(", ")", ")", ";", "$", "pregExp", "=", "'/<'", ".", "$", "element", ".", "'\\s([^>]*\\s)?'", ".", "$", "attribute", ".", "'\\s*=\\s*([\\'\"])(.+?)\\2[^>]*>/si'", ";", "\\", "preg_match_all", "(", "$", "pregExp", ",", "$", "data", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", "|", "PREG_SET_ORDER", ")", ";", "$", "keys", "=", "array", "(", ")", ";", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "$", "keys", "[", "]", "=", "new", "FoundKey", "(", "$", "match", "[", "0", "]", "[", "1", "]", ",", "$", "match", "[", "3", "]", "[", "0", "]", ")", ";", "}", "return", "$", "keys", ";", "}" ]
Returns an array with FoundKey objects $data is parsed for keys. The found keys are returned. @param string $data Parseable data @param int $offset The position where the date came from @return array @see FoundKey
[ "Returns", "an", "array", "with", "FoundKey", "objects" ]
6a6b476f1706b9524bfb34f6ce0963b1aea91259
https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/xml/XmlParser.php#L45-L67
12,012
bmdevel/php-index
classes/xml/XmlParser.php
XmlParser.getData
public function getData($offset) { $this->parserPosition = null; $this->parserLevel = 0; $data = ""; $parser = @\xml_parser_create(); $filePointer = $this->getIndex()->getFile()->getFilePointer(); if (! \is_resource($parser)) { $error = \error_get_last(); throw new ReadDataIndexException( "Could not create a xml parser: $error[message]" ); } \xml_set_element_handler( $parser, array($this, "onStartElement"), array($this, "onEndElement") ); \fseek($filePointer, $offset); while (\is_null($this->parserPosition) && $chunk = \fread($filePointer, $this->getIndex()->getFile()->getBlockSize()) ) { $data .= $chunk; \xml_parse($parser, $chunk); } \xml_parser_free($parser); if (\is_null($this->parserPosition)) { throw new ReadDataIndexException("Did not read any data"); } return \substr($data, 0, $this->parserPosition); }
php
public function getData($offset) { $this->parserPosition = null; $this->parserLevel = 0; $data = ""; $parser = @\xml_parser_create(); $filePointer = $this->getIndex()->getFile()->getFilePointer(); if (! \is_resource($parser)) { $error = \error_get_last(); throw new ReadDataIndexException( "Could not create a xml parser: $error[message]" ); } \xml_set_element_handler( $parser, array($this, "onStartElement"), array($this, "onEndElement") ); \fseek($filePointer, $offset); while (\is_null($this->parserPosition) && $chunk = \fread($filePointer, $this->getIndex()->getFile()->getBlockSize()) ) { $data .= $chunk; \xml_parse($parser, $chunk); } \xml_parser_free($parser); if (\is_null($this->parserPosition)) { throw new ReadDataIndexException("Did not read any data"); } return \substr($data, 0, $this->parserPosition); }
[ "public", "function", "getData", "(", "$", "offset", ")", "{", "$", "this", "->", "parserPosition", "=", "null", ";", "$", "this", "->", "parserLevel", "=", "0", ";", "$", "data", "=", "\"\"", ";", "$", "parser", "=", "@", "\\", "xml_parser_create", "(", ")", ";", "$", "filePointer", "=", "$", "this", "->", "getIndex", "(", ")", "->", "getFile", "(", ")", "->", "getFilePointer", "(", ")", ";", "if", "(", "!", "\\", "is_resource", "(", "$", "parser", ")", ")", "{", "$", "error", "=", "\\", "error_get_last", "(", ")", ";", "throw", "new", "ReadDataIndexException", "(", "\"Could not create a xml parser: $error[message]\"", ")", ";", "}", "\\", "xml_set_element_handler", "(", "$", "parser", ",", "array", "(", "$", "this", ",", "\"onStartElement\"", ")", ",", "array", "(", "$", "this", ",", "\"onEndElement\"", ")", ")", ";", "\\", "fseek", "(", "$", "filePointer", ",", "$", "offset", ")", ";", "while", "(", "\\", "is_null", "(", "$", "this", "->", "parserPosition", ")", "&&", "$", "chunk", "=", "\\", "fread", "(", "$", "filePointer", ",", "$", "this", "->", "getIndex", "(", ")", "->", "getFile", "(", ")", "->", "getBlockSize", "(", ")", ")", ")", "{", "$", "data", ".=", "$", "chunk", ";", "\\", "xml_parse", "(", "$", "parser", ",", "$", "chunk", ")", ";", "}", "\\", "xml_parser_free", "(", "$", "parser", ")", ";", "if", "(", "\\", "is_null", "(", "$", "this", "->", "parserPosition", ")", ")", "{", "throw", "new", "ReadDataIndexException", "(", "\"Did not read any data\"", ")", ";", "}", "return", "\\", "substr", "(", "$", "data", ",", "0", ",", "$", "this", "->", "parserPosition", ")", ";", "}" ]
Returns the XML container which begins at the specified offset This method uses the event based XML parser. So public handler methods are defined. @param int $offset Offset of the XML container @return string @throws ReadDataIndexException
[ "Returns", "the", "XML", "container", "which", "begins", "at", "the", "specified", "offset" ]
6a6b476f1706b9524bfb34f6ce0963b1aea91259
https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/xml/XmlParser.php#L80-L118
12,013
bmdevel/php-index
classes/xml/XmlParser.php
XmlParser.onEndElement
public function onEndElement($parser, $element) { $this->parserLevel--; if ($this->parserLevel > 0) { return; } if ($element != \strtoupper($this->getIndex()->getElement())) { throw new ReadDataIndexException( "Unexpected closing of element '$element'." ); } $this->parserPosition = \xml_get_current_byte_index($parser); }
php
public function onEndElement($parser, $element) { $this->parserLevel--; if ($this->parserLevel > 0) { return; } if ($element != \strtoupper($this->getIndex()->getElement())) { throw new ReadDataIndexException( "Unexpected closing of element '$element'." ); } $this->parserPosition = \xml_get_current_byte_index($parser); }
[ "public", "function", "onEndElement", "(", "$", "parser", ",", "$", "element", ")", "{", "$", "this", "->", "parserLevel", "--", ";", "if", "(", "$", "this", "->", "parserLevel", ">", "0", ")", "{", "return", ";", "}", "if", "(", "$", "element", "!=", "\\", "strtoupper", "(", "$", "this", "->", "getIndex", "(", ")", "->", "getElement", "(", ")", ")", ")", "{", "throw", "new", "ReadDataIndexException", "(", "\"Unexpected closing of element '$element'.\"", ")", ";", "}", "$", "this", "->", "parserPosition", "=", "\\", "xml_get_current_byte_index", "(", "$", "parser", ")", ";", "}" ]
Handler for an element end event This method is internally used by getData(). @param resource $parser XML Parser @param string $element Element name @return void @throws ReadDataIndexException @see XmlParser::getData() @see xml_set_element_handler()
[ "Handler", "for", "an", "element", "end", "event" ]
6a6b476f1706b9524bfb34f6ce0963b1aea91259
https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/xml/XmlParser.php#L151-L165
12,014
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Dashboard/Structure.php
Structure.reflectCss
protected function reflectCss( FieldsetInterface $fieldset, $selector ) { foreach ( $fieldset->getFieldsets() as $subFieldset ) { if ( ! $subFieldset instanceof Collection ) { $this->reflectCss( $subFieldset, $selector ); } } foreach ( $fieldset->getElements() as $name => $element ) { $types = array_filter( preg_split( '/\s+/', trim( $element->getAttribute( 'data-js-type' ) ) ) ); $types[] = 'js.paragraph.reflectCss'; $element->setAttributes( array( 'data-js-type' => implode( ' ', $types ), 'data-js-reflectcss-selector' => $selector, 'data-js-reflectcss-property' => String::decamelize( $name ), ) ); } return $fieldset; }
php
protected function reflectCss( FieldsetInterface $fieldset, $selector ) { foreach ( $fieldset->getFieldsets() as $subFieldset ) { if ( ! $subFieldset instanceof Collection ) { $this->reflectCss( $subFieldset, $selector ); } } foreach ( $fieldset->getElements() as $name => $element ) { $types = array_filter( preg_split( '/\s+/', trim( $element->getAttribute( 'data-js-type' ) ) ) ); $types[] = 'js.paragraph.reflectCss'; $element->setAttributes( array( 'data-js-type' => implode( ' ', $types ), 'data-js-reflectcss-selector' => $selector, 'data-js-reflectcss-property' => String::decamelize( $name ), ) ); } return $fieldset; }
[ "protected", "function", "reflectCss", "(", "FieldsetInterface", "$", "fieldset", ",", "$", "selector", ")", "{", "foreach", "(", "$", "fieldset", "->", "getFieldsets", "(", ")", "as", "$", "subFieldset", ")", "{", "if", "(", "!", "$", "subFieldset", "instanceof", "Collection", ")", "{", "$", "this", "->", "reflectCss", "(", "$", "subFieldset", ",", "$", "selector", ")", ";", "}", "}", "foreach", "(", "$", "fieldset", "->", "getElements", "(", ")", "as", "$", "name", "=>", "$", "element", ")", "{", "$", "types", "=", "array_filter", "(", "preg_split", "(", "'/\\s+/'", ",", "trim", "(", "$", "element", "->", "getAttribute", "(", "'data-js-type'", ")", ")", ")", ")", ";", "$", "types", "[", "]", "=", "'js.paragraph.reflectCss'", ";", "$", "element", "->", "setAttributes", "(", "array", "(", "'data-js-type'", "=>", "implode", "(", "' '", ",", "$", "types", ")", ",", "'data-js-reflectcss-selector'", "=>", "$", "selector", ",", "'data-js-reflectcss-property'", "=>", "String", "::", "decamelize", "(", "$", "name", ")", ",", ")", ")", ";", "}", "return", "$", "fieldset", ";", "}" ]
Reflect css properties @param \Zend\Form\FieldsetInterface $fieldset @param string $selector @return \Zend\Form\FieldsetInterface
[ "Reflect", "css", "properties" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Dashboard/Structure.php#L99-L125
12,015
registripe/registripe-core
code/pages/RegistrableEvent.php
RegistrableEvent.getAvailableTickets
public function getAvailableTickets() { $available = ArrayList::create(); $tickets = $this->Tickets(); foreach($tickets as $ticket) { if ($ticket->isAvailable()) { $available->push($ticket); } } return $available; }
php
public function getAvailableTickets() { $available = ArrayList::create(); $tickets = $this->Tickets(); foreach($tickets as $ticket) { if ($ticket->isAvailable()) { $available->push($ticket); } } return $available; }
[ "public", "function", "getAvailableTickets", "(", ")", "{", "$", "available", "=", "ArrayList", "::", "create", "(", ")", ";", "$", "tickets", "=", "$", "this", "->", "Tickets", "(", ")", ";", "foreach", "(", "$", "tickets", "as", "$", "ticket", ")", "{", "if", "(", "$", "ticket", "->", "isAvailable", "(", ")", ")", "{", "$", "available", "->", "push", "(", "$", "ticket", ")", ";", "}", "}", "return", "$", "available", ";", "}" ]
Get available tickets. @return ArrayList
[ "Get", "available", "tickets", "." ]
e52b3340aef323067ebfa9bd5fa07cb81bb63db9
https://github.com/registripe/registripe-core/blob/e52b3340aef323067ebfa9bd5fa07cb81bb63db9/code/pages/RegistrableEvent.php#L168-L177
12,016
registripe/registripe-core
code/pages/RegistrableEvent.php
RegistrableEvent.getRemainingCapacity
public function getRemainingCapacity($excludeId = null) { if (!$this->Capacity){ return true; } $bookings = $this->Registrations()->filter("Status:not", "Canceled"); if ($excludeId) { $bookings = $bookings->filter("ID:not", $excludeId); } $taken = $bookings->sum("Quantity"); if($this->Capacity >= $taken){ return $this->Capacity - $taken; } return false; }
php
public function getRemainingCapacity($excludeId = null) { if (!$this->Capacity){ return true; } $bookings = $this->Registrations()->filter("Status:not", "Canceled"); if ($excludeId) { $bookings = $bookings->filter("ID:not", $excludeId); } $taken = $bookings->sum("Quantity"); if($this->Capacity >= $taken){ return $this->Capacity - $taken; } return false; }
[ "public", "function", "getRemainingCapacity", "(", "$", "excludeId", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "Capacity", ")", "{", "return", "true", ";", "}", "$", "bookings", "=", "$", "this", "->", "Registrations", "(", ")", "->", "filter", "(", "\"Status:not\"", ",", "\"Canceled\"", ")", ";", "if", "(", "$", "excludeId", ")", "{", "$", "bookings", "=", "$", "bookings", "->", "filter", "(", "\"ID:not\"", ",", "$", "excludeId", ")", ";", "}", "$", "taken", "=", "$", "bookings", "->", "sum", "(", "\"Quantity\"", ")", ";", "if", "(", "$", "this", "->", "Capacity", ">=", "$", "taken", ")", "{", "return", "$", "this", "->", "Capacity", "-", "$", "taken", ";", "}", "return", "false", ";", "}" ]
Returns the overall number of places remaining at this event, TRUE if there are unlimited places or FALSE if they are all taken. @param int $excludeId A registration ID to exclude from calculations. @return int|bool
[ "Returns", "the", "overall", "number", "of", "places", "remaining", "at", "this", "event", "TRUE", "if", "there", "are", "unlimited", "places", "or", "FALSE", "if", "they", "are", "all", "taken", "." ]
e52b3340aef323067ebfa9bd5fa07cb81bb63db9
https://github.com/registripe/registripe-core/blob/e52b3340aef323067ebfa9bd5fa07cb81bb63db9/code/pages/RegistrableEvent.php#L228-L242
12,017
registripe/registripe-core
code/pages/RegistrableEvent.php
RegistrableEvent_Controller.registration
public function registration($request) { $id = $request->param('ID'); if (!ctype_digit($id)) { return $this->httpError(404); } $rego = EventRegistration::get()->byID($id); if (!$rego || $rego->EventID != $this->ID) { return $this->httpError(404); } $request->shift(); $request->shiftAllParams(); return new EventRegistrationDetailsController($this, $rego); }
php
public function registration($request) { $id = $request->param('ID'); if (!ctype_digit($id)) { return $this->httpError(404); } $rego = EventRegistration::get()->byID($id); if (!$rego || $rego->EventID != $this->ID) { return $this->httpError(404); } $request->shift(); $request->shiftAllParams(); return new EventRegistrationDetailsController($this, $rego); }
[ "public", "function", "registration", "(", "$", "request", ")", "{", "$", "id", "=", "$", "request", "->", "param", "(", "'ID'", ")", ";", "if", "(", "!", "ctype_digit", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "httpError", "(", "404", ")", ";", "}", "$", "rego", "=", "EventRegistration", "::", "get", "(", ")", "->", "byID", "(", "$", "id", ")", ";", "if", "(", "!", "$", "rego", "||", "$", "rego", "->", "EventID", "!=", "$", "this", "->", "ID", ")", "{", "return", "$", "this", "->", "httpError", "(", "404", ")", ";", "}", "$", "request", "->", "shift", "(", ")", ";", "$", "request", "->", "shiftAllParams", "(", ")", ";", "return", "new", "EventRegistrationDetailsController", "(", "$", "this", ",", "$", "rego", ")", ";", "}" ]
Allows a user to view the details of their registration. @param SS_HTTPRequest $request @return EventRegistrationDetailsController
[ "Allows", "a", "user", "to", "view", "the", "details", "of", "their", "registration", "." ]
e52b3340aef323067ebfa9bd5fa07cb81bb63db9
https://github.com/registripe/registripe-core/blob/e52b3340aef323067ebfa9bd5fa07cb81bb63db9/code/pages/RegistrableEvent.php#L268-L281
12,018
GustavSoftware/Lexer
src/ALexer.php
ALexer.getToken
public function getToken() { if(isset($this->_tokens[$this->_position])) { return $this->_tokens[$this->_position]; } else { return null; } }
php
public function getToken() { if(isset($this->_tokens[$this->_position])) { return $this->_tokens[$this->_position]; } else { return null; } }
[ "public", "function", "getToken", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_tokens", "[", "$", "this", "->", "_position", "]", ")", ")", "{", "return", "$", "this", "->", "_tokens", "[", "$", "this", "->", "_position", "]", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the current token on input. @return \Gustav\Lexer\Token|null The current token
[ "Returns", "the", "current", "token", "on", "input", "." ]
c0dca9d2c297eeccd37521fa52128e8a782f1f0b
https://github.com/GustavSoftware/Lexer/blob/c0dca9d2c297eeccd37521fa52128e8a782f1f0b/src/ALexer.php#L116-L123
12,019
joegreen88/zf1-components-base
src/Zend/Loader/PluginLoader.php
Zend_Loader_PluginLoader._formatPrefix
protected function _formatPrefix($prefix) { if($prefix == "") { return $prefix; } $nsSeparator = (false !== strpos($prefix, '\\'))?'\\':'_'; return rtrim($prefix, $nsSeparator) . $nsSeparator; }
php
protected function _formatPrefix($prefix) { if($prefix == "") { return $prefix; } $nsSeparator = (false !== strpos($prefix, '\\'))?'\\':'_'; return rtrim($prefix, $nsSeparator) . $nsSeparator; }
[ "protected", "function", "_formatPrefix", "(", "$", "prefix", ")", "{", "if", "(", "$", "prefix", "==", "\"\"", ")", "{", "return", "$", "prefix", ";", "}", "$", "nsSeparator", "=", "(", "false", "!==", "strpos", "(", "$", "prefix", ",", "'\\\\'", ")", ")", "?", "'\\\\'", ":", "'_'", ";", "return", "rtrim", "(", "$", "prefix", ",", "$", "nsSeparator", ")", ".", "$", "nsSeparator", ";", "}" ]
Format prefix for internal use @param string $prefix @return string
[ "Format", "prefix", "for", "internal", "use" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/PluginLoader.php#L124-L132
12,020
joegreen88/zf1-components-base
src/Zend/Loader/PluginLoader.php
Zend_Loader_PluginLoader.getPaths
public function getPaths($prefix = null) { if ((null !== $prefix) && is_string($prefix)) { $prefix = $this->_formatPrefix($prefix); if ($this->_useStaticRegistry) { if (isset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix])) { return self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix]; } return false; } if (isset($this->_prefixToPaths[$prefix])) { return $this->_prefixToPaths[$prefix]; } return false; } if ($this->_useStaticRegistry) { return self::$_staticPrefixToPaths[$this->_useStaticRegistry]; } return $this->_prefixToPaths; }
php
public function getPaths($prefix = null) { if ((null !== $prefix) && is_string($prefix)) { $prefix = $this->_formatPrefix($prefix); if ($this->_useStaticRegistry) { if (isset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix])) { return self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix]; } return false; } if (isset($this->_prefixToPaths[$prefix])) { return $this->_prefixToPaths[$prefix]; } return false; } if ($this->_useStaticRegistry) { return self::$_staticPrefixToPaths[$this->_useStaticRegistry]; } return $this->_prefixToPaths; }
[ "public", "function", "getPaths", "(", "$", "prefix", "=", "null", ")", "{", "if", "(", "(", "null", "!==", "$", "prefix", ")", "&&", "is_string", "(", "$", "prefix", ")", ")", "{", "$", "prefix", "=", "$", "this", "->", "_formatPrefix", "(", "$", "prefix", ")", ";", "if", "(", "$", "this", "->", "_useStaticRegistry", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "_staticPrefixToPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "prefix", "]", ")", ")", "{", "return", "self", "::", "$", "_staticPrefixToPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "prefix", "]", ";", "}", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_prefixToPaths", "[", "$", "prefix", "]", ")", ")", "{", "return", "$", "this", "->", "_prefixToPaths", "[", "$", "prefix", "]", ";", "}", "return", "false", ";", "}", "if", "(", "$", "this", "->", "_useStaticRegistry", ")", "{", "return", "self", "::", "$", "_staticPrefixToPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", ";", "}", "return", "$", "this", "->", "_prefixToPaths", ";", "}" ]
Get path stack @param string $prefix @return false|array False if prefix does not exist, array otherwise
[ "Get", "path", "stack" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/PluginLoader.php#L170-L194
12,021
joegreen88/zf1-components-base
src/Zend/Loader/PluginLoader.php
Zend_Loader_PluginLoader.clearPaths
public function clearPaths($prefix = null) { if ((null !== $prefix) && is_string($prefix)) { $prefix = $this->_formatPrefix($prefix); if ($this->_useStaticRegistry) { if (isset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix])) { unset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix]); return true; } return false; } if (isset($this->_prefixToPaths[$prefix])) { unset($this->_prefixToPaths[$prefix]); return true; } return false; } if ($this->_useStaticRegistry) { self::$_staticPrefixToPaths[$this->_useStaticRegistry] = array(); } else { $this->_prefixToPaths = array(); } return true; }
php
public function clearPaths($prefix = null) { if ((null !== $prefix) && is_string($prefix)) { $prefix = $this->_formatPrefix($prefix); if ($this->_useStaticRegistry) { if (isset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix])) { unset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix]); return true; } return false; } if (isset($this->_prefixToPaths[$prefix])) { unset($this->_prefixToPaths[$prefix]); return true; } return false; } if ($this->_useStaticRegistry) { self::$_staticPrefixToPaths[$this->_useStaticRegistry] = array(); } else { $this->_prefixToPaths = array(); } return true; }
[ "public", "function", "clearPaths", "(", "$", "prefix", "=", "null", ")", "{", "if", "(", "(", "null", "!==", "$", "prefix", ")", "&&", "is_string", "(", "$", "prefix", ")", ")", "{", "$", "prefix", "=", "$", "this", "->", "_formatPrefix", "(", "$", "prefix", ")", ";", "if", "(", "$", "this", "->", "_useStaticRegistry", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "_staticPrefixToPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "prefix", "]", ")", ")", "{", "unset", "(", "self", "::", "$", "_staticPrefixToPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "prefix", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_prefixToPaths", "[", "$", "prefix", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "_prefixToPaths", "[", "$", "prefix", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "if", "(", "$", "this", "->", "_useStaticRegistry", ")", "{", "self", "::", "$", "_staticPrefixToPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", "=", "array", "(", ")", ";", "}", "else", "{", "$", "this", "->", "_prefixToPaths", "=", "array", "(", ")", ";", "}", "return", "true", ";", "}" ]
Clear path stack @param string $prefix @return bool False only if $prefix does not exist
[ "Clear", "path", "stack" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/PluginLoader.php#L202-L230
12,022
joegreen88/zf1-components-base
src/Zend/Loader/PluginLoader.php
Zend_Loader_PluginLoader.isLoaded
public function isLoaded($name) { $name = $this->_formatName($name); if ($this->_useStaticRegistry) { return isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]); } return isset($this->_loadedPlugins[$name]); }
php
public function isLoaded($name) { $name = $this->_formatName($name); if ($this->_useStaticRegistry) { return isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]); } return isset($this->_loadedPlugins[$name]); }
[ "public", "function", "isLoaded", "(", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "_formatName", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "_useStaticRegistry", ")", "{", "return", "isset", "(", "self", "::", "$", "_staticLoadedPlugins", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "name", "]", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "_loadedPlugins", "[", "$", "name", "]", ")", ";", "}" ]
Whether or not a Plugin by a specific name is loaded @param string $name @return Zend_Loader_PluginLoader
[ "Whether", "or", "not", "a", "Plugin", "by", "a", "specific", "name", "is", "loaded" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/PluginLoader.php#L284-L292
12,023
joegreen88/zf1-components-base
src/Zend/Loader/PluginLoader.php
Zend_Loader_PluginLoader.getClassName
public function getClassName($name) { $name = $this->_formatName($name); if ($this->_useStaticRegistry && isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]) ) { return self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]; } elseif (isset($this->_loadedPlugins[$name])) { return $this->_loadedPlugins[$name]; } return false; }
php
public function getClassName($name) { $name = $this->_formatName($name); if ($this->_useStaticRegistry && isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]) ) { return self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]; } elseif (isset($this->_loadedPlugins[$name])) { return $this->_loadedPlugins[$name]; } return false; }
[ "public", "function", "getClassName", "(", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "_formatName", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "_useStaticRegistry", "&&", "isset", "(", "self", "::", "$", "_staticLoadedPlugins", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "name", "]", ")", ")", "{", "return", "self", "::", "$", "_staticLoadedPlugins", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "name", "]", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "_loadedPlugins", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "_loadedPlugins", "[", "$", "name", "]", ";", "}", "return", "false", ";", "}" ]
Return full class name for a named plugin @param string $name @return string|false False if class not found, class name otherwise
[ "Return", "full", "class", "name", "for", "a", "named", "plugin" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/PluginLoader.php#L300-L312
12,024
joegreen88/zf1-components-base
src/Zend/Loader/PluginLoader.php
Zend_Loader_PluginLoader.getClassPath
public function getClassPath($name) { $name = $this->_formatName($name); if ($this->_useStaticRegistry && !empty(self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name]) ) { return self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name]; } elseif (!empty($this->_loadedPluginPaths[$name])) { return $this->_loadedPluginPaths[$name]; } if ($this->isLoaded($name)) { $class = $this->getClassName($name); $r = new ReflectionClass($class); $path = $r->getFileName(); if ($this->_useStaticRegistry) { self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name] = $path; } else { $this->_loadedPluginPaths[$name] = $path; } return $path; } return false; }
php
public function getClassPath($name) { $name = $this->_formatName($name); if ($this->_useStaticRegistry && !empty(self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name]) ) { return self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name]; } elseif (!empty($this->_loadedPluginPaths[$name])) { return $this->_loadedPluginPaths[$name]; } if ($this->isLoaded($name)) { $class = $this->getClassName($name); $r = new ReflectionClass($class); $path = $r->getFileName(); if ($this->_useStaticRegistry) { self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name] = $path; } else { $this->_loadedPluginPaths[$name] = $path; } return $path; } return false; }
[ "public", "function", "getClassPath", "(", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "_formatName", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "_useStaticRegistry", "&&", "!", "empty", "(", "self", "::", "$", "_staticLoadedPluginPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "name", "]", ")", ")", "{", "return", "self", "::", "$", "_staticLoadedPluginPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "name", "]", ";", "}", "elseif", "(", "!", "empty", "(", "$", "this", "->", "_loadedPluginPaths", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "_loadedPluginPaths", "[", "$", "name", "]", ";", "}", "if", "(", "$", "this", "->", "isLoaded", "(", "$", "name", ")", ")", "{", "$", "class", "=", "$", "this", "->", "getClassName", "(", "$", "name", ")", ";", "$", "r", "=", "new", "ReflectionClass", "(", "$", "class", ")", ";", "$", "path", "=", "$", "r", "->", "getFileName", "(", ")", ";", "if", "(", "$", "this", "->", "_useStaticRegistry", ")", "{", "self", "::", "$", "_staticLoadedPluginPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "name", "]", "=", "$", "path", ";", "}", "else", "{", "$", "this", "->", "_loadedPluginPaths", "[", "$", "name", "]", "=", "$", "path", ";", "}", "return", "$", "path", ";", "}", "return", "false", ";", "}" ]
Get path to plugin class @param mixed $name @return string|false False if not found
[ "Get", "path", "to", "plugin", "class" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/PluginLoader.php#L320-L344
12,025
joegreen88/zf1-components-base
src/Zend/Loader/PluginLoader.php
Zend_Loader_PluginLoader.load
public function load($name, $throwExceptions = true) { $name = $this->_formatName($name); if ($this->isLoaded($name)) { return $this->getClassName($name); } if ($this->_useStaticRegistry) { $registry = self::$_staticPrefixToPaths[$this->_useStaticRegistry]; } else { $registry = $this->_prefixToPaths; } $registry = array_reverse($registry, true); $found = false; if (false !== strpos($name, '\\')) { $classFile = str_replace('\\', DIRECTORY_SEPARATOR, $name) . '.php'; } else { $classFile = str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php'; } $incFile = self::getIncludeFileCache(); foreach ($registry as $prefix => $paths) { $className = $prefix . $name; if (class_exists($className)) { $found = true; break; } $paths = array_reverse($paths, true); foreach ($paths as $path) { $loadFile = $path . $classFile; if (Zend_Loader::isReadable($loadFile)) { include_once $loadFile; if (class_exists($className, false)) { if (null !== $incFile) { self::_appendIncFile($loadFile); } $found = true; break 2; } } } } if (!$found) { if (!$throwExceptions) { return false; } $message = "Plugin by name '$name' was not found in the registry; used paths:"; foreach ($registry as $prefix => $paths) { $message .= "\n$prefix: " . implode(PATH_SEPARATOR, $paths); } throw new Zend_Loader_PluginLoader_Exception($message); } if ($this->_useStaticRegistry) { self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name] = $className; } else { $this->_loadedPlugins[$name] = $className; } return $className; }
php
public function load($name, $throwExceptions = true) { $name = $this->_formatName($name); if ($this->isLoaded($name)) { return $this->getClassName($name); } if ($this->_useStaticRegistry) { $registry = self::$_staticPrefixToPaths[$this->_useStaticRegistry]; } else { $registry = $this->_prefixToPaths; } $registry = array_reverse($registry, true); $found = false; if (false !== strpos($name, '\\')) { $classFile = str_replace('\\', DIRECTORY_SEPARATOR, $name) . '.php'; } else { $classFile = str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php'; } $incFile = self::getIncludeFileCache(); foreach ($registry as $prefix => $paths) { $className = $prefix . $name; if (class_exists($className)) { $found = true; break; } $paths = array_reverse($paths, true); foreach ($paths as $path) { $loadFile = $path . $classFile; if (Zend_Loader::isReadable($loadFile)) { include_once $loadFile; if (class_exists($className, false)) { if (null !== $incFile) { self::_appendIncFile($loadFile); } $found = true; break 2; } } } } if (!$found) { if (!$throwExceptions) { return false; } $message = "Plugin by name '$name' was not found in the registry; used paths:"; foreach ($registry as $prefix => $paths) { $message .= "\n$prefix: " . implode(PATH_SEPARATOR, $paths); } throw new Zend_Loader_PluginLoader_Exception($message); } if ($this->_useStaticRegistry) { self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name] = $className; } else { $this->_loadedPlugins[$name] = $className; } return $className; }
[ "public", "function", "load", "(", "$", "name", ",", "$", "throwExceptions", "=", "true", ")", "{", "$", "name", "=", "$", "this", "->", "_formatName", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "isLoaded", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "getClassName", "(", "$", "name", ")", ";", "}", "if", "(", "$", "this", "->", "_useStaticRegistry", ")", "{", "$", "registry", "=", "self", "::", "$", "_staticPrefixToPaths", "[", "$", "this", "->", "_useStaticRegistry", "]", ";", "}", "else", "{", "$", "registry", "=", "$", "this", "->", "_prefixToPaths", ";", "}", "$", "registry", "=", "array_reverse", "(", "$", "registry", ",", "true", ")", ";", "$", "found", "=", "false", ";", "if", "(", "false", "!==", "strpos", "(", "$", "name", ",", "'\\\\'", ")", ")", "{", "$", "classFile", "=", "str_replace", "(", "'\\\\'", ",", "DIRECTORY_SEPARATOR", ",", "$", "name", ")", ".", "'.php'", ";", "}", "else", "{", "$", "classFile", "=", "str_replace", "(", "'_'", ",", "DIRECTORY_SEPARATOR", ",", "$", "name", ")", ".", "'.php'", ";", "}", "$", "incFile", "=", "self", "::", "getIncludeFileCache", "(", ")", ";", "foreach", "(", "$", "registry", "as", "$", "prefix", "=>", "$", "paths", ")", "{", "$", "className", "=", "$", "prefix", ".", "$", "name", ";", "if", "(", "class_exists", "(", "$", "className", ")", ")", "{", "$", "found", "=", "true", ";", "break", ";", "}", "$", "paths", "=", "array_reverse", "(", "$", "paths", ",", "true", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "$", "loadFile", "=", "$", "path", ".", "$", "classFile", ";", "if", "(", "Zend_Loader", "::", "isReadable", "(", "$", "loadFile", ")", ")", "{", "include_once", "$", "loadFile", ";", "if", "(", "class_exists", "(", "$", "className", ",", "false", ")", ")", "{", "if", "(", "null", "!==", "$", "incFile", ")", "{", "self", "::", "_appendIncFile", "(", "$", "loadFile", ")", ";", "}", "$", "found", "=", "true", ";", "break", "2", ";", "}", "}", "}", "}", "if", "(", "!", "$", "found", ")", "{", "if", "(", "!", "$", "throwExceptions", ")", "{", "return", "false", ";", "}", "$", "message", "=", "\"Plugin by name '$name' was not found in the registry; used paths:\"", ";", "foreach", "(", "$", "registry", "as", "$", "prefix", "=>", "$", "paths", ")", "{", "$", "message", ".=", "\"\\n$prefix: \"", ".", "implode", "(", "PATH_SEPARATOR", ",", "$", "paths", ")", ";", "}", "throw", "new", "Zend_Loader_PluginLoader_Exception", "(", "$", "message", ")", ";", "}", "if", "(", "$", "this", "->", "_useStaticRegistry", ")", "{", "self", "::", "$", "_staticLoadedPlugins", "[", "$", "this", "->", "_useStaticRegistry", "]", "[", "$", "name", "]", "=", "$", "className", ";", "}", "else", "{", "$", "this", "->", "_loadedPlugins", "[", "$", "name", "]", "=", "$", "className", ";", "}", "return", "$", "className", ";", "}" ]
Load a plugin via the name provided @param string $name @param bool $throwExceptions Whether or not to throw exceptions if the class is not resolved @return string|false Class name of loaded class; false if $throwExceptions if false and no class found @throws Zend_Loader_Exception if class not found
[ "Load", "a", "plugin", "via", "the", "name", "provided" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/PluginLoader.php#L356-L421
12,026
joegreen88/zf1-components-base
src/Zend/Loader/PluginLoader.php
Zend_Loader_PluginLoader.setIncludeFileCache
public static function setIncludeFileCache($file) { if (null === $file) { self::$_includeFileCache = null; return; } if (!file_exists($file) && !file_exists(dirname($file))) { throw new Zend_Loader_PluginLoader_Exception('Specified file does not exist and/or directory does not exist (' . $file . ')'); } if (file_exists($file) && !is_writable($file)) { throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')'); } if (!file_exists($file) && file_exists(dirname($file)) && !is_writable(dirname($file))) { throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')'); } self::$_includeFileCache = $file; }
php
public static function setIncludeFileCache($file) { if (null === $file) { self::$_includeFileCache = null; return; } if (!file_exists($file) && !file_exists(dirname($file))) { throw new Zend_Loader_PluginLoader_Exception('Specified file does not exist and/or directory does not exist (' . $file . ')'); } if (file_exists($file) && !is_writable($file)) { throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')'); } if (!file_exists($file) && file_exists(dirname($file)) && !is_writable(dirname($file))) { throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')'); } self::$_includeFileCache = $file; }
[ "public", "static", "function", "setIncludeFileCache", "(", "$", "file", ")", "{", "if", "(", "null", "===", "$", "file", ")", "{", "self", "::", "$", "_includeFileCache", "=", "null", ";", "return", ";", "}", "if", "(", "!", "file_exists", "(", "$", "file", ")", "&&", "!", "file_exists", "(", "dirname", "(", "$", "file", ")", ")", ")", "{", "throw", "new", "Zend_Loader_PluginLoader_Exception", "(", "'Specified file does not exist and/or directory does not exist ('", ".", "$", "file", ".", "')'", ")", ";", "}", "if", "(", "file_exists", "(", "$", "file", ")", "&&", "!", "is_writable", "(", "$", "file", ")", ")", "{", "throw", "new", "Zend_Loader_PluginLoader_Exception", "(", "'Specified file is not writeable ('", ".", "$", "file", ".", "')'", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "file", ")", "&&", "file_exists", "(", "dirname", "(", "$", "file", ")", ")", "&&", "!", "is_writable", "(", "dirname", "(", "$", "file", ")", ")", ")", "{", "throw", "new", "Zend_Loader_PluginLoader_Exception", "(", "'Specified file is not writeable ('", ".", "$", "file", ".", "')'", ")", ";", "}", "self", "::", "$", "_includeFileCache", "=", "$", "file", ";", "}" ]
Set path to class file cache Specify a path to a file that will add include_once statements for each plugin class loaded. This is an opt-in feature for performance purposes. @param string $file @return void @throws Zend_Loader_PluginLoader_Exception if file is not writeable or path does not exist
[ "Set", "path", "to", "class", "file", "cache" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/PluginLoader.php#L433-L454
12,027
joegreen88/zf1-components-base
src/Zend/Loader/PluginLoader.php
Zend_Loader_PluginLoader._appendIncFile
protected static function _appendIncFile($incFile) { if (!file_exists(self::$_includeFileCache)) { $file = '<?php'; } else { $file = file_get_contents(self::$_includeFileCache); } if (!strstr($file, $incFile)) { $file .= "\ninclude_once '$incFile';"; file_put_contents(self::$_includeFileCache, $file); } }
php
protected static function _appendIncFile($incFile) { if (!file_exists(self::$_includeFileCache)) { $file = '<?php'; } else { $file = file_get_contents(self::$_includeFileCache); } if (!strstr($file, $incFile)) { $file .= "\ninclude_once '$incFile';"; file_put_contents(self::$_includeFileCache, $file); } }
[ "protected", "static", "function", "_appendIncFile", "(", "$", "incFile", ")", "{", "if", "(", "!", "file_exists", "(", "self", "::", "$", "_includeFileCache", ")", ")", "{", "$", "file", "=", "'<?php'", ";", "}", "else", "{", "$", "file", "=", "file_get_contents", "(", "self", "::", "$", "_includeFileCache", ")", ";", "}", "if", "(", "!", "strstr", "(", "$", "file", ",", "$", "incFile", ")", ")", "{", "$", "file", ".=", "\"\\ninclude_once '$incFile';\"", ";", "file_put_contents", "(", "self", "::", "$", "_includeFileCache", ",", "$", "file", ")", ";", "}", "}" ]
Append an include_once statement to the class file cache @param string $incFile @return void
[ "Append", "an", "include_once", "statement", "to", "the", "class", "file", "cache" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/PluginLoader.php#L472-L483
12,028
bwaidelich/Wwwision.Eventr
Classes/EventHandler/ProjectionHandleJob.php
ProjectionHandleJob.execute
public function execute(QueueInterface $queue, Message $message) { $projection = $this->eventr->getProjection($this->projectionName); $aggregateType = $this->eventr->getAggregateType($this->aggregateType); $aggregate = $aggregateType->getAggregate($this->aggregateId); $projection->handle($aggregate, $this->event); return true; }
php
public function execute(QueueInterface $queue, Message $message) { $projection = $this->eventr->getProjection($this->projectionName); $aggregateType = $this->eventr->getAggregateType($this->aggregateType); $aggregate = $aggregateType->getAggregate($this->aggregateId); $projection->handle($aggregate, $this->event); return true; }
[ "public", "function", "execute", "(", "QueueInterface", "$", "queue", ",", "Message", "$", "message", ")", "{", "$", "projection", "=", "$", "this", "->", "eventr", "->", "getProjection", "(", "$", "this", "->", "projectionName", ")", ";", "$", "aggregateType", "=", "$", "this", "->", "eventr", "->", "getAggregateType", "(", "$", "this", "->", "aggregateType", ")", ";", "$", "aggregate", "=", "$", "aggregateType", "->", "getAggregate", "(", "$", "this", "->", "aggregateId", ")", ";", "$", "projection", "->", "handle", "(", "$", "aggregate", ",", "$", "this", "->", "event", ")", ";", "return", "true", ";", "}" ]
Execute the job A job should finish itself after successful execution using the queue methods. @param QueueInterface $queue @param Message $message The original message @return boolean TRUE if the job was executed successfully and the message should be finished
[ "Execute", "the", "job", "A", "job", "should", "finish", "itself", "after", "successful", "execution", "using", "the", "queue", "methods", "." ]
c3cfac121c922e8e11e2605fe88711d22a0c49d7
https://github.com/bwaidelich/Wwwision.Eventr/blob/c3cfac121c922e8e11e2605fe88711d22a0c49d7/Classes/EventHandler/ProjectionHandleJob.php#L65-L72
12,029
horse-php/horse
src/Horse/Transformers/ClassTransformer.php
ClassTransformer.transform
public function transform(Command $command) { $block = $this->block->reflector(new \ReflectionClass($command)); $lines = []; foreach ($block->getLines() as $line) { $lines[] = $line->stripTag(); } list($name, $description, $signature) = $lines; $command->setName($name); $command->setDescription($description); $command->setDefinition($this->getDefinition($signature)); }
php
public function transform(Command $command) { $block = $this->block->reflector(new \ReflectionClass($command)); $lines = []; foreach ($block->getLines() as $line) { $lines[] = $line->stripTag(); } list($name, $description, $signature) = $lines; $command->setName($name); $command->setDescription($description); $command->setDefinition($this->getDefinition($signature)); }
[ "public", "function", "transform", "(", "Command", "$", "command", ")", "{", "$", "block", "=", "$", "this", "->", "block", "->", "reflector", "(", "new", "\\", "ReflectionClass", "(", "$", "command", ")", ")", ";", "$", "lines", "=", "[", "]", ";", "foreach", "(", "$", "block", "->", "getLines", "(", ")", "as", "$", "line", ")", "{", "$", "lines", "[", "]", "=", "$", "line", "->", "stripTag", "(", ")", ";", "}", "list", "(", "$", "name", ",", "$", "description", ",", "$", "signature", ")", "=", "$", "lines", ";", "$", "command", "->", "setName", "(", "$", "name", ")", ";", "$", "command", "->", "setDescription", "(", "$", "description", ")", ";", "$", "command", "->", "setDefinition", "(", "$", "this", "->", "getDefinition", "(", "$", "signature", ")", ")", ";", "}" ]
Read the command metadata and apply it. @param Command $command @return void
[ "Read", "the", "command", "metadata", "and", "apply", "it", "." ]
e2b72508dde353de6cacfbed852aa3de3fc06eff
https://github.com/horse-php/horse/blob/e2b72508dde353de6cacfbed852aa3de3fc06eff/src/Horse/Transformers/ClassTransformer.php#L54-L69
12,030
horse-php/horse
src/Horse/Transformers/ClassTransformer.php
ClassTransformer.getDefinition
public function getDefinition($signature) { $elements = $this->meta->parseMany($signature); return \array_map([$this->element, 'transform'], $elements); }
php
public function getDefinition($signature) { $elements = $this->meta->parseMany($signature); return \array_map([$this->element, 'transform'], $elements); }
[ "public", "function", "getDefinition", "(", "$", "signature", ")", "{", "$", "elements", "=", "$", "this", "->", "meta", "->", "parseMany", "(", "$", "signature", ")", ";", "return", "\\", "array_map", "(", "[", "$", "this", "->", "element", ",", "'transform'", "]", ",", "$", "elements", ")", ";", "}" ]
Transform the string to a valid command definition. @param string $signature @return array
[ "Transform", "the", "string", "to", "a", "valid", "command", "definition", "." ]
e2b72508dde353de6cacfbed852aa3de3fc06eff
https://github.com/horse-php/horse/blob/e2b72508dde353de6cacfbed852aa3de3fc06eff/src/Horse/Transformers/ClassTransformer.php#L77-L82
12,031
skgroup/php-rbac
src/Manager.php
Manager.addRole
public function addRole($role, $inherits = null) { if (is_string($role)) { $name = $role; $role = $this->createRole($name); } elseif ($role instanceof RoleInterface) { $name = $role->getName(); } else { throw new \InvalidArgumentException('Role must be a string or implement RoleInterface'); } if ($inherits) { if (!is_array($inherits)) { $inherits = [$inherits]; } foreach ($inherits as $inherit) { $role->inherit($this->getRole($inherit)); } } $this->roles[$name] = $role; return $role; }
php
public function addRole($role, $inherits = null) { if (is_string($role)) { $name = $role; $role = $this->createRole($name); } elseif ($role instanceof RoleInterface) { $name = $role->getName(); } else { throw new \InvalidArgumentException('Role must be a string or implement RoleInterface'); } if ($inherits) { if (!is_array($inherits)) { $inherits = [$inherits]; } foreach ($inherits as $inherit) { $role->inherit($this->getRole($inherit)); } } $this->roles[$name] = $role; return $role; }
[ "public", "function", "addRole", "(", "$", "role", ",", "$", "inherits", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "role", ")", ")", "{", "$", "name", "=", "$", "role", ";", "$", "role", "=", "$", "this", "->", "createRole", "(", "$", "name", ")", ";", "}", "elseif", "(", "$", "role", "instanceof", "RoleInterface", ")", "{", "$", "name", "=", "$", "role", "->", "getName", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Role must be a string or implement RoleInterface'", ")", ";", "}", "if", "(", "$", "inherits", ")", "{", "if", "(", "!", "is_array", "(", "$", "inherits", ")", ")", "{", "$", "inherits", "=", "[", "$", "inherits", "]", ";", "}", "foreach", "(", "$", "inherits", "as", "$", "inherit", ")", "{", "$", "role", "->", "inherit", "(", "$", "this", "->", "getRole", "(", "$", "inherit", ")", ")", ";", "}", "}", "$", "this", "->", "roles", "[", "$", "name", "]", "=", "$", "role", ";", "return", "$", "role", ";", "}" ]
Creates a new Role to the RBAC system. @param string $role @param string|array|RoleInterface $inherits @return RoleInterface
[ "Creates", "a", "new", "Role", "to", "the", "RBAC", "system", "." ]
89b08cacda9b1376b8f07d16038d2eade6dfb9e8
https://github.com/skgroup/php-rbac/blob/89b08cacda9b1376b8f07d16038d2eade6dfb9e8/src/Manager.php#L40-L64
12,032
skgroup/php-rbac
src/Manager.php
Manager.addPermission
public function addPermission($permission) { if (is_string($permission)) { $name = $permission; $permission = $this->createPermission($name); } elseif ($permission instanceof PermissionInterface) { $name = $permission->getName(); } else { throw new \InvalidArgumentException('Permission must be a string or implement PermissionInterface'); } $this->permissions[$name] = $permission; return $permission; }
php
public function addPermission($permission) { if (is_string($permission)) { $name = $permission; $permission = $this->createPermission($name); } elseif ($permission instanceof PermissionInterface) { $name = $permission->getName(); } else { throw new \InvalidArgumentException('Permission must be a string or implement PermissionInterface'); } $this->permissions[$name] = $permission; return $permission; }
[ "public", "function", "addPermission", "(", "$", "permission", ")", "{", "if", "(", "is_string", "(", "$", "permission", ")", ")", "{", "$", "name", "=", "$", "permission", ";", "$", "permission", "=", "$", "this", "->", "createPermission", "(", "$", "name", ")", ";", "}", "elseif", "(", "$", "permission", "instanceof", "PermissionInterface", ")", "{", "$", "name", "=", "$", "permission", "->", "getName", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Permission must be a string or implement PermissionInterface'", ")", ";", "}", "$", "this", "->", "permissions", "[", "$", "name", "]", "=", "$", "permission", ";", "return", "$", "permission", ";", "}" ]
Adds a permission to the RBAC system. @param string|PermissionInterface $permission @return PermissionInterface
[ "Adds", "a", "permission", "to", "the", "RBAC", "system", "." ]
89b08cacda9b1376b8f07d16038d2eade6dfb9e8
https://github.com/skgroup/php-rbac/blob/89b08cacda9b1376b8f07d16038d2eade6dfb9e8/src/Manager.php#L72-L85
12,033
skgroup/php-rbac
src/Manager.php
Manager.revokeRole
public function revokeRole($role) { if ($this->hasRole($role)) { unset($this->roles[$role]); return true; } else { return false; } }
php
public function revokeRole($role) { if ($this->hasRole($role)) { unset($this->roles[$role]); return true; } else { return false; } }
[ "public", "function", "revokeRole", "(", "$", "role", ")", "{", "if", "(", "$", "this", "->", "hasRole", "(", "$", "role", ")", ")", "{", "unset", "(", "$", "this", "->", "roles", "[", "$", "role", "]", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Revokes a role from the RBAC system. @param string $role @return bool
[ "Revokes", "a", "role", "from", "the", "RBAC", "system", "." ]
89b08cacda9b1376b8f07d16038d2eade6dfb9e8
https://github.com/skgroup/php-rbac/blob/89b08cacda9b1376b8f07d16038d2eade6dfb9e8/src/Manager.php#L93-L101
12,034
skgroup/php-rbac
src/Manager.php
Manager.getRole
public function getRole($name) { if ($this->hasRole($name)) { return $this->roles[$name]; } throw new \InvalidArgumentException(sprintf('No role with name "%s" could be found', $name)); }
php
public function getRole($name) { if ($this->hasRole($name)) { return $this->roles[$name]; } throw new \InvalidArgumentException(sprintf('No role with name "%s" could be found', $name)); }
[ "public", "function", "getRole", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "hasRole", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "roles", "[", "$", "name", "]", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'No role with name \"%s\" could be found'", ",", "$", "name", ")", ")", ";", "}" ]
Returns the named role from the RBAC system. @param string $name @return RoleInterface
[ "Returns", "the", "named", "role", "from", "the", "RBAC", "system", "." ]
89b08cacda9b1376b8f07d16038d2eade6dfb9e8
https://github.com/skgroup/php-rbac/blob/89b08cacda9b1376b8f07d16038d2eade6dfb9e8/src/Manager.php#L124-L131
12,035
skgroup/php-rbac
src/Manager.php
Manager.revokePermission
public function revokePermission($permission) { if ($this->hasPermission($permission)) { unset($this->permissions[$permission]); return true; } else { return false; } }
php
public function revokePermission($permission) { if ($this->hasPermission($permission)) { unset($this->permissions[$permission]); return true; } else { return false; } }
[ "public", "function", "revokePermission", "(", "$", "permission", ")", "{", "if", "(", "$", "this", "->", "hasPermission", "(", "$", "permission", ")", ")", "{", "unset", "(", "$", "this", "->", "permissions", "[", "$", "permission", "]", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Revokes a permission from the RBAC system. @param string $permission @return bool
[ "Revokes", "a", "permission", "from", "the", "RBAC", "system", "." ]
89b08cacda9b1376b8f07d16038d2eade6dfb9e8
https://github.com/skgroup/php-rbac/blob/89b08cacda9b1376b8f07d16038d2eade6dfb9e8/src/Manager.php#L149-L157
12,036
skgroup/php-rbac
src/Manager.php
Manager.getPermission
public function getPermission($name) { if ($this->hasPermission($name)) { return $this->permissions[$name]; } throw new \InvalidArgumentException(sprintf('No permission with name "%s" could be found', $name)); }
php
public function getPermission($name) { if ($this->hasPermission($name)) { return $this->permissions[$name]; } throw new \InvalidArgumentException(sprintf('No permission with name "%s" could be found', $name)); }
[ "public", "function", "getPermission", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "hasPermission", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "permissions", "[", "$", "name", "]", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'No permission with name \"%s\" could be found'", ",", "$", "name", ")", ")", ";", "}" ]
Returns the named permission from the RBAC system. @param string $name @return PermissionInterface
[ "Returns", "the", "named", "permission", "from", "the", "RBAC", "system", "." ]
89b08cacda9b1376b8f07d16038d2eade6dfb9e8
https://github.com/skgroup/php-rbac/blob/89b08cacda9b1376b8f07d16038d2eade6dfb9e8/src/Manager.php#L180-L187
12,037
fproject/php-common
fproject/common/utils/BinaryStream.php
BinaryStream.writeLongUTF
public function writeLongUTF($stream) { $this->writeLong($this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream)); $this->_stream.= $stream; }
php
public function writeLongUTF($stream) { $this->writeLong($this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream)); $this->_stream.= $stream; }
[ "public", "function", "writeLongUTF", "(", "$", "stream", ")", "{", "$", "this", "->", "writeLong", "(", "$", "this", "->", "_mbStringFunctionsOverloaded", "?", "mb_strlen", "(", "$", "stream", ",", "'8bit'", ")", ":", "strlen", "(", "$", "stream", ")", ")", ";", "$", "this", "->", "_stream", ".=", "$", "stream", ";", "}" ]
Write a long UTF string to the buffer @param string $stream @return BinaryStream
[ "Write", "a", "long", "UTF", "string", "to", "the", "buffer" ]
f8bb514e3fa421764e6a6f5bc167da28178e5236
https://github.com/fproject/php-common/blob/f8bb514e3fa421764e6a6f5bc167da28178e5236/fproject/common/utils/BinaryStream.php#L236-L240
12,038
bishopb/vanilla
applications/vanilla/controllers/class.categoriescontroller.php
CategoriesController.Table
public function Table() { if ($this->SyndicationMethod == SYNDICATION_NONE) { $this->View = 'table'; } else $this->View = 'all'; $this->All(); }
php
public function Table() { if ($this->SyndicationMethod == SYNDICATION_NONE) { $this->View = 'table'; } else $this->View = 'all'; $this->All(); }
[ "public", "function", "Table", "(", ")", "{", "if", "(", "$", "this", "->", "SyndicationMethod", "==", "SYNDICATION_NONE", ")", "{", "$", "this", "->", "View", "=", "'table'", ";", "}", "else", "$", "this", "->", "View", "=", "'all'", ";", "$", "this", "->", "All", "(", ")", ";", "}" ]
"Table" layout for categories. Mimics more traditional forum category layout.
[ "Table", "layout", "for", "categories", ".", "Mimics", "more", "traditional", "forum", "category", "layout", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.categoriescontroller.php#L56-L62
12,039
bishopb/vanilla
applications/vanilla/controllers/class.categoriescontroller.php
CategoriesController.Discussions
public function Discussions() { // Setup head $this->AddCssFile('vanilla.css'); $this->Menu->HighlightRoute('/discussions'); $this->AddJsFile('discussions.js'); $Title = C('Garden.HomepageTitle'); if ($Title) $this->Title($Title, ''); else $this->Title(T('All Categories')); $this->Description(C('Garden.Description', NULL)); Gdn_Theme::Section('CategoryDiscussionList'); // Set the category follow toggle before we load category data so that it affects the category query appropriately. $CategoryFollowToggleModule = new CategoryFollowToggleModule($this); $CategoryFollowToggleModule->SetToggle(); // Get category data and discussions $this->DiscussionsPerCategory = C('Vanilla.Discussions.PerCategory', 5); $DiscussionModel = new DiscussionModel(); $this->CategoryModel->Watching = !Gdn::Session()->GetPreference('ShowAllCategories'); $this->CategoryData = $this->CategoryModel->GetFull(); $this->SetData('Categories', $this->CategoryData); $this->CategoryDiscussionData = array(); foreach ($this->CategoryData->Result() as $Category) { if ($Category->CategoryID > 0) $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID, 'Announce' => 'all')); } // Add modules $this->AddModule('NewDiscussionModule'); $this->AddModule('DiscussionFilterModule'); $this->AddModule('CategoriesModule'); $this->AddModule('BookmarkedModule'); $this->AddModule($CategoryFollowToggleModule); // Set view and render $this->View = 'discussions'; $this->CanonicalUrl(Url('/categories', TRUE)); $Path = $this->FetchViewLocation('helper_functions', 'discussions', FALSE, FALSE); if ($Path) include_once $Path; $this->Render(); }
php
public function Discussions() { // Setup head $this->AddCssFile('vanilla.css'); $this->Menu->HighlightRoute('/discussions'); $this->AddJsFile('discussions.js'); $Title = C('Garden.HomepageTitle'); if ($Title) $this->Title($Title, ''); else $this->Title(T('All Categories')); $this->Description(C('Garden.Description', NULL)); Gdn_Theme::Section('CategoryDiscussionList'); // Set the category follow toggle before we load category data so that it affects the category query appropriately. $CategoryFollowToggleModule = new CategoryFollowToggleModule($this); $CategoryFollowToggleModule->SetToggle(); // Get category data and discussions $this->DiscussionsPerCategory = C('Vanilla.Discussions.PerCategory', 5); $DiscussionModel = new DiscussionModel(); $this->CategoryModel->Watching = !Gdn::Session()->GetPreference('ShowAllCategories'); $this->CategoryData = $this->CategoryModel->GetFull(); $this->SetData('Categories', $this->CategoryData); $this->CategoryDiscussionData = array(); foreach ($this->CategoryData->Result() as $Category) { if ($Category->CategoryID > 0) $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID, 'Announce' => 'all')); } // Add modules $this->AddModule('NewDiscussionModule'); $this->AddModule('DiscussionFilterModule'); $this->AddModule('CategoriesModule'); $this->AddModule('BookmarkedModule'); $this->AddModule($CategoryFollowToggleModule); // Set view and render $this->View = 'discussions'; $this->CanonicalUrl(Url('/categories', TRUE)); $Path = $this->FetchViewLocation('helper_functions', 'discussions', FALSE, FALSE); if ($Path) include_once $Path; $this->Render(); }
[ "public", "function", "Discussions", "(", ")", "{", "// Setup head", "$", "this", "->", "AddCssFile", "(", "'vanilla.css'", ")", ";", "$", "this", "->", "Menu", "->", "HighlightRoute", "(", "'/discussions'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'discussions.js'", ")", ";", "$", "Title", "=", "C", "(", "'Garden.HomepageTitle'", ")", ";", "if", "(", "$", "Title", ")", "$", "this", "->", "Title", "(", "$", "Title", ",", "''", ")", ";", "else", "$", "this", "->", "Title", "(", "T", "(", "'All Categories'", ")", ")", ";", "$", "this", "->", "Description", "(", "C", "(", "'Garden.Description'", ",", "NULL", ")", ")", ";", "Gdn_Theme", "::", "Section", "(", "'CategoryDiscussionList'", ")", ";", "// Set the category follow toggle before we load category data so that it affects the category query appropriately.", "$", "CategoryFollowToggleModule", "=", "new", "CategoryFollowToggleModule", "(", "$", "this", ")", ";", "$", "CategoryFollowToggleModule", "->", "SetToggle", "(", ")", ";", "// Get category data and discussions", "$", "this", "->", "DiscussionsPerCategory", "=", "C", "(", "'Vanilla.Discussions.PerCategory'", ",", "5", ")", ";", "$", "DiscussionModel", "=", "new", "DiscussionModel", "(", ")", ";", "$", "this", "->", "CategoryModel", "->", "Watching", "=", "!", "Gdn", "::", "Session", "(", ")", "->", "GetPreference", "(", "'ShowAllCategories'", ")", ";", "$", "this", "->", "CategoryData", "=", "$", "this", "->", "CategoryModel", "->", "GetFull", "(", ")", ";", "$", "this", "->", "SetData", "(", "'Categories'", ",", "$", "this", "->", "CategoryData", ")", ";", "$", "this", "->", "CategoryDiscussionData", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "CategoryData", "->", "Result", "(", ")", "as", "$", "Category", ")", "{", "if", "(", "$", "Category", "->", "CategoryID", ">", "0", ")", "$", "this", "->", "CategoryDiscussionData", "[", "$", "Category", "->", "CategoryID", "]", "=", "$", "DiscussionModel", "->", "Get", "(", "0", ",", "$", "this", "->", "DiscussionsPerCategory", ",", "array", "(", "'d.CategoryID'", "=>", "$", "Category", "->", "CategoryID", ",", "'Announce'", "=>", "'all'", ")", ")", ";", "}", "// Add modules", "$", "this", "->", "AddModule", "(", "'NewDiscussionModule'", ")", ";", "$", "this", "->", "AddModule", "(", "'DiscussionFilterModule'", ")", ";", "$", "this", "->", "AddModule", "(", "'CategoriesModule'", ")", ";", "$", "this", "->", "AddModule", "(", "'BookmarkedModule'", ")", ";", "$", "this", "->", "AddModule", "(", "$", "CategoryFollowToggleModule", ")", ";", "// Set view and render", "$", "this", "->", "View", "=", "'discussions'", ";", "$", "this", "->", "CanonicalUrl", "(", "Url", "(", "'/categories'", ",", "TRUE", ")", ")", ";", "$", "Path", "=", "$", "this", "->", "FetchViewLocation", "(", "'helper_functions'", ",", "'discussions'", ",", "FALSE", ",", "FALSE", ")", ";", "if", "(", "$", "Path", ")", "include_once", "$", "Path", ";", "$", "this", "->", "Render", "(", ")", ";", "}" ]
Show all categories and few discussions from each. @since 2.0.0 @access public
[ "Show", "all", "categories", "and", "few", "discussions", "from", "each", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.categoriescontroller.php#L297-L341
12,040
bishopb/vanilla
applications/vanilla/controllers/class.categoriescontroller.php
CategoriesController.Initialize
public function Initialize() { parent::Initialize(); if (!C('Vanilla.Categories.Use')) Redirect('/discussions'); if ($this->Menu) $this->Menu->HighlightRoute('/categories'); $this->CountCommentsPerPage = C('Vanilla.Comments.PerPage', 30); }
php
public function Initialize() { parent::Initialize(); if (!C('Vanilla.Categories.Use')) Redirect('/discussions'); if ($this->Menu) $this->Menu->HighlightRoute('/categories'); $this->CountCommentsPerPage = C('Vanilla.Comments.PerPage', 30); }
[ "public", "function", "Initialize", "(", ")", "{", "parent", "::", "Initialize", "(", ")", ";", "if", "(", "!", "C", "(", "'Vanilla.Categories.Use'", ")", ")", "Redirect", "(", "'/discussions'", ")", ";", "if", "(", "$", "this", "->", "Menu", ")", "$", "this", "->", "Menu", "->", "HighlightRoute", "(", "'/categories'", ")", ";", "$", "this", "->", "CountCommentsPerPage", "=", "C", "(", "'Vanilla.Comments.PerPage'", ",", "30", ")", ";", "}" ]
Highlight route. Always called by dispatcher before controller's requested method. @since 2.0.0 @access public
[ "Highlight", "route", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.categoriescontroller.php#L361-L369
12,041
netherphp/object
src/Nether/Object/Datastore.php
Datastore.Append
public function Append(Array $List, Bool $Keys=FALSE) { /*// goes through the given array and appends all the data to this dataset. by default the array keys are completely ignored. if you need to preseve the keys (and ergo overwrite any existing data) set the second argument to true. //*/ foreach($List as $Key => $Value) { if(!$Keys) $this->Push($Value); else $this->Shove($Key,$Value); } return; }
php
public function Append(Array $List, Bool $Keys=FALSE) { /*// goes through the given array and appends all the data to this dataset. by default the array keys are completely ignored. if you need to preseve the keys (and ergo overwrite any existing data) set the second argument to true. //*/ foreach($List as $Key => $Value) { if(!$Keys) $this->Push($Value); else $this->Shove($Key,$Value); } return; }
[ "public", "function", "Append", "(", "Array", "$", "List", ",", "Bool", "$", "Keys", "=", "FALSE", ")", "{", "/*//\r\n\tgoes through the given array and appends all the data to this dataset. by\r\n\tdefault the array keys are completely ignored. if you need to preseve\r\n\tthe keys (and ergo overwrite any existing data) set the second argument\r\n\tto true.\r\n\t//*/", "foreach", "(", "$", "List", "as", "$", "Key", "=>", "$", "Value", ")", "{", "if", "(", "!", "$", "Keys", ")", "$", "this", "->", "Push", "(", "$", "Value", ")", ";", "else", "$", "this", "->", "Shove", "(", "$", "Key", ",", "$", "Value", ")", ";", "}", "return", ";", "}" ]
item management api for the datastore.
[ "item", "management", "api", "for", "the", "datastore", "." ]
fd07e9340d9d2e4faff7ebb7e197d3ffb6f72ff4
https://github.com/netherphp/object/blob/fd07e9340d9d2e4faff7ebb7e197d3ffb6f72ff4/src/Nether/Object/Datastore.php#L233-L251
12,042
netherphp/object
src/Nether/Object/Datastore.php
Datastore.Each
public function Each(Callable $Function, ?Array $Argv=NULL) { /*// @argv callable Func run the specified function against every single thing in the list. it is is slower than running a direct foreach() on the property but it sure makes for some nice looking shit sometimes. //*/ foreach($this->Data as $Key => &$Value) $Function($Value,$Key,$this,...$Argv); return $this; }
php
public function Each(Callable $Function, ?Array $Argv=NULL) { /*// @argv callable Func run the specified function against every single thing in the list. it is is slower than running a direct foreach() on the property but it sure makes for some nice looking shit sometimes. //*/ foreach($this->Data as $Key => &$Value) $Function($Value,$Key,$this,...$Argv); return $this; }
[ "public", "function", "Each", "(", "Callable", "$", "Function", ",", "?", "Array", "$", "Argv", "=", "NULL", ")", "{", "/*//\r\n\t@argv callable Func\r\n\trun the specified function against every single thing in the list. it is\r\n\tis slower than running a direct foreach() on the property but it sure makes\r\n\tfor some nice looking shit sometimes.\r\n\t//*/", "foreach", "(", "$", "this", "->", "Data", "as", "$", "Key", "=>", "&", "$", "Value", ")", "$", "Function", "(", "$", "Value", ",", "$", "Key", ",", "$", "this", ",", "...", "$", "Argv", ")", ";", "return", "$", "this", ";", "}" ]
item manipulation api for the data.
[ "item", "manipulation", "api", "for", "the", "data", "." ]
fd07e9340d9d2e4faff7ebb7e197d3ffb6f72ff4
https://github.com/netherphp/object/blob/fd07e9340d9d2e4faff7ebb7e197d3ffb6f72ff4/src/Nether/Object/Datastore.php#L576-L589
12,043
bugotech/http
src/Exceptions/Handler.php
Handler.toIlluminateResponse
protected function toIlluminateResponse($response, Exception $e) { $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all()); $response->exception = $e; return $response; }
php
protected function toIlluminateResponse($response, Exception $e) { $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all()); $response->exception = $e; return $response; }
[ "protected", "function", "toIlluminateResponse", "(", "$", "response", ",", "Exception", "$", "e", ")", "{", "$", "response", "=", "new", "Response", "(", "$", "response", "->", "getContent", "(", ")", ",", "$", "response", "->", "getStatusCode", "(", ")", ",", "$", "response", "->", "headers", "->", "all", "(", ")", ")", ";", "$", "response", "->", "exception", "=", "$", "e", ";", "return", "$", "response", ";", "}" ]
Map exception into an illuminate response. @param \Symfony\Component\HttpFoundation\Response $response @param \Exception $e @return \Illuminate\Http\Response
[ "Map", "exception", "into", "an", "illuminate", "response", "." ]
68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486
https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/Exceptions/Handler.php#L40-L47
12,044
mijohansen/php-gae-util
src/Secrets.php
Secrets.getDefaultKeyName
static public function getDefaultKeyName(Config $conf = null) { $locationId = "global"; if (is_null($conf)) { $projectId = self::getProjectId(); $keyRingId = self::getKeyRingId(); $cryptoKeyId = self::getCryptoKeyId(); } else { $projectId = $conf->get(self::CONF_PROJECT_ID_NAME); $keyRingId = $conf->get(self::CONF_KEYRING_ID_NAME); $cryptoKeyId = $conf->get(self::CONF_KEY_ID_NAME); } return self::getKeyName($projectId, $locationId, $keyRingId, $cryptoKeyId); }
php
static public function getDefaultKeyName(Config $conf = null) { $locationId = "global"; if (is_null($conf)) { $projectId = self::getProjectId(); $keyRingId = self::getKeyRingId(); $cryptoKeyId = self::getCryptoKeyId(); } else { $projectId = $conf->get(self::CONF_PROJECT_ID_NAME); $keyRingId = $conf->get(self::CONF_KEYRING_ID_NAME); $cryptoKeyId = $conf->get(self::CONF_KEY_ID_NAME); } return self::getKeyName($projectId, $locationId, $keyRingId, $cryptoKeyId); }
[ "static", "public", "function", "getDefaultKeyName", "(", "Config", "$", "conf", "=", "null", ")", "{", "$", "locationId", "=", "\"global\"", ";", "if", "(", "is_null", "(", "$", "conf", ")", ")", "{", "$", "projectId", "=", "self", "::", "getProjectId", "(", ")", ";", "$", "keyRingId", "=", "self", "::", "getKeyRingId", "(", ")", ";", "$", "cryptoKeyId", "=", "self", "::", "getCryptoKeyId", "(", ")", ";", "}", "else", "{", "$", "projectId", "=", "$", "conf", "->", "get", "(", "self", "::", "CONF_PROJECT_ID_NAME", ")", ";", "$", "keyRingId", "=", "$", "conf", "->", "get", "(", "self", "::", "CONF_KEYRING_ID_NAME", ")", ";", "$", "cryptoKeyId", "=", "$", "conf", "->", "get", "(", "self", "::", "CONF_KEY_ID_NAME", ")", ";", "}", "return", "self", "::", "getKeyName", "(", "$", "projectId", ",", "$", "locationId", ",", "$", "keyRingId", ",", "$", "cryptoKeyId", ")", ";", "}" ]
Support passing the config object directly. @param Config|null $conf @return string
[ "Support", "passing", "the", "config", "object", "directly", "." ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Secrets.php#L75-L87
12,045
mijohansen/php-gae-util
src/Secrets.php
Secrets.encrypt
static public function encrypt($plaintextFileName, $ciphertextFileName, $key_name = null) { $kms = self::getService(); if (is_null($key_name)) { $key_name = self::getDefaultKeyName(); } // Use the KMS API to encrypt the text. $encoded = base64_encode(file_get_contents($plaintextFileName)); $request = new \Google_Service_CloudKMS_EncryptRequest(); $request->setPlaintext($encoded); $response = $kms->projects_locations_keyRings_cryptoKeys->encrypt( $key_name, $request ); // Write the encrypted text to a file. file_put_contents($ciphertextFileName, base64_decode($response['ciphertext'])); Util::cmdline("\tSaved encrypted text to $ciphertextFileName with key $key_name"); return true; }
php
static public function encrypt($plaintextFileName, $ciphertextFileName, $key_name = null) { $kms = self::getService(); if (is_null($key_name)) { $key_name = self::getDefaultKeyName(); } // Use the KMS API to encrypt the text. $encoded = base64_encode(file_get_contents($plaintextFileName)); $request = new \Google_Service_CloudKMS_EncryptRequest(); $request->setPlaintext($encoded); $response = $kms->projects_locations_keyRings_cryptoKeys->encrypt( $key_name, $request ); // Write the encrypted text to a file. file_put_contents($ciphertextFileName, base64_decode($response['ciphertext'])); Util::cmdline("\tSaved encrypted text to $ciphertextFileName with key $key_name"); return true; }
[ "static", "public", "function", "encrypt", "(", "$", "plaintextFileName", ",", "$", "ciphertextFileName", ",", "$", "key_name", "=", "null", ")", "{", "$", "kms", "=", "self", "::", "getService", "(", ")", ";", "if", "(", "is_null", "(", "$", "key_name", ")", ")", "{", "$", "key_name", "=", "self", "::", "getDefaultKeyName", "(", ")", ";", "}", "// Use the KMS API to encrypt the text.", "$", "encoded", "=", "base64_encode", "(", "file_get_contents", "(", "$", "plaintextFileName", ")", ")", ";", "$", "request", "=", "new", "\\", "Google_Service_CloudKMS_EncryptRequest", "(", ")", ";", "$", "request", "->", "setPlaintext", "(", "$", "encoded", ")", ";", "$", "response", "=", "$", "kms", "->", "projects_locations_keyRings_cryptoKeys", "->", "encrypt", "(", "$", "key_name", ",", "$", "request", ")", ";", "// Write the encrypted text to a file.", "file_put_contents", "(", "$", "ciphertextFileName", ",", "base64_decode", "(", "$", "response", "[", "'ciphertext'", "]", ")", ")", ";", "Util", "::", "cmdline", "(", "\"\\tSaved encrypted text to $ciphertextFileName with key $key_name\"", ")", ";", "return", "true", ";", "}" ]
Takes an input file and encrypts using the KMS service and puts it to an outputfile. @param $plaintextFileName @param $ciphertextFileName @return bool
[ "Takes", "an", "input", "file", "and", "encrypts", "using", "the", "KMS", "service", "and", "puts", "it", "to", "an", "outputfile", "." ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Secrets.php#L120-L139
12,046
mijohansen/php-gae-util
src/Secrets.php
Secrets.decrypt
static public function decrypt($ciphertextFileName, Config $config = null) { // Instantiate the client, authenticate, and add scopes. $kms = self::getService(); $name = self::getDefaultKeyName($config); // Use the KMS API to decrypt the text. $ciphertext = base64_encode(file_get_contents($ciphertextFileName)); $request = new \Google_Service_CloudKMS_DecryptRequest(); $request->setCiphertext($ciphertext); $response = $kms->projects_locations_keyRings_cryptoKeys->decrypt( $name, $request ); return base64_decode($response['plaintext']); }
php
static public function decrypt($ciphertextFileName, Config $config = null) { // Instantiate the client, authenticate, and add scopes. $kms = self::getService(); $name = self::getDefaultKeyName($config); // Use the KMS API to decrypt the text. $ciphertext = base64_encode(file_get_contents($ciphertextFileName)); $request = new \Google_Service_CloudKMS_DecryptRequest(); $request->setCiphertext($ciphertext); $response = $kms->projects_locations_keyRings_cryptoKeys->decrypt( $name, $request ); return base64_decode($response['plaintext']); }
[ "static", "public", "function", "decrypt", "(", "$", "ciphertextFileName", ",", "Config", "$", "config", "=", "null", ")", "{", "// Instantiate the client, authenticate, and add scopes.", "$", "kms", "=", "self", "::", "getService", "(", ")", ";", "$", "name", "=", "self", "::", "getDefaultKeyName", "(", "$", "config", ")", ";", "// Use the KMS API to decrypt the text.", "$", "ciphertext", "=", "base64_encode", "(", "file_get_contents", "(", "$", "ciphertextFileName", ")", ")", ";", "$", "request", "=", "new", "\\", "Google_Service_CloudKMS_DecryptRequest", "(", ")", ";", "$", "request", "->", "setCiphertext", "(", "$", "ciphertext", ")", ";", "$", "response", "=", "$", "kms", "->", "projects_locations_keyRings_cryptoKeys", "->", "decrypt", "(", "$", "name", ",", "$", "request", ")", ";", "return", "base64_decode", "(", "$", "response", "[", "'plaintext'", "]", ")", ";", "}" ]
Can receive the config singleton to be able to be used of the config class during initiation of that object. @param $ciphertextFileName @param Conf|null $conf @return bool|string
[ "Can", "receive", "the", "config", "singleton", "to", "be", "able", "to", "be", "used", "of", "the", "config", "class", "during", "initiation", "of", "that", "object", "." ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Secrets.php#L149-L162
12,047
mijohansen/php-gae-util
src/Secrets.php
Secrets.decryptJson
static public function decryptJson($ciphertextFileName, Config $config = null) { $content = self::decrypt($ciphertextFileName, $config); $data = json_decode($content, JSON_OBJECT_AS_ARRAY); Util::isArrayOrFail("Encrypted secrets", $data); return $data; }
php
static public function decryptJson($ciphertextFileName, Config $config = null) { $content = self::decrypt($ciphertextFileName, $config); $data = json_decode($content, JSON_OBJECT_AS_ARRAY); Util::isArrayOrFail("Encrypted secrets", $data); return $data; }
[ "static", "public", "function", "decryptJson", "(", "$", "ciphertextFileName", ",", "Config", "$", "config", "=", "null", ")", "{", "$", "content", "=", "self", "::", "decrypt", "(", "$", "ciphertextFileName", ",", "$", "config", ")", ";", "$", "data", "=", "json_decode", "(", "$", "content", ",", "JSON_OBJECT_AS_ARRAY", ")", ";", "Util", "::", "isArrayOrFail", "(", "\"Encrypted secrets\"", ",", "$", "data", ")", ";", "return", "$", "data", ";", "}" ]
Utility function to decrypt json. @param $ciphertextFileName @param Config|null $config @return mixed @throws \Exception
[ "Utility", "function", "to", "decrypt", "json", "." ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Secrets.php#L172-L177
12,048
mijohansen/php-gae-util
src/Secrets.php
Secrets.encryptString
static public function encryptString($plaintext_string, $key_name) { $kms = self::getService(); $base64_encoded_json = base64_encode($plaintext_string); $request = new \Google_Service_CloudKMS_EncryptRequest(); $request->setPlaintext($base64_encoded_json); $response = $kms->projects_locations_keyRings_cryptoKeys->encrypt( $key_name, $request ); return $response['ciphertext']; }
php
static public function encryptString($plaintext_string, $key_name) { $kms = self::getService(); $base64_encoded_json = base64_encode($plaintext_string); $request = new \Google_Service_CloudKMS_EncryptRequest(); $request->setPlaintext($base64_encoded_json); $response = $kms->projects_locations_keyRings_cryptoKeys->encrypt( $key_name, $request ); return $response['ciphertext']; }
[ "static", "public", "function", "encryptString", "(", "$", "plaintext_string", ",", "$", "key_name", ")", "{", "$", "kms", "=", "self", "::", "getService", "(", ")", ";", "$", "base64_encoded_json", "=", "base64_encode", "(", "$", "plaintext_string", ")", ";", "$", "request", "=", "new", "\\", "Google_Service_CloudKMS_EncryptRequest", "(", ")", ";", "$", "request", "->", "setPlaintext", "(", "$", "base64_encoded_json", ")", ";", "$", "response", "=", "$", "kms", "->", "projects_locations_keyRings_cryptoKeys", "->", "encrypt", "(", "$", "key_name", ",", "$", "request", ")", ";", "return", "$", "response", "[", "'ciphertext'", "]", ";", "}" ]
Encrypts a string and returns the base64_encoded response from KMS. @param $string @param $key_name @return mixed
[ "Encrypts", "a", "string", "and", "returns", "the", "base64_encoded", "response", "from", "KMS", "." ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Secrets.php#L186-L196
12,049
priskz/sorad-api
src/Priskz/SORAD/Laravel/APIServiceProvider.php
APIServiceProvider.includeRoutesFiles
public function includeRoutesFiles() { // Application Specific Module Route File Locations if(Config::get('sorad.api.routes.file') && is_array(Config::get('sorad.api.routes.file'))) { foreach(Config::get('sorad.api.routes.file') as $route) { // Check if is an app directory and use default routes file name. if(is_dir(app_path($route))) { $this->loadRoutesFrom(app_path($route . '/' . $this->getRouteFileName())); } elseif(is_file(app_path($route))) { $this->loadRoutesFrom(app_path($route)); } } } }
php
public function includeRoutesFiles() { // Application Specific Module Route File Locations if(Config::get('sorad.api.routes.file') && is_array(Config::get('sorad.api.routes.file'))) { foreach(Config::get('sorad.api.routes.file') as $route) { // Check if is an app directory and use default routes file name. if(is_dir(app_path($route))) { $this->loadRoutesFrom(app_path($route . '/' . $this->getRouteFileName())); } elseif(is_file(app_path($route))) { $this->loadRoutesFrom(app_path($route)); } } } }
[ "public", "function", "includeRoutesFiles", "(", ")", "{", "// Application Specific Module Route File Locations", "if", "(", "Config", "::", "get", "(", "'sorad.api.routes.file'", ")", "&&", "is_array", "(", "Config", "::", "get", "(", "'sorad.api.routes.file'", ")", ")", ")", "{", "foreach", "(", "Config", "::", "get", "(", "'sorad.api.routes.file'", ")", "as", "$", "route", ")", "{", "// Check if is an app directory and use default routes file name.", "if", "(", "is_dir", "(", "app_path", "(", "$", "route", ")", ")", ")", "{", "$", "this", "->", "loadRoutesFrom", "(", "app_path", "(", "$", "route", ".", "'/'", ".", "$", "this", "->", "getRouteFileName", "(", ")", ")", ")", ";", "}", "elseif", "(", "is_file", "(", "app_path", "(", "$", "route", ")", ")", ")", "{", "$", "this", "->", "loadRoutesFrom", "(", "app_path", "(", "$", "route", ")", ")", ";", "}", "}", "}", "}" ]
Include Routes Files @return void
[ "Include", "Routes", "Files" ]
7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74
https://github.com/priskz/sorad-api/blob/7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74/src/Priskz/SORAD/Laravel/APIServiceProvider.php#L60-L78
12,050
priskz/sorad-api
src/Priskz/SORAD/Laravel/APIServiceProvider.php
APIServiceProvider.loadRoutesClasses
public function loadRoutesClasses() { // Application Specific Module Route File Locations if(Config::get('sorad.api.routes.class') && is_array(Config::get('sorad.api.routes.class'))) { foreach(Config::get('sorad.api.routes.class') as $route => $config) { $route = sprintf('\\%s', $route); if(class_exists($route)) { $route::load($config); } elseif(class_exists(sprintf('%s\\%s', $route,$this->getRouteClassName()))) { sprintf('%s\\%s', $route,$this->getRouteClassName())::load($config); } } } }
php
public function loadRoutesClasses() { // Application Specific Module Route File Locations if(Config::get('sorad.api.routes.class') && is_array(Config::get('sorad.api.routes.class'))) { foreach(Config::get('sorad.api.routes.class') as $route => $config) { $route = sprintf('\\%s', $route); if(class_exists($route)) { $route::load($config); } elseif(class_exists(sprintf('%s\\%s', $route,$this->getRouteClassName()))) { sprintf('%s\\%s', $route,$this->getRouteClassName())::load($config); } } } }
[ "public", "function", "loadRoutesClasses", "(", ")", "{", "// Application Specific Module Route File Locations", "if", "(", "Config", "::", "get", "(", "'sorad.api.routes.class'", ")", "&&", "is_array", "(", "Config", "::", "get", "(", "'sorad.api.routes.class'", ")", ")", ")", "{", "foreach", "(", "Config", "::", "get", "(", "'sorad.api.routes.class'", ")", "as", "$", "route", "=>", "$", "config", ")", "{", "$", "route", "=", "sprintf", "(", "'\\\\%s'", ",", "$", "route", ")", ";", "if", "(", "class_exists", "(", "$", "route", ")", ")", "{", "$", "route", "::", "load", "(", "$", "config", ")", ";", "}", "elseif", "(", "class_exists", "(", "sprintf", "(", "'%s\\\\%s'", ",", "$", "route", ",", "$", "this", "->", "getRouteClassName", "(", ")", ")", ")", ")", "{", "sprintf", "(", "'%s\\\\%s'", ",", "$", "route", ",", "$", "this", "->", "getRouteClassName", "(", ")", ")", "::", "load", "(", "$", "config", ")", ";", "}", "}", "}", "}" ]
Load Routes Classes @return void
[ "Load", "Routes", "Classes" ]
7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74
https://github.com/priskz/sorad-api/blob/7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74/src/Priskz/SORAD/Laravel/APIServiceProvider.php#L85-L104
12,051
eureka-framework/component-routing
src/Routing/RouteCollection.php
RouteCollection.addFromConfig
public function addFromConfig(array $config) { foreach ($config as $name => $data) { $params = isset($data['params']) ? $data['params'] : array(); $parameters = array(); foreach ($params as $nameParam => $param) { if (empty($params['type'])) { $params['type'] = 'string'; } switch ($param['type']) { case 'int': $param['type'] = Parameter::TYPE_INTEGER; break; case 'mixed': $param['type'] = Parameter::TYPE_MIXED; break; case 'string': $param['type'] = Parameter::TYPE_STRING; break; default: // Consider current value as regexp } $parameters[$nameParam] = new Parameter($nameParam, $param['type'], (bool) $param['mandatory']); } $this->add(new Route($name, $data['route'], $data['controller'], $parameters)); } return $this; }
php
public function addFromConfig(array $config) { foreach ($config as $name => $data) { $params = isset($data['params']) ? $data['params'] : array(); $parameters = array(); foreach ($params as $nameParam => $param) { if (empty($params['type'])) { $params['type'] = 'string'; } switch ($param['type']) { case 'int': $param['type'] = Parameter::TYPE_INTEGER; break; case 'mixed': $param['type'] = Parameter::TYPE_MIXED; break; case 'string': $param['type'] = Parameter::TYPE_STRING; break; default: // Consider current value as regexp } $parameters[$nameParam] = new Parameter($nameParam, $param['type'], (bool) $param['mandatory']); } $this->add(new Route($name, $data['route'], $data['controller'], $parameters)); } return $this; }
[ "public", "function", "addFromConfig", "(", "array", "$", "config", ")", "{", "foreach", "(", "$", "config", "as", "$", "name", "=>", "$", "data", ")", "{", "$", "params", "=", "isset", "(", "$", "data", "[", "'params'", "]", ")", "?", "$", "data", "[", "'params'", "]", ":", "array", "(", ")", ";", "$", "parameters", "=", "array", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "nameParam", "=>", "$", "param", ")", "{", "if", "(", "empty", "(", "$", "params", "[", "'type'", "]", ")", ")", "{", "$", "params", "[", "'type'", "]", "=", "'string'", ";", "}", "switch", "(", "$", "param", "[", "'type'", "]", ")", "{", "case", "'int'", ":", "$", "param", "[", "'type'", "]", "=", "Parameter", "::", "TYPE_INTEGER", ";", "break", ";", "case", "'mixed'", ":", "$", "param", "[", "'type'", "]", "=", "Parameter", "::", "TYPE_MIXED", ";", "break", ";", "case", "'string'", ":", "$", "param", "[", "'type'", "]", "=", "Parameter", "::", "TYPE_STRING", ";", "break", ";", "default", ":", "// Consider current value as regexp", "}", "$", "parameters", "[", "$", "nameParam", "]", "=", "new", "Parameter", "(", "$", "nameParam", ",", "$", "param", "[", "'type'", "]", ",", "(", "bool", ")", "$", "param", "[", "'mandatory'", "]", ")", ";", "}", "$", "this", "->", "add", "(", "new", "Route", "(", "$", "name", ",", "$", "data", "[", "'route'", "]", ",", "$", "data", "[", "'controller'", "]", ",", "$", "parameters", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add routes data from configuration file. @param array $config @return self
[ "Add", "routes", "data", "from", "configuration", "file", "." ]
47b37ba7ce47731762a5eed873d1605eab1785e1
https://github.com/eureka-framework/component-routing/blob/47b37ba7ce47731762a5eed873d1605eab1785e1/src/Routing/RouteCollection.php#L72-L105
12,052
eureka-framework/component-routing
src/Routing/RouteCollection.php
RouteCollection.match
public function match($url, $redirect404 = true) { $routeFound = null; foreach ($this->routes as $route) { if (!$route->verify($url)) { continue; } $routeFound = $route; break; } if (!($routeFound instanceof RouteInterface) && $redirect404 === true) { $routeFound = $this->get('error404'); } return $routeFound; }
php
public function match($url, $redirect404 = true) { $routeFound = null; foreach ($this->routes as $route) { if (!$route->verify($url)) { continue; } $routeFound = $route; break; } if (!($routeFound instanceof RouteInterface) && $redirect404 === true) { $routeFound = $this->get('error404'); } return $routeFound; }
[ "public", "function", "match", "(", "$", "url", ",", "$", "redirect404", "=", "true", ")", "{", "$", "routeFound", "=", "null", ";", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "if", "(", "!", "$", "route", "->", "verify", "(", "$", "url", ")", ")", "{", "continue", ";", "}", "$", "routeFound", "=", "$", "route", ";", "break", ";", "}", "if", "(", "!", "(", "$", "routeFound", "instanceof", "RouteInterface", ")", "&&", "$", "redirect404", "===", "true", ")", "{", "$", "routeFound", "=", "$", "this", "->", "get", "(", "'error404'", ")", ";", "}", "return", "$", "routeFound", ";", "}" ]
Try to find a route that match the specified url. @param string $url @param bool $redirect404 @return Route|null @throws \Exception
[ "Try", "to", "find", "a", "route", "that", "match", "the", "specified", "url", "." ]
47b37ba7ce47731762a5eed873d1605eab1785e1
https://github.com/eureka-framework/component-routing/blob/47b37ba7ce47731762a5eed873d1605eab1785e1/src/Routing/RouteCollection.php#L144-L162
12,053
nirix/radium
src/Helpers/Form.php
Form.submit
public static function submit($text, $attributes = array()) { if (isset($attributes['name'])) { $name = $attributes['name']; unset($attributes['name']); } else { $name = 'submit'; } return self::input('submit', $name, array_merge(array('value' => $text), $attributes)); }
php
public static function submit($text, $attributes = array()) { if (isset($attributes['name'])) { $name = $attributes['name']; unset($attributes['name']); } else { $name = 'submit'; } return self::input('submit', $name, array_merge(array('value' => $text), $attributes)); }
[ "public", "static", "function", "submit", "(", "$", "text", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "attributes", "[", "'name'", "]", ")", ")", "{", "$", "name", "=", "$", "attributes", "[", "'name'", "]", ";", "unset", "(", "$", "attributes", "[", "'name'", "]", ")", ";", "}", "else", "{", "$", "name", "=", "'submit'", ";", "}", "return", "self", "::", "input", "(", "'submit'", ",", "$", "name", ",", "array_merge", "(", "array", "(", "'value'", "=>", "$", "text", ")", ",", "$", "attributes", ")", ")", ";", "}" ]
Creates a form submit button. @param string $text @param string $attributes @return string
[ "Creates", "a", "form", "submit", "button", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Form.php#L94-L104
12,054
nirix/radium
src/Helpers/Form.php
Form.checkbox
public static function checkbox($name, $value, $attributes = array()) { $attributes['value'] = $value; return self::input('checkbox', $name, $attributes); }
php
public static function checkbox($name, $value, $attributes = array()) { $attributes['value'] = $value; return self::input('checkbox', $name, $attributes); }
[ "public", "static", "function", "checkbox", "(", "$", "name", ",", "$", "value", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "attributes", "[", "'value'", "]", "=", "$", "value", ";", "return", "self", "::", "input", "(", "'checkbox'", ",", "$", "name", ",", "$", "attributes", ")", ";", "}" ]
Creates a checkbox field. @param string $name @param mixed $value @param array $attributes @return string
[ "Creates", "a", "checkbox", "field", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Form.php#L128-L132
12,055
nirix/radium
src/Helpers/Form.php
Form.radio
public static function radio($name, $value, $attributes = array()) { $attributes['value'] = $value; return self::input('radio', $name, $attributes); }
php
public static function radio($name, $value, $attributes = array()) { $attributes['value'] = $value; return self::input('radio', $name, $attributes); }
[ "public", "static", "function", "radio", "(", "$", "name", ",", "$", "value", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "attributes", "[", "'value'", "]", "=", "$", "value", ";", "return", "self", "::", "input", "(", "'radio'", ",", "$", "name", ",", "$", "attributes", ")", ";", "}" ]
Creates a radio field. @param string $name @param mixed $value @param array $attributes @return string
[ "Creates", "a", "radio", "field", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Form.php#L143-L147
12,056
nirix/radium
src/Helpers/Form.php
Form.select
public static function select($name, $options, $attributes = array()) { // Extract the value $value = isset($attributes['value']) ? $attributes['value'] : null; unset($attributes['value']); // Set the name $attributes['name'] = $name; // Set the id to the name if one // is not already set. if (!isset($attributes['id'])) { $attributes['id'] = $name; } // Opening tag $select = array(); $select[] = "<select " . HTML::buildAttributes($attributes) . ">"; // Options foreach ($options as $index => $option) { if (!is_numeric($index)) { $select[] = '<optgroup label="' . $index . '">'; foreach ($option as $opt) { $select[] = static::selectOption($opt, $value); } $select[] = '</optgroup>'; } else { $select[] = static::selectOption($option, $value); } } // Closing tags $select[] = '</select>'; return implode(PHP_EOL, $select); }
php
public static function select($name, $options, $attributes = array()) { // Extract the value $value = isset($attributes['value']) ? $attributes['value'] : null; unset($attributes['value']); // Set the name $attributes['name'] = $name; // Set the id to the name if one // is not already set. if (!isset($attributes['id'])) { $attributes['id'] = $name; } // Opening tag $select = array(); $select[] = "<select " . HTML::buildAttributes($attributes) . ">"; // Options foreach ($options as $index => $option) { if (!is_numeric($index)) { $select[] = '<optgroup label="' . $index . '">'; foreach ($option as $opt) { $select[] = static::selectOption($opt, $value); } $select[] = '</optgroup>'; } else { $select[] = static::selectOption($option, $value); } } // Closing tags $select[] = '</select>'; return implode(PHP_EOL, $select); }
[ "public", "static", "function", "select", "(", "$", "name", ",", "$", "options", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "// Extract the value", "$", "value", "=", "isset", "(", "$", "attributes", "[", "'value'", "]", ")", "?", "$", "attributes", "[", "'value'", "]", ":", "null", ";", "unset", "(", "$", "attributes", "[", "'value'", "]", ")", ";", "// Set the name", "$", "attributes", "[", "'name'", "]", "=", "$", "name", ";", "// Set the id to the name if one", "// is not already set.", "if", "(", "!", "isset", "(", "$", "attributes", "[", "'id'", "]", ")", ")", "{", "$", "attributes", "[", "'id'", "]", "=", "$", "name", ";", "}", "// Opening tag", "$", "select", "=", "array", "(", ")", ";", "$", "select", "[", "]", "=", "\"<select \"", ".", "HTML", "::", "buildAttributes", "(", "$", "attributes", ")", ".", "\">\"", ";", "// Options", "foreach", "(", "$", "options", "as", "$", "index", "=>", "$", "option", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "index", ")", ")", "{", "$", "select", "[", "]", "=", "'<optgroup label=\"'", ".", "$", "index", ".", "'\">'", ";", "foreach", "(", "$", "option", "as", "$", "opt", ")", "{", "$", "select", "[", "]", "=", "static", "::", "selectOption", "(", "$", "opt", ",", "$", "value", ")", ";", "}", "$", "select", "[", "]", "=", "'</optgroup>'", ";", "}", "else", "{", "$", "select", "[", "]", "=", "static", "::", "selectOption", "(", "$", "option", ",", "$", "value", ")", ";", "}", "}", "// Closing tags", "$", "select", "[", "]", "=", "'</select>'", ";", "return", "implode", "(", "PHP_EOL", ",", "$", "select", ")", ";", "}" ]
Creates a select field. @param string $name @param array $attributes @return string
[ "Creates", "a", "select", "field", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Form.php#L157-L193
12,057
nirix/radium
src/Helpers/Form.php
Form.selectOption
public static function selectOption($option, $value) { $attributes = ['']; $attributes[] = "value=\"{$option['value']}\""; if ( (is_array($value) && in_array($option['value'], $value)) || ($option['value'] == $value) ) { $attributes[] = 'selected="selected"'; } $attributes = implode(' ', $attributes); return "<option {$attributes}>{$option['label']}</option>"; }
php
public static function selectOption($option, $value) { $attributes = ['']; $attributes[] = "value=\"{$option['value']}\""; if ( (is_array($value) && in_array($option['value'], $value)) || ($option['value'] == $value) ) { $attributes[] = 'selected="selected"'; } $attributes = implode(' ', $attributes); return "<option {$attributes}>{$option['label']}</option>"; }
[ "public", "static", "function", "selectOption", "(", "$", "option", ",", "$", "value", ")", "{", "$", "attributes", "=", "[", "''", "]", ";", "$", "attributes", "[", "]", "=", "\"value=\\\"{$option['value']}\\\"\"", ";", "if", "(", "(", "is_array", "(", "$", "value", ")", "&&", "in_array", "(", "$", "option", "[", "'value'", "]", ",", "$", "value", ")", ")", "||", "(", "$", "option", "[", "'value'", "]", "==", "$", "value", ")", ")", "{", "$", "attributes", "[", "]", "=", "'selected=\"selected\"'", ";", "}", "$", "attributes", "=", "implode", "(", "' '", ",", "$", "attributes", ")", ";", "return", "\"<option {$attributes}>{$option['label']}</option>\"", ";", "}" ]
Return the HTML for a select option. @param array $option @return string
[ "Return", "the", "HTML", "for", "a", "select", "option", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Form.php#L202-L217
12,058
nirix/radium
src/Helpers/Form.php
Form.input
public static function input($type, $name, $attributes) { // Set id attribute to be same as the name // if one has not been set if (!isset($attributes['id'])) { $attributes['id'] = $name; } // Check if the value is set in the // attributes array if (isset($attributes['value'])) { $value = $attributes['value']; } // Check if its in the _POST array elseif (isset($_POST[$name])) { $value = $_POST[$name]; } // It's nowhere... else { $value = ''; } // Add selected or checked attribute? foreach (array('selected', 'checked') as $attr) { if (isset($attributes[$attr]) and !$attributes[$attr]) { unset($attributes[$attr]); } elseif (isset($attributes[$attr])) { $attributes[$attr] = $attr; } } // Merge default attributes with // the specified attributes. $attributes = array_merge(array('type' => $type, 'name' => $name), $attributes); // Textareas if ($type == 'textarea') { return "<textarea " . HTML::buildAttributes($attributes) . ">{$value}</textarea>"; } // Everything else else { // Don't pass the checked attribute if its false. if (isset($attributes['checked']) and !$attributes['checked']) { unset($attributes['checked']); } return "<input " . HTML::buildAttributes($attributes) . ">"; } }
php
public static function input($type, $name, $attributes) { // Set id attribute to be same as the name // if one has not been set if (!isset($attributes['id'])) { $attributes['id'] = $name; } // Check if the value is set in the // attributes array if (isset($attributes['value'])) { $value = $attributes['value']; } // Check if its in the _POST array elseif (isset($_POST[$name])) { $value = $_POST[$name]; } // It's nowhere... else { $value = ''; } // Add selected or checked attribute? foreach (array('selected', 'checked') as $attr) { if (isset($attributes[$attr]) and !$attributes[$attr]) { unset($attributes[$attr]); } elseif (isset($attributes[$attr])) { $attributes[$attr] = $attr; } } // Merge default attributes with // the specified attributes. $attributes = array_merge(array('type' => $type, 'name' => $name), $attributes); // Textareas if ($type == 'textarea') { return "<textarea " . HTML::buildAttributes($attributes) . ">{$value}</textarea>"; } // Everything else else { // Don't pass the checked attribute if its false. if (isset($attributes['checked']) and !$attributes['checked']) { unset($attributes['checked']); } return "<input " . HTML::buildAttributes($attributes) . ">"; } }
[ "public", "static", "function", "input", "(", "$", "type", ",", "$", "name", ",", "$", "attributes", ")", "{", "// Set id attribute to be same as the name", "// if one has not been set", "if", "(", "!", "isset", "(", "$", "attributes", "[", "'id'", "]", ")", ")", "{", "$", "attributes", "[", "'id'", "]", "=", "$", "name", ";", "}", "// Check if the value is set in the", "// attributes array", "if", "(", "isset", "(", "$", "attributes", "[", "'value'", "]", ")", ")", "{", "$", "value", "=", "$", "attributes", "[", "'value'", "]", ";", "}", "// Check if its in the _POST array", "elseif", "(", "isset", "(", "$", "_POST", "[", "$", "name", "]", ")", ")", "{", "$", "value", "=", "$", "_POST", "[", "$", "name", "]", ";", "}", "// It's nowhere...", "else", "{", "$", "value", "=", "''", ";", "}", "// Add selected or checked attribute?", "foreach", "(", "array", "(", "'selected'", ",", "'checked'", ")", "as", "$", "attr", ")", "{", "if", "(", "isset", "(", "$", "attributes", "[", "$", "attr", "]", ")", "and", "!", "$", "attributes", "[", "$", "attr", "]", ")", "{", "unset", "(", "$", "attributes", "[", "$", "attr", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "attributes", "[", "$", "attr", "]", ")", ")", "{", "$", "attributes", "[", "$", "attr", "]", "=", "$", "attr", ";", "}", "}", "// Merge default attributes with", "// the specified attributes.", "$", "attributes", "=", "array_merge", "(", "array", "(", "'type'", "=>", "$", "type", ",", "'name'", "=>", "$", "name", ")", ",", "$", "attributes", ")", ";", "// Textareas", "if", "(", "$", "type", "==", "'textarea'", ")", "{", "return", "\"<textarea \"", ".", "HTML", "::", "buildAttributes", "(", "$", "attributes", ")", ".", "\">{$value}</textarea>\"", ";", "}", "// Everything else", "else", "{", "// Don't pass the checked attribute if its false.", "if", "(", "isset", "(", "$", "attributes", "[", "'checked'", "]", ")", "and", "!", "$", "attributes", "[", "'checked'", "]", ")", "{", "unset", "(", "$", "attributes", "[", "'checked'", "]", ")", ";", "}", "return", "\"<input \"", ".", "HTML", "::", "buildAttributes", "(", "$", "attributes", ")", ".", "\">\"", ";", "}", "}" ]
Creates a form field. @param string $type @param string $name @param array $attributes @return string
[ "Creates", "a", "form", "field", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Form.php#L228-L275
12,059
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/Openssl.php
Openssl._setKeys
protected function _setKeys($keys) { if (!is_array($keys)) { throw new Exception\InvalidArgumentException('Invalid options argument provided to filter'); } foreach ($keys as $type => $key) { if (is_file($key) and is_readable($key)) { $file = fopen($key, 'r'); $cert = fread($file, 8192); fclose($file); } else { $cert = $key; $key = count($this->keys[$type]); } switch ($type) { case 'public': $test = openssl_pkey_get_public($cert); if ($test === false) { throw new Exception\InvalidArgumentException("Public key '{$cert}' not valid"); } openssl_free_key($test); $this->keys['public'][$key] = $cert; break; case 'private': $test = openssl_pkey_get_private($cert, $this->passphrase); if ($test === false) { throw new Exception\InvalidArgumentException("Private key '{$cert}' not valid"); } openssl_free_key($test); $this->keys['private'][$key] = $cert; break; case 'envelope': $this->keys['envelope'][$key] = $cert; break; default: break; } } return $this; }
php
protected function _setKeys($keys) { if (!is_array($keys)) { throw new Exception\InvalidArgumentException('Invalid options argument provided to filter'); } foreach ($keys as $type => $key) { if (is_file($key) and is_readable($key)) { $file = fopen($key, 'r'); $cert = fread($file, 8192); fclose($file); } else { $cert = $key; $key = count($this->keys[$type]); } switch ($type) { case 'public': $test = openssl_pkey_get_public($cert); if ($test === false) { throw new Exception\InvalidArgumentException("Public key '{$cert}' not valid"); } openssl_free_key($test); $this->keys['public'][$key] = $cert; break; case 'private': $test = openssl_pkey_get_private($cert, $this->passphrase); if ($test === false) { throw new Exception\InvalidArgumentException("Private key '{$cert}' not valid"); } openssl_free_key($test); $this->keys['private'][$key] = $cert; break; case 'envelope': $this->keys['envelope'][$key] = $cert; break; default: break; } } return $this; }
[ "protected", "function", "_setKeys", "(", "$", "keys", ")", "{", "if", "(", "!", "is_array", "(", "$", "keys", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Invalid options argument provided to filter'", ")", ";", "}", "foreach", "(", "$", "keys", "as", "$", "type", "=>", "$", "key", ")", "{", "if", "(", "is_file", "(", "$", "key", ")", "and", "is_readable", "(", "$", "key", ")", ")", "{", "$", "file", "=", "fopen", "(", "$", "key", ",", "'r'", ")", ";", "$", "cert", "=", "fread", "(", "$", "file", ",", "8192", ")", ";", "fclose", "(", "$", "file", ")", ";", "}", "else", "{", "$", "cert", "=", "$", "key", ";", "$", "key", "=", "count", "(", "$", "this", "->", "keys", "[", "$", "type", "]", ")", ";", "}", "switch", "(", "$", "type", ")", "{", "case", "'public'", ":", "$", "test", "=", "openssl_pkey_get_public", "(", "$", "cert", ")", ";", "if", "(", "$", "test", "===", "false", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "\"Public key '{$cert}' not valid\"", ")", ";", "}", "openssl_free_key", "(", "$", "test", ")", ";", "$", "this", "->", "keys", "[", "'public'", "]", "[", "$", "key", "]", "=", "$", "cert", ";", "break", ";", "case", "'private'", ":", "$", "test", "=", "openssl_pkey_get_private", "(", "$", "cert", ",", "$", "this", "->", "passphrase", ")", ";", "if", "(", "$", "test", "===", "false", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "\"Private key '{$cert}' not valid\"", ")", ";", "}", "openssl_free_key", "(", "$", "test", ")", ";", "$", "this", "->", "keys", "[", "'private'", "]", "[", "$", "key", "]", "=", "$", "cert", ";", "break", ";", "case", "'envelope'", ":", "$", "this", "->", "keys", "[", "'envelope'", "]", "[", "$", "key", "]", "=", "$", "cert", ";", "break", ";", "default", ":", "break", ";", "}", "}", "return", "$", "this", ";", "}" ]
Sets the encryption keys @param string|array $keys Key with type association @return self @throws Exception\InvalidArgumentException
[ "Sets", "the", "encryption", "keys" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/Openssl.php#L110-L154
12,060
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/Openssl.php
Openssl.setPublicKey
public function setPublicKey($key) { if (is_array($key)) { foreach ($key as $type => $option) { if ($type !== 'public') { $key['public'] = $option; unset($key[$type]); } } } else { $key = ['public' => $key]; } return $this->_setKeys($key); }
php
public function setPublicKey($key) { if (is_array($key)) { foreach ($key as $type => $option) { if ($type !== 'public') { $key['public'] = $option; unset($key[$type]); } } } else { $key = ['public' => $key]; } return $this->_setKeys($key); }
[ "public", "function", "setPublicKey", "(", "$", "key", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "foreach", "(", "$", "key", "as", "$", "type", "=>", "$", "option", ")", "{", "if", "(", "$", "type", "!==", "'public'", ")", "{", "$", "key", "[", "'public'", "]", "=", "$", "option", ";", "unset", "(", "$", "key", "[", "$", "type", "]", ")", ";", "}", "}", "}", "else", "{", "$", "key", "=", "[", "'public'", "=>", "$", "key", "]", ";", "}", "return", "$", "this", "->", "_setKeys", "(", "$", "key", ")", ";", "}" ]
Sets public keys @param string|array $key Public keys @return self
[ "Sets", "public", "keys" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/Openssl.php#L173-L187
12,061
MrJiawen/php-support
src/Tool/StringTool.php
StringTool.str_utf8_chinese_word_count
public static function str_utf8_chinese_word_count($str = "") { $str = preg_replace(self::UTF8_SYMBOL_PATTERN, "", $str); return preg_match_all(self::UTF8_CHINESE_PATTERN, $str, $arr); }
php
public static function str_utf8_chinese_word_count($str = "") { $str = preg_replace(self::UTF8_SYMBOL_PATTERN, "", $str); return preg_match_all(self::UTF8_CHINESE_PATTERN, $str, $arr); }
[ "public", "static", "function", "str_utf8_chinese_word_count", "(", "$", "str", "=", "\"\"", ")", "{", "$", "str", "=", "preg_replace", "(", "self", "::", "UTF8_SYMBOL_PATTERN", ",", "\"\"", ",", "$", "str", ")", ";", "return", "preg_match_all", "(", "self", "::", "UTF8_CHINESE_PATTERN", ",", "$", "str", ",", "$", "arr", ")", ";", "}" ]
count only chinese words @param string $str @return int
[ "count", "only", "chinese", "words" ]
5e878486a916eef5437f4614e6ae286c21f8782c
https://github.com/MrJiawen/php-support/blob/5e878486a916eef5437f4614e6ae286c21f8782c/src/Tool/StringTool.php#L17-L21
12,062
MrJiawen/php-support
src/Tool/StringTool.php
StringTool.str_utf8_mix_word_count
public static function str_utf8_mix_word_count($str = "") { $str = preg_replace(self::UTF8_SYMBOL_PATTERN, "", $str); return self::str_utf8_chinese_word_count($str) + str_word_count(preg_replace(self::UTF8_CHINESE_PATTERN, "", $str)); }
php
public static function str_utf8_mix_word_count($str = "") { $str = preg_replace(self::UTF8_SYMBOL_PATTERN, "", $str); return self::str_utf8_chinese_word_count($str) + str_word_count(preg_replace(self::UTF8_CHINESE_PATTERN, "", $str)); }
[ "public", "static", "function", "str_utf8_mix_word_count", "(", "$", "str", "=", "\"\"", ")", "{", "$", "str", "=", "preg_replace", "(", "self", "::", "UTF8_SYMBOL_PATTERN", ",", "\"\"", ",", "$", "str", ")", ";", "return", "self", "::", "str_utf8_chinese_word_count", "(", "$", "str", ")", "+", "str_word_count", "(", "preg_replace", "(", "self", "::", "UTF8_CHINESE_PATTERN", ",", "\"\"", ",", "$", "str", ")", ")", ";", "}" ]
count both chinese and english @param string $str @return int
[ "count", "both", "chinese", "and", "english" ]
5e878486a916eef5437f4614e6ae286c21f8782c
https://github.com/MrJiawen/php-support/blob/5e878486a916eef5437f4614e6ae286c21f8782c/src/Tool/StringTool.php#L27-L31
12,063
douyacun/dyc-pay
src/Gateways/Wechat/Support.php
Support.baseUri
public static function baseUri($mode = null): string { switch ($mode) { case Wechat::MODE_DEV: self::getInstance()->baseUri = 'https://api.mch.weixin.qq.com/sandboxnew/'; break; case Wechat::MODE_HK: self::getInstance()->baseUri = 'https://apihk.mch.weixin.qq.com/'; break; default: break; } return self::getInstance()->baseUri; }
php
public static function baseUri($mode = null): string { switch ($mode) { case Wechat::MODE_DEV: self::getInstance()->baseUri = 'https://api.mch.weixin.qq.com/sandboxnew/'; break; case Wechat::MODE_HK: self::getInstance()->baseUri = 'https://apihk.mch.weixin.qq.com/'; break; default: break; } return self::getInstance()->baseUri; }
[ "public", "static", "function", "baseUri", "(", "$", "mode", "=", "null", ")", ":", "string", "{", "switch", "(", "$", "mode", ")", "{", "case", "Wechat", "::", "MODE_DEV", ":", "self", "::", "getInstance", "(", ")", "->", "baseUri", "=", "'https://api.mch.weixin.qq.com/sandboxnew/'", ";", "break", ";", "case", "Wechat", "::", "MODE_HK", ":", "self", "::", "getInstance", "(", ")", "->", "baseUri", "=", "'https://apihk.mch.weixin.qq.com/'", ";", "break", ";", "default", ":", "break", ";", "}", "return", "self", "::", "getInstance", "(", ")", "->", "baseUri", ";", "}" ]
Wechat gateway. @author yansongda <[email protected]> @param string $mode @return string
[ "Wechat", "gateway", "." ]
9fac85d375bdd52b872c3fa8174920e40609f6f2
https://github.com/douyacun/dyc-pay/blob/9fac85d375bdd52b872c3fa8174920e40609f6f2/src/Gateways/Wechat/Support.php#L250-L266
12,064
tagadvance/Gilligan
src/tagadvance/gilligan/session/MySQLSessionHandler.php
MySQLSessionHandler.triggerError
private function triggerError($message) { $pdo = $this->pdoSupplier->getPDO(); $mode = $pdo->getAttribute(\PDO::ATTR_ERRMODE); switch ($mode) { case \PDO::ERRMODE_WARNING: trigger_error($message, E_USER_ERROR); break; case \PDO::ERRMODE_EXCEPTION: throw new \RuntimeException($message); break; case \PDO::ERRMODE_SILENT: default: break; } }
php
private function triggerError($message) { $pdo = $this->pdoSupplier->getPDO(); $mode = $pdo->getAttribute(\PDO::ATTR_ERRMODE); switch ($mode) { case \PDO::ERRMODE_WARNING: trigger_error($message, E_USER_ERROR); break; case \PDO::ERRMODE_EXCEPTION: throw new \RuntimeException($message); break; case \PDO::ERRMODE_SILENT: default: break; } }
[ "private", "function", "triggerError", "(", "$", "message", ")", "{", "$", "pdo", "=", "$", "this", "->", "pdoSupplier", "->", "getPDO", "(", ")", ";", "$", "mode", "=", "$", "pdo", "->", "getAttribute", "(", "\\", "PDO", "::", "ATTR_ERRMODE", ")", ";", "switch", "(", "$", "mode", ")", "{", "case", "\\", "PDO", "::", "ERRMODE_WARNING", ":", "trigger_error", "(", "$", "message", ",", "E_USER_ERROR", ")", ";", "break", ";", "case", "\\", "PDO", "::", "ERRMODE_EXCEPTION", ":", "throw", "new", "\\", "RuntimeException", "(", "$", "message", ")", ";", "break", ";", "case", "\\", "PDO", "::", "ERRMODE_SILENT", ":", "default", ":", "break", ";", "}", "}" ]
Honor the PDO ATTR_ERRMODE.
[ "Honor", "the", "PDO", "ATTR_ERRMODE", "." ]
470c82b1ef16d0f839ba2245cd96cd414792483b
https://github.com/tagadvance/Gilligan/blob/470c82b1ef16d0f839ba2245cd96cd414792483b/src/tagadvance/gilligan/session/MySQLSessionHandler.php#L136-L150
12,065
slickframework/template
src/Template.php
Template.addExtension
public function addExtension($className) { $object = is_object($className) ? $className : null; $className = is_object($className) ? get_class($object) : $className; $this->checkExtension($className); self::$extensions[$className] = $object; return $this; }
php
public function addExtension($className) { $object = is_object($className) ? $className : null; $className = is_object($className) ? get_class($object) : $className; $this->checkExtension($className); self::$extensions[$className] = $object; return $this; }
[ "public", "function", "addExtension", "(", "$", "className", ")", "{", "$", "object", "=", "is_object", "(", "$", "className", ")", "?", "$", "className", ":", "null", ";", "$", "className", "=", "is_object", "(", "$", "className", ")", "?", "get_class", "(", "$", "object", ")", ":", "$", "className", ";", "$", "this", "->", "checkExtension", "(", "$", "className", ")", ";", "self", "::", "$", "extensions", "[", "$", "className", "]", "=", "$", "object", ";", "return", "$", "this", ";", "}" ]
Adds an extension to the template engine @param string|object $className The class name or an instance of EngineExtensionInterface interface @return self|$this|Template
[ "Adds", "an", "extension", "to", "the", "template", "engine" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Template.php#L107-L116
12,066
slickframework/template
src/Template.php
Template.applyExtensions
private function applyExtensions(TemplateEngineInterface $engine) { foreach (static::$extensions as $className => $extension) { $ext = $this->getExtension($className, $extension); if ($ext->appliesTo($engine)) { $ext->update($engine); } } return $engine; }
php
private function applyExtensions(TemplateEngineInterface $engine) { foreach (static::$extensions as $className => $extension) { $ext = $this->getExtension($className, $extension); if ($ext->appliesTo($engine)) { $ext->update($engine); } } return $engine; }
[ "private", "function", "applyExtensions", "(", "TemplateEngineInterface", "$", "engine", ")", "{", "foreach", "(", "static", "::", "$", "extensions", "as", "$", "className", "=>", "$", "extension", ")", "{", "$", "ext", "=", "$", "this", "->", "getExtension", "(", "$", "className", ",", "$", "extension", ")", ";", "if", "(", "$", "ext", "->", "appliesTo", "(", "$", "engine", ")", ")", "{", "$", "ext", "->", "update", "(", "$", "engine", ")", ";", "}", "}", "return", "$", "engine", ";", "}" ]
Apply defined extensions to the provided template engine @param TemplateEngineInterface $engine @return TemplateEngineInterface
[ "Apply", "defined", "extensions", "to", "the", "provided", "template", "engine" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Template.php#L157-L166
12,067
digipolisgent/openbib-id-api
src/Value/UserActivities/Hold.php
Hold.fromXml
public static function fromXml(\DOMElement $xml) { $static = new static(); $static->libraryItemMetadata = LibraryItemMetadata::fromXml($xml); $static->pickupLocation = PickupLocation::fromXml($xml); $requestStartDate = $xml->getElementsByTagName('requestDate'); $requestEndDate = $xml->getElementsByTagName('endRequestDate'); $static->requestDateRange = DateTimeRange::fromXml($requestStartDate, $requestEndDate); $holdStartDate = $xml->getElementsByTagName('holdDate'); $holdEndDate = $xml->getElementsByTagName('endHoldDate'); $static->holdDateRange = DateTimeRange::fromXml($holdStartDate, $holdEndDate); $cancelable = $xml->getElementsByTagName('cancelable'); $static->cancelable = BoolLiteral::fromXml($cancelable); $stringLiterals = array( 'requestNumber' => $xml->getElementsByTagName('requestNumber'), 'sequence' => $xml->getElementsByTagName('sequence'), 'queuePosition' => $xml->getElementsByTagName('queuePosition'), 'itemSequence' => $xml->getElementsByTagName('itemSequence'), 'status' => $xml->getElementsByTagName('status'), ); foreach ($stringLiterals as $propertyName => $xmlTag) { $static->$propertyName = StringLiteral::fromXml($xmlTag); } return $static; }
php
public static function fromXml(\DOMElement $xml) { $static = new static(); $static->libraryItemMetadata = LibraryItemMetadata::fromXml($xml); $static->pickupLocation = PickupLocation::fromXml($xml); $requestStartDate = $xml->getElementsByTagName('requestDate'); $requestEndDate = $xml->getElementsByTagName('endRequestDate'); $static->requestDateRange = DateTimeRange::fromXml($requestStartDate, $requestEndDate); $holdStartDate = $xml->getElementsByTagName('holdDate'); $holdEndDate = $xml->getElementsByTagName('endHoldDate'); $static->holdDateRange = DateTimeRange::fromXml($holdStartDate, $holdEndDate); $cancelable = $xml->getElementsByTagName('cancelable'); $static->cancelable = BoolLiteral::fromXml($cancelable); $stringLiterals = array( 'requestNumber' => $xml->getElementsByTagName('requestNumber'), 'sequence' => $xml->getElementsByTagName('sequence'), 'queuePosition' => $xml->getElementsByTagName('queuePosition'), 'itemSequence' => $xml->getElementsByTagName('itemSequence'), 'status' => $xml->getElementsByTagName('status'), ); foreach ($stringLiterals as $propertyName => $xmlTag) { $static->$propertyName = StringLiteral::fromXml($xmlTag); } return $static; }
[ "public", "static", "function", "fromXml", "(", "\\", "DOMElement", "$", "xml", ")", "{", "$", "static", "=", "new", "static", "(", ")", ";", "$", "static", "->", "libraryItemMetadata", "=", "LibraryItemMetadata", "::", "fromXml", "(", "$", "xml", ")", ";", "$", "static", "->", "pickupLocation", "=", "PickupLocation", "::", "fromXml", "(", "$", "xml", ")", ";", "$", "requestStartDate", "=", "$", "xml", "->", "getElementsByTagName", "(", "'requestDate'", ")", ";", "$", "requestEndDate", "=", "$", "xml", "->", "getElementsByTagName", "(", "'endRequestDate'", ")", ";", "$", "static", "->", "requestDateRange", "=", "DateTimeRange", "::", "fromXml", "(", "$", "requestStartDate", ",", "$", "requestEndDate", ")", ";", "$", "holdStartDate", "=", "$", "xml", "->", "getElementsByTagName", "(", "'holdDate'", ")", ";", "$", "holdEndDate", "=", "$", "xml", "->", "getElementsByTagName", "(", "'endHoldDate'", ")", ";", "$", "static", "->", "holdDateRange", "=", "DateTimeRange", "::", "fromXml", "(", "$", "holdStartDate", ",", "$", "holdEndDate", ")", ";", "$", "cancelable", "=", "$", "xml", "->", "getElementsByTagName", "(", "'cancelable'", ")", ";", "$", "static", "->", "cancelable", "=", "BoolLiteral", "::", "fromXml", "(", "$", "cancelable", ")", ";", "$", "stringLiterals", "=", "array", "(", "'requestNumber'", "=>", "$", "xml", "->", "getElementsByTagName", "(", "'requestNumber'", ")", ",", "'sequence'", "=>", "$", "xml", "->", "getElementsByTagName", "(", "'sequence'", ")", ",", "'queuePosition'", "=>", "$", "xml", "->", "getElementsByTagName", "(", "'queuePosition'", ")", ",", "'itemSequence'", "=>", "$", "xml", "->", "getElementsByTagName", "(", "'itemSequence'", ")", ",", "'status'", "=>", "$", "xml", "->", "getElementsByTagName", "(", "'status'", ")", ",", ")", ";", "foreach", "(", "$", "stringLiterals", "as", "$", "propertyName", "=>", "$", "xmlTag", ")", "{", "$", "static", "->", "$", "propertyName", "=", "StringLiteral", "::", "fromXml", "(", "$", "xmlTag", ")", ";", "}", "return", "$", "static", ";", "}" ]
Builds a Hold object from XML. @param \DOMElement $xml The xml element containing the hold. @return Hold A Hold object.
[ "Builds", "a", "Hold", "object", "from", "XML", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Value/UserActivities/Hold.php#L96-L125
12,068
tadcka/Breadcrumbs
Breadcrumb.php
Breadcrumb.truncate
protected function truncate($string, $length = 30, $separator = '...') { if (mb_strlen($string) > $length) { return rtrim(mb_substr($string, 0, $length)) . $separator; } return $string; }
php
protected function truncate($string, $length = 30, $separator = '...') { if (mb_strlen($string) > $length) { return rtrim(mb_substr($string, 0, $length)) . $separator; } return $string; }
[ "protected", "function", "truncate", "(", "$", "string", ",", "$", "length", "=", "30", ",", "$", "separator", "=", "'...'", ")", "{", "if", "(", "mb_strlen", "(", "$", "string", ")", ">", "$", "length", ")", "{", "return", "rtrim", "(", "mb_substr", "(", "$", "string", ",", "0", ",", "$", "length", ")", ")", ".", "$", "separator", ";", "}", "return", "$", "string", ";", "}" ]
Truncate string. @param string $string @param int $length @param string $separator @return string
[ "Truncate", "string", "." ]
3608361cb21d1a26d5e1929ab4e11645b51b13ac
https://github.com/tadcka/Breadcrumbs/blob/3608361cb21d1a26d5e1929ab4e11645b51b13ac/Breadcrumb.php#L108-L116
12,069
SocietyCMS/Core
Providers/ModulesServiceProvider.php
ModulesServiceProvider.bootModules
private function bootModules() { foreach ($this->app['modules']->enabled() as $module) { $this->registerViewNamespace($module); $this->registerLanguageNamespace($module); $this->registerConfigNamespace($module); } }
php
private function bootModules() { foreach ($this->app['modules']->enabled() as $module) { $this->registerViewNamespace($module); $this->registerLanguageNamespace($module); $this->registerConfigNamespace($module); } }
[ "private", "function", "bootModules", "(", ")", "{", "foreach", "(", "$", "this", "->", "app", "[", "'modules'", "]", "->", "enabled", "(", ")", "as", "$", "module", ")", "{", "$", "this", "->", "registerViewNamespace", "(", "$", "module", ")", ";", "$", "this", "->", "registerLanguageNamespace", "(", "$", "module", ")", ";", "$", "this", "->", "registerConfigNamespace", "(", "$", "module", ")", ";", "}", "}" ]
Register the modules aliases.
[ "Register", "the", "modules", "aliases", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Providers/ModulesServiceProvider.php#L51-L58
12,070
SocietyCMS/Core
Providers/ModulesServiceProvider.php
ModulesServiceProvider.registerViewNamespace
protected function registerViewNamespace(Module $module) { $this->app['view']->addNamespace( $module->getName(), $module->getPath().'/Resources/views' ); }
php
protected function registerViewNamespace(Module $module) { $this->app['view']->addNamespace( $module->getName(), $module->getPath().'/Resources/views' ); }
[ "protected", "function", "registerViewNamespace", "(", "Module", "$", "module", ")", "{", "$", "this", "->", "app", "[", "'view'", "]", "->", "addNamespace", "(", "$", "module", "->", "getName", "(", ")", ",", "$", "module", "->", "getPath", "(", ")", ".", "'/Resources/views'", ")", ";", "}" ]
Register the view namespaces for the modules. @param Module $module
[ "Register", "the", "view", "namespaces", "for", "the", "modules", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Providers/ModulesServiceProvider.php#L75-L81
12,071
SocietyCMS/Core
Providers/ModulesServiceProvider.php
ModulesServiceProvider.registerLanguageNamespace
protected function registerLanguageNamespace(Module $module) { $moduleName = $module->getName(); $langPath = base_path("resources/lang/modules/$moduleName"); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $moduleName); $this->app['localization.js-generator']->addSourcePath($langPath, $moduleName); } else { $this->loadTranslationsFrom($module->getPath().'/Resources/lang', $moduleName); $this->app['localization.js-generator']->addSourcePath($module->getPath().'/Resources/lang', $moduleName); } }
php
protected function registerLanguageNamespace(Module $module) { $moduleName = $module->getName(); $langPath = base_path("resources/lang/modules/$moduleName"); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $moduleName); $this->app['localization.js-generator']->addSourcePath($langPath, $moduleName); } else { $this->loadTranslationsFrom($module->getPath().'/Resources/lang', $moduleName); $this->app['localization.js-generator']->addSourcePath($module->getPath().'/Resources/lang', $moduleName); } }
[ "protected", "function", "registerLanguageNamespace", "(", "Module", "$", "module", ")", "{", "$", "moduleName", "=", "$", "module", "->", "getName", "(", ")", ";", "$", "langPath", "=", "base_path", "(", "\"resources/lang/modules/$moduleName\"", ")", ";", "if", "(", "is_dir", "(", "$", "langPath", ")", ")", "{", "$", "this", "->", "loadTranslationsFrom", "(", "$", "langPath", ",", "$", "moduleName", ")", ";", "$", "this", "->", "app", "[", "'localization.js-generator'", "]", "->", "addSourcePath", "(", "$", "langPath", ",", "$", "moduleName", ")", ";", "}", "else", "{", "$", "this", "->", "loadTranslationsFrom", "(", "$", "module", "->", "getPath", "(", ")", ".", "'/Resources/lang'", ",", "$", "moduleName", ")", ";", "$", "this", "->", "app", "[", "'localization.js-generator'", "]", "->", "addSourcePath", "(", "$", "module", "->", "getPath", "(", ")", ".", "'/Resources/lang'", ",", "$", "moduleName", ")", ";", "}", "}" ]
Register the language namespaces for the modules. @param Module $module
[ "Register", "the", "language", "namespaces", "for", "the", "modules", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Providers/ModulesServiceProvider.php#L88-L101
12,072
xloit/xloit-bridge-zend-log
src/Log.php
Log.exception
public static function exception($title, PhpException $e) { $exceptionMessage = (string) $e->getMessage(); $content = (string) $title . PHP_EOL . 'Exception of type \'' . get_class($e) . '\': ' . $exceptionMessage; // need to add check if the log verbosity is info or debug. Look at old code self::$logger->exception(new PhpException($content, null, $e)); return true; }
php
public static function exception($title, PhpException $e) { $exceptionMessage = (string) $e->getMessage(); $content = (string) $title . PHP_EOL . 'Exception of type \'' . get_class($e) . '\': ' . $exceptionMessage; // need to add check if the log verbosity is info or debug. Look at old code self::$logger->exception(new PhpException($content, null, $e)); return true; }
[ "public", "static", "function", "exception", "(", "$", "title", ",", "PhpException", "$", "e", ")", "{", "$", "exceptionMessage", "=", "(", "string", ")", "$", "e", "->", "getMessage", "(", ")", ";", "$", "content", "=", "(", "string", ")", "$", "title", ".", "PHP_EOL", ".", "'Exception of type \\''", ".", "get_class", "(", "$", "e", ")", ".", "'\\': '", ".", "$", "exceptionMessage", ";", "// need to add check if the log verbosity is info or debug. Look at old code", "self", "::", "$", "logger", "->", "exception", "(", "new", "PhpException", "(", "$", "content", ",", "null", ",", "$", "e", ")", ")", ";", "return", "true", ";", "}" ]
Save an exception as an error in the log file. @param string $title @param PhpException $e @return bool @throws \Zend\Log\Exception\InvalidArgumentException @throws \Zend\Log\Exception\RuntimeException
[ "Save", "an", "exception", "as", "an", "error", "in", "the", "log", "file", "." ]
d5c93341931089a6bbf71328f88616bc544e3864
https://github.com/xloit/xloit-bridge-zend-log/blob/d5c93341931089a6bbf71328f88616bc544e3864/src/Log.php#L126-L136
12,073
xloit/xloit-bridge-zend-log
src/Log.php
Log.err
public static function err($message, array $extras = []) { if (self::$logger) { self::$logger->err($message, $extras); } }
php
public static function err($message, array $extras = []) { if (self::$logger) { self::$logger->err($message, $extras); } }
[ "public", "static", "function", "err", "(", "$", "message", ",", "array", "$", "extras", "=", "[", "]", ")", "{", "if", "(", "self", "::", "$", "logger", ")", "{", "self", "::", "$", "logger", "->", "err", "(", "$", "message", ",", "$", "extras", ")", ";", "}", "}" ]
Log an error message for external consumption. @param string $message @param array $extras @return void @throws \Zend\Log\Exception\InvalidArgumentException @throws \Zend\Log\Exception\RuntimeException
[ "Log", "an", "error", "message", "for", "external", "consumption", "." ]
d5c93341931089a6bbf71328f88616bc544e3864
https://github.com/xloit/xloit-bridge-zend-log/blob/d5c93341931089a6bbf71328f88616bc544e3864/src/Log.php#L148-L153
12,074
xloit/xloit-bridge-zend-log
src/Log.php
Log.debug
public static function debug($message, array $extras = []) { if (self::$logger) { self::$logger->debug($message, $extras); } }
php
public static function debug($message, array $extras = []) { if (self::$logger) { self::$logger->debug($message, $extras); } }
[ "public", "static", "function", "debug", "(", "$", "message", ",", "array", "$", "extras", "=", "[", "]", ")", "{", "if", "(", "self", "::", "$", "logger", ")", "{", "self", "::", "$", "logger", "->", "debug", "(", "$", "message", ",", "$", "extras", ")", ";", "}", "}" ]
Log a debug message for internal use. @param string $message @param array $extras @return void
[ "Log", "a", "debug", "message", "for", "internal", "use", "." ]
d5c93341931089a6bbf71328f88616bc544e3864
https://github.com/xloit/xloit-bridge-zend-log/blob/d5c93341931089a6bbf71328f88616bc544e3864/src/Log.php#L163-L168
12,075
xloit/xloit-bridge-zend-log
src/Log.php
Log.info
public static function info($message, array $extras = []) { if (self::$logger) { self::$logger->info($message, $extras); } }
php
public static function info($message, array $extras = []) { if (self::$logger) { self::$logger->info($message, $extras); } }
[ "public", "static", "function", "info", "(", "$", "message", ",", "array", "$", "extras", "=", "[", "]", ")", "{", "if", "(", "self", "::", "$", "logger", ")", "{", "self", "::", "$", "logger", "->", "info", "(", "$", "message", ",", "$", "extras", ")", ";", "}", "}" ]
Log an info message for external consumption. @param string $message @param array $extras @return void
[ "Log", "an", "info", "message", "for", "external", "consumption", "." ]
d5c93341931089a6bbf71328f88616bc544e3864
https://github.com/xloit/xloit-bridge-zend-log/blob/d5c93341931089a6bbf71328f88616bc544e3864/src/Log.php#L178-L183
12,076
xloit/xloit-bridge-zend-log
src/Log.php
Log.notice
public static function notice($message, array $extras = []) { if (self::$logger) { self::$logger->notice($message, $extras); } }
php
public static function notice($message, array $extras = []) { if (self::$logger) { self::$logger->notice($message, $extras); } }
[ "public", "static", "function", "notice", "(", "$", "message", ",", "array", "$", "extras", "=", "[", "]", ")", "{", "if", "(", "self", "::", "$", "logger", ")", "{", "self", "::", "$", "logger", "->", "notice", "(", "$", "message", ",", "$", "extras", ")", ";", "}", "}" ]
Log a notice message for external consumption. @param string $message @param array $extras @return void
[ "Log", "a", "notice", "message", "for", "external", "consumption", "." ]
d5c93341931089a6bbf71328f88616bc544e3864
https://github.com/xloit/xloit-bridge-zend-log/blob/d5c93341931089a6bbf71328f88616bc544e3864/src/Log.php#L193-L198
12,077
xloit/xloit-bridge-zend-log
src/Log.php
Log.warn
public static function warn($message, array $extras = []) { if (self::$logger) { self::$logger->warn($message, $extras); } }
php
public static function warn($message, array $extras = []) { if (self::$logger) { self::$logger->warn($message, $extras); } }
[ "public", "static", "function", "warn", "(", "$", "message", ",", "array", "$", "extras", "=", "[", "]", ")", "{", "if", "(", "self", "::", "$", "logger", ")", "{", "self", "::", "$", "logger", "->", "warn", "(", "$", "message", ",", "$", "extras", ")", ";", "}", "}" ]
Log a warning message for external consumption. @param string $message @param array $extras @return void
[ "Log", "a", "warning", "message", "for", "external", "consumption", "." ]
d5c93341931089a6bbf71328f88616bc544e3864
https://github.com/xloit/xloit-bridge-zend-log/blob/d5c93341931089a6bbf71328f88616bc544e3864/src/Log.php#L208-L213
12,078
xloit/xloit-bridge-zend-log
src/Log.php
Log.crit
public static function crit($message, array $extras = []) { if (self::$logger) { self::$logger->crit($message, $extras); } }
php
public static function crit($message, array $extras = []) { if (self::$logger) { self::$logger->crit($message, $extras); } }
[ "public", "static", "function", "crit", "(", "$", "message", ",", "array", "$", "extras", "=", "[", "]", ")", "{", "if", "(", "self", "::", "$", "logger", ")", "{", "self", "::", "$", "logger", "->", "crit", "(", "$", "message", ",", "$", "extras", ")", ";", "}", "}" ]
Log a critical message for external consumption. @param string $message @param array $extras @return void
[ "Log", "a", "critical", "message", "for", "external", "consumption", "." ]
d5c93341931089a6bbf71328f88616bc544e3864
https://github.com/xloit/xloit-bridge-zend-log/blob/d5c93341931089a6bbf71328f88616bc544e3864/src/Log.php#L223-L228
12,079
xloit/xloit-bridge-zend-log
src/Log.php
Log.alert
public static function alert($message, array $extras = []) { if (self::$logger) { self::$logger->alert($message, $extras); } }
php
public static function alert($message, array $extras = []) { if (self::$logger) { self::$logger->alert($message, $extras); } }
[ "public", "static", "function", "alert", "(", "$", "message", ",", "array", "$", "extras", "=", "[", "]", ")", "{", "if", "(", "self", "::", "$", "logger", ")", "{", "self", "::", "$", "logger", "->", "alert", "(", "$", "message", ",", "$", "extras", ")", ";", "}", "}" ]
Log an alert message for external consumption. @param string $message @param array $extras @return void
[ "Log", "an", "alert", "message", "for", "external", "consumption", "." ]
d5c93341931089a6bbf71328f88616bc544e3864
https://github.com/xloit/xloit-bridge-zend-log/blob/d5c93341931089a6bbf71328f88616bc544e3864/src/Log.php#L238-L243
12,080
xloit/xloit-bridge-zend-log
src/Log.php
Log.emerg
public static function emerg($message, array $extras = []) { if (self::$logger) { self::$logger->emerg($message, $extras); } }
php
public static function emerg($message, array $extras = []) { if (self::$logger) { self::$logger->emerg($message, $extras); } }
[ "public", "static", "function", "emerg", "(", "$", "message", ",", "array", "$", "extras", "=", "[", "]", ")", "{", "if", "(", "self", "::", "$", "logger", ")", "{", "self", "::", "$", "logger", "->", "emerg", "(", "$", "message", ",", "$", "extras", ")", ";", "}", "}" ]
Log an emergency message for external consumption. @param string $message @param array $extras @return void
[ "Log", "an", "emergency", "message", "for", "external", "consumption", "." ]
d5c93341931089a6bbf71328f88616bc544e3864
https://github.com/xloit/xloit-bridge-zend-log/blob/d5c93341931089a6bbf71328f88616bc544e3864/src/Log.php#L253-L258
12,081
phplegends/collections
src/Collection.php
Collection.delete
public function delete($key) { if (! $this->has($key)) return null; $value = $this->items[$key]; unset($this->items[$key]); return $value; }
php
public function delete($key) { if (! $this->has($key)) return null; $value = $this->items[$key]; unset($this->items[$key]); return $value; }
[ "public", "function", "delete", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "return", "null", ";", "$", "value", "=", "$", "this", "->", "items", "[", "$", "key", "]", ";", "unset", "(", "$", "this", "->", "items", "[", "$", "key", "]", ")", ";", "return", "$", "value", ";", "}" ]
Unset item from collection via index and return value @param int|string $key @return mixed
[ "Unset", "item", "from", "collection", "via", "index", "and", "return", "value" ]
33b048176b09e58fcecf229dd3fe0a16eca8605f
https://github.com/phplegends/collections/blob/33b048176b09e58fcecf229dd3fe0a16eca8605f/src/Collection.php#L121-L130
12,082
cybalex/session
DefaultSessionStorage.php
DefaultSessionStorage.loadSession
protected function loadSession(array &$session = null) { if (null === $session) { $session = &$_SESSION; } //initialize the attributes bag $key = $this->getAttributes()->getName(); $session[$key] = isset($session[$key]) ? $session[$key] : array(); $this->getAttributes()->initialize($session[$key]); $this->started = true; $this->closed = false; }
php
protected function loadSession(array &$session = null) { if (null === $session) { $session = &$_SESSION; } //initialize the attributes bag $key = $this->getAttributes()->getName(); $session[$key] = isset($session[$key]) ? $session[$key] : array(); $this->getAttributes()->initialize($session[$key]); $this->started = true; $this->closed = false; }
[ "protected", "function", "loadSession", "(", "array", "&", "$", "session", "=", "null", ")", "{", "if", "(", "null", "===", "$", "session", ")", "{", "$", "session", "=", "&", "$", "_SESSION", ";", "}", "//initialize the attributes bag", "$", "key", "=", "$", "this", "->", "getAttributes", "(", ")", "->", "getName", "(", ")", ";", "$", "session", "[", "$", "key", "]", "=", "isset", "(", "$", "session", "[", "$", "key", "]", ")", "?", "$", "session", "[", "$", "key", "]", ":", "array", "(", ")", ";", "$", "this", "->", "getAttributes", "(", ")", "->", "initialize", "(", "$", "session", "[", "$", "key", "]", ")", ";", "$", "this", "->", "started", "=", "true", ";", "$", "this", "->", "closed", "=", "false", ";", "}" ]
Load the session with attributes After starting the session, PHP retrieves the session from whatever handlers are set to (either PHP's internal, or a custom save handler set with session_set_save_handler()). PHP takes the return value from the read() handler, unserializes it and populates $_SESSION with the result automatically. @param array|null $session
[ "Load", "the", "session", "with", "attributes" ]
527679d8f5dca9aa1cb0c843cb3a6e86ff740da8
https://github.com/cybalex/session/blob/527679d8f5dca9aa1cb0c843cb3a6e86ff740da8/DefaultSessionStorage.php#L273-L287
12,083
fazland/elastica-odm
src/Persister/DocumentPersister.php
DocumentPersister.exists
public function exists(array $criteria): bool { $query = $this->prepareQuery($criteria); $query->setSize(0); $query->setParam('terminate_after', 1); return $this->collection->search($query)->count() > 0; }
php
public function exists(array $criteria): bool { $query = $this->prepareQuery($criteria); $query->setSize(0); $query->setParam('terminate_after', 1); return $this->collection->search($query)->count() > 0; }
[ "public", "function", "exists", "(", "array", "$", "criteria", ")", ":", "bool", "{", "$", "query", "=", "$", "this", "->", "prepareQuery", "(", "$", "criteria", ")", ";", "$", "query", "->", "setSize", "(", "0", ")", ";", "$", "query", "->", "setParam", "(", "'terminate_after'", ",", "1", ")", ";", "return", "$", "this", "->", "collection", "->", "search", "(", "$", "query", ")", "->", "count", "(", ")", ">", "0", ";", "}" ]
Checks whether a document matching criteria exists in collection. @param array $criteria @return bool
[ "Checks", "whether", "a", "document", "matching", "criteria", "exists", "in", "collection", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Persister/DocumentPersister.php#L110-L117
12,084
fazland/elastica-odm
src/Persister/DocumentPersister.php
DocumentPersister.insert
public function insert($document): ?PostInsertId { /** @var DocumentMetadata $class */ $class = $this->dm->getClassMetadata(get_class($document)); $idGenerator = $this->dm->getUnitOfWork()->getIdGenerator($class->idGeneratorType); $postIdGenerator = $idGenerator->isPostInsertGenerator(); $id = $postIdGenerator ? null : $class->getSingleIdentifier($document); $body = $this->prepareUpdateData($document)['body']; $response = $this->collection->create($id, $body); $data = $response->getData(); foreach ($class->attributesMetadata as $field) { if (! $field instanceof FieldMetadata) { continue; } if ($field->indexName) { $field->setValue($document, $data['_index'] ?? null); } if ($field->typeName) { $field->setValue($document, $data['_type'] ?? null); } } $postInsertId = null; if ($postIdGenerator) { $postInsertId = new PostInsertId($document, $this->collection->getLastInsertedId()); } return $postInsertId; }
php
public function insert($document): ?PostInsertId { /** @var DocumentMetadata $class */ $class = $this->dm->getClassMetadata(get_class($document)); $idGenerator = $this->dm->getUnitOfWork()->getIdGenerator($class->idGeneratorType); $postIdGenerator = $idGenerator->isPostInsertGenerator(); $id = $postIdGenerator ? null : $class->getSingleIdentifier($document); $body = $this->prepareUpdateData($document)['body']; $response = $this->collection->create($id, $body); $data = $response->getData(); foreach ($class->attributesMetadata as $field) { if (! $field instanceof FieldMetadata) { continue; } if ($field->indexName) { $field->setValue($document, $data['_index'] ?? null); } if ($field->typeName) { $field->setValue($document, $data['_type'] ?? null); } } $postInsertId = null; if ($postIdGenerator) { $postInsertId = new PostInsertId($document, $this->collection->getLastInsertedId()); } return $postInsertId; }
[ "public", "function", "insert", "(", "$", "document", ")", ":", "?", "PostInsertId", "{", "/** @var DocumentMetadata $class */", "$", "class", "=", "$", "this", "->", "dm", "->", "getClassMetadata", "(", "get_class", "(", "$", "document", ")", ")", ";", "$", "idGenerator", "=", "$", "this", "->", "dm", "->", "getUnitOfWork", "(", ")", "->", "getIdGenerator", "(", "$", "class", "->", "idGeneratorType", ")", ";", "$", "postIdGenerator", "=", "$", "idGenerator", "->", "isPostInsertGenerator", "(", ")", ";", "$", "id", "=", "$", "postIdGenerator", "?", "null", ":", "$", "class", "->", "getSingleIdentifier", "(", "$", "document", ")", ";", "$", "body", "=", "$", "this", "->", "prepareUpdateData", "(", "$", "document", ")", "[", "'body'", "]", ";", "$", "response", "=", "$", "this", "->", "collection", "->", "create", "(", "$", "id", ",", "$", "body", ")", ";", "$", "data", "=", "$", "response", "->", "getData", "(", ")", ";", "foreach", "(", "$", "class", "->", "attributesMetadata", "as", "$", "field", ")", "{", "if", "(", "!", "$", "field", "instanceof", "FieldMetadata", ")", "{", "continue", ";", "}", "if", "(", "$", "field", "->", "indexName", ")", "{", "$", "field", "->", "setValue", "(", "$", "document", ",", "$", "data", "[", "'_index'", "]", "??", "null", ")", ";", "}", "if", "(", "$", "field", "->", "typeName", ")", "{", "$", "field", "->", "setValue", "(", "$", "document", ",", "$", "data", "[", "'_type'", "]", "??", "null", ")", ";", "}", "}", "$", "postInsertId", "=", "null", ";", "if", "(", "$", "postIdGenerator", ")", "{", "$", "postInsertId", "=", "new", "PostInsertId", "(", "$", "document", ",", "$", "this", "->", "collection", "->", "getLastInsertedId", "(", ")", ")", ";", "}", "return", "$", "postInsertId", ";", "}" ]
Insert a document in the collection. @param object $document @return PostInsertId|null
[ "Insert", "a", "document", "in", "the", "collection", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Persister/DocumentPersister.php#L126-L159
12,085
fazland/elastica-odm
src/Persister/DocumentPersister.php
DocumentPersister.update
public function update($document): void { $class = $this->dm->getClassMetadata(get_class($document)); $data = $this->prepareUpdateData($document); $id = $class->getSingleIdentifier($document); $this->collection->update((string) $id, $data['body'], $data['script']); }
php
public function update($document): void { $class = $this->dm->getClassMetadata(get_class($document)); $data = $this->prepareUpdateData($document); $id = $class->getSingleIdentifier($document); $this->collection->update((string) $id, $data['body'], $data['script']); }
[ "public", "function", "update", "(", "$", "document", ")", ":", "void", "{", "$", "class", "=", "$", "this", "->", "dm", "->", "getClassMetadata", "(", "get_class", "(", "$", "document", ")", ")", ";", "$", "data", "=", "$", "this", "->", "prepareUpdateData", "(", "$", "document", ")", ";", "$", "id", "=", "$", "class", "->", "getSingleIdentifier", "(", "$", "document", ")", ";", "$", "this", "->", "collection", "->", "update", "(", "(", "string", ")", "$", "id", ",", "$", "data", "[", "'body'", "]", ",", "$", "data", "[", "'script'", "]", ")", ";", "}" ]
Updates a managed document. @param object $document
[ "Updates", "a", "managed", "document", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Persister/DocumentPersister.php#L166-L173
12,086
fazland/elastica-odm
src/Persister/DocumentPersister.php
DocumentPersister.delete
public function delete($document): void { $class = $this->dm->getClassMetadata(get_class($document)); $id = $class->getSingleIdentifier($document); $this->collection->delete((string) $id); }
php
public function delete($document): void { $class = $this->dm->getClassMetadata(get_class($document)); $id = $class->getSingleIdentifier($document); $this->collection->delete((string) $id); }
[ "public", "function", "delete", "(", "$", "document", ")", ":", "void", "{", "$", "class", "=", "$", "this", "->", "dm", "->", "getClassMetadata", "(", "get_class", "(", "$", "document", ")", ")", ";", "$", "id", "=", "$", "class", "->", "getSingleIdentifier", "(", "$", "document", ")", ";", "$", "this", "->", "collection", "->", "delete", "(", "(", "string", ")", "$", "id", ")", ";", "}" ]
Deletes a managed document. @param object $document
[ "Deletes", "a", "managed", "document", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Persister/DocumentPersister.php#L180-L186
12,087
watoki/reflect
src/watoki/reflect/PropertyReader.php
PropertyReader.readInterface
public function readInterface($object = null) { $properties = new Map(); if ($this->class->getConstructor()) { foreach ($this->class->getConstructor()->getParameters() as $parameter) { $this->accumulate($properties, new property\ConstructorProperty($this->factory, $this->class->getConstructor(), $parameter)); } } $declaredProperties = array(); foreach ($this->class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { if (!$property->isStatic()) { $declaredProperties[] = $property->name; $this->accumulate($properties, new property\InstanceVariableProperty($this->factory, $property)); } } if (is_object($object)) { foreach ($object as $name => $value) { if (!in_array($name, $declaredProperties)) { $this->accumulate($properties, new property\DynamicProperty($this->factory, new \ReflectionClass($object), $name)); } } } foreach ($this->class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { if (property\AccessorProperty::isAccessor($method) && !$method->isStatic()) { $this->accumulate($properties, new property\AccessorProperty($this->factory, $method)); } } return $properties; }
php
public function readInterface($object = null) { $properties = new Map(); if ($this->class->getConstructor()) { foreach ($this->class->getConstructor()->getParameters() as $parameter) { $this->accumulate($properties, new property\ConstructorProperty($this->factory, $this->class->getConstructor(), $parameter)); } } $declaredProperties = array(); foreach ($this->class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { if (!$property->isStatic()) { $declaredProperties[] = $property->name; $this->accumulate($properties, new property\InstanceVariableProperty($this->factory, $property)); } } if (is_object($object)) { foreach ($object as $name => $value) { if (!in_array($name, $declaredProperties)) { $this->accumulate($properties, new property\DynamicProperty($this->factory, new \ReflectionClass($object), $name)); } } } foreach ($this->class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { if (property\AccessorProperty::isAccessor($method) && !$method->isStatic()) { $this->accumulate($properties, new property\AccessorProperty($this->factory, $method)); } } return $properties; }
[ "public", "function", "readInterface", "(", "$", "object", "=", "null", ")", "{", "$", "properties", "=", "new", "Map", "(", ")", ";", "if", "(", "$", "this", "->", "class", "->", "getConstructor", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "class", "->", "getConstructor", "(", ")", "->", "getParameters", "(", ")", "as", "$", "parameter", ")", "{", "$", "this", "->", "accumulate", "(", "$", "properties", ",", "new", "property", "\\", "ConstructorProperty", "(", "$", "this", "->", "factory", ",", "$", "this", "->", "class", "->", "getConstructor", "(", ")", ",", "$", "parameter", ")", ")", ";", "}", "}", "$", "declaredProperties", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "class", "->", "getProperties", "(", "\\", "ReflectionProperty", "::", "IS_PUBLIC", ")", "as", "$", "property", ")", "{", "if", "(", "!", "$", "property", "->", "isStatic", "(", ")", ")", "{", "$", "declaredProperties", "[", "]", "=", "$", "property", "->", "name", ";", "$", "this", "->", "accumulate", "(", "$", "properties", ",", "new", "property", "\\", "InstanceVariableProperty", "(", "$", "this", "->", "factory", ",", "$", "property", ")", ")", ";", "}", "}", "if", "(", "is_object", "(", "$", "object", ")", ")", "{", "foreach", "(", "$", "object", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "name", ",", "$", "declaredProperties", ")", ")", "{", "$", "this", "->", "accumulate", "(", "$", "properties", ",", "new", "property", "\\", "DynamicProperty", "(", "$", "this", "->", "factory", ",", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ",", "$", "name", ")", ")", ";", "}", "}", "}", "foreach", "(", "$", "this", "->", "class", "->", "getMethods", "(", "\\", "ReflectionMethod", "::", "IS_PUBLIC", ")", "as", "$", "method", ")", "{", "if", "(", "property", "\\", "AccessorProperty", "::", "isAccessor", "(", "$", "method", ")", "&&", "!", "$", "method", "->", "isStatic", "(", ")", ")", "{", "$", "this", "->", "accumulate", "(", "$", "properties", ",", "new", "property", "\\", "AccessorProperty", "(", "$", "this", "->", "factory", ",", "$", "method", ")", ")", ";", "}", "}", "return", "$", "properties", ";", "}" ]
Derives properties from constructor, public instance variables, getters and setters. @param object|null $object If provided, dynamic (run-time) variables are read as well @return \watoki\collections\Map|Property[] indexed by property name
[ "Derives", "properties", "from", "constructor", "public", "instance", "variables", "getters", "and", "setters", "." ]
1d85de462f942d6d387811cd71ccc7623dc01f12
https://github.com/watoki/reflect/blob/1d85de462f942d6d387811cd71ccc7623dc01f12/src/watoki/reflect/PropertyReader.php#L30-L66
12,088
fly-studio/laravel-addons-func
src/SSHClient.php
SSHClient.connect
public function connect() { //Attempt to connect to host $link = ssh2_connect($this->_config['host'], $this->_config['port']); //If host connection fails, throw exception if(!$link) { throw new \Exception('Unable to connect to '.$host.' on port '.$port); } else { //Assign the connection link to the class property $this->_conn_link = $link; //If host fingerprint is not NULL, attempt to verify fingerprint if(!is_null($this->_config['host_fingerprint'])) { $verify = $this->verify_host_fingerprint(); //If the fingerprint is not verified, throw exception if(!$verify) { throw new \Exception('Unable to verify host fingerprint'); } } } //Attempt to login user if($this->_config['authentication_method'] == 'KEY') { $this->_connected = $this->login_key(); } else { $this->_connected = $this->login_password(); } $this->_connected && $this->_sftp = ssh2_sftp($link); }
php
public function connect() { //Attempt to connect to host $link = ssh2_connect($this->_config['host'], $this->_config['port']); //If host connection fails, throw exception if(!$link) { throw new \Exception('Unable to connect to '.$host.' on port '.$port); } else { //Assign the connection link to the class property $this->_conn_link = $link; //If host fingerprint is not NULL, attempt to verify fingerprint if(!is_null($this->_config['host_fingerprint'])) { $verify = $this->verify_host_fingerprint(); //If the fingerprint is not verified, throw exception if(!$verify) { throw new \Exception('Unable to verify host fingerprint'); } } } //Attempt to login user if($this->_config['authentication_method'] == 'KEY') { $this->_connected = $this->login_key(); } else { $this->_connected = $this->login_password(); } $this->_connected && $this->_sftp = ssh2_sftp($link); }
[ "public", "function", "connect", "(", ")", "{", "//Attempt to connect to host", "$", "link", "=", "ssh2_connect", "(", "$", "this", "->", "_config", "[", "'host'", "]", ",", "$", "this", "->", "_config", "[", "'port'", "]", ")", ";", "//If host connection fails, throw exception", "if", "(", "!", "$", "link", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unable to connect to '", ".", "$", "host", ".", "' on port '", ".", "$", "port", ")", ";", "}", "else", "{", "//Assign the connection link to the class property", "$", "this", "->", "_conn_link", "=", "$", "link", ";", "//If host fingerprint is not NULL, attempt to verify fingerprint", "if", "(", "!", "is_null", "(", "$", "this", "->", "_config", "[", "'host_fingerprint'", "]", ")", ")", "{", "$", "verify", "=", "$", "this", "->", "verify_host_fingerprint", "(", ")", ";", "//If the fingerprint is not verified, throw exception", "if", "(", "!", "$", "verify", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unable to verify host fingerprint'", ")", ";", "}", "}", "}", "//Attempt to login user", "if", "(", "$", "this", "->", "_config", "[", "'authentication_method'", "]", "==", "'KEY'", ")", "{", "$", "this", "->", "_connected", "=", "$", "this", "->", "login_key", "(", ")", ";", "}", "else", "{", "$", "this", "->", "_connected", "=", "$", "this", "->", "login_password", "(", ")", ";", "}", "$", "this", "->", "_connected", "&&", "$", "this", "->", "_sftp", "=", "ssh2_sftp", "(", "$", "link", ")", ";", "}" ]
Connect to host Connects to the host. Throws exception if the host is unable to be connected to. Will automatically verify the host fingerprint, if one was provided, and throw an exception if the fingerprint is not verified.
[ "Connect", "to", "host" ]
02043c7a3834ec8525aca8156b3c89dfd4ff0d22
https://github.com/fly-studio/laravel-addons-func/blob/02043c7a3834ec8525aca8156b3c89dfd4ff0d22/src/SSHClient.php#L76-L115
12,089
fly-studio/laravel-addons-func
src/SSHClient.php
SSHClient.verify_host_fingerprint
protected function verify_host_fingerprint() { //Get the hosts fingerprint $fingerprint = ssh2_fingerprint($this->_conn_link); //Check the returned fingerprint, to the one expected if($this->_config['host_fingerprint'] === $fingerprint) { return TRUE; } else { return FALSE; } }
php
protected function verify_host_fingerprint() { //Get the hosts fingerprint $fingerprint = ssh2_fingerprint($this->_conn_link); //Check the returned fingerprint, to the one expected if($this->_config['host_fingerprint'] === $fingerprint) { return TRUE; } else { return FALSE; } }
[ "protected", "function", "verify_host_fingerprint", "(", ")", "{", "//Get the hosts fingerprint", "$", "fingerprint", "=", "ssh2_fingerprint", "(", "$", "this", "->", "_conn_link", ")", ";", "//Check the returned fingerprint, to the one expected", "if", "(", "$", "this", "->", "_config", "[", "'host_fingerprint'", "]", "===", "$", "fingerprint", ")", "{", "return", "TRUE", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}" ]
Verify host fingerprint Verifies the host fingerprint. @return TRUE on success, FALSE on failure
[ "Verify", "host", "fingerprint" ]
02043c7a3834ec8525aca8156b3c89dfd4ff0d22
https://github.com/fly-studio/laravel-addons-func/blob/02043c7a3834ec8525aca8156b3c89dfd4ff0d22/src/SSHClient.php#L138-L152
12,090
fly-studio/laravel-addons-func
src/SSHClient.php
SSHClient.login_key
public function login_key() { //TODO: add location for pub/private key files return ssh2_auth_pubkey_file($this->_conn_link, $this->_config['pub_key'], $this->_config['private_key'], $this->_config['passphrase']); }
php
public function login_key() { //TODO: add location for pub/private key files return ssh2_auth_pubkey_file($this->_conn_link, $this->_config['pub_key'], $this->_config['private_key'], $this->_config['passphrase']); }
[ "public", "function", "login_key", "(", ")", "{", "//TODO: add location for pub/private key files", "return", "ssh2_auth_pubkey_file", "(", "$", "this", "->", "_conn_link", ",", "$", "this", "->", "_config", "[", "'pub_key'", "]", ",", "$", "this", "->", "_config", "[", "'private_key'", "]", ",", "$", "this", "->", "_config", "[", "'passphrase'", "]", ")", ";", "}" ]
Login using a key This will attempt to login using the provided user and a hash key. @return bool TRUE on success, FALSE on failure
[ "Login", "using", "a", "key" ]
02043c7a3834ec8525aca8156b3c89dfd4ff0d22
https://github.com/fly-studio/laravel-addons-func/blob/02043c7a3834ec8525aca8156b3c89dfd4ff0d22/src/SSHClient.php#L161-L165
12,091
fly-studio/laravel-addons-func
src/SSHClient.php
SSHClient.exec
public function exec($command, $pty = NULL, $env = array(), $width = 80, $height = 25, $width_height_type = SSH2_TERM_UNIT_CHARS) { return ssh2_exec($this->_conn_link, $command); }
php
public function exec($command, $pty = NULL, $env = array(), $width = 80, $height = 25, $width_height_type = SSH2_TERM_UNIT_CHARS) { return ssh2_exec($this->_conn_link, $command); }
[ "public", "function", "exec", "(", "$", "command", ",", "$", "pty", "=", "NULL", ",", "$", "env", "=", "array", "(", ")", ",", "$", "width", "=", "80", ",", "$", "height", "=", "25", ",", "$", "width_height_type", "=", "SSH2_TERM_UNIT_CHARS", ")", "{", "return", "ssh2_exec", "(", "$", "this", "->", "_conn_link", ",", "$", "command", ")", ";", "}" ]
Exec a command @param $command string 命令 @param
[ "Exec", "a", "command" ]
02043c7a3834ec8525aca8156b3c89dfd4ff0d22
https://github.com/fly-studio/laravel-addons-func/blob/02043c7a3834ec8525aca8156b3c89dfd4ff0d22/src/SSHClient.php#L186-L189
12,092
fly-studio/laravel-addons-func
src/SSHClient.php
SSHClient.send_file
public function send_file($local_filepath, $remote_filepath, $create_mode = 0644) { $local_filepath = $this->format_path($local_filepath); $remote_filepath = $this->format_path($remote_filepath); //Attempt to send the file return ssh2_scp_send($this->_conn_link, $local_filepath, $remote_filepath, $create_mode); }
php
public function send_file($local_filepath, $remote_filepath, $create_mode = 0644) { $local_filepath = $this->format_path($local_filepath); $remote_filepath = $this->format_path($remote_filepath); //Attempt to send the file return ssh2_scp_send($this->_conn_link, $local_filepath, $remote_filepath, $create_mode); }
[ "public", "function", "send_file", "(", "$", "local_filepath", ",", "$", "remote_filepath", ",", "$", "create_mode", "=", "0644", ")", "{", "$", "local_filepath", "=", "$", "this", "->", "format_path", "(", "$", "local_filepath", ")", ";", "$", "remote_filepath", "=", "$", "this", "->", "format_path", "(", "$", "remote_filepath", ")", ";", "//Attempt to send the file", "return", "ssh2_scp_send", "(", "$", "this", "->", "_conn_link", ",", "$", "local_filepath", ",", "$", "remote_filepath", ",", "$", "create_mode", ")", ";", "}" ]
Sends a file to the remote server using scp Attempts to send a file via SCP to the remote server currently connected to @param $local_filepath string The path to the file to send @param $remote_filepath string The path to the remote location to save the file
[ "Sends", "a", "file", "to", "the", "remote", "server", "using", "scp" ]
02043c7a3834ec8525aca8156b3c89dfd4ff0d22
https://github.com/fly-studio/laravel-addons-func/blob/02043c7a3834ec8525aca8156b3c89dfd4ff0d22/src/SSHClient.php#L199-L207
12,093
fly-studio/laravel-addons-func
src/SSHClient.php
SSHClient.receive_file
public function receive_file($remote_filepath, $local_filepath) { $local_filepath = $this->format_path($local_filepath); $remote_filepath = $this->format_path($remote_filepath); return ssh2_scp_recv($this->_conn_link, $remote_filepath, $local_filepath); }
php
public function receive_file($remote_filepath, $local_filepath) { $local_filepath = $this->format_path($local_filepath); $remote_filepath = $this->format_path($remote_filepath); return ssh2_scp_recv($this->_conn_link, $remote_filepath, $local_filepath); }
[ "public", "function", "receive_file", "(", "$", "remote_filepath", ",", "$", "local_filepath", ")", "{", "$", "local_filepath", "=", "$", "this", "->", "format_path", "(", "$", "local_filepath", ")", ";", "$", "remote_filepath", "=", "$", "this", "->", "format_path", "(", "$", "remote_filepath", ")", ";", "return", "ssh2_scp_recv", "(", "$", "this", "->", "_conn_link", ",", "$", "remote_filepath", ",", "$", "local_filepath", ")", ";", "}" ]
Requests a file from the remote server using SCP Attempts to request and save a file from the currently connected to server using SCP. @param $local_filepath string The path to save the file to on local server @param $remote_filepath string The path to the remote file that is being requested
[ "Requests", "a", "file", "from", "the", "remote", "server", "using", "SCP" ]
02043c7a3834ec8525aca8156b3c89dfd4ff0d22
https://github.com/fly-studio/laravel-addons-func/blob/02043c7a3834ec8525aca8156b3c89dfd4ff0d22/src/SSHClient.php#L218-L224
12,094
fly-studio/laravel-addons-func
src/SSHClient.php
SSHClient.disconnect
public function disconnect() { $this->exec('echo "EXITING" && exit;'); $this->_conn_link = NULL; $this->_connected = FALSE; $this->_sftp = NULL; }
php
public function disconnect() { $this->exec('echo "EXITING" && exit;'); $this->_conn_link = NULL; $this->_connected = FALSE; $this->_sftp = NULL; }
[ "public", "function", "disconnect", "(", ")", "{", "$", "this", "->", "exec", "(", "'echo \"EXITING\" && exit;'", ")", ";", "$", "this", "->", "_conn_link", "=", "NULL", ";", "$", "this", "->", "_connected", "=", "FALSE", ";", "$", "this", "->", "_sftp", "=", "NULL", ";", "}" ]
Disconnects from the connected server
[ "Disconnects", "from", "the", "connected", "server" ]
02043c7a3834ec8525aca8156b3c89dfd4ff0d22
https://github.com/fly-studio/laravel-addons-func/blob/02043c7a3834ec8525aca8156b3c89dfd4ff0d22/src/SSHClient.php#L381-L388
12,095
eix/core
src/php/main/Eix/Services/Data/Sources/MongoDB.php
MongoDB.convertFromMongo
private static function convertFromMongo(array $data) { // Move the Mongo _id field into an 'id' field. if (isset($data['_id'])) { $data['id'] = $data['_id']; unset($data['_id']); } foreach ($data as $name => &$value) { if (is_array($value)) { // Inner documents are converted too. $value = self::convertFromMongo($value); } elseif (is_object($value)) { switch (get_class($value)) { case 'MongoId': $value = $value->__toString(); break; case 'MongoDate': $value = new \DateTime('@' . $value->sec); break; } } } return $data; }
php
private static function convertFromMongo(array $data) { // Move the Mongo _id field into an 'id' field. if (isset($data['_id'])) { $data['id'] = $data['_id']; unset($data['_id']); } foreach ($data as $name => &$value) { if (is_array($value)) { // Inner documents are converted too. $value = self::convertFromMongo($value); } elseif (is_object($value)) { switch (get_class($value)) { case 'MongoId': $value = $value->__toString(); break; case 'MongoDate': $value = new \DateTime('@' . $value->sec); break; } } } return $data; }
[ "private", "static", "function", "convertFromMongo", "(", "array", "$", "data", ")", "{", "// Move the Mongo _id field into an 'id' field.", "if", "(", "isset", "(", "$", "data", "[", "'_id'", "]", ")", ")", "{", "$", "data", "[", "'id'", "]", "=", "$", "data", "[", "'_id'", "]", ";", "unset", "(", "$", "data", "[", "'_id'", "]", ")", ";", "}", "foreach", "(", "$", "data", "as", "$", "name", "=>", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "// Inner documents are converted too.", "$", "value", "=", "self", "::", "convertFromMongo", "(", "$", "value", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "switch", "(", "get_class", "(", "$", "value", ")", ")", "{", "case", "'MongoId'", ":", "$", "value", "=", "$", "value", "->", "__toString", "(", ")", ";", "break", ";", "case", "'MongoDate'", ":", "$", "value", "=", "new", "\\", "DateTime", "(", "'@'", ".", "$", "value", "->", "sec", ")", ";", "break", ";", "}", "}", "}", "return", "$", "data", ";", "}" ]
Convert the various Mongo-based objects into PHP standard types, and apply other conversions to standardise Mongo's idiosyncrasies. @param array $data the data that will be passed to Mongo for storage. @return array
[ "Convert", "the", "various", "Mongo", "-", "based", "objects", "into", "PHP", "standard", "types", "and", "apply", "other", "conversions", "to", "standardise", "Mongo", "s", "idiosyncrasies", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Services/Data/Sources/MongoDB.php#L178-L203
12,096
eix/core
src/php/main/Eix/Services/Data/Sources/MongoDB.php
MongoDB.convertToMongo
private static function convertToMongo(array &$data) { // Move the ID field where Mongo expects it. if (isset($data['id'])) { // Create the _id field Mongo expects. $data['_id'] = $data['id']; // Remove the 'id' field from the data set that will be stored. unset($data['id']); } foreach ($data as $name => &$value) { // Ensure that all strings are UTF-8. if (is_string($value)) { // Convert all strings to UTF-8, otherwise Mongo complains. if (mb_detect_encoding($value) != 'UTF-8') { $value = mb_convert_encoding($value, 'UTF-8'); } } elseif ($value instanceof Entity) { // Only the presistable fields of Entities are kept. $value = $value->getFieldsData(); } elseif (is_array($value)) { // The elements in an array are also checked in case they // contain sub-documents. self::convertToMongo($value); } } }
php
private static function convertToMongo(array &$data) { // Move the ID field where Mongo expects it. if (isset($data['id'])) { // Create the _id field Mongo expects. $data['_id'] = $data['id']; // Remove the 'id' field from the data set that will be stored. unset($data['id']); } foreach ($data as $name => &$value) { // Ensure that all strings are UTF-8. if (is_string($value)) { // Convert all strings to UTF-8, otherwise Mongo complains. if (mb_detect_encoding($value) != 'UTF-8') { $value = mb_convert_encoding($value, 'UTF-8'); } } elseif ($value instanceof Entity) { // Only the presistable fields of Entities are kept. $value = $value->getFieldsData(); } elseif (is_array($value)) { // The elements in an array are also checked in case they // contain sub-documents. self::convertToMongo($value); } } }
[ "private", "static", "function", "convertToMongo", "(", "array", "&", "$", "data", ")", "{", "// Move the ID field where Mongo expects it.", "if", "(", "isset", "(", "$", "data", "[", "'id'", "]", ")", ")", "{", "// Create the _id field Mongo expects.", "$", "data", "[", "'_id'", "]", "=", "$", "data", "[", "'id'", "]", ";", "// Remove the 'id' field from the data set that will be stored.", "unset", "(", "$", "data", "[", "'id'", "]", ")", ";", "}", "foreach", "(", "$", "data", "as", "$", "name", "=>", "&", "$", "value", ")", "{", "// Ensure that all strings are UTF-8.", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "// Convert all strings to UTF-8, otherwise Mongo complains.", "if", "(", "mb_detect_encoding", "(", "$", "value", ")", "!=", "'UTF-8'", ")", "{", "$", "value", "=", "mb_convert_encoding", "(", "$", "value", ",", "'UTF-8'", ")", ";", "}", "}", "elseif", "(", "$", "value", "instanceof", "Entity", ")", "{", "// Only the presistable fields of Entities are kept.", "$", "value", "=", "$", "value", "->", "getFieldsData", "(", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "// The elements in an array are also checked in case they", "// contain sub-documents.", "self", "::", "convertToMongo", "(", "$", "value", ")", ";", "}", "}", "}" ]
Convert entity data so that it better fits Mongo's idiosyncrasies.
[ "Convert", "entity", "data", "so", "that", "it", "better", "fits", "Mongo", "s", "idiosyncrasies", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Services/Data/Sources/MongoDB.php#L208-L234
12,097
thecodingmachine/utils.common.conditioninterface
src/Mouf/Utils/Common/ConditionInterface/AndCondition.php
AndCondition.isOk
public function isOk($caller = null) { foreach ($this->conditions as $condition) { if (!$condition->isOk($caller)) { return false; } } return true; }
php
public function isOk($caller = null) { foreach ($this->conditions as $condition) { if (!$condition->isOk($caller)) { return false; } } return true; }
[ "public", "function", "isOk", "(", "$", "caller", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "conditions", "as", "$", "condition", ")", "{", "if", "(", "!", "$", "condition", "->", "isOk", "(", "$", "caller", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Returns true if the condition is met, false otherwise. @param mixed $caller The condition caller. Optional. @return bool
[ "Returns", "true", "if", "the", "condition", "is", "met", "false", "otherwise", "." ]
d38b67427a68bd7e37615c08ba28182e6c1867f1
https://github.com/thecodingmachine/utils.common.conditioninterface/blob/d38b67427a68bd7e37615c08ba28182e6c1867f1/src/Mouf/Utils/Common/ConditionInterface/AndCondition.php#L33-L40
12,098
sheychen290/colis
src/Response.php
Response.withStatus
public function withStatus($code, $reason = '') { $code = Validator::checkCode($code); if (!is_string($reason) && !method_exists($reason, '__toString')) { throw new InvalidArgumentException('ReasonPhrase must be a string'); } $clone = clone $this; $clone->code = $code; if ($reason === '') { $reason = Validator::getCodeMessage($code); } if ($reason === '') { throw new InvalidArgumentException('ReasonPhrase must be supplied for this code'); } $clone->phrase = $reason; return $clone; }
php
public function withStatus($code, $reason = '') { $code = Validator::checkCode($code); if (!is_string($reason) && !method_exists($reason, '__toString')) { throw new InvalidArgumentException('ReasonPhrase must be a string'); } $clone = clone $this; $clone->code = $code; if ($reason === '') { $reason = Validator::getCodeMessage($code); } if ($reason === '') { throw new InvalidArgumentException('ReasonPhrase must be supplied for this code'); } $clone->phrase = $reason; return $clone; }
[ "public", "function", "withStatus", "(", "$", "code", ",", "$", "reason", "=", "''", ")", "{", "$", "code", "=", "Validator", "::", "checkCode", "(", "$", "code", ")", ";", "if", "(", "!", "is_string", "(", "$", "reason", ")", "&&", "!", "method_exists", "(", "$", "reason", ",", "'__toString'", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'ReasonPhrase must be a string'", ")", ";", "}", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "code", "=", "$", "code", ";", "if", "(", "$", "reason", "===", "''", ")", "{", "$", "reason", "=", "Validator", "::", "getCodeMessage", "(", "$", "code", ")", ";", "}", "if", "(", "$", "reason", "===", "''", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'ReasonPhrase must be supplied for this code'", ")", ";", "}", "$", "clone", "->", "phrase", "=", "$", "reason", ";", "return", "$", "clone", ";", "}" ]
Return an instance with the specified status code and, optionally, reason phrase
[ "Return", "an", "instance", "with", "the", "specified", "status", "code", "and", "optionally", "reason", "phrase" ]
b0552ece885d6b258e73ddbccf0b52c5c28e6054
https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Response.php#L48-L69
12,099
helionogueir/database
core/command/table/Create.class.php
Create.table
public function table(stdClass $variable) { (new Table())->render($this->pdo, $this->info, $variable, $this->output); }
php
public function table(stdClass $variable) { (new Table())->render($this->pdo, $this->info, $variable, $this->output); }
[ "public", "function", "table", "(", "stdClass", "$", "variable", ")", "{", "(", "new", "Table", "(", ")", ")", "->", "render", "(", "$", "this", "->", "pdo", ",", "$", "this", "->", "info", ",", "$", "variable", ",", "$", "this", "->", "output", ")", ";", "}" ]
- Create table and insert rows @param stdClass $variable Content variables for execute functionality @return null
[ "-", "Create", "table", "and", "insert", "rows" ]
685606726cd90cc730c419681383e2cb6c4150f3
https://github.com/helionogueir/database/blob/685606726cd90cc730c419681383e2cb6c4150f3/core/command/table/Create.class.php#L35-L37