repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
ttools/ttools
src/TTools/TTools.php
TTools.getAccessTokens
public function getAccessTokens($request_token, $request_secret, $oauth_verifier) { $this->setUserTokens($request_token, $request_secret); $result = $this->OAuthRequest( self::API_BASE . self::ACCESS_PATH, ['oauth_verifier' => $oauth_verifier], 'POST' ); if ($result->getCode() == 200) { $tokens = $this->parseResponse($result->getResponse()); $this->setUserTokens($tokens['oauth_token'], $tokens['oauth_token_secret']); return [ 'access_token' => $this->access_token, 'access_token_secret' => $this->access_token_secret, 'screen_name' => $tokens['screen_name'], 'user_id' => $tokens['user_id'], ]; } else { return $this->handleError($result); } }
php
public function getAccessTokens($request_token, $request_secret, $oauth_verifier) { $this->setUserTokens($request_token, $request_secret); $result = $this->OAuthRequest( self::API_BASE . self::ACCESS_PATH, ['oauth_verifier' => $oauth_verifier], 'POST' ); if ($result->getCode() == 200) { $tokens = $this->parseResponse($result->getResponse()); $this->setUserTokens($tokens['oauth_token'], $tokens['oauth_token_secret']); return [ 'access_token' => $this->access_token, 'access_token_secret' => $this->access_token_secret, 'screen_name' => $tokens['screen_name'], 'user_id' => $tokens['user_id'], ]; } else { return $this->handleError($result); } }
Makes a Request to get the user access tokens @param string $request_token @param string $request_secret @param string $oauth_verifier @return array Returns an array with the user data and tokens, or an error array with code and message
https://github.com/ttools/ttools/blob/32e6b1d9ffa346db3bbfff46a258f12d0c322819/src/TTools/TTools.php#L103-L127
chadicus/coding-standard
Chadicus/Sniffs/ControlStructures/ElseIfAndElseDeclarationSniff.php
Chadicus_Sniffs_ControlStructures_ElseIfAndElseDeclarationSniff.processTokenWithinScope
public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) { $error = 'Use of ELSE and ELSEIF is discouraged. An if expression with an else branch is never necessary. You ' . 'can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to ' . 'read.'; $phpcsFile->addWarning($error, $stackPtr, 'Discouraged'); }
php
public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) { $error = 'Use of ELSE and ELSEIF is discouraged. An if expression with an else branch is never necessary. You ' . 'can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to ' . 'read.'; $phpcsFile->addWarning($error, $stackPtr, 'Discouraged'); }
Processes this test, when one of its tokens is encountered. @param PHP_CodeSniffer_File $phpcsFile The current file being scanned. @param int $stackPtr The position of the current token in the stack passed in $tokens. @param int $currScope A pointer to the start of the scope. @return void
https://github.com/chadicus/coding-standard/blob/e877151eed0c300e4e33e00308470e3873aa04ea/Chadicus/Sniffs/ControlStructures/ElseIfAndElseDeclarationSniff.php#L26-L32
IftekherSunny/Planet-Framework
src/Sun/Console/Commands/MakeConsole.php
MakeConsole.handle
public function handle() { $consoleName = $this->input->getArgument('name'); $consoleNamespace = $this->getNamespace('Commands', $consoleName); $consoleStubs = $this->filesystem->get(__DIR__.'/../stubs/MakeConsole.txt'); $consoleStubs = str_replace([ 'dummyConsoleCommandName', 'dummyNamespace', '\\\\' ], [ basename($consoleName), $consoleNamespace, '\\' ], $consoleStubs); if(!file_exists($filename = app_path() ."/Console/{$consoleName}.php")) { $this->filesystem->create($filename, $consoleStubs); $this->info("{$consoleName} console command has been created successfully."); } else { $this->info("{$consoleName} console command already exists."); } }
php
public function handle() { $consoleName = $this->input->getArgument('name'); $consoleNamespace = $this->getNamespace('Commands', $consoleName); $consoleStubs = $this->filesystem->get(__DIR__.'/../stubs/MakeConsole.txt'); $consoleStubs = str_replace([ 'dummyConsoleCommandName', 'dummyNamespace', '\\\\' ], [ basename($consoleName), $consoleNamespace, '\\' ], $consoleStubs); if(!file_exists($filename = app_path() ."/Console/{$consoleName}.php")) { $this->filesystem->create($filename, $consoleStubs); $this->info("{$consoleName} console command has been created successfully."); } else { $this->info("{$consoleName} console command already exists."); } }
To handle console command
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Console/Commands/MakeConsole.php#L42-L58
schpill/thin
src/Webquery.php
Webquery.where
public function where($where = null, $value = null) { if (Arrays::is($this->where)) { $this->whereKey = count($this->where) + 1; } $this->where[$this->whereKey]['attr'] = $where; $this->where[$this->whereKey]['value'] = $value; return $this; }
php
public function where($where = null, $value = null) { if (Arrays::is($this->where)) { $this->whereKey = count($this->where) + 1; } $this->where[$this->whereKey]['attr'] = $where; $this->where[$this->whereKey]['value'] = $value; return $this; }
where() Sets where object @access public @param string $where @param string $value @return \Thin\Webquery
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Webquery.php#L87-L97
schpill/thin
src/Webquery.php
Webquery.execute
public function execute() { libxml_use_internal_errors(true); $result = []; $this->content = fgc($this->from); @$this->dom->loadHTML('<?xml encoding="UTF-8">' . $this->content); if (isset($this->select) && $this->select != "*") { $xpath = new DOMXpath($this->dom); $nodes = $xpath->query("//" . $this->select); $html = ''; foreach ($nodes as $node) { $html.= $this->removeHeaders($this->dom->saveHTML($node)); } @$this->dom->loadHTML('<?xml encoding="UTF-8">' . $html); } if (isset($this->where)) { $xpath = new DOMXpath($this->dom); foreach ($this->where as $where) { $nodes = $xpath->query("//*[contains(concat(' ', @" . $where['attr'] . ", ' '), '" . $where['value'] . "')]"); foreach ($nodes as $node) { $result[] = $this->removeHeaders($this->dom->saveHTML($node)); } } } if (!isset($this->where) && empty($result)) { $result[] = $this->removeHeaders($this->dom->saveHTML()); } return $result; }
php
public function execute() { libxml_use_internal_errors(true); $result = []; $this->content = fgc($this->from); @$this->dom->loadHTML('<?xml encoding="UTF-8">' . $this->content); if (isset($this->select) && $this->select != "*") { $xpath = new DOMXpath($this->dom); $nodes = $xpath->query("//" . $this->select); $html = ''; foreach ($nodes as $node) { $html.= $this->removeHeaders($this->dom->saveHTML($node)); } @$this->dom->loadHTML('<?xml encoding="UTF-8">' . $html); } if (isset($this->where)) { $xpath = new DOMXpath($this->dom); foreach ($this->where as $where) { $nodes = $xpath->query("//*[contains(concat(' ', @" . $where['attr'] . ", ' '), '" . $where['value'] . "')]"); foreach ($nodes as $node) { $result[] = $this->removeHeaders($this->dom->saveHTML($node)); } } } if (!isset($this->where) && empty($result)) { $result[] = $this->removeHeaders($this->dom->saveHTML()); } return $result; }
execute() builds and runs query, result returned as array @access public @return array
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Webquery.php#L105-L142
schpill/thin
src/Webquery.php
Webquery.removeHeaders
private function removeHeaders($content) { $content = str_replace('<?xml encoding="UTF-8">', "", $content); $content = str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">', "", $content); $content = str_replace('<html><body>', "", $content); $content = str_replace('</body></html>', "", $content); return $content; }
php
private function removeHeaders($content) { $content = str_replace('<?xml encoding="UTF-8">', "", $content); $content = str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">', "", $content); $content = str_replace('<html><body>', "", $content); $content = str_replace('</body></html>', "", $content); return $content; }
removeHeaders() removes extra headers added by DOMDocument @param string $content @return string
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Webquery.php#L150-L158
webeith/dnsbl
src/Dnsbl/Resolver/NetDnsDomainResolver.php
NetDnsDomainResolver.execute
public function execute($hostname) { $server = $this->getContext(); $query = $hostname. '.' . $server->getHostname(); $result = @$this->query($query); $response = new Response\NetDnsResponse(); $response->setHostname($hostname); $response->setServer($server); $response->setQuery($query); if ($result) { $response->listed(); $answer = ''; $resultTXT = @$this->query($query, 'TXT'); if ($resultTXT) { foreach ($resultTXT->answer as $txt) { $answer .= $txt->text[0]; } } $response->setAnswer($answer); } return $response; }
php
public function execute($hostname) { $server = $this->getContext(); $query = $hostname. '.' . $server->getHostname(); $result = @$this->query($query); $response = new Response\NetDnsResponse(); $response->setHostname($hostname); $response->setServer($server); $response->setQuery($query); if ($result) { $response->listed(); $answer = ''; $resultTXT = @$this->query($query, 'TXT'); if ($resultTXT) { foreach ($resultTXT->answer as $txt) { $answer .= $txt->text[0]; } } $response->setAnswer($answer); } return $response; }
Execute query @param string $hostname @return Dnsbl\Resolver\Response\InterfaceResponse
https://github.com/webeith/dnsbl/blob/062e30f1ccaf6578bebe1bbe51a6a833337ba825/src/Dnsbl/Resolver/NetDnsDomainResolver.php#L32-L59
beyoio/beyod
protocol/http/Request.php
Request.loadRequest
public function loadRequest($buffer) { $this->requestAt = microtime(true); list($this->_rawHeader, $this->_rawBody) = explode("\r\n\r\n", $buffer, 2); $headers = explode("\r\n", $this->_rawHeader, 2); list($this->method, $this->uri, $this->version) = explode(' ',$headers[0]); $this->loadHeaders(); $this->loadBody(); $this->_REQUEST = array_merge($this->_GET, $this->_POST); $this->loadServerVars(); $this->loadGet(); }
php
public function loadRequest($buffer) { $this->requestAt = microtime(true); list($this->_rawHeader, $this->_rawBody) = explode("\r\n\r\n", $buffer, 2); $headers = explode("\r\n", $this->_rawHeader, 2); list($this->method, $this->uri, $this->version) = explode(' ',$headers[0]); $this->loadHeaders(); $this->loadBody(); $this->_REQUEST = array_merge($this->_GET, $this->_POST); $this->loadServerVars(); $this->loadGet(); }
load reqeust buffer to this object @param string $buffer
https://github.com/beyoio/beyod/blob/11941db9c4ae4abbca6c8e634d21873c690efc79/protocol/http/Request.php#L92-L112
brick/validation
src/Internal/Luhn.php
Luhn.getCheckDigit
public static function getCheckDigit(string $number) : int { if (! ctype_digit($number)) { throw new \InvalidArgumentException('The number must be a string of digits'); } $checksum = self::checksum($number . '0'); return ($checksum === 0) ? 0 : 10 - $checksum; }
php
public static function getCheckDigit(string $number) : int { if (! ctype_digit($number)) { throw new \InvalidArgumentException('The number must be a string of digits'); } $checksum = self::checksum($number . '0'); return ($checksum === 0) ? 0 : 10 - $checksum; }
Computes and returns the check digit of a number. @param string $number @return int @throws \InvalidArgumentException
https://github.com/brick/validation/blob/b33593f75df80530417007bde97c4772807563ab/src/Internal/Luhn.php#L23-L32
brick/validation
src/Internal/Luhn.php
Luhn.isValid
public static function isValid(string $number) : bool { if (ctype_digit($number)) { return self::checksum($number) === 0; } return false; }
php
public static function isValid(string $number) : bool { if (ctype_digit($number)) { return self::checksum($number) === 0; } return false; }
Checks that a number is valid. @param string $number @return bool
https://github.com/brick/validation/blob/b33593f75df80530417007bde97c4772807563ab/src/Internal/Luhn.php#L41-L48
brick/validation
src/Internal/Luhn.php
Luhn.checksum
private static function checksum(string $number) : int { $number = strrev($number); $length = strlen($number); $sum = 0; for ($i = 0; $i < $length; $i++) { $value = $number[$i] * ($i % 2 + 1); $sum += ($value >= 10 ? $value - 9 : $value); } return $sum % 10; }
php
private static function checksum(string $number) : int { $number = strrev($number); $length = strlen($number); $sum = 0; for ($i = 0; $i < $length; $i++) { $value = $number[$i] * ($i % 2 + 1); $sum += ($value >= 10 ? $value - 9 : $value); } return $sum % 10; }
Computes the checksum of a number. @param string $number The number, validated as a string of digits. @return int
https://github.com/brick/validation/blob/b33593f75df80530417007bde97c4772807563ab/src/Internal/Luhn.php#L57-L70
Etenil/assegai
src/assegai/modules/mail/services/ses/utilities/info.class.php
CFInfo.api_support
public static function api_support() { $existing_classes = get_declared_classes(); foreach (glob(dirname(dirname(__FILE__)) . '/services/*.class.php') as $file) { include $file; } $with_sdk_classes = get_declared_classes(); $new_classes = array_diff($with_sdk_classes, $existing_classes); $filtered_classes = array(); $collect = array(); foreach ($new_classes as $class) { if (strpos($class, 'Amazon') !== false) { $filtered_classes[] = $class; } } $filtered_classes = array_values($filtered_classes); foreach ($filtered_classes as $class) { $obj = new $class(); $collect[get_class($obj)] = $obj->api_version; unset($obj); } return $collect; }
php
public static function api_support() { $existing_classes = get_declared_classes(); foreach (glob(dirname(dirname(__FILE__)) . '/services/*.class.php') as $file) { include $file; } $with_sdk_classes = get_declared_classes(); $new_classes = array_diff($with_sdk_classes, $existing_classes); $filtered_classes = array(); $collect = array(); foreach ($new_classes as $class) { if (strpos($class, 'Amazon') !== false) { $filtered_classes[] = $class; } } $filtered_classes = array_values($filtered_classes); foreach ($filtered_classes as $class) { $obj = new $class(); $collect[get_class($obj)] = $obj->api_version; unset($obj); } return $collect; }
Gets information about the web service APIs that the SDK supports. @return array An associative array containing service classes and API versions.
https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/mail/services/ses/utilities/info.class.php#L36-L68
Boolive/Core
cli/CLI.php
CLI.run_php
static function run_php($command, $background_mode = false, $ignore_duplicates = true) { if (!$ignore_duplicates || empty(self::$running_commands[$command])) { $config = Config::read('core'); $php = empty($config['php']) ? 'php' : $config['php']; if (substr(php_uname(), 0, 7) == "Windows") { pclose(popen('start' . ($background_mode ? ' /B ' : ' ') . $php . ' ' . $command, "r")); } else { exec($php . ' ' . $command . ($background_mode ? " > /dev/null &" : '')); } } self::$running_commands[$command] = true; }
php
static function run_php($command, $background_mode = false, $ignore_duplicates = true) { if (!$ignore_duplicates || empty(self::$running_commands[$command])) { $config = Config::read('core'); $php = empty($config['php']) ? 'php' : $config['php']; if (substr(php_uname(), 0, 7) == "Windows") { pclose(popen('start' . ($background_mode ? ' /B ' : ' ') . $php . ' ' . $command, "r")); } else { exec($php . ' ' . $command . ($background_mode ? " > /dev/null &" : '')); } } self::$running_commands[$command] = true; }
Исполнение php скрипта в командной строке @param string $command Команда - запускаемый скрипт с аргументами @param bool $background_mode Признак, запускать в фоновом режиме. По умолчанию нет @param bool $ignore_duplicates Признак, игнорировать дубликаты
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/cli/CLI.php#L134-L146
Boolive/Core
cli/CLI.php
CLI.clear_running_commands
static function clear_running_commands($command = null) { if (empty($command)){ self::$running_commands = []; }else if (array_key_exists($command, self::$running_commands)){ unset(self::$running_commands, $command); } }
php
static function clear_running_commands($command = null) { if (empty($command)){ self::$running_commands = []; }else if (array_key_exists($command, self::$running_commands)){ unset(self::$running_commands, $command); } }
Удаления признака, что команда была запущена @param null $command Команда. Если null, то удаляются все команды
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/cli/CLI.php#L152-L160
oliwierptak/Everon1
src/Everon/Helper/Asserts/IsInstance.php
IsInstance.assertIsInstance
public function assertIsInstance($class, $instance, $message='%s and %s are not the same instance', $exception='Asserts') { $is_instance = (get_class($class) === $instance); if ($is_instance === false) { $this->throwException($exception, $message, array(get_class($class), $instance)); } }
php
public function assertIsInstance($class, $instance, $message='%s and %s are not the same instance', $exception='Asserts') { $is_instance = (get_class($class) === $instance); if ($is_instance === false) { $this->throwException($exception, $message, array(get_class($class), $instance)); } }
Verifies that the specified conditions are of the same instance. The assertion fails if they are not. @param mixed $class Concreet class to check @param string $instance Instance name @param string $message @param string $exception @throws \Everon\Exception\Asserts
https://github.com/oliwierptak/Everon1/blob/ac93793d1fa517a8394db5f00062f1925dc218a3/src/Everon/Helper/Asserts/IsInstance.php#L24-L30
RowlandOti/ooglee-blogmodule
src/OoGlee/Application/Entities/Post/Listeners/IncrementPostViewsListener.php
IncrementPostViewsListener.listenerHandle
public function listenerHandle(IEvent $event) { $event->post->count_views++; $event->post->save(); var_dump($event->post->count_views); }
php
public function listenerHandle(IEvent $event) { $event->post->count_views++; $event->post->save(); var_dump($event->post->count_views); }
Update the post view count @param IEvent $event @return void
https://github.com/RowlandOti/ooglee-blogmodule/blob/d9c0fe4745bb09f8b94047b0cda4fd7438cde16a/src/OoGlee/Application/Entities/Post/Listeners/IncrementPostViewsListener.php#L34-L39
fly-studio/laravel-addons-smarty
src/ServiceProvider.php
ServiceProvider.register
public function register() { $this->mergeConfigFrom(__DIR__ . '/../config/smarty.php', 'smarty'); $this->app['view']->addExtension(config('smarty.extension', 'tpl'), 'smarty', function () { return new Engine(config('smarty')); }); }
php
public function register() { $this->mergeConfigFrom(__DIR__ . '/../config/smarty.php', 'smarty'); $this->app['view']->addExtension(config('smarty.extension', 'tpl'), 'smarty', function () { return new Engine(config('smarty')); }); }
Register the service provider. @return void
https://github.com/fly-studio/laravel-addons-smarty/blob/7e25b2b87596095686b2928bb12df84501fbfff9/src/ServiceProvider.php#L35-L43
gplcart/file_manager
helpers/Filter.php
Filter.accept
public function accept() { static $callable = null; $file = $this->getInnerIterator()->current(); if (isset($callable)) { return $callable ? $this->filters[$this->options['filter_key']]['handlers']['filter']($file, $this->options['filter_value']) : true; } if (empty($this->filters[$this->options['filter_key']]['handlers']['filter'])) { $callable = false; return true; } $function = $this->filters[$this->options['filter_key']]['handlers']['filter']; if (!is_callable($function)) { $callable = false; return true; } $callable = true; return $function($file, $this->options['filter_value']); }
php
public function accept() { static $callable = null; $file = $this->getInnerIterator()->current(); if (isset($callable)) { return $callable ? $this->filters[$this->options['filter_key']]['handlers']['filter']($file, $this->options['filter_value']) : true; } if (empty($this->filters[$this->options['filter_key']]['handlers']['filter'])) { $callable = false; return true; } $function = $this->filters[$this->options['filter_key']]['handlers']['filter']; if (!is_callable($function)) { $callable = false; return true; } $callable = true; return $function($file, $this->options['filter_value']); }
Check whether the current element of the iterator is acceptable
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/helpers/Filter.php#L48-L72
phramework/phramework
src/Models/Operator.php
Operator.validate
public static function validate($operator, $attributeName = 'operator') { if (!in_array($operator, self::$operators)) { throw new \Phramework\Exceptions\IncorrectParametersException( [$attributeName] ); } return $operator; }
php
public static function validate($operator, $attributeName = 'operator') { if (!in_array($operator, self::$operators)) { throw new \Phramework\Exceptions\IncorrectParametersException( [$attributeName] ); } return $operator; }
Check if a string is a valid operator @param string $operator @param string $attributeName *[Optional]* Attribute's name, used for thrown exception @throws \Phramework\Exceptions\IncorrectParametersException @return string Returns the operator
https://github.com/phramework/phramework/blob/40041d1ef23b1f8cdbd26fb112448d6a3dbef012/src/Models/Operator.php#L94-L103
gplcart/file_manager
handlers/commands/Download.php
Download.submit
public function submit($controller) { set_time_limit(0); // Download method calls exit() so clean session here $this->session->delete('file_manager_selected'); $destination = $this->file->getTempFile(); $files = $controller->getSubmitted('files'); /* @var $file \SplFileInfo */ $file = reset($files); $path = $file->getRealPath(); $filename = $file->getBasename(); if ($file->isFile()) { $result = $this->zip->file($path, $destination); } else if ($file->isDir()) { $result = $this->zip->directory($path, $destination, $filename); } if (!empty($result)) { $controller->download($destination, "$filename.zip"); } }
php
public function submit($controller) { set_time_limit(0); // Download method calls exit() so clean session here $this->session->delete('file_manager_selected'); $destination = $this->file->getTempFile(); $files = $controller->getSubmitted('files'); /* @var $file \SplFileInfo */ $file = reset($files); $path = $file->getRealPath(); $filename = $file->getBasename(); if ($file->isFile()) { $result = $this->zip->file($path, $destination); } else if ($file->isDir()) { $result = $this->zip->directory($path, $destination, $filename); } if (!empty($result)) { $controller->download($destination, "$filename.zip"); } }
Download file(s) @param \gplcart\core\Controller $controller
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/commands/Download.php#L82-L107
bennybi/yii2-cza-base
widgets/ActiveField.php
ActiveField.hiddenInput
public function hiddenInput($options = []) { $options = array_replace_recursive($this->inputOptions, $options); $this->adjustLabelFor($options); $this->parts['{label}'] = false; $this->parts['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $options); return $this; }
php
public function hiddenInput($options = []) { $options = array_replace_recursive($this->inputOptions, $options); $this->adjustLabelFor($options); $this->parts['{label}'] = false; $this->parts['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $options); return $this; }
override original method @param type $options @return \cza\base\widgets\ActiveField
https://github.com/bennybi/yii2-cza-base/blob/8257db8034bd948712fa469062921f210f0ba8da/widgets/ActiveField.php#L76-L83
bennybi/yii2-cza-base
widgets/ActiveField.php
ActiveField.datePickerInput
public function datePickerInput($options = [], $pluginOptions = [], $pluginEvents = []) { $defaults = [ 'htmlOptions' => $this->inputOptions, ]; $options = array_replace_recursive($defaults, $options); $defaults = [ 'autoclose' => true, 'todayHighlight' => true, 'format' => 'yyyy-mm-dd', ]; $pluginOptions = array_replace_recursive($defaults, $pluginOptions); $this->adjustLabelFor($options); $this->parts['{input}'] = \kartik\widgets\DatePicker::widget([ 'model' => $this->model, 'attribute' => $this->attribute, 'pluginOptions' => $pluginOptions, 'options' => $options['htmlOptions'], ]); return $this; }
php
public function datePickerInput($options = [], $pluginOptions = [], $pluginEvents = []) { $defaults = [ 'htmlOptions' => $this->inputOptions, ]; $options = array_replace_recursive($defaults, $options); $defaults = [ 'autoclose' => true, 'todayHighlight' => true, 'format' => 'yyyy-mm-dd', ]; $pluginOptions = array_replace_recursive($defaults, $pluginOptions); $this->adjustLabelFor($options); $this->parts['{input}'] = \kartik\widgets\DatePicker::widget([ 'model' => $this->model, 'attribute' => $this->attribute, 'pluginOptions' => $pluginOptions, 'options' => $options['htmlOptions'], ]); return $this; }
refert to http://demos.krajee.com/widget-details/datepicker @param type $options @param type $pluginOptions @param type $pluginEvents @return \cza\base\widgets\ActiveField
https://github.com/bennybi/yii2-cza-base/blob/8257db8034bd948712fa469062921f210f0ba8da/widgets/ActiveField.php#L128-L150
bennybi/yii2-cza-base
widgets/ActiveField.php
ActiveField.richtextInput
public function richtextInput($options = [], $pluginOptions = [], $htmlOptions = []) { $defaults = [ 'fontsize', 'fontfamily', 'fontcolor', 'table', 'textdirection', 'video', // 'textexpander', // 'limiter', 'filemanager', 'imagemanager', // 'clips', 'fullscreen', ]; $pluginOptions = array_replace_recursive($defaults, $pluginOptions); $defaults = [ 'minHeight' => 150, 'imageUpload' => Url::to([$this->imageUploadUrl, 'attr' => $this->attribute]), 'imageManagerJson' => Url::to([$this->imageListUrl, 'attr' => $this->attribute]), 'fileUpload' => Url::to([$this->fileUploadUrl, 'attr' => $this->attribute]), 'fileManagerJson' => Url::to([$this->fileListUrl, 'attr' => $this->attribute]), 'buttonSource' => true, 'lang' => \Yii::$app->czaHelper->getRegularLangName(), 'plugins' => $pluginOptions, ]; $options = array_replace_recursive($defaults, $options); $defaults = [ 'id' => isset($params['language']) ? Html::getInputId($this->model, $this->attribute) . "-{$params['language']}" : Html::getInputId($this->model, $this->attribute), ]; $htmlOptions = array_replace_recursive($defaults, $htmlOptions); $this->adjustLabelFor($options); $this->parts['{input}'] = \vova07\imperavi\Widget::widget([ 'model' => $this->model, 'attribute' => $this->attribute, // 'htmlOptions' => $htmlOptions, 'settings' => $options, ]); return $this; }
php
public function richtextInput($options = [], $pluginOptions = [], $htmlOptions = []) { $defaults = [ 'fontsize', 'fontfamily', 'fontcolor', 'table', 'textdirection', 'video', // 'textexpander', // 'limiter', 'filemanager', 'imagemanager', // 'clips', 'fullscreen', ]; $pluginOptions = array_replace_recursive($defaults, $pluginOptions); $defaults = [ 'minHeight' => 150, 'imageUpload' => Url::to([$this->imageUploadUrl, 'attr' => $this->attribute]), 'imageManagerJson' => Url::to([$this->imageListUrl, 'attr' => $this->attribute]), 'fileUpload' => Url::to([$this->fileUploadUrl, 'attr' => $this->attribute]), 'fileManagerJson' => Url::to([$this->fileListUrl, 'attr' => $this->attribute]), 'buttonSource' => true, 'lang' => \Yii::$app->czaHelper->getRegularLangName(), 'plugins' => $pluginOptions, ]; $options = array_replace_recursive($defaults, $options); $defaults = [ 'id' => isset($params['language']) ? Html::getInputId($this->model, $this->attribute) . "-{$params['language']}" : Html::getInputId($this->model, $this->attribute), ]; $htmlOptions = array_replace_recursive($defaults, $htmlOptions); $this->adjustLabelFor($options); $this->parts['{input}'] = \vova07\imperavi\Widget::widget([ 'model' => $this->model, 'attribute' => $this->attribute, // 'htmlOptions' => $htmlOptions, 'settings' => $options, ]); return $this; }
imperavi editor @param type $options @param type $htmlOptions @param type $params - [language] @return \cza\base\widgets\ActiveField
https://github.com/bennybi/yii2-cza-base/blob/8257db8034bd948712fa469062921f210f0ba8da/widgets/ActiveField.php#L188-L231
event-bus/event-dispatcher
src/Util/Pattern/AnyOrZeroWords.php
AnyOrZeroWords.matches
function matches($expression) { $parts = explode('.', $expression); // Defer evaluation of next expression to loop node. if (isset($parts[1])) { return ($this->loopNode->matches($parts[1])); } // Next expression is empty, hence it matches. return true; }
php
function matches($expression) { $parts = explode('.', $expression); // Defer evaluation of next expression to loop node. if (isset($parts[1])) { return ($this->loopNode->matches($parts[1])); } // Next expression is empty, hence it matches. return true; }
(non-PHPdoc) @see \Aztech\Events\Util\Pattern\Pattern::matches()
https://github.com/event-bus/event-dispatcher/blob/0954a9fe0084fbd096b1c32e386c21fb4754b5ff/src/Util/Pattern/AnyOrZeroWords.php#L31-L42
valu-digital/valuso
src/ValuSo/Annotation/Trigger.php
Trigger.getEventDescription
public function getEventDescription() { $event = array( 'type' => null, 'name' => null, 'args' => null, 'params' => null ); if (is_string($this->value)) { $event['type'] = $this->value; } else { $event['type'] = isset($this->value['type']) ? $this->value['type'] : null; $event['name'] = isset($this->value['name']) ? $this->value['name'] : null; $event['args'] = isset($this->value['args']) ? $this->value['args'] : null; $event['params'] = isset($this->value['params']) ? $this->value['params'] : null; } return $event; }
php
public function getEventDescription() { $event = array( 'type' => null, 'name' => null, 'args' => null, 'params' => null ); if (is_string($this->value)) { $event['type'] = $this->value; } else { $event['type'] = isset($this->value['type']) ? $this->value['type'] : null; $event['name'] = isset($this->value['name']) ? $this->value['name'] : null; $event['args'] = isset($this->value['args']) ? $this->value['args'] : null; $event['params'] = isset($this->value['params']) ? $this->value['params'] : null; } return $event; }
Retrieve event description Event description is an array that contains following keys: - type (event type, which is either 'pre' or 'post') - name (name of the event) - args (event arguments) @return array
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Annotation/Trigger.php#L34-L53
carlosV2/DumbsmartRepositories
src/Persister.php
Persister.findById
public function findById($className, $id) { return $this->factory->createTransaction()->findByReference(new Reference($className, $id)); }
php
public function findById($className, $id) { return $this->factory->createTransaction()->findByReference(new Reference($className, $id)); }
@param string $className @param string $id @return object
https://github.com/carlosV2/DumbsmartRepositories/blob/4170d5e196003aa83b295c686bdce42987e22a14/src/Persister.php#L43-L46
as3io/symfony-data-importer
src/Import/Configuration.php
Configuration.getImporters
public function getImporters($all = false) { $importers = []; foreach ($this->importers as $importer) { if ($importer->isEnabled() || true === $all) { $importers[$importer->getKey()] = $importer; } } return $importers; }
php
public function getImporters($all = false) { $importers = []; foreach ($this->importers as $importer) { if ($importer->isEnabled() || true === $all) { $importers[$importer->getKey()] = $importer; } } return $importers; }
Returns importers keyed by their internal key. @param bool $all If all importers should be returned, regardless of status. @return array
https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L296-L305
as3io/symfony-data-importer
src/Import/Configuration.php
Configuration.getImporter
public function getImporter($key) { foreach ($this->getImporters(true) as $k => $importer) { if ($key === $k) { return $importer; } } throw new \InvalidArgumentException(sprintf('Importer could not be found by key `%s`.', $key)); }
php
public function getImporter($key) { foreach ($this->getImporters(true) as $k => $importer) { if ($key === $k) { return $importer; } } throw new \InvalidArgumentException(sprintf('Importer could not be found by key `%s`.', $key)); }
Retrieves an importer by key @param string $key @return ImporterInterface @throws InvalidArgumentInterface
https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L314-L322
as3io/symfony-data-importer
src/Import/Configuration.php
Configuration.getImporterKeys
public function getImporterKeys($all = false) { $keys = []; if ($all) { $keys = $this->importerKeys; } else { foreach ($this->importerKeys as $key => $bit) { if ($bit) { $keys[] = $key; } } } return $keys; }
php
public function getImporterKeys($all = false) { $keys = []; if ($all) { $keys = $this->importerKeys; } else { foreach ($this->importerKeys as $key => $bit) { if ($bit) { $keys[] = $key; } } } return $keys; }
Returns the stored enabled importers for this model. @param bool $all If all importers should be returned, regardless of status. @return array
https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L330-L343
as3io/symfony-data-importer
src/Import/Configuration.php
Configuration.getSegmentKeys
public function getSegmentKeys($all = false) { $keys = []; if ($all) { $keys = $this->segmentKeys; } else { foreach ($this->segmentKeys as $key => $bit) { if ($bit) { $keys[] = $key; } } } return $keys; }
php
public function getSegmentKeys($all = false) { $keys = []; if ($all) { $keys = $this->segmentKeys; } else { foreach ($this->segmentKeys as $key => $bit) { if ($bit) { $keys[] = $key; } } } return $keys; }
Returns the stored enabled segments for this model. @param bool $all If all segments should be returned, regardless of status. @return array
https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L351-L364
as3io/symfony-data-importer
src/Import/Configuration.php
Configuration.getSegment
public function getSegment($key) { foreach ($this->getImporters() as $importer) { if ($importer->hasSegment($key)) { return $importer->getSegment($key); } } throw new \InvalidArgumentException(sprintf('Segment could not be found by key `%s`.', $key)); }
php
public function getSegment($key) { foreach ($this->getImporters() as $importer) { if ($importer->hasSegment($key)) { return $importer->getSegment($key); } } throw new \InvalidArgumentException(sprintf('Segment could not be found by key `%s`.', $key)); }
Retrieves a segment by key @param string $key @return SegmentInterface @throws InvalidArgumentInterface
https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L373-L381
as3io/symfony-data-importer
src/Import/Configuration.php
Configuration.toggleImporter
public function toggleImporter($key) { $importer = $this->getImporter($key); $importer->toggle(); foreach ($importer->getSegments() as $segment) { if ($importer->isEnabled()) { $this->addSegment($segment); } else { $this->removeSegment($segment); } } }
php
public function toggleImporter($key) { $importer = $this->getImporter($key); $importer->toggle(); foreach ($importer->getSegments() as $segment) { if ($importer->isEnabled()) { $this->addSegment($segment); } else { $this->removeSegment($segment); } } }
Toggles an importer and its segments @param string $key
https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L388-L399
as3io/symfony-data-importer
src/Import/Configuration.php
Configuration.toggleSegment
public function toggleSegment($key) { $segment = $this->getSegment($key); if (false === $segment->isEnabled()) { return $segment->enable(); } return $segment->disable(); }
php
public function toggleSegment($key) { $segment = $this->getSegment($key); if (false === $segment->isEnabled()) { return $segment->enable(); } return $segment->disable(); }
Toggles a segment @param string $key
https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L406-L413
as3io/symfony-data-importer
src/Import/Configuration.php
Configuration.getSegments
public function getSegments($all = false) { if ($all) { return $this->segments; } $segments = []; foreach ($this->segments as $segment) { if ($segment->isEnabled()) { $segments[] = $segment; } } return $segments; }
php
public function getSegments($all = false) { if ($all) { return $this->segments; } $segments = []; foreach ($this->segments as $segment) { if ($segment->isEnabled()) { $segments[] = $segment; } } return $segments; }
Returns segments keyed by their internal key. @param bool $all If all segments should be returned, regardless of status. @return array
https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L422-L434
makinacorpus/drupal-calista
src/Datasource/DefaultAccountDatasource.php
DefaultAccountDatasource.getFilters
public function getFilters() { $roles = user_roles(true); unset($roles[DRUPAL_AUTHENTICATED_RID]); return [ (new Filter('status', $this->t("Active")))->setChoicesMap( [ 0 => $this->t("No"), 1 => $this->t("Yes"), ] ), (new Filter('role', $this->t("Role")))->setChoicesMap($roles), (new Filter('name', $this->t("Name"))), ]; }
php
public function getFilters() { $roles = user_roles(true); unset($roles[DRUPAL_AUTHENTICATED_RID]); return [ (new Filter('status', $this->t("Active")))->setChoicesMap( [ 0 => $this->t("No"), 1 => $this->t("Yes"), ] ), (new Filter('role', $this->t("Role")))->setChoicesMap($roles), (new Filter('name', $this->t("Name"))), ]; }
Implementors should override this method to add their filters {@inheritdoc}
https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/Datasource/DefaultAccountDatasource.php#L49-L64
makinacorpus/drupal-calista
src/Datasource/DefaultAccountDatasource.php
DefaultAccountDatasource.applyFilters
protected function applyFilters(\SelectQueryInterface $select, Query $query) { if ($query->has('name')) { $select->condition('name', '%'.db_like($query->get('name')).'%', 'LIKE'); } if ($query->has('roles')) { $select->leftJoin( 'users_roles', 'ur', 'ur.uid = u.uid' ); $select->condition('ur.rid', $query->get('roles')); } if ($query->has('status')) { $select->condition('u.status', $query->get('status')); } }
php
protected function applyFilters(\SelectQueryInterface $select, Query $query) { if ($query->has('name')) { $select->condition('name', '%'.db_like($query->get('name')).'%', 'LIKE'); } if ($query->has('roles')) { $select->leftJoin( 'users_roles', 'ur', 'ur.uid = u.uid' ); $select->condition('ur.rid', $query->get('roles')); } if ($query->has('status')) { $select->condition('u.status', $query->get('status')); } }
Implementors should override this method to apply their filters @param \SelectQueryInterface $select @param Query $query
https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/Datasource/DefaultAccountDatasource.php#L121-L138
makinacorpus/drupal-calista
src/Datasource/DefaultAccountDatasource.php
DefaultAccountDatasource.process
final protected function process(\SelectQueryInterface $select, Query $query) { if ($query->hasSortField()) { $select->orderBy( $query->getSortField(), Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc' ); } $select->orderBy( 'u.uid', Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc' ); if ($searchstring = $query->getSearchString()) { $select->condition( 'u.name', '%'.db_like($searchstring).'%', 'LIKE' ); } $this->applyFilters($select, $query); return $select /*->extend(DrupalPager::class)->setQuery($query) */; }
php
final protected function process(\SelectQueryInterface $select, Query $query) { if ($query->hasSortField()) { $select->orderBy( $query->getSortField(), Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc' ); } $select->orderBy( 'u.uid', Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc' ); if ($searchstring = $query->getSearchString()) { $select->condition( 'u.name', '%'.db_like($searchstring).'%', 'LIKE' ); } $this->applyFilters($select, $query); return $select /*->extend(DrupalPager::class)->setQuery($query) */; }
Implementors must set the users table with 'u' as alias, and call this method for the datasource to work correctly. @param \SelectQueryInterface $select @param Query $query @return \SelectQuery It can be an extended query, so use this object.
https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/Datasource/DefaultAccountDatasource.php#L150-L174
makinacorpus/drupal-calista
src/Datasource/DefaultAccountDatasource.php
DefaultAccountDatasource.getItems
public function getItems(Query $query) { $select = $this->getDatabase()->select('users', 'u'); $select = $this->process($select, $query); /** @var \MakinaCorpus\Drupal\Calista\Datasource\QueryExtender\DrupalPager $pager */ $pager = $select->extend(DrupalPager::class); $pager->setDatasourceQuery($query); // Remove anonymous user $accountIdList = $pager ->fields('u', ['uid']) ->condition('u.uid', 0, '>') ->groupBy('u.uid') ->execute() ->fetchCol() ; // Preload and set nodes at once $result = new DefaultDatasourceResult(User::class, $this->preloadDependencies($accountIdList)); $result->setTotalItemCount($pager->getTotalCount()); return $result; }
php
public function getItems(Query $query) { $select = $this->getDatabase()->select('users', 'u'); $select = $this->process($select, $query); /** @var \MakinaCorpus\Drupal\Calista\Datasource\QueryExtender\DrupalPager $pager */ $pager = $select->extend(DrupalPager::class); $pager->setDatasourceQuery($query); // Remove anonymous user $accountIdList = $pager ->fields('u', ['uid']) ->condition('u.uid', 0, '>') ->groupBy('u.uid') ->execute() ->fetchCol() ; // Preload and set nodes at once $result = new DefaultDatasourceResult(User::class, $this->preloadDependencies($accountIdList)); $result->setTotalItemCount($pager->getTotalCount()); return $result; }
{@inheritdoc}
https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/Datasource/DefaultAccountDatasource.php#L179-L202
schpill/thin
src/File.php
File.readdir
public static function readdir($path) { // initialisation variable de retour $ret = array(); // on gère par sécurité la fin du path pour ajouter ou pas le / if ('/' != substr($path, -1)) { $path .= '/'; } // on vérifie que $path est bien un répertoire if (is_dir($path)) { // ouverture du répertoire if ($dir = opendir($path)) { // on parcours le répertoire while (false !== ($dirElt = readdir($dir))) { if ($dirElt != '.' && $dirElt != '..') { if (!is_dir($path . $dirElt)) { $ret[] = $path . $dirElt; } else { $ret[] = static::readdir($path . $dirElt); } } } // fermeture du répertoire closedir($dir); } else { throw new Exception('error while opening ' . $path); } } else { throw new Exception($path . ' is not a directory'); } return Arrays::flatten($ret); }
php
public static function readdir($path) { // initialisation variable de retour $ret = array(); // on gère par sécurité la fin du path pour ajouter ou pas le / if ('/' != substr($path, -1)) { $path .= '/'; } // on vérifie que $path est bien un répertoire if (is_dir($path)) { // ouverture du répertoire if ($dir = opendir($path)) { // on parcours le répertoire while (false !== ($dirElt = readdir($dir))) { if ($dirElt != '.' && $dirElt != '..') { if (!is_dir($path . $dirElt)) { $ret[] = $path . $dirElt; } else { $ret[] = static::readdir($path . $dirElt); } } } // fermeture du répertoire closedir($dir); } else { throw new Exception('error while opening ' . $path); } } else { throw new Exception($path . ' is not a directory'); } return Arrays::flatten($ret); }
Permet de lire le contenu d'un répertoire lorsqu'on n'a pas accès à la SPL FileSystemIterator (version PHP < 5.3) @param string $path le chemin du répertoire @return array tableau contenant tout le contenu du répertoire
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/File.php#L325-L360
schpill/thin
src/File.php
File.read
public static function read($file, $default = false, $mode = 'rb') { if (static::exists($file)) { $fp = fopen($file, $mode); $data = fread($fp, static::size($file)); fclose($fp); return $data; } return $default; }
php
public static function read($file, $default = false, $mode = 'rb') { if (static::exists($file)) { $fp = fopen($file, $mode); $data = fread($fp, static::size($file)); fclose($fp); return $data; } return $default; }
/* GP 12-10-2014 - Use this method vs file_get_contents to ensure the reading mode and improve the lock status
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/File.php#L498-L510
issei-m/spike-php
src/Spike.php
Spike.requestToken
public function requestToken(TokenRequest $request) { $result = $this->request('POST', '/tokens', [ 'card[number]' => $request->getCardNumber(), 'card[exp_month]' => $request->getExpirationMonth(), 'card[exp_year]' => $request->getExpirationYear(), 'card[cvc]' => $request->getSecurityCode(), 'card[name]' => $request->getHolderName(), 'currency' => $request->getCurrency(), 'email' => $request->getEmail(), ]); return $this->objectConverter->convert($result); }
php
public function requestToken(TokenRequest $request) { $result = $this->request('POST', '/tokens', [ 'card[number]' => $request->getCardNumber(), 'card[exp_month]' => $request->getExpirationMonth(), 'card[exp_year]' => $request->getExpirationYear(), 'card[cvc]' => $request->getSecurityCode(), 'card[name]' => $request->getHolderName(), 'currency' => $request->getCurrency(), 'email' => $request->getEmail(), ]); return $this->objectConverter->convert($result); }
Returns a new token. @param TokenRequest $request @return Token @throws RequestException
https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L52-L65
issei-m/spike-php
src/Spike.php
Spike.getToken
public function getToken($id) { $result = $this->request('GET', '/tokens/' . $id); return $this->objectConverter->convert($result); }
php
public function getToken($id) { $result = $this->request('GET', '/tokens/' . $id); return $this->objectConverter->convert($result); }
Returns the token by id. @param string $id @return Token @throws RequestException
https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L75-L80
issei-m/spike-php
src/Spike.php
Spike.getCharges
public function getCharges($limit = 10, $startingAfter = null, $endingBefore = null) { $endpointUrl = '/charges?limit=' . $limit; if ($startingAfter) { $endpointUrl .= '&starting_after=' . $startingAfter; } if ($endingBefore) { $endpointUrl .= '&ending_before=' . $endingBefore; } $result = $this->request('GET', $endpointUrl); return $this->objectConverter->convert($result); }
php
public function getCharges($limit = 10, $startingAfter = null, $endingBefore = null) { $endpointUrl = '/charges?limit=' . $limit; if ($startingAfter) { $endpointUrl .= '&starting_after=' . $startingAfter; } if ($endingBefore) { $endpointUrl .= '&ending_before=' . $endingBefore; } $result = $this->request('GET', $endpointUrl); return $this->objectConverter->convert($result); }
Returns the charges. @param integer $limit @param Charge|string $startingAfter @param Charge|string $endingBefore @return Charge[] @throws RequestException
https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L92-L106
issei-m/spike-php
src/Spike.php
Spike.getCharge
public function getCharge($id) { $result = $this->request('GET', '/charges/' . $id); return $this->objectConverter->convert($result); }
php
public function getCharge($id) { $result = $this->request('GET', '/charges/' . $id); return $this->objectConverter->convert($result); }
Returns the charge by id. @param string $id @return Charge @throws RequestException
https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L116-L121
issei-m/spike-php
src/Spike.php
Spike.charge
public function charge(ChargeRequest $request) { $result = $this->request('POST', '/charges', [ 'card' => (string) $request->getToken(), 'amount' => $request->getAmount() ? $request->getAmount()->getAmount() : null, 'currency' => $request->getAmount() ? $request->getAmount()->getCurrency() : null, 'capture' => $request->isCapture() ? 'true' : 'false', 'products' => json_encode($request->getProducts()), ]); return $this->objectConverter->convert($result); }
php
public function charge(ChargeRequest $request) { $result = $this->request('POST', '/charges', [ 'card' => (string) $request->getToken(), 'amount' => $request->getAmount() ? $request->getAmount()->getAmount() : null, 'currency' => $request->getAmount() ? $request->getAmount()->getCurrency() : null, 'capture' => $request->isCapture() ? 'true' : 'false', 'products' => json_encode($request->getProducts()), ]); return $this->objectConverter->convert($result); }
Creates a new charge. @param ChargeRequest $request @return Charge @throws RequestException
https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L131-L142
issei-m/spike-php
src/Spike.php
Spike.capture
public function capture($charge) { $result = $this->request('POST', '/charges/' . $charge . '/capture'); return $this->objectConverter->convert($result); }
php
public function capture($charge) { $result = $this->request('POST', '/charges/' . $charge . '/capture'); return $this->objectConverter->convert($result); }
Captures the charge. @param Charge|string $charge @return Charge @throws RequestException
https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L152-L157
issei-m/spike-php
src/Spike.php
Spike.refund
public function refund($charge) { $result = $this->request('POST', '/charges/' . $charge . '/refund'); return $this->objectConverter->convert($result); }
php
public function refund($charge) { $result = $this->request('POST', '/charges/' . $charge . '/refund'); return $this->objectConverter->convert($result); }
Refunds the charge. @param Charge|string $charge @return Charge @throws RequestException
https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L167-L172
YiMAproject/yimaWidgetator
src/yimaWidgetator/Service/WidgetManagerFactory.php
WidgetManagerFactory.createService
public function createService(ServiceManager\ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); $config = (isset($config['yima_widgetator'])) ? $config['yima_widgetator'] : []; (isset($config['services'])) ? $config = $config['services'] : []; // ServiceLocator Will Injected into WidgetManager // because is instanceof serviceLocatorAwareInterface $smConfig = new ServiceManager\Config($config); $widgetManager = new WidgetManager($smConfig); return $widgetManager; }
php
public function createService(ServiceManager\ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); $config = (isset($config['yima_widgetator'])) ? $config['yima_widgetator'] : []; (isset($config['services'])) ? $config = $config['services'] : []; // ServiceLocator Will Injected into WidgetManager // because is instanceof serviceLocatorAwareInterface $smConfig = new ServiceManager\Config($config); $widgetManager = new WidgetManager($smConfig); return $widgetManager; }
Create service @param ServiceManager\ServiceLocatorInterface $serviceLocator @return WidgetManager
https://github.com/YiMAproject/yimaWidgetator/blob/332bc9318e6ceaec918147b30317da2f5b3d2636/src/yimaWidgetator/Service/WidgetManagerFactory.php#L15-L28
phramework/testphase
src/Expression.php
Expression.getPrefixSuffix
public static function getPrefixSuffix($expressionType = Expression::EXPRESSION_TYPE_PLAIN) { $prefix = ''; $suffix = ''; $patternPrefix = ''; $patternSuffix = ''; switch ($expressionType) { case Expression::EXPRESSION_TYPE_PLAIN: $patternPrefix = '^'; $patternSuffix = '$'; break; case Expression::EXPRESSION_TYPE_REPLACE: $prefix = '{{{'; $suffix = '}}}'; $patternPrefix = '^'; $patternSuffix = '$'; break; case Expression::EXPRESSION_TYPE_INLINE_REPLACE: $prefix = '{{'; $suffix = '}}'; break; } return [$prefix, $suffix, $patternPrefix, $patternSuffix]; }
php
public static function getPrefixSuffix($expressionType = Expression::EXPRESSION_TYPE_PLAIN) { $prefix = ''; $suffix = ''; $patternPrefix = ''; $patternSuffix = ''; switch ($expressionType) { case Expression::EXPRESSION_TYPE_PLAIN: $patternPrefix = '^'; $patternSuffix = '$'; break; case Expression::EXPRESSION_TYPE_REPLACE: $prefix = '{{{'; $suffix = '}}}'; $patternPrefix = '^'; $patternSuffix = '$'; break; case Expression::EXPRESSION_TYPE_INLINE_REPLACE: $prefix = '{{'; $suffix = '}}'; break; } return [$prefix, $suffix, $patternPrefix, $patternSuffix]; }
Get prefix and suffix @param string $expressionType @return string[4] Returns the expression type prefix, suffix, pattern prefix and suffix. @example ```php list( $prefix, $suffix, $patternPrefix, $patternSuffix ) = Expression::getPrefixSuffix(Expression::EXPRESSION_TYPE_INLINE_REPLACE); ```
https://github.com/phramework/testphase/blob/b00107b7a37cf1a1b9b8860b3eb031aacfa2634c/src/Expression.php#L74-L99
phramework/testphase
src/Expression.php
Expression.parse
public static function parse($value) { $expression = Expression::getExpression(); $return = preg_match( $expression, $value, $matches ); if (!$return) { return null; } $parsed = new \stdClass(); $parsed->key = $matches['key']; $parsed->mode = Globals::KEY_VARIABLE; if (isset($matches['function']) && !empty($matches['function'])) { $parsed->mode = Globals::KEY_FUNCTION; if (key_exists('parameters', $matches) && strlen((string)$matches['parameters'])) { //Handles only one parameter $parsed->parameters = [$matches['parameters']]; } } elseif (isset($matches['array']) && !empty($matches['array'])) { $parsed->mode = Globals::KEY_ARRAY; //should exists $parsed->index = $matches['index']; } return $parsed; }
php
public static function parse($value) { $expression = Expression::getExpression(); $return = preg_match( $expression, $value, $matches ); if (!$return) { return null; } $parsed = new \stdClass(); $parsed->key = $matches['key']; $parsed->mode = Globals::KEY_VARIABLE; if (isset($matches['function']) && !empty($matches['function'])) { $parsed->mode = Globals::KEY_FUNCTION; if (key_exists('parameters', $matches) && strlen((string)$matches['parameters'])) { //Handles only one parameter $parsed->parameters = [$matches['parameters']]; } } elseif (isset($matches['array']) && !empty($matches['array'])) { $parsed->mode = Globals::KEY_ARRAY; //should exists $parsed->index = $matches['index']; } return $parsed; }
@param $value @return null|object @example ```php $parsed = Expression::parse('myFunction(10)'); print_r($parsed); //Will output //stdClass Object //( // [key] => myFunction // [mode] => function // [parameters] => [6] //) ```
https://github.com/phramework/testphase/blob/b00107b7a37cf1a1b9b8860b3eb031aacfa2634c/src/Expression.php#L152-L185
matryoshka-model/matryoshka
library/Hydrator/Strategy/HasOneStrategy.php
HasOneStrategy.extract
public function extract($value) { if (null === $value) { return $this->nullable ? null : []; } if (is_object($value)) { $objectPrototype = $this->getObjectPrototype(); return $objectPrototype->getHydrator()->extract($value); } if (is_array($value)) { return $value; } throw new Exception\InvalidArgumentException(sprintf( 'Invalid value: must be null, or an array, or an object: "%s" given', is_object($value) ? get_class($value) : gettype($value) )); }
php
public function extract($value) { if (null === $value) { return $this->nullable ? null : []; } if (is_object($value)) { $objectPrototype = $this->getObjectPrototype(); return $objectPrototype->getHydrator()->extract($value); } if (is_array($value)) { return $value; } throw new Exception\InvalidArgumentException(sprintf( 'Invalid value: must be null, or an array, or an object: "%s" given', is_object($value) ? get_class($value) : gettype($value) )); }
Converts the given value so that it can be extracted by the hydrator. @param object|array|null $value The original value. @return array|null Returns the value that should be extracted.
https://github.com/matryoshka-model/matryoshka/blob/51792df00d9897f556d5a3c53193eed0974ff09d/library/Hydrator/Strategy/HasOneStrategy.php#L59-L78
matryoshka-model/matryoshka
library/Hydrator/Strategy/HasOneStrategy.php
HasOneStrategy.hydrate
public function hydrate($value) { $objectPrototype = $this->getObjectPrototype(); if (is_array($value)) { $object = $this->getPrototypeStrategy()->createObject($objectPrototype, $value); return $object->getHydrator()->hydrate($value, $object); } if (null === $value) { return $this->nullable ? null : clone $objectPrototype; } if ($value instanceof $objectPrototype) { return clone $value; } throw new Exception\InvalidArgumentException(sprintf( 'Invalid value: must be null (only if nullable option is enabled), or an array, or an instance of "%s": "%s" given', get_class($objectPrototype), is_object($value) ? get_class($value) : gettype($value) )); }
php
public function hydrate($value) { $objectPrototype = $this->getObjectPrototype(); if (is_array($value)) { $object = $this->getPrototypeStrategy()->createObject($objectPrototype, $value); return $object->getHydrator()->hydrate($value, $object); } if (null === $value) { return $this->nullable ? null : clone $objectPrototype; } if ($value instanceof $objectPrototype) { return clone $value; } throw new Exception\InvalidArgumentException(sprintf( 'Invalid value: must be null (only if nullable option is enabled), or an array, or an instance of "%s": "%s" given', get_class($objectPrototype), is_object($value) ? get_class($value) : gettype($value) )); }
Converts the given value so that it can be hydrated by the hydrator. @param object|array|null $value The original value. @return object|null Returns the value that should be hydrated.
https://github.com/matryoshka-model/matryoshka/blob/51792df00d9897f556d5a3c53193eed0974ff09d/library/Hydrator/Strategy/HasOneStrategy.php#L86-L108
znframework/package-hypertext
JQueryBuilder.php
JQueryBuilder.selector
public function selector($selector) { if( is_scalar($selector) ) { $this->selector = json_encode($selector); } else { $this->selector = Buffering\Callback::do($selector); } return $this; }
php
public function selector($selector) { if( is_scalar($selector) ) { $this->selector = json_encode($selector); } else { $this->selector = Buffering\Callback::do($selector); } return $this; }
Keeps jquery selector @param string $selector @return object
https://github.com/znframework/package-hypertext/blob/12bbc3bd47a2fae735f638a3e01cc82c1b9c9005/JQueryBuilder.php#L63-L76
znframework/package-hypertext
JQueryBuilder.php
JQueryBuilder.build
protected function build(String $content) { $string = '$(' . $this->selector . ')' . $content . ';'; $this->builder = NULL; return $string; }
php
protected function build(String $content) { $string = '$(' . $this->selector . ')' . $content . ';'; $this->builder = NULL; return $string; }
Protected build
https://github.com/znframework/package-hypertext/blob/12bbc3bd47a2fae735f638a3e01cc82c1b9c9005/JQueryBuilder.php#L81-L88
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.getQueryExecutor
function getQueryExecutor() { if (!$this->exec) { $this->exec = new QueryExecutor($this->conn); } return $this->exec; }
php
function getQueryExecutor() { if (!$this->exec) { $this->exec = new QueryExecutor($this->conn); } return $this->exec; }
Get the query executor @return \pq\Query\ExecutorInterface
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L175-L180
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.getMetadataCache
function getMetadataCache() { if (!isset($this->metadatCache)) { $this->metadataCache = static::$defaultMetadataCache ?: new Table\StaticCache; } return $this->metadataCache; }
php
function getMetadataCache() { if (!isset($this->metadatCache)) { $this->metadataCache = static::$defaultMetadataCache ?: new Table\StaticCache; } return $this->metadataCache; }
Get the metadata cache @return \pq\Gateway\Table\CacheInterface
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L186-L191
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.getIdentity
function getIdentity() { if (!isset($this->identity)) { $this->identity = new Table\Identity($this); } return $this->identity; }
php
function getIdentity() { if (!isset($this->identity)) { $this->identity = new Table\Identity($this); } return $this->identity; }
Get the primary key @return \pq\Gateway\Table\Identity
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L206-L211
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.getAttributes
function getAttributes() { if (!isset($this->attributes)) { $this->attributes = new Table\Attributes($this); } return $this->attributes; }
php
function getAttributes() { if (!isset($this->attributes)) { $this->attributes = new Table\Attributes($this); } return $this->attributes; }
Get the table attribute definition (column list) @return \pq\Table\Attributes
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L217-L222
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.getRelations
function getRelations() { if (!isset($this->relations)) { $this->relations = new Table\Relations($this); } return $this->relations; }
php
function getRelations() { if (!isset($this->relations)) { $this->relations = new Table\Relations($this); } return $this->relations; }
Get foreign key relations @return \pq\Gateway\Table\Relations
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L228-L233
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.notify
function notify(\pq\Gateway\Row $row = null, $event = null, array &$where = null) { foreach ($this->observers as $observer) { $observer->update($this, $row, $event, $where); } }
php
function notify(\pq\Gateway\Row $row = null, $event = null, array &$where = null) { foreach ($this->observers as $observer) { $observer->update($this, $row, $event, $where); } }
Implements \SplSubject
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L282-L286
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.onResult
public function onResult(\pq\Result $result = null) { if ($result && $result->status != \pq\Result::TUPLES_OK) { return $result; } $rowset = $this->getRowsetPrototype(); if (is_callable($rowset)) { return $rowset($result); } elseif ($rowset) { return new $rowset($this, $result); } return $result; }
php
public function onResult(\pq\Result $result = null) { if ($result && $result->status != \pq\Result::TUPLES_OK) { return $result; } $rowset = $this->getRowsetPrototype(); if (is_callable($rowset)) { return $rowset($result); } elseif ($rowset) { return new $rowset($this, $result); } return $result; }
Retreives the result of an executed query @param \pq\Result $result @return mixed
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L302-L315
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.find
function find(array $where = null, $order = null, $limit = 0, $offset = 0, $lock = null) { $query = $this->getQueryWriter()->reset(); $query->write("SELECT * FROM", $this->conn->quoteName($this->name)); if ($where) { $query->write("WHERE")->criteria($where); } if ($order) { $query->write("ORDER BY", $order); } if ($limit) { $query->write("LIMIT", $limit); } if ($offset) { $query->write("OFFSET", $offset); } if ($lock) { $query->write("FOR", $lock); } return $this->execute($query); }
php
function find(array $where = null, $order = null, $limit = 0, $offset = 0, $lock = null) { $query = $this->getQueryWriter()->reset(); $query->write("SELECT * FROM", $this->conn->quoteName($this->name)); if ($where) { $query->write("WHERE")->criteria($where); } if ($order) { $query->write("ORDER BY", $order); } if ($limit) { $query->write("LIMIT", $limit); } if ($offset) { $query->write("OFFSET", $offset); } if ($lock) { $query->write("FOR", $lock); } return $this->execute($query); }
Find rows in the table @param array $where @param array|string $order @param int $limit @param int $offset @param string $lock @return mixed
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L326-L345
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.of
function of(Row $foreign, $ref = null, $order = null, $limit = 0, $offset = 0) { // select * from $this where $this->$foreignColumn = $foreign->$referencedColumn if (!($rel = $this->getRelation($foreign->getTable()->getName(), $ref))) { return $this->onResult(null); } $where = array(); foreach ($rel as $key => $ref) { $where["$key="] = $foreign->$ref; } return $this->find($where, $order, $limit, $offset); }
php
function of(Row $foreign, $ref = null, $order = null, $limit = 0, $offset = 0) { // select * from $this where $this->$foreignColumn = $foreign->$referencedColumn if (!($rel = $this->getRelation($foreign->getTable()->getName(), $ref))) { return $this->onResult(null); } $where = array(); foreach ($rel as $key => $ref) { $where["$key="] = $foreign->$ref; } return $this->find($where, $order, $limit, $offset); }
Get the child rows of a row by foreign key @param \pq\Gateway\Row $foreign @param string $ref optional fkey name @param string $order @param int $limit @param int $offset @return mixed
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L356-L369
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.by
function by(Row $foreign, $ref = null) { // select * from $this where $this->$referencedColumn = $me->$foreignColumn if (!($rel = $foreign->getTable()->getRelation($this->getName(), $ref))) { return $this->onResult(null); } $where = array(); foreach ($rel as $key => $ref) { $where["$ref="] = $foreign->$key; } return $this->find($where); }
php
function by(Row $foreign, $ref = null) { // select * from $this where $this->$referencedColumn = $me->$foreignColumn if (!($rel = $foreign->getTable()->getRelation($this->getName(), $ref))) { return $this->onResult(null); } $where = array(); foreach ($rel as $key => $ref) { $where["$ref="] = $foreign->$key; } return $this->find($where); }
Get the parent rows of a row by foreign key @param \pq\Gateway\Row $foreign @param string $ref @return mixed
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L377-L389
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.with
function with(array $relations, array $where = null, $order = null, $limit = 0, $offset = 0) { $qthis = $this->conn->quoteName($this->getName()); $query = $this->getQueryWriter()->reset(); $query->write("SELECT", "$qthis.*", "FROM", $qthis); foreach ($relations as $relation) { if (!($relation instanceof Table\Reference)) { $relation = static::resolve($relation)->getRelation($this->getName()); } if ($this->getName() === $relation->foreignTable) { $query->write("JOIN", $relation->referencedTable)->write("ON"); foreach ($relation as $key => $ref) { $query->criteria( array( "{$relation->referencedTable}.{$ref}=" => new QueryExpr("{$relation->foreignTable}.{$key}") ) ); } } else { $query->write("JOIN", $relation->foreignTable)->write("ON"); foreach ($relation as $key => $ref) { $query->criteria( array( "{$relation->referencedTable}.{$ref}=" => new QueryExpr("{$relation->foreignTable}.{$key}") ) ); } } } if ($where) { $query->write("WHERE")->criteria($where); } if ($order) { $query->write("ORDER BY", $order); } if ($limit) { $query->write("LIMIT", $limit); } if ($offset) { $query->write("OFFSET", $offset); } return $this->execute($query); }
php
function with(array $relations, array $where = null, $order = null, $limit = 0, $offset = 0) { $qthis = $this->conn->quoteName($this->getName()); $query = $this->getQueryWriter()->reset(); $query->write("SELECT", "$qthis.*", "FROM", $qthis); foreach ($relations as $relation) { if (!($relation instanceof Table\Reference)) { $relation = static::resolve($relation)->getRelation($this->getName()); } if ($this->getName() === $relation->foreignTable) { $query->write("JOIN", $relation->referencedTable)->write("ON"); foreach ($relation as $key => $ref) { $query->criteria( array( "{$relation->referencedTable}.{$ref}=" => new QueryExpr("{$relation->foreignTable}.{$key}") ) ); } } else { $query->write("JOIN", $relation->foreignTable)->write("ON"); foreach ($relation as $key => $ref) { $query->criteria( array( "{$relation->referencedTable}.{$ref}=" => new QueryExpr("{$relation->foreignTable}.{$key}") ) ); } } } if ($where) { $query->write("WHERE")->criteria($where); } if ($order) { $query->write("ORDER BY", $order); } if ($limit) { $query->write("LIMIT", $limit); } if ($offset) { $query->write("OFFSET", $offset); } return $this->execute($query); }
Get rows dependent on other rows by foreign keys @param array $relations @param array $where @param string $order @param int $limit @param int $offset @return mixed
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L400-L443
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.create
function create(array $data = null, $returning = "*") { $query = $this->getQueryWriter()->reset(); $query->write("INSERT INTO", $this->conn->quoteName($this->name)); if ($data) { $first = true; $params = array(); foreach ($data as $key => $val) { $query->write($first ? "(" : ",", $key); $params[] = $query->param($val, $this->getAttributes()->getColumn($key)->type); $first and $first = false; } $query->write(") VALUES (", $params, ")"); } else { $query->write("DEFAULT VALUES"); } if (strlen($returning)) { $query->write("RETURNING", $returning); } return $this->execute($query); }
php
function create(array $data = null, $returning = "*") { $query = $this->getQueryWriter()->reset(); $query->write("INSERT INTO", $this->conn->quoteName($this->name)); if ($data) { $first = true; $params = array(); foreach ($data as $key => $val) { $query->write($first ? "(" : ",", $key); $params[] = $query->param($val, $this->getAttributes()->getColumn($key)->type); $first and $first = false; } $query->write(") VALUES (", $params, ")"); } else { $query->write("DEFAULT VALUES"); } if (strlen($returning)) { $query->write("RETURNING", $returning); } return $this->execute($query); }
Insert a row into the table @param array $data @param string $returning @return mixed
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L451-L471
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.update
function update(array $where, array $data, $returning = "*") { $query = $this->getQueryWriter()->reset(); $query->write("UPDATE", $this->conn->quoteName($this->name)); $first = true; foreach ($data as $key => $val) { $query->write($first ? "SET" : ",", $key, "=", $query->param($val, $this->getAttributes()->getColumn($key)->type)); $first and $first = false; } $query->write("WHERE")->criteria($where); if (strlen($returning)) { $query->write("RETURNING", $returning); } return $this->execute($query); }
php
function update(array $where, array $data, $returning = "*") { $query = $this->getQueryWriter()->reset(); $query->write("UPDATE", $this->conn->quoteName($this->name)); $first = true; foreach ($data as $key => $val) { $query->write($first ? "SET" : ",", $key, "=", $query->param($val, $this->getAttributes()->getColumn($key)->type)); $first and $first = false; } $query->write("WHERE")->criteria($where); if (strlen($returning)) { $query->write("RETURNING", $returning); } return $this->execute($query); }
Update rows in the table @param array $where @param array $data @param string $returning @retunr mixed
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L480-L494
m6w6/pq-gateway
lib/pq/Gateway/Table.php
Table.delete
function delete(array $where, $returning = null) { $query = $this->getQueryWriter()->reset(); $query->write("DELETE FROM", $this->conn->quoteName($this->name)); $query->write("WHERE")->criteria($where); if (strlen($returning)) { $query->write("RETURNING", $returning); } return $this->execute($query); }
php
function delete(array $where, $returning = null) { $query = $this->getQueryWriter()->reset(); $query->write("DELETE FROM", $this->conn->quoteName($this->name)); $query->write("WHERE")->criteria($where); if (strlen($returning)) { $query->write("RETURNING", $returning); } return $this->execute($query); }
Delete rows from the table @param array $where @param string $returning @return mixed
https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L502-L510
schpill/thin
src/Google/Chart.php
Chart.load
public function load($data, $dataType = 'json') { $this->_data = ($dataType != 'json') ? $this->dataToJson($data) : $data; }
php
public function load($data, $dataType = 'json') { $this->_data = ($dataType != 'json') ? $this->dataToJson($data) : $data; }
loads the dataset and converts it to the correct format
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Google/Chart.php#L34-L37
schpill/thin
src/Google/Chart.php
Chart.draw
public function draw($div, array $options = []) { $output = ''; if (self::$_first) { $output .= $this->initChart(); } // start a code block $output .= '<script type="text/javascript">' . "\n"; // set callback function $output .= 'google.setOnLoadCallback(drawChart' . self::$_count . ');' . "\n"; // create callback function $output .= 'function drawChart' . self::$_count . '() {' . "\n"; $output .= 'var data = new google.visualization.DataTable(' . $this->_data . ');' . "\n"; // set the options $output .= 'var options = ' . json_encode($options) . ';' . "\n"; // create and draw the chart $output .= 'var chart = new google.visualization.' . $this->_chartType . '(document.getElementById(\'' . $div . '\'));' . "\n"; $output .= 'chart.draw(data, options);' . "\n"; $output .= '} </script>' . "\n"; return $output; }
php
public function draw($div, array $options = []) { $output = ''; if (self::$_first) { $output .= $this->initChart(); } // start a code block $output .= '<script type="text/javascript">' . "\n"; // set callback function $output .= 'google.setOnLoadCallback(drawChart' . self::$_count . ');' . "\n"; // create callback function $output .= 'function drawChart' . self::$_count . '() {' . "\n"; $output .= 'var data = new google.visualization.DataTable(' . $this->_data . ');' . "\n"; // set the options $output .= 'var options = ' . json_encode($options) . ';' . "\n"; // create and draw the chart $output .= 'var chart = new google.visualization.' . $this->_chartType . '(document.getElementById(\'' . $div . '\'));' . "\n"; $output .= 'chart.draw(data, options);' . "\n"; $output .= '} </script>' . "\n"; return $output; }
draws the chart
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Google/Chart.php#L58-L87
schpill/thin
src/Google/Chart.php
Chart.getColumns
private function getColumns($data) { $cols = []; foreach ($data[0] as $key => $value) { if (is_numeric($key)){ if (is_string($data[1][$key])) { $cols[] = ['id' => '', 'label' => $value, 'type' => 'string']; } else { $cols[] = ['id' => '', 'label' => $value, 'type' => 'number']; } $this->_skipFirstRow = true; } else { if (is_string($value)) { $cols[] = ['id' => '', 'label' => $key, 'type' => 'string']; } else { $cols[] = ['id' => '', 'label' => $key, 'type' => 'number']; } } } return $cols; }
php
private function getColumns($data) { $cols = []; foreach ($data[0] as $key => $value) { if (is_numeric($key)){ if (is_string($data[1][$key])) { $cols[] = ['id' => '', 'label' => $value, 'type' => 'string']; } else { $cols[] = ['id' => '', 'label' => $value, 'type' => 'number']; } $this->_skipFirstRow = true; } else { if (is_string($value)) { $cols[] = ['id' => '', 'label' => $key, 'type' => 'string']; } else { $cols[] = ['id' => '', 'label' => $key, 'type' => 'number']; } } } return $cols; }
substracts the column names from the first and second row in the dataset
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Google/Chart.php#L92-L115
schpill/thin
src/Google/Chart.php
Chart.dataToJson
private function dataToJson($data) { $cols = $this->getColumns($data); $rows = []; foreach ($data as $key => $row) { if ($key != 0 || !$this->_skipFirstRow) { $c = []; foreach ($row as $v) { $c[] = ['v' => $v]; } $rows[] = ['c' => $c]; } } return json_encode(['cols' => $cols, 'rows' => $rows]); }
php
private function dataToJson($data) { $cols = $this->getColumns($data); $rows = []; foreach ($data as $key => $row) { if ($key != 0 || !$this->_skipFirstRow) { $c = []; foreach ($row as $v) { $c[] = ['v' => $v]; } $rows[] = ['c' => $c]; } } return json_encode(['cols' => $cols, 'rows' => $rows]); }
convert array data to json
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Google/Chart.php#L120-L139
kamilabs/icobench-client
src/Kami/IcoBench/Client.php
Client.request
protected function request($action, array $data, $async = false) { $method = $async ? 'postAsync' : 'post'; $payload = json_encode($data); $response = $this->httpClient->$method($action, [ 'json' => $data, 'headers' => [ 'X-ICObench-Key' => $this->publicKey, 'X-ICObench-Sig' => $this->sign($payload) ] ]); if($async){ return $response->then( function (ResponseInterface $res) { return $this->processResponse($res); } ); } return $this->processResponse($response); }
php
protected function request($action, array $data, $async = false) { $method = $async ? 'postAsync' : 'post'; $payload = json_encode($data); $response = $this->httpClient->$method($action, [ 'json' => $data, 'headers' => [ 'X-ICObench-Key' => $this->publicKey, 'X-ICObench-Sig' => $this->sign($payload) ] ]); if($async){ return $response->then( function (ResponseInterface $res) { return $this->processResponse($res); } ); } return $this->processResponse($response); }
@param $action @param $data @param boolean $async @throws IcoBenchException @return array | string
https://github.com/kamilabs/icobench-client/blob/b06def3015e00de0587b485648d2ff2828595186/src/Kami/IcoBench/Client.php#L81-L103
kamilabs/icobench-client
src/Kami/IcoBench/Client.php
Client.processResponse
protected function processResponse(ResponseInterface $response) { if (200 !== $response->getStatusCode()) { throw new IcoBenchException( sprintf('IcoBench replied with non-success status (%s)', $response->getStatusCode()) ); } $data = json_decode($response->getBody(), true); if (isset($data['error'])) { throw new IcoBenchException($data['error']); } if (isset($data['message'])) { return $data['message']; } return $data; }
php
protected function processResponse(ResponseInterface $response) { if (200 !== $response->getStatusCode()) { throw new IcoBenchException( sprintf('IcoBench replied with non-success status (%s)', $response->getStatusCode()) ); } $data = json_decode($response->getBody(), true); if (isset($data['error'])) { throw new IcoBenchException($data['error']); } if (isset($data['message'])) { return $data['message']; } return $data; }
Get data from response @param ResponseInterface $response @return array | string @throws IcoBenchException
https://github.com/kamilabs/icobench-client/blob/b06def3015e00de0587b485648d2ff2828595186/src/Kami/IcoBench/Client.php#L124-L143
gregorybesson/PlaygroundFlow
src/Service/Event.php
Event.getTotal
public function getTotal($user, $type = '', $count = 'points') { $em = $this->serviceLocator->get('playgroundflow_doctrine_em'); if ($count == 'points') { $aggregate = 'SUM(e.points)'; } elseif ($count == 'count') { $aggregate = 'COUNT(e.id)'; } switch ($type) { case 'game': $filter = array(12); break; case 'user': $filter = array(1,4,5,6,7,8,9,10,11); break; case 'newsletter': $filter = array(2,3); break; case 'sponsorship': $filter = array(20); break; case 'social': $filter = array(13,14,15,16,17); break; case 'quizAnswer': $filter = array(30); break; case 'badgesBronze': $filter = array(100); break; case 'badgesSilver': $filter = array(101); break; case 'badgesGold': $filter = array(102); break; case 'anniversary': $filter = array(25); break; default: $filter = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,100,101,102,103); } $query = $em->createQuery('SELECT ' . $aggregate . ' FROM PlaygroundFlow\Entity\Event e WHERE e.user = :user AND e.actionId in (?1)'); $query->setParameter('user', $user); $query->setParameter(1, $filter); $total = $query->getSingleScalarResult(); return $total; }
php
public function getTotal($user, $type = '', $count = 'points') { $em = $this->serviceLocator->get('playgroundflow_doctrine_em'); if ($count == 'points') { $aggregate = 'SUM(e.points)'; } elseif ($count == 'count') { $aggregate = 'COUNT(e.id)'; } switch ($type) { case 'game': $filter = array(12); break; case 'user': $filter = array(1,4,5,6,7,8,9,10,11); break; case 'newsletter': $filter = array(2,3); break; case 'sponsorship': $filter = array(20); break; case 'social': $filter = array(13,14,15,16,17); break; case 'quizAnswer': $filter = array(30); break; case 'badgesBronze': $filter = array(100); break; case 'badgesSilver': $filter = array(101); break; case 'badgesGold': $filter = array(102); break; case 'anniversary': $filter = array(25); break; default: $filter = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,100,101,102,103); } $query = $em->createQuery('SELECT ' . $aggregate . ' FROM PlaygroundFlow\Entity\Event e WHERE e.user = :user AND e.actionId in (?1)'); $query->setParameter('user', $user); $query->setParameter(1, $filter); $total = $query->getSingleScalarResult(); return $total; }
This function return count of events or total points by event category for one user @param unknown_type $user @param unknown_type $type @param unknown_type $count
https://github.com/gregorybesson/PlaygroundFlow/blob/f97493f8527e425d46223ac7b5c41331ab8b3022/src/Service/Event.php#L54-L105
gregorybesson/PlaygroundFlow
src/Service/Event.php
Event.getEventMapper
public function getEventMapper() { if (null === $this->eventMapper) { $this->eventMapper = $this->serviceLocator->get('playgroundflow_event_mapper'); } return $this->eventMapper; }
php
public function getEventMapper() { if (null === $this->eventMapper) { $this->eventMapper = $this->serviceLocator->get('playgroundflow_event_mapper'); } return $this->eventMapper; }
getEventMapper @return EventMapperInterface
https://github.com/gregorybesson/PlaygroundFlow/blob/f97493f8527e425d46223ac7b5c41331ab8b3022/src/Service/Event.php#L117-L124
juliangut/doctrine-manager-builder
src/CouchDBBuilder.php
CouchDBBuilder.buildManager
protected function buildManager() { $config = new Configuration; $this->setUpGeneralConfigurations($config); $this->setUpSpecificConfigurations($config); $documentManager = DocumentManager::create($this->getOption('connection'), $config, $this->getEventManager()); if ($this->getRepositoryFactory() !== null) { $documentManager->setRepositoryFactory($this->getRepositoryFactory()); } if ($this->getDefaultRepositoryClass() !== null) { $documentManager->setDefaultRepositoryClassName($this->getDefaultRepositoryClass()); } return $documentManager; }
php
protected function buildManager() { $config = new Configuration; $this->setUpGeneralConfigurations($config); $this->setUpSpecificConfigurations($config); $documentManager = DocumentManager::create($this->getOption('connection'), $config, $this->getEventManager()); if ($this->getRepositoryFactory() !== null) { $documentManager->setRepositoryFactory($this->getRepositoryFactory()); } if ($this->getDefaultRepositoryClass() !== null) { $documentManager->setDefaultRepositoryClassName($this->getDefaultRepositoryClass()); } return $documentManager; }
{@inheritdoc} @throws \InvalidArgumentException @throws \RuntimeException @throws \UnexpectedValueException @return DocumentManager
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/CouchDBBuilder.php#L66-L84
juliangut/doctrine-manager-builder
src/CouchDBBuilder.php
CouchDBBuilder.setUpGeneralConfigurations
protected function setUpGeneralConfigurations(Configuration $config) { $this->setupAnnotationMetadata(); $config->setMetadataDriverImpl($this->getMetadataMappingDriver()); $config->setProxyDir($this->getProxiesPath()); $config->setProxyNamespace($this->getProxiesNamespace()); $config->setAutoGenerateProxyClasses($this->getProxiesAutoGeneration()); $config->setMetadataCacheImpl($this->getMetadataCacheDriver()); }
php
protected function setUpGeneralConfigurations(Configuration $config) { $this->setupAnnotationMetadata(); $config->setMetadataDriverImpl($this->getMetadataMappingDriver()); $config->setProxyDir($this->getProxiesPath()); $config->setProxyNamespace($this->getProxiesNamespace()); $config->setAutoGenerateProxyClasses($this->getProxiesAutoGeneration()); $config->setMetadataCacheImpl($this->getMetadataCacheDriver()); }
Set up general manager configurations. @param Configuration $config
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/CouchDBBuilder.php#L91-L101
juliangut/doctrine-manager-builder
src/CouchDBBuilder.php
CouchDBBuilder.setUpSpecificConfigurations
protected function setUpSpecificConfigurations(Configuration $config) { if ($this->getLuceneHandlerName() !== null) { $config->setLuceneHandlerName($this->getLuceneHandlerName()); } }
php
protected function setUpSpecificConfigurations(Configuration $config) { if ($this->getLuceneHandlerName() !== null) { $config->setLuceneHandlerName($this->getLuceneHandlerName()); } }
Set up manager specific configurations. @param Configuration $config
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/CouchDBBuilder.php#L108-L113
juliangut/doctrine-manager-builder
src/CouchDBBuilder.php
CouchDBBuilder.getXmlMappingDriver
protected function getXmlMappingDriver(array $paths, $extension = null) { $extension = $extension ?: XmlDriver::DEFAULT_FILE_EXTENSION; return new XmlDriver($paths, $extension); }
php
protected function getXmlMappingDriver(array $paths, $extension = null) { $extension = $extension ?: XmlDriver::DEFAULT_FILE_EXTENSION; return new XmlDriver($paths, $extension); }
{@inheritdoc}
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/CouchDBBuilder.php#L126-L131
juliangut/doctrine-manager-builder
src/CouchDBBuilder.php
CouchDBBuilder.getYamlMappingDriver
protected function getYamlMappingDriver(array $paths, $extension = null) { $extension = $extension ?: YamlDriver::DEFAULT_FILE_EXTENSION; return new YamlDriver($paths, $extension); }
php
protected function getYamlMappingDriver(array $paths, $extension = null) { $extension = $extension ?: YamlDriver::DEFAULT_FILE_EXTENSION; return new YamlDriver($paths, $extension); }
{@inheritdoc}
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/CouchDBBuilder.php#L136-L141
juliangut/doctrine-manager-builder
src/CouchDBBuilder.php
CouchDBBuilder.getConsoleCommands
public function getConsoleCommands() { $commands = [ // CouchDB new \Doctrine\CouchDB\Tools\Console\Command\ReplicationStartCommand, new \Doctrine\CouchDB\Tools\Console\Command\ReplicationCancelCommand, new \Doctrine\CouchDB\Tools\Console\Command\ViewCleanupCommand, new \Doctrine\CouchDB\Tools\Console\Command\CompactDatabaseCommand, new \Doctrine\CouchDB\Tools\Console\Command\CompactViewCommand, new \Doctrine\CouchDB\Tools\Console\Command\MigrationCommand, // ODM new \Doctrine\ODM\CouchDB\Tools\Console\Command\GenerateProxiesCommand, new \Doctrine\ODM\CouchDB\Tools\Console\Command\UpdateDesignDocCommand, ]; $helperSet = $this->getConsoleHelperSet(); $commandPrefix = (string) $this->getName(); $commands = array_map( function (Command $command) use ($helperSet, $commandPrefix) { if ($commandPrefix !== '') { $commandNames = array_map( function ($commandName) use ($commandPrefix) { $key = preg_match('/^couchdb:odm:/', $commandName) ? 'couchdb_odm' : 'couchdb'; return preg_replace( '/^couchdb:(odm:)?/', $key . ':' . $commandPrefix . ':', $commandName ); }, array_merge([$command->getName()], $command->getAliases()) ); $command->setName(array_shift($commandNames)); $command->setAliases($commandNames); } $command->setHelperSet($helperSet); return $command; }, $commands ); return $commands; }
php
public function getConsoleCommands() { $commands = [ // CouchDB new \Doctrine\CouchDB\Tools\Console\Command\ReplicationStartCommand, new \Doctrine\CouchDB\Tools\Console\Command\ReplicationCancelCommand, new \Doctrine\CouchDB\Tools\Console\Command\ViewCleanupCommand, new \Doctrine\CouchDB\Tools\Console\Command\CompactDatabaseCommand, new \Doctrine\CouchDB\Tools\Console\Command\CompactViewCommand, new \Doctrine\CouchDB\Tools\Console\Command\MigrationCommand, // ODM new \Doctrine\ODM\CouchDB\Tools\Console\Command\GenerateProxiesCommand, new \Doctrine\ODM\CouchDB\Tools\Console\Command\UpdateDesignDocCommand, ]; $helperSet = $this->getConsoleHelperSet(); $commandPrefix = (string) $this->getName(); $commands = array_map( function (Command $command) use ($helperSet, $commandPrefix) { if ($commandPrefix !== '') { $commandNames = array_map( function ($commandName) use ($commandPrefix) { $key = preg_match('/^couchdb:odm:/', $commandName) ? 'couchdb_odm' : 'couchdb'; return preg_replace( '/^couchdb:(odm:)?/', $key . ':' . $commandPrefix . ':', $commandName ); }, array_merge([$command->getName()], $command->getAliases()) ); $command->setName(array_shift($commandNames)); $command->setAliases($commandNames); } $command->setHelperSet($helperSet); return $command; }, $commands ); return $commands; }
{@inheritdoc} @throws \InvalidArgumentException @throws \RuntimeException @throws \Symfony\Component\Console\Exception\InvalidArgumentException @throws \Symfony\Component\Console\Exception\LogicException @throws \UnexpectedValueException @return Command[]
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/CouchDBBuilder.php#L189-L236
foothing/laravel-wrappr
src/Foothing/Wrappr/Routes/RouteRepository.php
RouteRepository.create
function create($route) { $route->pattern = $this->parser->trimPath($route->pattern); return parent::create($route); }
php
function create($route) { $route->pattern = $this->parser->trimPath($route->pattern); return parent::create($route); }
Override default implementation so that pattern is properly trimmed before being persisted. @param $route @return Route
https://github.com/foothing/laravel-wrappr/blob/4f6b0181679866b2e42c2e86bdbc1d9fb5d2390b/src/Foothing/Wrappr/Routes/RouteRepository.php#L24-L27
foothing/laravel-wrappr
src/Foothing/Wrappr/Routes/RouteRepository.php
RouteRepository.update
function update($route) { $route->pattern = $this->parser->trimPath($route->pattern); return parent::update($route); }
php
function update($route) { $route->pattern = $this->parser->trimPath($route->pattern); return parent::update($route); }
Override default implementation so that pattern is properly trimmed before being persisted. @param $route @return Route
https://github.com/foothing/laravel-wrappr/blob/4f6b0181679866b2e42c2e86bdbc1d9fb5d2390b/src/Foothing/Wrappr/Routes/RouteRepository.php#L36-L39
MovingImage24/VM6ApiClient
lib/Util/UnlockTokenGenerator.php
UnlockTokenGenerator.generate
public function generate($videoId, $ipRestriction = 0, $expiration = null) { $expiration = !is_null($expiration) ? $expiration : $this->defaultExpiration; $expirationTime = time() + $expiration; return $expirationTime. '_'.$ipRestriction. '_'.md5($this->signingKey. '_'.$videoId. '_'.$expirationTime. '_'.$ipRestriction); }
php
public function generate($videoId, $ipRestriction = 0, $expiration = null) { $expiration = !is_null($expiration) ? $expiration : $this->defaultExpiration; $expirationTime = time() + $expiration; return $expirationTime. '_'.$ipRestriction. '_'.md5($this->signingKey. '_'.$videoId. '_'.$expirationTime. '_'.$ipRestriction); }
@param int $videoId @param int $ipRestriction @param int|null $expiration @return string
https://github.com/MovingImage24/VM6ApiClient/blob/84e6510fa0fb71cfbb42ea9f23775f681c266fac/lib/Util/UnlockTokenGenerator.php#L41-L55
Phpillip/phpillip
src/Console/Model/Builder.php
Builder.clear
public function clear() { if ($this->files->exists($this->destination)) { $this->files->remove($this->destination); } $this->files->mkdir($this->destination); }
php
public function clear() { if ($this->files->exists($this->destination)) { $this->files->remove($this->destination); } $this->files->mkdir($this->destination); }
Clear destination folder
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Model/Builder.php#L53-L60
Phpillip/phpillip
src/Console/Model/Builder.php
Builder.build
public function build(Route $route, $name, array $parameters = []) { $url = $this->app['url_generator']->generate($name, $parameters, UrlGeneratorInterface::ABSOLUTE_URL); $request = Request::create($url, 'GET', array_merge(['_format' => $route->getFormat()], $parameters)); $response = $this->app->handle($request); $this->write( $this->getFilePath($route, $parameters), $response->getContent(), $request->getFormat($response->headers->get('Content-Type')), $route->getFileName() ); }
php
public function build(Route $route, $name, array $parameters = []) { $url = $this->app['url_generator']->generate($name, $parameters, UrlGeneratorInterface::ABSOLUTE_URL); $request = Request::create($url, 'GET', array_merge(['_format' => $route->getFormat()], $parameters)); $response = $this->app->handle($request); $this->write( $this->getFilePath($route, $parameters), $response->getContent(), $request->getFormat($response->headers->get('Content-Type')), $route->getFileName() ); }
Dump the given Route into a file @param Route $route @param string $name @param array $parameters
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Model/Builder.php#L69-L81
Phpillip/phpillip
src/Console/Model/Builder.php
Builder.write
public function write($path, $content, $extension = 'html', $filename = 'index') { $directory = sprintf('%s/%s', $this->destination, trim($path, '/')); $file = sprintf('%s.%s', $filename, $extension); if (!$this->files->exists($directory)) { $this->files->mkdir($directory); } $this->files->dumpFile(sprintf('%s/%s', $directory, $file), $content); }
php
public function write($path, $content, $extension = 'html', $filename = 'index') { $directory = sprintf('%s/%s', $this->destination, trim($path, '/')); $file = sprintf('%s.%s', $filename, $extension); if (!$this->files->exists($directory)) { $this->files->mkdir($directory); } $this->files->dumpFile(sprintf('%s/%s', $directory, $file), $content); }
Write a file @param string $path The directory to put the file in (in the current destination) @param string $content The file content @param string $filename The file name @param string $extension The file extension
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Model/Builder.php#L91-L101
Phpillip/phpillip
src/Console/Model/Builder.php
Builder.getFilePath
protected function getFilePath(Route $route, array $parameters = []) { $filepath = trim($route->getFilePath(), '/'); foreach ($route->getDefaults() as $key => $value) { if (isset($parameters[$key]) && $parameters[$key] == $value) { $filepath = rtrim(preg_replace(sprintf('#{%s}/?#', $key), null, $filepath), '/'); } } foreach ($parameters as $key => $value) { $filepath = str_replace(sprintf('{%s}', $key), (string) $value, $filepath); } return $filepath; }
php
protected function getFilePath(Route $route, array $parameters = []) { $filepath = trim($route->getFilePath(), '/'); foreach ($route->getDefaults() as $key => $value) { if (isset($parameters[$key]) && $parameters[$key] == $value) { $filepath = rtrim(preg_replace(sprintf('#{%s}/?#', $key), null, $filepath), '/'); } } foreach ($parameters as $key => $value) { $filepath = str_replace(sprintf('{%s}', $key), (string) $value, $filepath); } return $filepath; }
Get destination file path for the given route / parameters @param Route $route @param array $parameters @return string
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Model/Builder.php#L111-L126
nasumilu/geometry
src/Geometry.php
Geometry.fireOperationEvent
protected function fireOperationEvent(string $eventName, AbstractOpEvent $event) { $this->gf->performOperation($eventName, $event); }
php
protected function fireOperationEvent(string $eventName, AbstractOpEvent $event) { $this->gf->performOperation($eventName, $event); }
Dispatches an AbstractOpEvent for the <code>$eventName</code>. @param string $eventName @param AbstractOpEvent $event @deprecated @throws \Throwable The last error created by the event. @throws Operation\OperationError If no results are found for the operation.
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L91-L93
nasumilu/geometry
src/Geometry.php
Geometry.getBoundary
public function getBoundary(): Geometry { $event = new AccessorOpEvent($this); $this->fireOperationEvent(AccessorOpEvent::BOUNDARY_EVENT, $event); return $event->getResults(); }
php
public function getBoundary(): Geometry { $event = new AccessorOpEvent($this); $this->fireOperationEvent(AccessorOpEvent::BOUNDARY_EVENT, $event); return $event->getResults(); }
Gets the closure of the combinatorial bound of this Geometry object
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L125-L129
nasumilu/geometry
src/Geometry.php
Geometry.getEnvelope
public function getEnvelope(): Geometry { $event = new AccessorOpEvent($this); $this->fireOperationEvent(AccessorOpEvent::ENVELOPE_EVENT, $event); return $event->getResults(); }
php
public function getEnvelope(): Geometry { $event = new AccessorOpEvent($this); $this->fireOperationEvent(AccessorOpEvent::ENVELOPE_EVENT, $event); return $event->getResults(); }
Gets the minimum bounding box for this Geometry as a Geometry. The polygon is defined by the corner points of the bound box as [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINZX, MAXY), (MINX, MINY)]. The minimums for z and m may be added. @return Geometry
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L171-L175
nasumilu/geometry
src/Geometry.php
Geometry.asText
public function asText(bool $extended = false): string { $event = new OutputOpEvent($this, ['extended' => $extended]); $this->fireOperationEvent(OutputOpEvent::AS_TEXT_EVENT, $event); return $event->getResults(); }
php
public function asText(bool $extended = false): string { $event = new OutputOpEvent($this, ['extended' => $extended]); $this->fireOperationEvent(OutputOpEvent::AS_TEXT_EVENT, $event); return $event->getResults(); }
Exports this Geometry object to a specific Well-known Text Representation. @param bool $extended true will export to Extended Well-known Text
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L193-L197
nasumilu/geometry
src/Geometry.php
Geometry.asBinary
public function asBinary(bool $extended = false, string $endianness = 'NDR', bool $unpack = false): string { $event = new OutputOpEvent($this, [ 'extended' => $extended, 'endianness' => $endianness, 'unpack' => $unpack]); $this->fireOperationEvent(OutputOpEvent::AS_BINARY_EVENT, $event); return $event->getResults(); }
php
public function asBinary(bool $extended = false, string $endianness = 'NDR', bool $unpack = false): string { $event = new OutputOpEvent($this, [ 'extended' => $extended, 'endianness' => $endianness, 'unpack' => $unpack]); $this->fireOperationEvent(OutputOpEvent::AS_BINARY_EVENT, $event); return $event->getResults(); }
Exports this Geometry object to a specific Well-known Binary Representation. @param bool $extended true will export to Extended Well-known Binary @param string $endianness either 'NDR' little-endian or 'XDR' big-endian @param bool $unpack true will return hex_string; false binary string
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L206-L213
nasumilu/geometry
src/Geometry.php
Geometry.isSimple
public function isSimple(): bool { $event = new AccessorOpEvent($this); $this->fireOperationEvent(AccessorOpEvent::IS_SIMPLE_EVENT, $event); return $event->getResults(); }
php
public function isSimple(): bool { $event = new AccessorOpEvent($this); $this->fireOperationEvent(AccessorOpEvent::IS_SIMPLE_EVENT, $event); return $event->getResults(); }
Indicates whether this Geometry object has no anomalous geometric points, such as self intersection of self tangency. @return bool
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L229-L233
nasumilu/geometry
src/Geometry.php
Geometry.disjoint
public function disjoint(Geometry $other, bool $_3D = false): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other, '3D' => $_3D]); $this->fireOperationEvent(SpatialRelationshipOpEvent::DISJOINT_EVENT, $event); return $event->getResults(); }
php
public function disjoint(Geometry $other, bool $_3D = false): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other, '3D' => $_3D]); $this->fireOperationEvent(SpatialRelationshipOpEvent::DISJOINT_EVENT, $event); return $event->getResults(); }
Indicates whether the this Geometry is "spatially disjoint" from the <code>$other</code>. The optional <code>$_3D</code> parameter may be used to test if the objects are "spatially disjoint" on 3-dimensional objects. If this or the other Geometry object is <strong>not</strong> 3d than this method should evaluate whether the objects are 2d "spatially disjoint" @param \Nasumilu\Geometry\Geometry $other @param bool $_3D @return bool
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L248-L252
nasumilu/geometry
src/Geometry.php
Geometry.intersects
public function intersects(Geometry $other, bool $_3D = false): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other, '3D' => $_3D]); $this->fireOperationEvent(SpatialRelationshipOpEvent::INTERSECTS_EVENT, $event); return $event->getResults(); }
php
public function intersects(Geometry $other, bool $_3D = false): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other, '3D' => $_3D]); $this->fireOperationEvent(SpatialRelationshipOpEvent::INTERSECTS_EVENT, $event); return $event->getResults(); }
Indicates whether this Geometry is "spatially intersects" the <code> $other</code>. The optional <code>$_3D</code> parameter may be used to test if the objects "spatially intersects" on 3-dimensional objects. If this or the other Geometry objects is <strong>not</strong> 3d than this method should evaluate whether the objects are 2d "spatially intersects". @param \Nasumilu\Geometry\Geometry $other @param bool $_3D @return bool
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L267-L271
nasumilu/geometry
src/Geometry.php
Geometry.touches
public function touches(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::TOUCHES_EVENT, $event); return $event->getResults(); }
php
public function touches(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::TOUCHES_EVENT, $event); return $event->getResults(); }
Indicates whether this Geometry "spatially touches" the <code>$other</code>. @param \Nasumilu\Geometry\Geometry $other @return bool
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L279-L283
nasumilu/geometry
src/Geometry.php
Geometry.crosses
public function crosses(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::CROSSES_EVENT, $event); return $event->getResults(); }
php
public function crosses(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::CROSSES_EVENT, $event); return $event->getResults(); }
Indicates whether this Geometry "spatially crosses" the <code>$other</code>. @param \Nasumilu\Geometry\Geometry $other @return bool
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L291-L295
nasumilu/geometry
src/Geometry.php
Geometry.within
public function within(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::WITHIN_EVENT, $event); return $event->getResults(); }
php
public function within(Geometry $other): bool { $event = new SpatialRelationshipOpEvent($this, ['other' => $other]); $this->fireOperationEvent(SpatialRelationshipOpEvent::WITHIN_EVENT, $event); return $event->getResults(); }
Indicates whether this Geometry is "spatially within" the <code>$other</code>. @param \Nasumilu\Geometry\Geometry $other @return bool
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L303-L307