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_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
Deathnerd/php-wtforms
src/fields/core/DateTimeField.php
DateTimeField.processFormData
public function processFormData(array $valuelist) { if ($valuelist) { $date_str = implode(" ", $valuelist); try { $this->data = Carbon::createFromFormat($this->carbon_format, $date_str); } catch (Exception $e) { $this->data = null; throw new ValueError("Not a valid datetime value"); } } }
php
public function processFormData(array $valuelist) { if ($valuelist) { $date_str = implode(" ", $valuelist); try { $this->data = Carbon::createFromFormat($this->carbon_format, $date_str); } catch (Exception $e) { $this->data = null; throw new ValueError("Not a valid datetime value"); } } }
[ "public", "function", "processFormData", "(", "array", "$", "valuelist", ")", "{", "if", "(", "$", "valuelist", ")", "{", "$", "date_str", "=", "implode", "(", "\" \"", ",", "$", "valuelist", ")", ";", "try", "{", "$", "this", "->", "data", "=", "Car...
@param array $valuelist @throws ValueError
[ "@param", "array", "$valuelist" ]
train
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/fields/core/DateTimeField.php#L72-L83
diemuzi/mp3
src/Mp3/Controller/IndexController.php
IndexController.indexAction
public function indexAction() { $form = $this->formSearch; if ($this->getRequest() ->isPost() ) { $form->setData( $this->params() ->fromPost() ); if ($form->isValid()) { return $this->redirect() ->toRoute( 'mp3-search', [ 'name' => $this->params() ->fromPost('name') ] ); } } $service = $this->serviceIndex ->index( $this->params() ->fromRoute() ); return (new ViewModel()) ->setTemplate('mp3/mp3/search') ->setVariables( [ 'form' => $form, 'paginator' => $service['paginator'], 'path' => $service['path'], 'totalLength' => $service['totalLength'], 'totalFileSize' => $service['totalFileSize'], 'search' => $service['search'], 'dir' => $this->params() ->fromRoute('dir') ] ); }
php
public function indexAction() { $form = $this->formSearch; if ($this->getRequest() ->isPost() ) { $form->setData( $this->params() ->fromPost() ); if ($form->isValid()) { return $this->redirect() ->toRoute( 'mp3-search', [ 'name' => $this->params() ->fromPost('name') ] ); } } $service = $this->serviceIndex ->index( $this->params() ->fromRoute() ); return (new ViewModel()) ->setTemplate('mp3/mp3/search') ->setVariables( [ 'form' => $form, 'paginator' => $service['paginator'], 'path' => $service['path'], 'totalLength' => $service['totalLength'], 'totalFileSize' => $service['totalFileSize'], 'search' => $service['search'], 'dir' => $this->params() ->fromRoute('dir') ] ); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "form", "=", "$", "this", "->", "formSearch", ";", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isPost", "(", ")", ")", "{", "$", "form", "->", "setData", "(", "$", "this", ...
Index @return ViewModel
[ "Index" ]
train
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Controller/IndexController.php#L58-L102
diemuzi/mp3
src/Mp3/Controller/IndexController.php
IndexController.downloadfolderAction
public function downloadfolderAction() { $this->serviceIndex ->downloadFolder( [ 'dir' => $this->params() ->fromRoute('dir'), 'format' => $this->params() ->fromRoute('format') ] ); }
php
public function downloadfolderAction() { $this->serviceIndex ->downloadFolder( [ 'dir' => $this->params() ->fromRoute('dir'), 'format' => $this->params() ->fromRoute('format') ] ); }
[ "public", "function", "downloadfolderAction", "(", ")", "{", "$", "this", "->", "serviceIndex", "->", "downloadFolder", "(", "[", "'dir'", "=>", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'dir'", ")", ",", "'format'", "=>", "$", "thi...
Download Folder
[ "Download", "Folder" ]
train
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Controller/IndexController.php#L131-L142
diemuzi/mp3
src/Mp3/Service/Search.php
Search.find
public function find($string) { try { $array = []; $totalLength = null; $totalFileSize = null; if ($string != null) { $searchFile = $this->getSearchFile(); clearstatcache(); if (is_file($searchFile)) { /** * Error: Search File is Empty */ if (filesize($searchFile) <= '0') { $errorString = 'The search file is currently empty. '; $errorString .= 'Use the Import Tool to populate the Search Results'; $translateError = $this->translate->translate( $errorString, 'mp3' ); $location = $this->serverUrl ->get('url') ->__invoke( 'mp3-search', [ 'flash' => $translateError ] ); header('Location: ' . $location); exit; } $handle = fopen( $searchFile, 'r' ); $contents = fread( $handle, filesize($searchFile) ); $unserialize = preg_grep( '/' . $string . '/i', unserialize($contents) ); fclose($handle); if (count($unserialize) > '0') { foreach ($unserialize as $path) { $this->memoryUsage(); /** * Set Paths */ $basePath = $path; $fullPath = $this->getSearchPath() . '/' . $path; clearstatcache(); if (is_dir($fullPath)) { $array[] = [ 'name' => $path, 'basePath' => $basePath, 'base64' => base64_encode( ltrim( $basePath, '/' ) ), 'fullPath' => $fullPath, 'type' => 'dir' ]; } if (is_file($fullPath)) { $id3 = $this->getId3($fullPath); $title = !empty($id3['comments_html']['title']) ? implode( '<br>', $id3['comments_html']['title'] ) : basename($fullPath); $bitRate = !empty($id3['audio']['bitrate']) ? round($id3['audio']['bitrate'] / '1000') : '-'; $length = !empty($id3['playtime_string']) ? $id3['playtime_string'] : '-'; $fileSize = !empty($id3['filesize']) ? $id3['filesize'] : '-'; $totalLength += $this->convertTime($length); $totalFileSize += $fileSize; $array[] = [ 'name' => $path, 'basePath' => $basePath, 'base64' => base64_encode( ltrim( $basePath, '/' ) ), 'fullPath' => $fullPath, 'type' => 'file', 'id3' => [ 'title' => $title, 'bitRate' => $bitRate, 'length' => $length, 'fileSize' => $fileSize ] ]; } } } } else { throw new \Exception( $searchFile . ' ' . $this->translate->translate( 'was not found', 'mp3' ) ); } } $paginator = new Paginator(new ArrayAdapter($array)); $paginator->setDefaultItemCountPerPage( (count($array) > '0') ? count($array) : '1' ); if ($totalLength > '0') { $totalLength = sprintf( "%d:%02d", ($totalLength / '60'), $totalLength % '60' ); } return [ 'paginator' => $paginator, 'totalLength' => $totalLength, 'totalFileSize' => $totalFileSize, 'search' => (is_file($this->getSearchFile())) ]; } catch (\Exception $e) { throw $e; } }
php
public function find($string) { try { $array = []; $totalLength = null; $totalFileSize = null; if ($string != null) { $searchFile = $this->getSearchFile(); clearstatcache(); if (is_file($searchFile)) { /** * Error: Search File is Empty */ if (filesize($searchFile) <= '0') { $errorString = 'The search file is currently empty. '; $errorString .= 'Use the Import Tool to populate the Search Results'; $translateError = $this->translate->translate( $errorString, 'mp3' ); $location = $this->serverUrl ->get('url') ->__invoke( 'mp3-search', [ 'flash' => $translateError ] ); header('Location: ' . $location); exit; } $handle = fopen( $searchFile, 'r' ); $contents = fread( $handle, filesize($searchFile) ); $unserialize = preg_grep( '/' . $string . '/i', unserialize($contents) ); fclose($handle); if (count($unserialize) > '0') { foreach ($unserialize as $path) { $this->memoryUsage(); /** * Set Paths */ $basePath = $path; $fullPath = $this->getSearchPath() . '/' . $path; clearstatcache(); if (is_dir($fullPath)) { $array[] = [ 'name' => $path, 'basePath' => $basePath, 'base64' => base64_encode( ltrim( $basePath, '/' ) ), 'fullPath' => $fullPath, 'type' => 'dir' ]; } if (is_file($fullPath)) { $id3 = $this->getId3($fullPath); $title = !empty($id3['comments_html']['title']) ? implode( '<br>', $id3['comments_html']['title'] ) : basename($fullPath); $bitRate = !empty($id3['audio']['bitrate']) ? round($id3['audio']['bitrate'] / '1000') : '-'; $length = !empty($id3['playtime_string']) ? $id3['playtime_string'] : '-'; $fileSize = !empty($id3['filesize']) ? $id3['filesize'] : '-'; $totalLength += $this->convertTime($length); $totalFileSize += $fileSize; $array[] = [ 'name' => $path, 'basePath' => $basePath, 'base64' => base64_encode( ltrim( $basePath, '/' ) ), 'fullPath' => $fullPath, 'type' => 'file', 'id3' => [ 'title' => $title, 'bitRate' => $bitRate, 'length' => $length, 'fileSize' => $fileSize ] ]; } } } } else { throw new \Exception( $searchFile . ' ' . $this->translate->translate( 'was not found', 'mp3' ) ); } } $paginator = new Paginator(new ArrayAdapter($array)); $paginator->setDefaultItemCountPerPage( (count($array) > '0') ? count($array) : '1' ); if ($totalLength > '0') { $totalLength = sprintf( "%d:%02d", ($totalLength / '60'), $totalLength % '60' ); } return [ 'paginator' => $paginator, 'totalLength' => $totalLength, 'totalFileSize' => $totalFileSize, 'search' => (is_file($this->getSearchFile())) ]; } catch (\Exception $e) { throw $e; } }
[ "public", "function", "find", "(", "$", "string", ")", "{", "try", "{", "$", "array", "=", "[", "]", ";", "$", "totalLength", "=", "null", ";", "$", "totalFileSize", "=", "null", ";", "if", "(", "$", "string", "!=", "null", ")", "{", "$", "search...
Search @param string $string @return array|Paginator @throws \Exception
[ "Search" ]
train
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/Search.php#L31-L199
diemuzi/mp3
src/Mp3/Service/Search.php
Search.import
public function import() { try { ini_set( 'max_execution_time', '0' ); clearstatcache(); if (is_dir($this->getSearchPath())) { $searchPath = new \RecursiveDirectoryIterator( $this->getSearchPath(), \FilesystemIterator::FOLLOW_SYMLINKS ); $searchFile = $this->getSearchFile(); clearstatcache(); if (!touch($searchFile)) { throw new \Exception( $searchFile . ' ' . $this->translate->translate( 'could not be created', 'mp3' ) ); } if (is_file($searchFile)) { $handle = fopen( $searchFile, 'w' ); if (is_writable($searchFile)) { if (!$handle) { throw new \Exception( $this->translate->translate('Cannot Open File') . ': ' . $searchFile ); } } else { throw new \Exception( $this->translate->translate('File Is Not Writable') . ': ' . $searchFile ); } $array = []; /** * @var \RecursiveDirectoryIterator $current */ foreach (new \RecursiveIteratorIterator($searchPath) as $current) { $basePathName = basename($current->getPathname()); if ($basePathName != '..') { $fileExtension = substr( strrchr( $basePathName, '.' ), 1 ); clearstatcache(); /** * Directory */ if (is_dir($current->getPathname())) { $directoryName = substr( $current->getPathName(), 0, -2 ); $replaceDirectory = str_replace( $this->getSearchPath(), '', $directoryName ); $directoryTrim = ltrim( $replaceDirectory, '/' ); $array[] = $directoryTrim; } /** * File */ if (is_file($current->getPathname()) && in_array( '.' . $fileExtension, $this->getExtensions() ) ) { $fileName = $current->getPathname(); $replaceFileName = str_replace( $this->getSearchPath(), '', $fileName ); $fileNameTrim = ltrim( $replaceFileName, '/' ); $array[] = $fileNameTrim; } } } $result = array_unique($array); sort($result); fwrite( $handle, serialize($result) ); fclose($handle); } else { throw new \Exception( $searchFile . ' ' . $this->translate->translate( 'was not found', 'mp3' ) ); } } else { throw new \Exception( $this->getBaseDir() . ' ' . $this->translate->translate( 'was not found', 'mp3' ) ); } } catch (\Exception $e) { echo $e->getMessage(); throw $e; } }
php
public function import() { try { ini_set( 'max_execution_time', '0' ); clearstatcache(); if (is_dir($this->getSearchPath())) { $searchPath = new \RecursiveDirectoryIterator( $this->getSearchPath(), \FilesystemIterator::FOLLOW_SYMLINKS ); $searchFile = $this->getSearchFile(); clearstatcache(); if (!touch($searchFile)) { throw new \Exception( $searchFile . ' ' . $this->translate->translate( 'could not be created', 'mp3' ) ); } if (is_file($searchFile)) { $handle = fopen( $searchFile, 'w' ); if (is_writable($searchFile)) { if (!$handle) { throw new \Exception( $this->translate->translate('Cannot Open File') . ': ' . $searchFile ); } } else { throw new \Exception( $this->translate->translate('File Is Not Writable') . ': ' . $searchFile ); } $array = []; /** * @var \RecursiveDirectoryIterator $current */ foreach (new \RecursiveIteratorIterator($searchPath) as $current) { $basePathName = basename($current->getPathname()); if ($basePathName != '..') { $fileExtension = substr( strrchr( $basePathName, '.' ), 1 ); clearstatcache(); /** * Directory */ if (is_dir($current->getPathname())) { $directoryName = substr( $current->getPathName(), 0, -2 ); $replaceDirectory = str_replace( $this->getSearchPath(), '', $directoryName ); $directoryTrim = ltrim( $replaceDirectory, '/' ); $array[] = $directoryTrim; } /** * File */ if (is_file($current->getPathname()) && in_array( '.' . $fileExtension, $this->getExtensions() ) ) { $fileName = $current->getPathname(); $replaceFileName = str_replace( $this->getSearchPath(), '', $fileName ); $fileNameTrim = ltrim( $replaceFileName, '/' ); $array[] = $fileNameTrim; } } } $result = array_unique($array); sort($result); fwrite( $handle, serialize($result) ); fclose($handle); } else { throw new \Exception( $searchFile . ' ' . $this->translate->translate( 'was not found', 'mp3' ) ); } } else { throw new \Exception( $this->getBaseDir() . ' ' . $this->translate->translate( 'was not found', 'mp3' ) ); } } catch (\Exception $e) { echo $e->getMessage(); throw $e; } }
[ "public", "function", "import", "(", ")", "{", "try", "{", "ini_set", "(", "'max_execution_time'", ",", "'0'", ")", ";", "clearstatcache", "(", ")", ";", "if", "(", "is_dir", "(", "$", "this", "->", "getSearchPath", "(", ")", ")", ")", "{", "$", "sea...
Import Search Results @throws \Exception
[ "Import", "Search", "Results" ]
train
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/Search.php#L206-L352
diemuzi/mp3
src/Mp3/Service/Search.php
Search.help
public function help($help) { $green = "\033[49;32m"; $end = "\033[0m"; $array['import'] = [ 'Import Search Results', $green . 'mp3 import' . $end, '', 'Option Description Required Default Available Options', '--confirm= Display Confirmation No Yes Yes, No' ]; $implode = implode( "\n", $array[$help] ); return $implode . "\n"; }
php
public function help($help) { $green = "\033[49;32m"; $end = "\033[0m"; $array['import'] = [ 'Import Search Results', $green . 'mp3 import' . $end, '', 'Option Description Required Default Available Options', '--confirm= Display Confirmation No Yes Yes, No' ]; $implode = implode( "\n", $array[$help] ); return $implode . "\n"; }
[ "public", "function", "help", "(", "$", "help", ")", "{", "$", "green", "=", "\"\\033[49;32m\"", ";", "$", "end", "=", "\"\\033[0m\"", ";", "$", "array", "[", "'import'", "]", "=", "[", "'Import Search Results'", ",", "$", "green", ".", "'mp3 import'", "...
Parse Help @param string $help @return string
[ "Parse", "Help" ]
train
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/Search.php#L361-L380
diemuzi/mp3
src/Mp3/Service/Search.php
Search.memoryUsage
public function memoryUsage() { if ($this->getMemoryLimit()) { $remaining = (memory_get_peak_usage() - memory_get_usage()); $left = (memory_get_peak_usage() + $remaining); if ($left < memory_get_peak_usage(true)) { $translateError = $this->translate->translate( 'PHP Ran Out of Memory. Please Try Again', 'mp3' ); $location = $this->serverUrl ->get('url') ->__invoke( 'mp3-search', [ 'flash' => $translateError ] ); header('Location: ' . $location); exit; } } }
php
public function memoryUsage() { if ($this->getMemoryLimit()) { $remaining = (memory_get_peak_usage() - memory_get_usage()); $left = (memory_get_peak_usage() + $remaining); if ($left < memory_get_peak_usage(true)) { $translateError = $this->translate->translate( 'PHP Ran Out of Memory. Please Try Again', 'mp3' ); $location = $this->serverUrl ->get('url') ->__invoke( 'mp3-search', [ 'flash' => $translateError ] ); header('Location: ' . $location); exit; } } }
[ "public", "function", "memoryUsage", "(", ")", "{", "if", "(", "$", "this", "->", "getMemoryLimit", "(", ")", ")", "{", "$", "remaining", "=", "(", "memory_get_peak_usage", "(", ")", "-", "memory_get_usage", "(", ")", ")", ";", "$", "left", "=", "(", ...
Determines PHP's Memory Usage Overflow Usage: Set memoryLimit in mp3.global.php to true in order to use this feature @return void
[ "Determines", "PHP", "s", "Memory", "Usage", "Overflow" ]
train
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/Search.php#L389-L416
diemuzi/mp3
Module.php
Module.onBootstrap
public function onBootstrap(MvcEvent $mvcEvent) { $eventManager = $mvcEvent->getApplication() ->getEventManager(); /** * Disable Layout on Error */ $eventManager->attach( MvcEvent::EVENT_DISPATCH_ERROR, function ($mvcEvent) { /** * @var MvcEvent $mvcEvent */ $mvcEvent->getResult() ->setTerminal(true); } ); $sharedEvents = $eventManager ->getSharedManager(); /** * Disable Layout in ViewModel */ $sharedEvents->attach( 'Zend\Mvc\Controller\AbstractActionController', 'dispatch', function ($mvcEvent) { /** * @var MvcEvent $mvcEvent */ $result = $mvcEvent->getResult(); if ($result instanceof ViewModel) { $result->setTerminal(true); } } ); $mvcEvent->getApplication() ->getEventManager() ->getSharedManager() ->attach( 'Mp3\Controller\SearchController', 'Mp3Help', function ($event) use ( $mvcEvent ) { /** * @var MvcEvent $event */ echo $mvcEvent->getApplication() ->getServiceManager() ->get('Mp3\Service\Search') ->help($event->getParam('help')); } ); }
php
public function onBootstrap(MvcEvent $mvcEvent) { $eventManager = $mvcEvent->getApplication() ->getEventManager(); /** * Disable Layout on Error */ $eventManager->attach( MvcEvent::EVENT_DISPATCH_ERROR, function ($mvcEvent) { /** * @var MvcEvent $mvcEvent */ $mvcEvent->getResult() ->setTerminal(true); } ); $sharedEvents = $eventManager ->getSharedManager(); /** * Disable Layout in ViewModel */ $sharedEvents->attach( 'Zend\Mvc\Controller\AbstractActionController', 'dispatch', function ($mvcEvent) { /** * @var MvcEvent $mvcEvent */ $result = $mvcEvent->getResult(); if ($result instanceof ViewModel) { $result->setTerminal(true); } } ); $mvcEvent->getApplication() ->getEventManager() ->getSharedManager() ->attach( 'Mp3\Controller\SearchController', 'Mp3Help', function ($event) use ( $mvcEvent ) { /** * @var MvcEvent $event */ echo $mvcEvent->getApplication() ->getServiceManager() ->get('Mp3\Service\Search') ->help($event->getParam('help')); } ); }
[ "public", "function", "onBootstrap", "(", "MvcEvent", "$", "mvcEvent", ")", "{", "$", "eventManager", "=", "$", "mvcEvent", "->", "getApplication", "(", ")", "->", "getEventManager", "(", ")", ";", "/**\n * Disable Layout on Error\n */", "$", "eventM...
Boostrap @param MvcEvent $mvcEvent
[ "Boostrap" ]
train
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/Module.php#L37-L96
mcustiel/php-simple-config
src/Util/RawConfigToArrayConverter.php
RawConfigToArrayConverter.convert
public function convert(array $rawConfig) { $return = []; foreach ($rawConfig as $key => $value) { $return[$key] = $this->getConfigValue($value); } return $return; }
php
public function convert(array $rawConfig) { $return = []; foreach ($rawConfig as $key => $value) { $return[$key] = $this->getConfigValue($value); } return $return; }
[ "public", "function", "convert", "(", "array", "$", "rawConfig", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "rawConfig", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "return", "[", "$", "key", "]", "=", "$", "this",...
Converts the rawConfig and returns a pure PHP array. @param array $rawConfig The config from the Config object @return array A pure PHP array
[ "Converts", "the", "rawConfig", "and", "returns", "a", "pure", "PHP", "array", "." ]
train
https://github.com/mcustiel/php-simple-config/blob/da1b56cb9c3d4582a00da9d2380295a79f318ebb/src/Util/RawConfigToArrayConverter.php#L37-L45
swoft-cloud/swoft-console
src/Bean/Collector/CommandCollector.php
CommandCollector.collect
public static function collect( string $className, $objectAnnotation = null, string $propertyName = '', string $methodName = '', $propertyValue = null ) { if ($objectAnnotation instanceof Command) { self::collectCommand($className, $objectAnnotation); } elseif ($objectAnnotation instanceof Mapping) { self::collectMapping($className, $objectAnnotation, $methodName); } elseif ($objectAnnotation === null && isset(self::$commandMapping[$className])) { self::collectWithoutAnnotation($className, $methodName); } }
php
public static function collect( string $className, $objectAnnotation = null, string $propertyName = '', string $methodName = '', $propertyValue = null ) { if ($objectAnnotation instanceof Command) { self::collectCommand($className, $objectAnnotation); } elseif ($objectAnnotation instanceof Mapping) { self::collectMapping($className, $objectAnnotation, $methodName); } elseif ($objectAnnotation === null && isset(self::$commandMapping[$className])) { self::collectWithoutAnnotation($className, $methodName); } }
[ "public", "static", "function", "collect", "(", "string", "$", "className", ",", "$", "objectAnnotation", "=", "null", ",", "string", "$", "propertyName", "=", "''", ",", "string", "$", "methodName", "=", "''", ",", "$", "propertyValue", "=", "null", ")", ...
collect @param string $className @param mixed $objectAnnotation @param string $propertyName @param string $methodName @param null $propertyValue
[ "collect" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Bean/Collector/CommandCollector.php#L28-L42
swoft-cloud/swoft-console
src/Bean/Collector/CommandCollector.php
CommandCollector.collectCommand
private static function collectCommand(string $className, Command $objectAnnotation) { $commandName = $objectAnnotation->getName(); $coroutine = $objectAnnotation->isCoroutine(); $server = $objectAnnotation->isServer(); self::$commandMapping[$className]['name'] = $commandName; self::$commandMapping[$className]['enabled'] = $objectAnnotation->isEnabled(); self::$commandMapping[$className]['coroutine'] = $coroutine; self::$commandMapping[$className]['server'] = $server; }
php
private static function collectCommand(string $className, Command $objectAnnotation) { $commandName = $objectAnnotation->getName(); $coroutine = $objectAnnotation->isCoroutine(); $server = $objectAnnotation->isServer(); self::$commandMapping[$className]['name'] = $commandName; self::$commandMapping[$className]['enabled'] = $objectAnnotation->isEnabled(); self::$commandMapping[$className]['coroutine'] = $coroutine; self::$commandMapping[$className]['server'] = $server; }
[ "private", "static", "function", "collectCommand", "(", "string", "$", "className", ",", "Command", "$", "objectAnnotation", ")", "{", "$", "commandName", "=", "$", "objectAnnotation", "->", "getName", "(", ")", ";", "$", "coroutine", "=", "$", "objectAnnotati...
collect command @param string $className @param Command $objectAnnotation
[ "collect", "command" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Bean/Collector/CommandCollector.php#L50-L60
swoft-cloud/swoft-console
src/Bean/Collector/CommandCollector.php
CommandCollector.collectMapping
private static function collectMapping(string $className, Mapping $objectAnnotation, string $methodName) { $mapped = $objectAnnotation->getName(); self::$commandMapping[$className]['routes'][] = [ 'mappedName' => $mapped, 'methodName' => $methodName, ]; }
php
private static function collectMapping(string $className, Mapping $objectAnnotation, string $methodName) { $mapped = $objectAnnotation->getName(); self::$commandMapping[$className]['routes'][] = [ 'mappedName' => $mapped, 'methodName' => $methodName, ]; }
[ "private", "static", "function", "collectMapping", "(", "string", "$", "className", ",", "Mapping", "$", "objectAnnotation", ",", "string", "$", "methodName", ")", "{", "$", "mapped", "=", "$", "objectAnnotation", "->", "getName", "(", ")", ";", "self", "::"...
collect mapping @param string $className @param Mapping $objectAnnotation @param string $methodName
[ "collect", "mapping" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Bean/Collector/CommandCollector.php#L69-L77
opus-online/yii2-payment
lib/helpers/StringHelper.php
StringHelper.mbStringPad
public static function mbStringPad($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT, $encoding = NULL) { if (!$encoding) { $diff = strlen($input) - mb_strlen($input); } else { $diff = strlen($input) - mb_strlen($input, $encoding); } return str_pad($input, $pad_length + $diff, $pad_string, $pad_type); }
php
public static function mbStringPad($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT, $encoding = NULL) { if (!$encoding) { $diff = strlen($input) - mb_strlen($input); } else { $diff = strlen($input) - mb_strlen($input, $encoding); } return str_pad($input, $pad_length + $diff, $pad_string, $pad_type); }
[ "public", "static", "function", "mbStringPad", "(", "$", "input", ",", "$", "pad_length", ",", "$", "pad_string", "=", "' '", ",", "$", "pad_type", "=", "STR_PAD_RIGHT", ",", "$", "encoding", "=", "NULL", ")", "{", "if", "(", "!", "$", "encoding", ")",...
Multi-byte str-pad @param string $input @param integer $pad_length @param string $pad_string @param int $pad_type @param null $encoding @return string
[ "Multi", "-", "byte", "str", "-", "pad" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/helpers/StringHelper.php#L27-L39
joomla-framework/twitter-api
src/Search.php
Search.search
public function search($query, $callback = null, $geocode = null, $lang = null, $locale = null, $resultType = null, $count = 15, $until = null, $sinceId = 0, $maxId = 0, $entities = null ) { // Check the rate limit for remaining hits $this->checkRateLimit('search', 'tweets'); // Set the API path $path = '/search/tweets.json'; // Set query parameter. $data['q'] = rawurlencode($query); // Check if callback is specified. if ($callback) { $data['callback'] = $callback; } // Check if geocode is specified. if ($geocode) { $data['geocode'] = $geocode; } // Check if lang is specified. if ($lang) { $data['lang'] = $lang; } // Check if locale is specified. if ($locale) { $data['locale'] = $locale; } // Check if result_type is specified. if ($resultType) { $data['result_type'] = $resultType; } // Check if count is specified. if ($count != 15) { $data['count'] = $count; } // Check if until is specified. if ($until) { $data['until'] = $until; } // Check if since_id is specified. if ($sinceId > 0) { $data['since_id'] = $sinceId; } // Check if max_id is specified. if ($maxId > 0) { $data['max_id'] = $maxId; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
php
public function search($query, $callback = null, $geocode = null, $lang = null, $locale = null, $resultType = null, $count = 15, $until = null, $sinceId = 0, $maxId = 0, $entities = null ) { // Check the rate limit for remaining hits $this->checkRateLimit('search', 'tweets'); // Set the API path $path = '/search/tweets.json'; // Set query parameter. $data['q'] = rawurlencode($query); // Check if callback is specified. if ($callback) { $data['callback'] = $callback; } // Check if geocode is specified. if ($geocode) { $data['geocode'] = $geocode; } // Check if lang is specified. if ($lang) { $data['lang'] = $lang; } // Check if locale is specified. if ($locale) { $data['locale'] = $locale; } // Check if result_type is specified. if ($resultType) { $data['result_type'] = $resultType; } // Check if count is specified. if ($count != 15) { $data['count'] = $count; } // Check if until is specified. if ($until) { $data['until'] = $until; } // Check if since_id is specified. if ($sinceId > 0) { $data['since_id'] = $sinceId; } // Check if max_id is specified. if ($maxId > 0) { $data['max_id'] = $maxId; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
[ "public", "function", "search", "(", "$", "query", ",", "$", "callback", "=", "null", ",", "$", "geocode", "=", "null", ",", "$", "lang", "=", "null", ",", "$", "locale", "=", "null", ",", "$", "resultType", "=", "null", ",", "$", "count", "=", "...
Method to get tweets that match a specified query. @param string $query Search query. Should be URL encoded. Queries will be limited by complexity. @param string $callback If supplied, the response will use the JSONP format with a callback of the given name @param string $geocode Returns tweets by users located within a given radius of the given latitude/longitude. The parameter value is specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). @param string $lang Restricts tweets to the given language, given by an ISO 639-1 code. @param string $locale Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific clients and the default should work in the majority of cases. @param string $resultType Specifies what type of search results you would prefer to receive. The current default is "mixed." @param integer $count The number of tweets to return per page, up to a maximum of 100. Defaults to 15. @param string $until Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD. @param integer $sinceId Returns results with an ID greater than (that is, more recent than) the specified ID. @param integer $maxId Returns results with an ID less than (that is, older than) or equal to the specified ID. @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discrete structure, including: urls, media and hashtags. @return array The decoded JSON response @since 1.0
[ "Method", "to", "get", "tweets", "that", "match", "a", "specified", "query", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Search.php#L42-L117
CampaignChain/core
EntityService/UserService.php
UserService.downloadGravatarImage
public function downloadGravatarImage($email) { try { $gravatarUrl = $this->generateGravatarUrl($email); $response = $this->httpClient->get($gravatarUrl); $avatarPath = $this->generateAvatarPath($response->getHeader('Content-Type')); $this->fileUploadService->storeImage($avatarPath, $response->getBody()); return $avatarPath; } catch (\Exception $e) { // If Guzzle throws an error, then most likely because you're // developing CampaignChain offline. Hence, don't worry about the // error. } }
php
public function downloadGravatarImage($email) { try { $gravatarUrl = $this->generateGravatarUrl($email); $response = $this->httpClient->get($gravatarUrl); $avatarPath = $this->generateAvatarPath($response->getHeader('Content-Type')); $this->fileUploadService->storeImage($avatarPath, $response->getBody()); return $avatarPath; } catch (\Exception $e) { // If Guzzle throws an error, then most likely because you're // developing CampaignChain offline. Hence, don't worry about the // error. } }
[ "public", "function", "downloadGravatarImage", "(", "$", "email", ")", "{", "try", "{", "$", "gravatarUrl", "=", "$", "this", "->", "generateGravatarUrl", "(", "$", "email", ")", ";", "$", "response", "=", "$", "this", "->", "httpClient", "->", "get", "(...
Download Gravatar image and store it to the user upload directory. @param $email @return string path to downloaded image, relative to the storage directory
[ "Download", "Gravatar", "image", "and", "store", "it", "to", "the", "user", "upload", "directory", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/UserService.php#L94-L110
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.processElement
public function processElement(\DOMElement $element, ContextInterface $context) { // Create a property $propertyContext = $this->processProperty($element, $context); // Process the element in case it's an anonymous thing with no children if (!$element->childNodes->length) { $this->processChild($element, $context); } return $propertyContext; }
php
public function processElement(\DOMElement $element, ContextInterface $context) { // Create a property $propertyContext = $this->processProperty($element, $context); // Process the element in case it's an anonymous thing with no children if (!$element->childNodes->length) { $this->processChild($element, $context); } return $propertyContext; }
[ "public", "function", "processElement", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "// Create a property", "$", "propertyContext", "=", "$", "this", "->", "processProperty", "(", "$", "element", ",", "$", "context...
Process a DOM element @param \DOMElement $element DOM element @param ContextInterface $context Inherited Context @return ContextInterface Local context for this element
[ "Process", "a", "DOM", "element" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L69-L80
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.processProperty
protected function processProperty(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('itemprop') && !($context->getParentThing() instanceof RootThing)) { $itemprops = trim($element->getAttribute('itemprop')); $itemprops = strlen($itemprops) ? preg_split('/\s+/', $itemprops) : []; $context = $this->processProperties($itemprops, $element, $context); } return $context; }
php
protected function processProperty(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('itemprop') && !($context->getParentThing() instanceof RootThing)) { $itemprops = trim($element->getAttribute('itemprop')); $itemprops = strlen($itemprops) ? preg_split('/\s+/', $itemprops) : []; $context = $this->processProperties($itemprops, $element, $context); } return $context; }
[ "protected", "function", "processProperty", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "if", "(", "$", "element", "->", "hasAttribute", "(", "'itemprop'", ")", "&&", "!", "(", "$", "context", "->", "getParentT...
Create a property @param \DOMElement $element DOM element @param ContextInterface $context Inherited Context @return ContextInterface Local context for this element
[ "Create", "a", "property" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L89-L98
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.processProperties
protected function processProperties(array $itemprops, \DOMElement $element, ContextInterface $context) { foreach ($itemprops as $index => $itemprop) { $context = $this->processPropertyPrefixName( null, $itemprop, $element, $context, $index == (count($itemprops) - 1) ); } return $context; }
php
protected function processProperties(array $itemprops, \DOMElement $element, ContextInterface $context) { foreach ($itemprops as $index => $itemprop) { $context = $this->processPropertyPrefixName( null, $itemprop, $element, $context, $index == (count($itemprops) - 1) ); } return $context; }
[ "protected", "function", "processProperties", "(", "array", "$", "itemprops", ",", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "foreach", "(", "$", "itemprops", "as", "$", "index", "=>", "$", "itemprop", ")", "{", ...
Process properties @param array $itemprops Properties @param \DOMElement $element DOM element @param ContextInterface $context Inherited Context @return ContextInterface Local context for this element
[ "Process", "properties" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L108-L121
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.processChild
protected function processChild(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('itemscope') && empty($element->getAttribute('itemprop'))) { $context = $this->createAndAddChild($element, $context); } return $context; }
php
protected function processChild(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('itemscope') && empty($element->getAttribute('itemprop'))) { $context = $this->createAndAddChild($element, $context); } return $context; }
[ "protected", "function", "processChild", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "if", "(", "$", "element", "->", "hasAttribute", "(", "'itemscope'", ")", "&&", "empty", "(", "$", "element", "->", "getAttri...
Create a nested child @param \DOMElement $element DOM element @param ContextInterface $context Context @return ContextInterface Context for children
[ "Create", "a", "nested", "child" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L130-L137
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.createAndAddChild
protected function createAndAddChild(\DOMElement $element, ContextInterface $context) { $thing = $this->getThing( trim($element->getAttribute('itemtype')) ?: null, trim($element->getAttribute('itemid')) ?: null, $context ); // Process item references $this->processItemReferences($element, $context, $thing); // Add the new thing as a child to the current context // and set the thing as parent thing for nested iterations return $context->addChild($thing)->setParentThing($thing); }
php
protected function createAndAddChild(\DOMElement $element, ContextInterface $context) { $thing = $this->getThing( trim($element->getAttribute('itemtype')) ?: null, trim($element->getAttribute('itemid')) ?: null, $context ); // Process item references $this->processItemReferences($element, $context, $thing); // Add the new thing as a child to the current context // and set the thing as parent thing for nested iterations return $context->addChild($thing)->setParentThing($thing); }
[ "protected", "function", "createAndAddChild", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "$", "thing", "=", "$", "this", "->", "getThing", "(", "trim", "(", "$", "element", "->", "getAttribute", "(", "'itemtyp...
Create and add a nested child @param \DOMElement $element DOM element @param ContextInterface $context Context @return ContextInterface Context for children
[ "Create", "and", "add", "a", "nested", "child" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L146-L160
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.processItemReferences
protected function processItemReferences(\DOMElement $element, ContextInterface $context, ThingInterface $thing) { // If the element has item references if ($element->hasAttribute('itemref')) { $itemrefElements = $this->getItemReferenceElements($element); if (count($itemrefElements)) { $this->processItemReferenceElements($itemrefElements, $context, $thing); } } return $thing; }
php
protected function processItemReferences(\DOMElement $element, ContextInterface $context, ThingInterface $thing) { // If the element has item references if ($element->hasAttribute('itemref')) { $itemrefElements = $this->getItemReferenceElements($element); if (count($itemrefElements)) { $this->processItemReferenceElements($itemrefElements, $context, $thing); } } return $thing; }
[ "protected", "function", "processItemReferences", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ",", "ThingInterface", "$", "thing", ")", "{", "// If the element has item references", "if", "(", "$", "element", "->", "hasAttribute",...
Process item references @param \DOMElement $element DOM element @param ContextInterface $context Context @param ThingInterface $thing Thing @return ThingInterface Thing
[ "Process", "item", "references" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L170-L181
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.getItemReferenceElements
protected function getItemReferenceElements(\DOMElement $element) { $itemrefElements = []; $itemrefs = trim($element->getAttribute('itemref')); $itemrefs = strlen($itemrefs) ? preg_split('/\s+/', $itemrefs) : []; foreach ($itemrefs as $itemref) { $itemrefElement = $element->ownerDocument->getElementById($itemref); if ($itemrefElement instanceof \DOMElement) { $itemrefElements[] = $itemrefElement; } } return $itemrefElements; }
php
protected function getItemReferenceElements(\DOMElement $element) { $itemrefElements = []; $itemrefs = trim($element->getAttribute('itemref')); $itemrefs = strlen($itemrefs) ? preg_split('/\s+/', $itemrefs) : []; foreach ($itemrefs as $itemref) { $itemrefElement = $element->ownerDocument->getElementById($itemref); if ($itemrefElement instanceof \DOMElement) { $itemrefElements[] = $itemrefElement; } } return $itemrefElements; }
[ "protected", "function", "getItemReferenceElements", "(", "\\", "DOMElement", "$", "element", ")", "{", "$", "itemrefElements", "=", "[", "]", ";", "$", "itemrefs", "=", "trim", "(", "$", "element", "->", "getAttribute", "(", "'itemref'", ")", ")", ";", "$...
Find all reference elements @param \DOMElement $element DOM element @return \DOMElement[] Reference elements
[ "Find", "all", "reference", "elements" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L189-L201
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.processItemReferenceElements
protected function processItemReferenceElements( array $itemrefElements, ContextInterface $context, ThingInterface $thing ) { $iterator = new DOMIterator( $itemrefElements, $context->setParentThing($thing), new MicrodataElementProcessor() ); // Iterate through all $node foreach ($iterator->getRecursiveIterator() as $node) { $node || true; } }
php
protected function processItemReferenceElements( array $itemrefElements, ContextInterface $context, ThingInterface $thing ) { $iterator = new DOMIterator( $itemrefElements, $context->setParentThing($thing), new MicrodataElementProcessor() ); // Iterate through all $node foreach ($iterator->getRecursiveIterator() as $node) { $node || true; } }
[ "protected", "function", "processItemReferenceElements", "(", "array", "$", "itemrefElements", ",", "ContextInterface", "$", "context", ",", "ThingInterface", "$", "thing", ")", "{", "$", "iterator", "=", "new", "DOMIterator", "(", "$", "itemrefElements", ",", "$"...
Process item reference elements @param \DOMElement[] $itemrefElements Item reference DOM elements @param ContextInterface $context Context @param ThingInterface $thing Thing @return void
[ "Process", "item", "reference", "elements" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L211-L226
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.getPropertyChildValue
protected function getPropertyChildValue(\DOMElement $element, ContextInterface $context) { // If the property creates a new type: Return the element itself if ($element->hasAttribute('itemscope')) { $thing = $this->getThing($element->getAttribute('itemtype'), null, $context); return $this->processItemReferences($element, $context, $thing); } return null; }
php
protected function getPropertyChildValue(\DOMElement $element, ContextInterface $context) { // If the property creates a new type: Return the element itself if ($element->hasAttribute('itemscope')) { $thing = $this->getThing($element->getAttribute('itemtype'), null, $context); return $this->processItemReferences($element, $context, $thing); } return null; }
[ "protected", "function", "getPropertyChildValue", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "// If the property creates a new type: Return the element itself", "if", "(", "$", "element", "->", "hasAttribute", "(", "'itemsc...
Return a property child value @param \DOMElement $element DOM element @param ContextInterface $context Context @return ThingInterface|null Property child value
[ "Return", "a", "property", "child", "value" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L246-L255
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php
MicrodataElementProcessor.getType
protected function getType($prefixedType, ContextInterface $context) { $defaultVocabulary = $context->getDefaultVocabulary(); if ($defaultVocabulary && strpos($prefixedType, $defaultVocabulary->getUri()) === 0) { $prefixedType = substr($prefixedType, strlen($defaultVocabulary->getUri())); } return parent::getType($prefixedType, $context); }
php
protected function getType($prefixedType, ContextInterface $context) { $defaultVocabulary = $context->getDefaultVocabulary(); if ($defaultVocabulary && strpos($prefixedType, $defaultVocabulary->getUri()) === 0) { $prefixedType = substr($prefixedType, strlen($defaultVocabulary->getUri())); } return parent::getType($prefixedType, $context); }
[ "protected", "function", "getType", "(", "$", "prefixedType", ",", "ContextInterface", "$", "context", ")", "{", "$", "defaultVocabulary", "=", "$", "context", "->", "getDefaultVocabulary", "(", ")", ";", "if", "(", "$", "defaultVocabulary", "&&", "strpos", "(...
Instanciate a type @param string $prefixedType Prefixed type @param ContextInterface $context Context @return TypeInterface Type
[ "Instanciate", "a", "type" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L289-L296
CampaignChain/core
Service/FileUploadService.php
FileUploadService.deleteFile
public function deleteFile($file) { if (!$this->filesystem->has($file)) { return; } $this->filesystem->delete($file); $this->cacheManager->remove($file); }
php
public function deleteFile($file) { if (!$this->filesystem->has($file)) { return; } $this->filesystem->delete($file); $this->cacheManager->remove($file); }
[ "public", "function", "deleteFile", "(", "$", "file", ")", "{", "if", "(", "!", "$", "this", "->", "filesystem", "->", "has", "(", "$", "file", ")", ")", "{", "return", ";", "}", "$", "this", "->", "filesystem", "->", "delete", "(", "$", "file", ...
delete the given file @param string $file
[ "delete", "the", "given", "file" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Service/FileUploadService.php#L74-L82
joomla-framework/twitter-api
src/Profile.php
Profile.updateProfileBackgroundImage
public function updateProfileBackgroundImage($image = null, $tile = false, $entities = null, $skipStatus = null, $use = false) { // Check the rate limit for remaining hits $this->checkRateLimit('account', 'update_profile_background_image'); $data = array(); // Check if image is specified. if ($image) { $data['image'] = "@{$image}"; } // Check if url is true. if ($tile) { $data['tile'] = $tile; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is specified. if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Check if use is true. if ($use) { $data['use'] = $use; } // Set the API path $path = '/account/update_profile_background_image.json'; $header = array('Content-Type' => 'multipart/form-data', 'Expect' => ''); // Send the request. return $this->sendRequest($path, 'POST', $data, $header); }
php
public function updateProfileBackgroundImage($image = null, $tile = false, $entities = null, $skipStatus = null, $use = false) { // Check the rate limit for remaining hits $this->checkRateLimit('account', 'update_profile_background_image'); $data = array(); // Check if image is specified. if ($image) { $data['image'] = "@{$image}"; } // Check if url is true. if ($tile) { $data['tile'] = $tile; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is specified. if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Check if use is true. if ($use) { $data['use'] = $use; } // Set the API path $path = '/account/update_profile_background_image.json'; $header = array('Content-Type' => 'multipart/form-data', 'Expect' => ''); // Send the request. return $this->sendRequest($path, 'POST', $data, $header); }
[ "public", "function", "updateProfileBackgroundImage", "(", "$", "image", "=", "null", ",", "$", "tile", "=", "false", ",", "$", "entities", "=", "null", ",", "$", "skipStatus", "=", "null", ",", "$", "use", "=", "false", ")", "{", "// Check the rate limit ...
Method to update the authenticating user's profile background image. This method can also be used to enable or disable the profile background image. @param string $image The background image for the profile. @param boolean $tile Whether or not to tile the background image. @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. @param boolean $skipStatus When set to either true, t or 1 statuses will not be included in the returned user objects. @param boolean $use Determines whether to display the profile background image or not. @return array The decoded JSON response @since 1.0
[ "Method", "to", "update", "the", "authenticating", "user", "s", "profile", "background", "image", ".", "This", "method", "can", "also", "be", "used", "to", "enable", "or", "disable", "the", "profile", "background", "image", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Profile.php#L100-L144
joomla-framework/twitter-api
src/Profile.php
Profile.updateProfileImage
public function updateProfileImage($image = null, $entities = null, $skipStatus = null) { // Check the rate limit for remaining hits $this->checkRateLimit('account', 'update_profile_image'); $data = array(); // Check if image is specified. if ($image) { $data['image'] = "@{$image}"; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is specified. if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Set the API path $path = '/account/update_profile_image.json'; $header = array('Content-Type' => 'multipart/form-data', 'Expect' => ''); // Send the request. return $this->sendRequest($path, 'POST', $data, $header); }
php
public function updateProfileImage($image = null, $entities = null, $skipStatus = null) { // Check the rate limit for remaining hits $this->checkRateLimit('account', 'update_profile_image'); $data = array(); // Check if image is specified. if ($image) { $data['image'] = "@{$image}"; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is specified. if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Set the API path $path = '/account/update_profile_image.json'; $header = array('Content-Type' => 'multipart/form-data', 'Expect' => ''); // Send the request. return $this->sendRequest($path, 'POST', $data, $header); }
[ "public", "function", "updateProfileImage", "(", "$", "image", "=", "null", ",", "$", "entities", "=", "null", ",", "$", "skipStatus", "=", "null", ")", "{", "// Check the rate limit for remaining hits", "$", "this", "->", "checkRateLimit", "(", "'account'", ","...
Method to update the authenticating user's profile image. @param string $image The background image for the profile. @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. @param boolean $skipStatus When set to either true, t or 1 statuses will not be included in the returned user objects. @return array The decoded JSON response @since 1.0
[ "Method", "to", "update", "the", "authenticating", "user", "s", "profile", "image", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Profile.php#L158-L190
joomla-framework/twitter-api
src/Profile.php
Profile.updateProfileColors
public function updateProfileColors($background = null, $link = null, $sidebarBorder = null, $sidebarFill = null, $text = null, $entities = null, $skipStatus = null ) { // Check the rate limit for remaining hits $this->checkRateLimit('account', 'update_profile_colors'); $data = array(); // Check if background is specified. if ($background) { $data['profile_background_color'] = $background; } // Check if link is specified. if ($link) { $data['profile_link_color'] = $link; } // Check if sidebar_border is specified. if ($sidebarBorder) { $data['profile_sidebar_border_color'] = $sidebarBorder; } // Check if sidebar_fill is specified. if ($sidebarFill) { $data['profile_sidebar_fill_color'] = $sidebarFill; } // Check if text is specified. if ($text) { $data['profile_text_color'] = $text; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is true. if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Set the API path $path = '/account/update_profile_colors.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
php
public function updateProfileColors($background = null, $link = null, $sidebarBorder = null, $sidebarFill = null, $text = null, $entities = null, $skipStatus = null ) { // Check the rate limit for remaining hits $this->checkRateLimit('account', 'update_profile_colors'); $data = array(); // Check if background is specified. if ($background) { $data['profile_background_color'] = $background; } // Check if link is specified. if ($link) { $data['profile_link_color'] = $link; } // Check if sidebar_border is specified. if ($sidebarBorder) { $data['profile_sidebar_border_color'] = $sidebarBorder; } // Check if sidebar_fill is specified. if ($sidebarFill) { $data['profile_sidebar_fill_color'] = $sidebarFill; } // Check if text is specified. if ($text) { $data['profile_text_color'] = $text; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is true. if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Set the API path $path = '/account/update_profile_colors.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
[ "public", "function", "updateProfileColors", "(", "$", "background", "=", "null", ",", "$", "link", "=", "null", ",", "$", "sidebarBorder", "=", "null", ",", "$", "sidebarFill", "=", "null", ",", "$", "text", "=", "null", ",", "$", "entities", "=", "nu...
Method to set one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com. @param string $background Profile background color. @param string $link Profile link color. @param string $sidebarBorder Profile sidebar's border color. @param string $sidebarFill Profile sidebar's fill color. @param string $text Profile text color. @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. @param boolean $skipStatus When set to either true, t or 1 statuses will not be included in the returned user objects. @return array The decoded JSON response @since 1.0
[ "Method", "to", "set", "one", "or", "more", "hex", "values", "that", "control", "the", "color", "scheme", "of", "the", "authenticating", "user", "s", "profile", "page", "on", "twitter", ".", "com", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Profile.php#L208-L264
joomla-framework/twitter-api
src/Profile.php
Profile.updateSettings
public function updateSettings($location = null, $sleepTime = false, $startSleep = null, $endSleep = null, $timeZone = null, $lang = null) { $data = array(); // Check if location is specified. if ($location) { $data['trend_location_woeid '] = $location; } // Check if sleep_time is true. if ($sleepTime) { $data['sleep_time_enabled'] = $sleepTime; } // Check if start_sleep is specified. if ($startSleep) { $data['start_sleep_time'] = $startSleep; } // Check if end_sleep is specified. if ($endSleep) { $data['end_sleep_time'] = $endSleep; } // Check if time_zone is specified. if ($timeZone) { $data['time_zone'] = $timeZone; } // Check if lang is specified. if ($lang) { $data['lang'] = $lang; } // Set the API path $path = '/account/settings.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
php
public function updateSettings($location = null, $sleepTime = false, $startSleep = null, $endSleep = null, $timeZone = null, $lang = null) { $data = array(); // Check if location is specified. if ($location) { $data['trend_location_woeid '] = $location; } // Check if sleep_time is true. if ($sleepTime) { $data['sleep_time_enabled'] = $sleepTime; } // Check if start_sleep is specified. if ($startSleep) { $data['start_sleep_time'] = $startSleep; } // Check if end_sleep is specified. if ($endSleep) { $data['end_sleep_time'] = $endSleep; } // Check if time_zone is specified. if ($timeZone) { $data['time_zone'] = $timeZone; } // Check if lang is specified. if ($lang) { $data['lang'] = $lang; } // Set the API path $path = '/account/settings.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
[ "public", "function", "updateSettings", "(", "$", "location", "=", "null", ",", "$", "sleepTime", "=", "false", ",", "$", "startSleep", "=", "null", ",", "$", "endSleep", "=", "null", ",", "$", "timeZone", "=", "null", ",", "$", "lang", "=", "null", ...
Method to update the authenticating user's settings. @param integer $location The Yahoo! Where On Earth ID to use as the user's default trend location. @param boolean $sleepTime When set to true, t or 1, will enable sleep time for the user. @param integer $startSleep The hour that sleep time should begin if it is enabled. @param integer $endSleep The hour that sleep time should end if it is enabled. @param string $timeZone The timezone dates and times should be displayed in for the user. The timezone must be one of the Rails TimeZone names. @param string $lang The language which Twitter should render in for this user. @return array The decoded JSON response @since 1.0
[ "Method", "to", "update", "the", "authenticating", "user", "s", "settings", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Profile.php#L300-L345
bpolaszek/bentools-pusher
src/BenTools/Pusher/Model/Handler/GoogleCloudMessagingHandler.php
GoogleCloudMessagingHandler.prepareRequest
private function prepareRequest(MessageInterface $message, RecipientInterface $recipient) { if (!$this->getApiKey()) { throw new \RuntimeException("No API Key provided."); } $uri = new Uri($recipient->getEndpoint()); return Pusher::createStandardRequest($message, $recipient) ->withUri($uri) ->withHeader('Authorization', sprintf('key=%s', $this->getApiKey())); }
php
private function prepareRequest(MessageInterface $message, RecipientInterface $recipient) { if (!$this->getApiKey()) { throw new \RuntimeException("No API Key provided."); } $uri = new Uri($recipient->getEndpoint()); return Pusher::createStandardRequest($message, $recipient) ->withUri($uri) ->withHeader('Authorization', sprintf('key=%s', $this->getApiKey())); }
[ "private", "function", "prepareRequest", "(", "MessageInterface", "$", "message", ",", "RecipientInterface", "$", "recipient", ")", "{", "if", "(", "!", "$", "this", "->", "getApiKey", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"No ...
@param MessageInterface $message @param array $recipientIdentifiers @return RequestInterface @throws \RuntimeException
[ "@param", "MessageInterface", "$message", "@param", "array", "$recipientIdentifiers" ]
train
https://github.com/bpolaszek/bentools-pusher/blob/35b99677ac769e489ed0e63ed06de2226357c5dd/src/BenTools/Pusher/Model/Handler/GoogleCloudMessagingHandler.php#L49-L58
CampaignChain/core
Controller/ReportController.php
ReportController.apiListCtaLocationsPerCampaignAction
public function apiListCtaLocationsPerCampaignAction($id) { $repository = $this->getDoctrine() ->getRepository('CampaignChainCoreBundle:ReportCTA'); $qb = $repository->createQueryBuilder('r'); $qb->select('r') ->where('r.campaign = :campaignId') ->andWhere('r.sourceLocation = r.targetLocation') ->andWhere('r.targetLocation IS NOT NULL') ->groupBy('r.sourceLocation') ->orderBy('r.sourceName', 'ASC') ->setParameter('campaignId', $id); $query = $qb->getQuery(); $locations = $query->getResult(); $response = array(); foreach ($locations as $location) { $response[] = [ 'id' => $location->getTargetLocation()->getId(), 'display_name' => $location->getTargetName() .' ('.$location->getTargetUrl().')', ]; } $serializer = $this->get('campaignchain.core.serializer.default'); return new Response($serializer->serialize($response, 'json')); }
php
public function apiListCtaLocationsPerCampaignAction($id) { $repository = $this->getDoctrine() ->getRepository('CampaignChainCoreBundle:ReportCTA'); $qb = $repository->createQueryBuilder('r'); $qb->select('r') ->where('r.campaign = :campaignId') ->andWhere('r.sourceLocation = r.targetLocation') ->andWhere('r.targetLocation IS NOT NULL') ->groupBy('r.sourceLocation') ->orderBy('r.sourceName', 'ASC') ->setParameter('campaignId', $id); $query = $qb->getQuery(); $locations = $query->getResult(); $response = array(); foreach ($locations as $location) { $response[] = [ 'id' => $location->getTargetLocation()->getId(), 'display_name' => $location->getTargetName() .' ('.$location->getTargetUrl().')', ]; } $serializer = $this->get('campaignchain.core.serializer.default'); return new Response($serializer->serialize($response, 'json')); }
[ "public", "function", "apiListCtaLocationsPerCampaignAction", "(", "$", "id", ")", "{", "$", "repository", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'CampaignChainCoreBundle:ReportCTA'", ")", ";", "$", "qb", "=", "$", "reposit...
Returns all Locations with CTA data within a Campaign. @ApiDoc( section = "Core", views = { "private" }, requirements={ { "name"="id", "requirement"="\d+" } } ) @param $id Campaign ID @return Response
[ "Returns", "all", "Locations", "with", "CTA", "data", "within", "a", "Campaign", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/ReportController.php#L73-L100
notthatbad/silverstripe-rest-api
code/extensions/DataListExtension.php
DataListExtension.byURL
public function byURL($url) { $URL = \Convert::raw2sql($url); return $this->owner->filter('URLSegment', $URL)->first(); }
php
public function byURL($url) { $URL = \Convert::raw2sql($url); return $this->owner->filter('URLSegment', $URL)->first(); }
[ "public", "function", "byURL", "(", "$", "url", ")", "{", "$", "URL", "=", "\\", "Convert", "::", "raw2sql", "(", "$", "url", ")", ";", "return", "$", "this", "->", "owner", "->", "filter", "(", "'URLSegment'", ",", "$", "URL", ")", "->", "first", ...
Returns the first element in a data list, that has the given url segment. Works in the same way as DataList::byID. @param string $url the url segment @return \DataObject the object, that has the given url segment
[ "Returns", "the", "first", "element", "in", "a", "data", "list", "that", "has", "the", "given", "url", "segment", "." ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/extensions/DataListExtension.php#L19-L22
opus-online/yii2-payment
lib/adapters/Nordea.php
Nordea.generateMacKey
private function generateMacKey(Dataset $dataset, $requestType) { $macDefinition = $this->getParamMacOrderDefinition(); $hashFunction = $this->getConfParam('hash_function', self::DEFAULT_HASH_FUNCTION); $macKey = ''; foreach ($macDefinition[$requestType] as $param) { $macKey .= sprintf('%s&', $dataset->hasParam($param) ? $dataset->getParam($param) : null); } $macKey .= $this->getConfParam('MAC_SECRET') . '&'; $macKey = \strtoupper($hashFunction($macKey)); return $macKey; }
php
private function generateMacKey(Dataset $dataset, $requestType) { $macDefinition = $this->getParamMacOrderDefinition(); $hashFunction = $this->getConfParam('hash_function', self::DEFAULT_HASH_FUNCTION); $macKey = ''; foreach ($macDefinition[$requestType] as $param) { $macKey .= sprintf('%s&', $dataset->hasParam($param) ? $dataset->getParam($param) : null); } $macKey .= $this->getConfParam('MAC_SECRET') . '&'; $macKey = \strtoupper($hashFunction($macKey)); return $macKey; }
[ "private", "function", "generateMacKey", "(", "Dataset", "$", "dataset", ",", "$", "requestType", ")", "{", "$", "macDefinition", "=", "$", "this", "->", "getParamMacOrderDefinition", "(", ")", ";", "$", "hashFunction", "=", "$", "this", "->", "getConfParam", ...
Generates a MAC key that corresponds to the parameter set specified by the first parameter. @param Dataset $dataset @param string $requestType Key of 'mac param order definition' array @return string
[ "Generates", "a", "MAC", "key", "that", "corresponds", "to", "the", "parameter", "set", "specified", "by", "the", "first", "parameter", "." ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/Nordea.php#L149-L161
opus-online/yii2-payment
lib/adapters/Nordea.php
Nordea.verifyResponseMac
public function verifyResponseMac(Response $response) { $mac = $this->generateMacKey($response, 'payment_response'); /** @noinspection SpellCheckingInspection */ if ($mac !== $response->getParam('SOLOPMT_RETURN_MAC')) { /** @noinspection SpellCheckingInspection */ $params = [ 'SOLOPMT_RETURN_VERSION' => $response->getParam('SOLOPMT_RETURN_VERSION'), 'SOLOPMT_RETURN_STAMP' => $response->getParam('SOLOPMT_RETURN_STAMP'), 'SOLOPMT_RETURN_REF' => $response->getParam('SOLOPMT_RETURN_REF'), 'SOLOPMT_RETURN_PAID' => $response->getParam('SOLOPMT_RETURN_PAID'), 'SOLOPMT_RETURN_MAC' => $response->getParam('SOLOPMT_RETURN_MAC'), 'generated_mac' => $mac, ]; throw new Exception('BankNet-> Incorrect signature. (' . implode(',', $params) . ')'); } }
php
public function verifyResponseMac(Response $response) { $mac = $this->generateMacKey($response, 'payment_response'); /** @noinspection SpellCheckingInspection */ if ($mac !== $response->getParam('SOLOPMT_RETURN_MAC')) { /** @noinspection SpellCheckingInspection */ $params = [ 'SOLOPMT_RETURN_VERSION' => $response->getParam('SOLOPMT_RETURN_VERSION'), 'SOLOPMT_RETURN_STAMP' => $response->getParam('SOLOPMT_RETURN_STAMP'), 'SOLOPMT_RETURN_REF' => $response->getParam('SOLOPMT_RETURN_REF'), 'SOLOPMT_RETURN_PAID' => $response->getParam('SOLOPMT_RETURN_PAID'), 'SOLOPMT_RETURN_MAC' => $response->getParam('SOLOPMT_RETURN_MAC'), 'generated_mac' => $mac, ]; throw new Exception('BankNet-> Incorrect signature. (' . implode(',', $params) . ')'); } }
[ "public", "function", "verifyResponseMac", "(", "Response", "$", "response", ")", "{", "$", "mac", "=", "$", "this", "->", "generateMacKey", "(", "$", "response", ",", "'payment_response'", ")", ";", "/** @noinspection SpellCheckingInspection */", "if", "(", "$", ...
Verifies if a given MAC in a response object is valid @param Response $response @throws \opus\payment\Exception
[ "Verifies", "if", "a", "given", "MAC", "in", "a", "response", "object", "is", "valid" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/Nordea.php#L232-L249
Patroklo/yii2-comments
migrations/m010101_100002_init_comment.php
m010101_100002_init_comment.up
public function up() { $tableOptions = null; if ($this->db->driverName === 'mysql') { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; } $this->createTable('{{%Comment}}', [ 'id' => Schema::TYPE_PK, 'entity' => 'CHAR(10) NOT NULL', 'entityId' => Schema::TYPE_INTEGER . ' NOT NULL', 'content' => Schema::TYPE_TEXT . ' NOT NULL', 'parentId' => Schema::TYPE_INTEGER . ' DEFAULT NULL', 'level' => 'TINYINT(3) NOT NULL DEFAULT 1', 'anonymousUsername' => Schema::TYPE_STRING, 'createdBy' => Schema::TYPE_INTEGER, 'updatedBy' => Schema::TYPE_INTEGER, 'status' => 'TINYINT(2) NOT NULL DEFAULT 1', 'createdAt' => Schema::TYPE_INTEGER . ' NOT NULL', 'updatedAt' => Schema::TYPE_INTEGER . ' NOT NULL', ], $tableOptions); $this->createIndex('comment_entity_index', '{{%Comment}}', 'entity'); $this->createIndex('comment_status_index', '{{%Comment}}', 'status'); $this->createIndex('comment_complete_entity_index', '{{%Comment}}', ['entity', 'entityId']); $this->createIndex('comment_parent_index', '{{%Comment}}', 'parentId'); $this->createIndex('comment_author_index', '{{%Comment}}', 'createdBy'); }
php
public function up() { $tableOptions = null; if ($this->db->driverName === 'mysql') { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; } $this->createTable('{{%Comment}}', [ 'id' => Schema::TYPE_PK, 'entity' => 'CHAR(10) NOT NULL', 'entityId' => Schema::TYPE_INTEGER . ' NOT NULL', 'content' => Schema::TYPE_TEXT . ' NOT NULL', 'parentId' => Schema::TYPE_INTEGER . ' DEFAULT NULL', 'level' => 'TINYINT(3) NOT NULL DEFAULT 1', 'anonymousUsername' => Schema::TYPE_STRING, 'createdBy' => Schema::TYPE_INTEGER, 'updatedBy' => Schema::TYPE_INTEGER, 'status' => 'TINYINT(2) NOT NULL DEFAULT 1', 'createdAt' => Schema::TYPE_INTEGER . ' NOT NULL', 'updatedAt' => Schema::TYPE_INTEGER . ' NOT NULL', ], $tableOptions); $this->createIndex('comment_entity_index', '{{%Comment}}', 'entity'); $this->createIndex('comment_status_index', '{{%Comment}}', 'status'); $this->createIndex('comment_complete_entity_index', '{{%Comment}}', ['entity', 'entityId']); $this->createIndex('comment_parent_index', '{{%Comment}}', 'parentId'); $this->createIndex('comment_author_index', '{{%Comment}}', 'createdBy'); }
[ "public", "function", "up", "(", ")", "{", "$", "tableOptions", "=", "null", ";", "if", "(", "$", "this", "->", "db", "->", "driverName", "===", "'mysql'", ")", "{", "$", "tableOptions", "=", "'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'", ";", "...
Create table `Comment`
[ "Create", "table", "Comment" ]
train
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/migrations/m010101_100002_init_comment.php#L14-L41
yeriomin/getopt
src/Yeriomin/Getopt/OptionDefinition.php
OptionDefinition.setShort
public function setShort($short) { $short = (string) $short; $this->short = function_exists('mb_substr') ? mb_substr($short, 0, 1) : substr($short, 0, 1) ; return $this; }
php
public function setShort($short) { $short = (string) $short; $this->short = function_exists('mb_substr') ? mb_substr($short, 0, 1) : substr($short, 0, 1) ; return $this; }
[ "public", "function", "setShort", "(", "$", "short", ")", "{", "$", "short", "=", "(", "string", ")", "$", "short", ";", "$", "this", "->", "short", "=", "function_exists", "(", "'mb_substr'", ")", "?", "mb_substr", "(", "$", "short", ",", "0", ",", ...
Set short argument definition @param string $short A letter to identify the option @return OptionDefinition
[ "Set", "short", "argument", "definition" ]
train
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/OptionDefinition.php#L87-L95
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Factories/DomDocumentFactory.php
DomDocumentFactory.createDocumentFromSource
public function createDocumentFromSource($source) { if ($source instanceof \DOMDocument) { return $source; } throw new RuntimeException(RuntimeException::INVALID_DOM_SOURCE_STR, RuntimeException::INVALID_DOM_SOURCE); }
php
public function createDocumentFromSource($source) { if ($source instanceof \DOMDocument) { return $source; } throw new RuntimeException(RuntimeException::INVALID_DOM_SOURCE_STR, RuntimeException::INVALID_DOM_SOURCE); }
[ "public", "function", "createDocumentFromSource", "(", "$", "source", ")", "{", "if", "(", "$", "source", "instanceof", "\\", "DOMDocument", ")", "{", "return", "$", "source", ";", "}", "throw", "new", "RuntimeException", "(", "RuntimeException", "::", "INVALI...
Create a DOM document from a source @param mixed $source Source @return \DOMDocument DOM document @throws RuntimeException If the source is no DOM document
[ "Create", "a", "DOM", "document", "from", "a", "source" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Factories/DomDocumentFactory.php#L57-L64
prooph/link-process-manager
src/Api/Log.php
Log.populateTaskEvents
private function populateTaskEvents(array &$processLog) { foreach ($processLog['tasks'] as &$task) { $task['events'] = []; foreach ($processLog['events'] as $event) { if ($event['client_task_id'] == $task['id']) { $task['events'][] = $event; } } } }
php
private function populateTaskEvents(array &$processLog) { foreach ($processLog['tasks'] as &$task) { $task['events'] = []; foreach ($processLog['events'] as $event) { if ($event['client_task_id'] == $task['id']) { $task['events'][] = $event; } } } }
[ "private", "function", "populateTaskEvents", "(", "array", "&", "$", "processLog", ")", "{", "foreach", "(", "$", "processLog", "[", "'tasks'", "]", "as", "&", "$", "task", ")", "{", "$", "task", "[", "'events'", "]", "=", "[", "]", ";", "foreach", "...
Copy each task event to its task @param array $processLog
[ "Copy", "each", "task", "event", "to", "its", "task" ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Api/Log.php#L166-L176
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php
RdfaLiteContext.registerVocabulary
public function registerVocabulary($prefix, $uri) { $prefix = self::validateVocabPrefix($prefix); $uri = (new VocabularyService())->validateVocabularyUri($uri); // Register the new URI if (empty($this->vocabularies[$prefix]) || ($this->vocabularies[$prefix] !== $uri)) { $context = clone $this; $context->vocabularies[$prefix] = $uri; return $context; } return $this; }
php
public function registerVocabulary($prefix, $uri) { $prefix = self::validateVocabPrefix($prefix); $uri = (new VocabularyService())->validateVocabularyUri($uri); // Register the new URI if (empty($this->vocabularies[$prefix]) || ($this->vocabularies[$prefix] !== $uri)) { $context = clone $this; $context->vocabularies[$prefix] = $uri; return $context; } return $this; }
[ "public", "function", "registerVocabulary", "(", "$", "prefix", ",", "$", "uri", ")", "{", "$", "prefix", "=", "self", "::", "validateVocabPrefix", "(", "$", "prefix", ")", ";", "$", "uri", "=", "(", "new", "VocabularyService", "(", ")", ")", "->", "va...
Register a vocabulary and its prefix @param string $prefix Vocabulary prefix @param string $uri Vocabulary URI @return RdfaLiteContext New context
[ "Register", "a", "vocabulary", "and", "its", "prefix" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php#L131-L144
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php
RdfaLiteContext.validateVocabPrefix
protected static function validateVocabPrefix($prefix) { $prefix = trim($prefix); // If the vocabulary prefix is invalid if (!strlen($prefix)) { throw new RuntimeException( sprintf(RuntimeException::INVALID_VOCABULARY_PREFIX_STR, $prefix), RuntimeException::INVALID_VOCABULARY_PREFIX ); } return $prefix; }
php
protected static function validateVocabPrefix($prefix) { $prefix = trim($prefix); // If the vocabulary prefix is invalid if (!strlen($prefix)) { throw new RuntimeException( sprintf(RuntimeException::INVALID_VOCABULARY_PREFIX_STR, $prefix), RuntimeException::INVALID_VOCABULARY_PREFIX ); } return $prefix; }
[ "protected", "static", "function", "validateVocabPrefix", "(", "$", "prefix", ")", "{", "$", "prefix", "=", "trim", "(", "$", "prefix", ")", ";", "// If the vocabulary prefix is invalid", "if", "(", "!", "strlen", "(", "$", "prefix", ")", ")", "{", "throw", ...
Validata a vocabulary prefix @param string $prefix Vocabulary prefix @return string Valid vocabulary prefix @throws RuntimeException If the vocabulary prefix is invalid
[ "Validata", "a", "vocabulary", "prefix" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php#L153-L166
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php
RdfaLiteContext.getVocabulary
public function getVocabulary($prefix) { $prefix = self::validateVocabPrefix($prefix); // If the prefix has not been registered if (empty($this->vocabularies[$prefix])) { throw new OutOfBoundsException( sprintf(OutOfBoundsException::UNKNOWN_VOCABULARY_PREFIX_STR, $prefix), OutOfBoundsException::UNKNOWN_VOCABULARY_PREFIX ); } return new Vocabulary($this->vocabularies[$prefix]); }
php
public function getVocabulary($prefix) { $prefix = self::validateVocabPrefix($prefix); // If the prefix has not been registered if (empty($this->vocabularies[$prefix])) { throw new OutOfBoundsException( sprintf(OutOfBoundsException::UNKNOWN_VOCABULARY_PREFIX_STR, $prefix), OutOfBoundsException::UNKNOWN_VOCABULARY_PREFIX ); } return new Vocabulary($this->vocabularies[$prefix]); }
[ "public", "function", "getVocabulary", "(", "$", "prefix", ")", "{", "$", "prefix", "=", "self", "::", "validateVocabPrefix", "(", "$", "prefix", ")", ";", "// If the prefix has not been registered", "if", "(", "empty", "(", "$", "this", "->", "vocabularies", ...
Return a particular vocabulary @param string $prefix Vocabulary Prefix @return VocabularyInterface Vocabulary @throws OutOfBoundsException If the prefix has not been registered
[ "Return", "a", "particular", "vocabulary" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php#L175-L188
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php
RdfaLiteContext.setDefaultVocabulary
public function setDefaultVocabulary(VocabularyInterface $vocabulary) { // If the new default vocabulary differs from the current one if ($this->defaultVocabulary !== $vocabulary) { $context = clone $this; $context->defaultVocabulary = $vocabulary; return $context; } return $this; }
php
public function setDefaultVocabulary(VocabularyInterface $vocabulary) { // If the new default vocabulary differs from the current one if ($this->defaultVocabulary !== $vocabulary) { $context = clone $this; $context->defaultVocabulary = $vocabulary; return $context; } return $this; }
[ "public", "function", "setDefaultVocabulary", "(", "VocabularyInterface", "$", "vocabulary", ")", "{", "// If the new default vocabulary differs from the current one", "if", "(", "$", "this", "->", "defaultVocabulary", "!==", "$", "vocabulary", ")", "{", "$", "context", ...
Set the default vocabulary by URI @param VocabularyInterface $vocabulary Current default vocabulary @return RdfaLiteContext Self reference
[ "Set", "the", "default", "vocabulary", "by", "URI" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php#L207-L217
JustBlackBird/handlebars.php-helpers
src/Layout/Helpers.php
Helpers.addDefaultHelpers
protected function addDefaultHelpers() { parent::addDefaultHelpers(); $storage = new BlockStorage(); $this->add('block', new BlockHelper($storage)); $this->add('extends', new ExtendsHelper($storage)); $this->add('override', new OverrideHelper($storage)); $this->add('ifOverridden', new IfOverriddenHelper($storage)); $this->add('unlessOverridden', new UnlessOverriddenHelper($storage)); }
php
protected function addDefaultHelpers() { parent::addDefaultHelpers(); $storage = new BlockStorage(); $this->add('block', new BlockHelper($storage)); $this->add('extends', new ExtendsHelper($storage)); $this->add('override', new OverrideHelper($storage)); $this->add('ifOverridden', new IfOverriddenHelper($storage)); $this->add('unlessOverridden', new UnlessOverriddenHelper($storage)); }
[ "protected", "function", "addDefaultHelpers", "(", ")", "{", "parent", "::", "addDefaultHelpers", "(", ")", ";", "$", "storage", "=", "new", "BlockStorage", "(", ")", ";", "$", "this", "->", "add", "(", "'block'", ",", "new", "BlockHelper", "(", "$", "st...
{@inheritdoc}
[ "{" ]
train
https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Layout/Helpers.php#L25-L35
JustBlackBird/handlebars.php-helpers
src/Collection/Helpers.php
Helpers.addDefaultHelpers
protected function addDefaultHelpers() { parent::addDefaultHelpers(); $this->add('count', new CountHelper()); $this->add('first', new FirstHelper()); $this->add('last', new LastHelper()); }
php
protected function addDefaultHelpers() { parent::addDefaultHelpers(); $this->add('count', new CountHelper()); $this->add('first', new FirstHelper()); $this->add('last', new LastHelper()); }
[ "protected", "function", "addDefaultHelpers", "(", ")", "{", "parent", "::", "addDefaultHelpers", "(", ")", ";", "$", "this", "->", "add", "(", "'count'", ",", "new", "CountHelper", "(", ")", ")", ";", "$", "this", "->", "add", "(", "'first'", ",", "ne...
{@inheritdoc}
[ "{" ]
train
https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Collection/Helpers.php#L25-L32
corycollier/markdown-blogger
src/BlogIterator.php
BlogIterator.isBlogPost
public function isBlogPost() { $skips = ['404.md', 'front-page.md']; if ($this->getExtension() != 'md') { return false; } if (in_array($this->getFilename(), $skips)) { return false; } return true; }
php
public function isBlogPost() { $skips = ['404.md', 'front-page.md']; if ($this->getExtension() != 'md') { return false; } if (in_array($this->getFilename(), $skips)) { return false; } return true; }
[ "public", "function", "isBlogPost", "(", ")", "{", "$", "skips", "=", "[", "'404.md'", ",", "'front-page.md'", "]", ";", "if", "(", "$", "this", "->", "getExtension", "(", ")", "!=", "'md'", ")", "{", "return", "false", ";", "}", "if", "(", "in_array...
Function to determine if this file is a valid blog post @return boolean true if not a 404 page, an empty file, or a folder
[ "Function", "to", "determine", "if", "this", "file", "is", "a", "valid", "blog", "post" ]
train
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogIterator.php#L11-L21
gorriecoe/silverstripe-menu
src/extensions/MenuSetSubsiteExtension.php
MenuSetSubsiteExtension.updateCMSFields
public function updateCMSFields(FieldList $fields) { $owner = $this->owner; $fields->addFieldToTab( "Root.Main", HiddenField::create( 'SubsiteID', 'SubsiteID', Subsite::currentSubsiteID() ) ); return $fields; }
php
public function updateCMSFields(FieldList $fields) { $owner = $this->owner; $fields->addFieldToTab( "Root.Main", HiddenField::create( 'SubsiteID', 'SubsiteID', Subsite::currentSubsiteID() ) ); return $fields; }
[ "public", "function", "updateCMSFields", "(", "FieldList", "$", "fields", ")", "{", "$", "owner", "=", "$", "this", "->", "owner", ";", "$", "fields", "->", "addFieldToTab", "(", "\"Root.Main\"", ",", "HiddenField", "::", "create", "(", "'SubsiteID'", ",", ...
Update Fields @return FieldList
[ "Update", "Fields" ]
train
https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/extensions/MenuSetSubsiteExtension.php#L30-L42
gorriecoe/silverstripe-menu
src/extensions/MenuSetSubsiteExtension.php
MenuSetSubsiteExtension.onBeforeWrite
public function onBeforeWrite() { $owner = $this->owner; if(!$owner->ID && !$owner->SubsiteID){ $owner->SubsiteID = Subsite::currentSubsiteID(); } parent::onBeforeWrite(); }
php
public function onBeforeWrite() { $owner = $this->owner; if(!$owner->ID && !$owner->SubsiteID){ $owner->SubsiteID = Subsite::currentSubsiteID(); } parent::onBeforeWrite(); }
[ "public", "function", "onBeforeWrite", "(", ")", "{", "$", "owner", "=", "$", "this", "->", "owner", ";", "if", "(", "!", "$", "owner", "->", "ID", "&&", "!", "$", "owner", "->", "SubsiteID", ")", "{", "$", "owner", "->", "SubsiteID", "=", "Subsite...
Event handler called before writing to the database.
[ "Event", "handler", "called", "before", "writing", "to", "the", "database", "." ]
train
https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/extensions/MenuSetSubsiteExtension.php#L47-L54
vipsoft/code-coverage-extension
src/VIPSoft/CodeCoverageExtension/Driver/RemoteXdebug.php
RemoteXdebug.start
public function start() { $request = $this->buildRequest('create'); $response = $request->send(); if ($response->getStatusCode() !== 200) { throw new \Exception('remote driver start failed: ' . $response->getReasonPhrase()); } }
php
public function start() { $request = $this->buildRequest('create'); $response = $request->send(); if ($response->getStatusCode() !== 200) { throw new \Exception('remote driver start failed: ' . $response->getReasonPhrase()); } }
[ "public", "function", "start", "(", ")", "{", "$", "request", "=", "$", "this", "->", "buildRequest", "(", "'create'", ")", ";", "$", "response", "=", "$", "request", "->", "send", "(", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "("...
{@inheritdoc}
[ "{" ]
train
https://github.com/vipsoft/code-coverage-extension/blob/b49c1fe33528aa74024fd23a43428e615c104cdf/src/VIPSoft/CodeCoverageExtension/Driver/RemoteXdebug.php#L68-L77
vipsoft/code-coverage-extension
src/VIPSoft/CodeCoverageExtension/Driver/RemoteXdebug.php
RemoteXdebug.stop
public function stop() { $request = $this->buildRequest('read'); $request->setHeader('Accept', 'application/json'); $response = $request->send(); if ($response->getStatusCode() !== 200) { throw new \Exception('remote driver fetch failed: ' . $response->getReasonPhrase()); } $request = $this->buildRequest('delete'); $request->send(); return json_decode($response->getBody(true), true); }
php
public function stop() { $request = $this->buildRequest('read'); $request->setHeader('Accept', 'application/json'); $response = $request->send(); if ($response->getStatusCode() !== 200) { throw new \Exception('remote driver fetch failed: ' . $response->getReasonPhrase()); } $request = $this->buildRequest('delete'); $request->send(); return json_decode($response->getBody(true), true); }
[ "public", "function", "stop", "(", ")", "{", "$", "request", "=", "$", "this", "->", "buildRequest", "(", "'read'", ")", ";", "$", "request", "->", "setHeader", "(", "'Accept'", ",", "'application/json'", ")", ";", "$", "response", "=", "$", "request", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/vipsoft/code-coverage-extension/blob/b49c1fe33528aa74024fd23a43428e615c104cdf/src/VIPSoft/CodeCoverageExtension/Driver/RemoteXdebug.php#L82-L97
vipsoft/code-coverage-extension
src/VIPSoft/CodeCoverageExtension/Driver/RemoteXdebug.php
RemoteXdebug.buildRequest
private function buildRequest($endpoint) { $method = strtolower($this->config[$endpoint]['method']); if (! in_array($method, array('get', 'post', 'put', 'delete'))) { throw new \Exception($endpoint . ' method must be GET, POST, PUT, or DELETE'); } $request = $this->client->$method($this->config[$endpoint]['path']); if (isset($this->config['auth'])) { $request->setAuth($this->config['auth']['user'], $this->config['auth']['password']); } return $request; }
php
private function buildRequest($endpoint) { $method = strtolower($this->config[$endpoint]['method']); if (! in_array($method, array('get', 'post', 'put', 'delete'))) { throw new \Exception($endpoint . ' method must be GET, POST, PUT, or DELETE'); } $request = $this->client->$method($this->config[$endpoint]['path']); if (isset($this->config['auth'])) { $request->setAuth($this->config['auth']['user'], $this->config['auth']['password']); } return $request; }
[ "private", "function", "buildRequest", "(", "$", "endpoint", ")", "{", "$", "method", "=", "strtolower", "(", "$", "this", "->", "config", "[", "$", "endpoint", "]", "[", "'method'", "]", ")", ";", "if", "(", "!", "in_array", "(", "$", "method", ",",...
Construct request @param string $endpoint @return \Guzzle\Http\Message\Request
[ "Construct", "request" ]
train
https://github.com/vipsoft/code-coverage-extension/blob/b49c1fe33528aa74024fd23a43428e615c104cdf/src/VIPSoft/CodeCoverageExtension/Driver/RemoteXdebug.php#L106-L121
vipsoft/code-coverage-extension
src/VIPSoft/CodeCoverageExtension/Driver/Proxy.php
Proxy.stop
public function stop() { $aggregate = new Aggregate; foreach ($this->drivers as $driver) { $coverage = $driver->stop(); if (! $coverage) { continue; } foreach ($coverage as $class => $counts) { $aggregate->update($class, $counts); } } return $aggregate->getCoverage(); }
php
public function stop() { $aggregate = new Aggregate; foreach ($this->drivers as $driver) { $coverage = $driver->stop(); if (! $coverage) { continue; } foreach ($coverage as $class => $counts) { $aggregate->update($class, $counts); } } return $aggregate->getCoverage(); }
[ "public", "function", "stop", "(", ")", "{", "$", "aggregate", "=", "new", "Aggregate", ";", "foreach", "(", "$", "this", "->", "drivers", "as", "$", "driver", ")", "{", "$", "coverage", "=", "$", "driver", "->", "stop", "(", ")", ";", "if", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/vipsoft/code-coverage-extension/blob/b49c1fe33528aa74024fd23a43428e615c104cdf/src/VIPSoft/CodeCoverageExtension/Driver/Proxy.php#L52-L69
malenkiki/aleavatar
src/Malenki/Aleavatar/Primitive/Rectangle.php
Rectangle.point
public function point($int_x, $int_y) { if (is_double($int_x)) { $int_x = (integer) $int_x; } if (is_double($int_y)) { $int_y = (integer) $int_y; } if (!is_integer($int_x) || !is_integer($int_y) || $int_x < 0 || $int_y < 0) { throw new \InvalidArgumentException('Coordinates must be valid positive integers!'); } $this->point->x = $int_x; $this->point->y = $int_y; return $this; }
php
public function point($int_x, $int_y) { if (is_double($int_x)) { $int_x = (integer) $int_x; } if (is_double($int_y)) { $int_y = (integer) $int_y; } if (!is_integer($int_x) || !is_integer($int_y) || $int_x < 0 || $int_y < 0) { throw new \InvalidArgumentException('Coordinates must be valid positive integers!'); } $this->point->x = $int_x; $this->point->y = $int_y; return $this; }
[ "public", "function", "point", "(", "$", "int_x", ",", "$", "int_y", ")", "{", "if", "(", "is_double", "(", "$", "int_x", ")", ")", "{", "$", "int_x", "=", "(", "integer", ")", "$", "int_x", ";", "}", "if", "(", "is_double", "(", "$", "int_y", ...
Sets one point by giving its coordinates. @param integer $int_x @param integer $int_y @throws \InvalidArgumentException If one of the two coordinate is not a positive integer. @access public @return Rectangle
[ "Sets", "one", "point", "by", "giving", "its", "coordinates", "." ]
train
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Rectangle.php#L91-L108
malenkiki/aleavatar
src/Malenki/Aleavatar/Primitive/Rectangle.php
Rectangle.size
public function size($int_width, $int_height) { if (!is_integer($int_width) || !is_integer($int_height) || $int_width < 0 || $int_height < 0) { throw new \InvalidArgumentException('Width and height must be positive integers!'); } $this->size->w = $int_width; $this->size->h = $int_height; return $this; }
php
public function size($int_width, $int_height) { if (!is_integer($int_width) || !is_integer($int_height) || $int_width < 0 || $int_height < 0) { throw new \InvalidArgumentException('Width and height must be positive integers!'); } $this->size->w = $int_width; $this->size->h = $int_height; return $this; }
[ "public", "function", "size", "(", "$", "int_width", ",", "$", "int_height", ")", "{", "if", "(", "!", "is_integer", "(", "$", "int_width", ")", "||", "!", "is_integer", "(", "$", "int_height", ")", "||", "$", "int_width", "<", "0", "||", "$", "int_h...
Sets the size of the current rectangle. @param integer $int_width @param integer $int_height @throws \InvalidArgumentException If width or height is not a positive integer. @access public @return Rectangle
[ "Sets", "the", "size", "of", "the", "current", "rectangle", "." ]
train
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Rectangle.php#L119-L129
malenkiki/aleavatar
src/Malenki/Aleavatar/Primitive/Rectangle.php
Rectangle.svg
public function svg() { return sprintf( '<rect x="%d" y="%d" width="%d" height="%d" fill="%s" />', $this->point->x, $this->point->y, $this->size->w, $this->size->h, $this->color ); }
php
public function svg() { return sprintf( '<rect x="%d" y="%d" width="%d" height="%d" fill="%s" />', $this->point->x, $this->point->y, $this->size->w, $this->size->h, $this->color ); }
[ "public", "function", "svg", "(", ")", "{", "return", "sprintf", "(", "'<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"%s\" />'", ",", "$", "this", "->", "point", "->", "x", ",", "$", "this", "->", "point", "->", "y", ",", "$", "this", "->", "size",...
Returns the current shape as a SVG primitive. @access public @return string
[ "Returns", "the", "current", "shape", "as", "a", "SVG", "primitive", "." ]
train
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Rectangle.php#L151-L161
CampaignChain/core
Entity/SchedulerReportLocation.php
SchedulerReportLocation.setLocation
public function setLocation(Location $location = null) { $this->location = $location; $this->setStartDate(new \DateTime('now', new \DateTimeZone('UTC'))); return $this; }
php
public function setLocation(Location $location = null) { $this->location = $location; $this->setStartDate(new \DateTime('now', new \DateTimeZone('UTC'))); return $this; }
[ "public", "function", "setLocation", "(", "Location", "$", "location", "=", "null", ")", "{", "$", "this", "->", "location", "=", "$", "location", ";", "$", "this", "->", "setStartDate", "(", "new", "\\", "DateTime", "(", "'now'", ",", "new", "\\", "Da...
Set location @param Location $location @return $this
[ "Set", "location" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/SchedulerReportLocation.php#L33-L40
vinterskogen/laravel-uploaded-image
src/UploadedImageServiceProvider.php
UploadedImageServiceProvider.getImageRetrivingClosure
private function getImageRetrivingClosure() { /* * Closure to retrieve an instnce of uploaded image with given filename * from request. * * @param string $filename * @return \Vinterskogen\UploadedImage\UploadedImage|null */ return function ($filename) { if (! Request::hasFile($filename)) { return; } $uploadedFile = Request::file($filename); return UploadedImage::createFromBase($uploadedFile); }; }
php
private function getImageRetrivingClosure() { /* * Closure to retrieve an instnce of uploaded image with given filename * from request. * * @param string $filename * @return \Vinterskogen\UploadedImage\UploadedImage|null */ return function ($filename) { if (! Request::hasFile($filename)) { return; } $uploadedFile = Request::file($filename); return UploadedImage::createFromBase($uploadedFile); }; }
[ "private", "function", "getImageRetrivingClosure", "(", ")", "{", "/*\n * Closure to retrieve an instnce of uploaded image with given filename\n * from request.\n *\n * @param string $filename\n * @return \\Vinterskogen\\UploadedImage\\UploadedImage|null\n ...
Get image retrieving closure. @return \Closure
[ "Get", "image", "retrieving", "closure", "." ]
train
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/UploadedImageServiceProvider.php#L35-L53
notthatbad/silverstripe-rest-api
code/serializers/XmlSerializer.php
XmlSerializer.serialize
public function serialize($data) { $xml = new \SimpleXMLElement('<result/>'); $this->toXml($xml, $data); return $xml->asXML(); }
php
public function serialize($data) { $xml = new \SimpleXMLElement('<result/>'); $this->toXml($xml, $data); return $xml->asXML(); }
[ "public", "function", "serialize", "(", "$", "data", ")", "{", "$", "xml", "=", "new", "\\", "SimpleXMLElement", "(", "'<result/>'", ")", ";", "$", "this", "->", "toXml", "(", "$", "xml", ",", "$", "data", ")", ";", "return", "$", "xml", "->", "asX...
Serializes the given data into a xml string. @param array $data the data that should be serialized @return string a xml formatted string
[ "Serializes", "the", "given", "data", "into", "a", "xml", "string", "." ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/serializers/XmlSerializer.php#L28-L32
sulu/SuluAutomationBundle
Controller/TaskHandlerController.php
TaskHandlerController.getAction
public function getAction(Request $request) { $handlerFactory = $this->get('task.handler.factory'); $entityClass = $this->getRequestParameter($request, 'entity-class', true); $handlers = []; foreach ($handlerFactory->getHandlers() as $handler) { if ($handler instanceof AutomationTaskHandlerInterface && $handler->supports($entityClass)) { $configuration = $handler->getConfiguration(); $handlers[] = ['id' => get_class($handler), 'title' => $configuration->getTitle()]; } } return new JsonResponse(['_embedded' => ['handlers' => $handlers]]); }
php
public function getAction(Request $request) { $handlerFactory = $this->get('task.handler.factory'); $entityClass = $this->getRequestParameter($request, 'entity-class', true); $handlers = []; foreach ($handlerFactory->getHandlers() as $handler) { if ($handler instanceof AutomationTaskHandlerInterface && $handler->supports($entityClass)) { $configuration = $handler->getConfiguration(); $handlers[] = ['id' => get_class($handler), 'title' => $configuration->getTitle()]; } } return new JsonResponse(['_embedded' => ['handlers' => $handlers]]); }
[ "public", "function", "getAction", "(", "Request", "$", "request", ")", "{", "$", "handlerFactory", "=", "$", "this", "->", "get", "(", "'task.handler.factory'", ")", ";", "$", "entityClass", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request"...
@param Request $request @return Response
[ "@param", "Request", "$request" ]
train
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Controller/TaskHandlerController.php#L36-L50
wisp-x/hopephp
hopephp/library/hope/File.php
File.createFolder
public static function createFolder($path) { if (!file_exists($path)) { self::createFolder(dirname($path)); mkdir($path, 0777); } }
php
public static function createFolder($path) { if (!file_exists($path)) { self::createFolder(dirname($path)); mkdir($path, 0777); } }
[ "public", "static", "function", "createFolder", "(", "$", "path", ")", "{", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "self", "::", "createFolder", "(", "dirname", "(", "$", "path", ")", ")", ";", "mkdir", "(", "$", "path", ",...
创建文件夹 @param string $path 文件夹路径
[ "创建文件夹" ]
train
https://github.com/wisp-x/hopephp/blob/5d4ec0fdb847772783259c16c97e9843b81df3c9/hopephp/library/hope/File.php#L24-L30
wisp-x/hopephp
hopephp/library/hope/File.php
File.getFolder
public static function getFolder($path) { if (!is_dir($path)) return null; $path = rtrim($path, '/') . '/'; $array = array('file' => array(), 'folder' => array()); $dir_obj = opendir($path); while ($dir = readdir($dir_obj)) { if ($dir != '.' && $dir != '..') { $file = $path . $dir; if (is_dir($file)) { $array['folder'][] = $dir; } elseif (is_file($file)) { $array['file'][] = $dir; } } } closedir($dir_obj); return $array; }
php
public static function getFolder($path) { if (!is_dir($path)) return null; $path = rtrim($path, '/') . '/'; $array = array('file' => array(), 'folder' => array()); $dir_obj = opendir($path); while ($dir = readdir($dir_obj)) { if ($dir != '.' && $dir != '..') { $file = $path . $dir; if (is_dir($file)) { $array['folder'][] = $dir; } elseif (is_file($file)) { $array['file'][] = $dir; } } } closedir($dir_obj); return $array; }
[ "public", "static", "function", "getFolder", "(", "$", "path", ")", "{", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "return", "null", ";", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ".", "'/'", ";", "$", "array", "...
得到指定目录里的信息 @param $path 目录 @return array|null
[ "得到指定目录里的信息" ]
train
https://github.com/wisp-x/hopephp/blob/5d4ec0fdb847772783259c16c97e9843b81df3c9/hopephp/library/hope/File.php#L38-L61
wisp-x/hopephp
hopephp/library/hope/File.php
File.deleteDir
public static function deleteDir($path) { if (!is_dir($path)) return; $path = rtrim($path, '/') . '/'; $dir_obj = opendir($path); while ($dir = readdir($dir_obj)) { if ($dir != '.' && $dir != '..') { $file = $path . $dir; if (is_dir($file)) { self::deleteDir($file); } elseif (is_file($file)) { unlink($file); } } } closedir($dir_obj); rmdir($path); }
php
public static function deleteDir($path) { if (!is_dir($path)) return; $path = rtrim($path, '/') . '/'; $dir_obj = opendir($path); while ($dir = readdir($dir_obj)) { if ($dir != '.' && $dir != '..') { $file = $path . $dir; if (is_dir($file)) { self::deleteDir($file); } elseif (is_file($file)) { unlink($file); } } } closedir($dir_obj); rmdir($path); }
[ "public", "static", "function", "deleteDir", "(", "$", "path", ")", "{", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "return", ";", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ".", "'/'", ";", "$", "dir_obj", "=", "o...
删除目录 @param $path 目录
[ "删除目录" ]
train
https://github.com/wisp-x/hopephp/blob/5d4ec0fdb847772783259c16c97e9843b81df3c9/hopephp/library/hope/File.php#L80-L101
wisp-x/hopephp
hopephp/library/hope/File.php
File.xCopy
public static function xCopy($source, $destination, $child = 1) { if (!is_dir($source)) { echo("Error:the $source is not a direction!"); return 0; } if (!is_dir($destination)) { mkdir($destination, 0777); } $handle = dir($source); while ($entry = $handle->read()) { if (($entry != ".") && ($entry != "..")) { if (is_dir($source . "/" . $entry)) { if ($child) self::xCopy($source . "/" . $entry, $destination . "/" . $entry, $child); } else { copy($source . "/" . $entry, $destination . "/" . $entry); } } } return 1; }
php
public static function xCopy($source, $destination, $child = 1) { if (!is_dir($source)) { echo("Error:the $source is not a direction!"); return 0; } if (!is_dir($destination)) { mkdir($destination, 0777); } $handle = dir($source); while ($entry = $handle->read()) { if (($entry != ".") && ($entry != "..")) { if (is_dir($source . "/" . $entry)) { if ($child) self::xCopy($source . "/" . $entry, $destination . "/" . $entry, $child); } else { copy($source . "/" . $entry, $destination . "/" . $entry); } } } return 1; }
[ "public", "static", "function", "xCopy", "(", "$", "source", ",", "$", "destination", ",", "$", "child", "=", "1", ")", "{", "if", "(", "!", "is_dir", "(", "$", "source", ")", ")", "{", "echo", "(", "\"Error:the $source is not a direction!\"", ")", ";", ...
复制目录 @param string $source 要复制的目录地址 @param string $destination 目标目录地址 @param int $child 是否复制子目录 @return bool
[ "复制目录" ]
train
https://github.com/wisp-x/hopephp/blob/5d4ec0fdb847772783259c16c97e9843b81df3c9/hopephp/library/hope/File.php#L111-L131
wisp-x/hopephp
hopephp/library/hope/File.php
File.copyFile
public static function copyFile($source, $path) { $path = str_replace('\\', '/', $path); $arr = explode('/', $path); array_pop($arr); $folder = join('/', $arr); if (!is_dir($folder)) { self::createFolder($folder); } if (is_file($source)) { copy($source, $path); } }
php
public static function copyFile($source, $path) { $path = str_replace('\\', '/', $path); $arr = explode('/', $path); array_pop($arr); $folder = join('/', $arr); if (!is_dir($folder)) { self::createFolder($folder); } if (is_file($source)) { copy($source, $path); } }
[ "public", "static", "function", "copyFile", "(", "$", "source", ",", "$", "path", ")", "{", "$", "path", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "path", ")", ";", "$", "arr", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";"...
复制文件 @param string $source 要复制的目录地址 @param string $path 目标目录地址 @return null
[ "复制文件" ]
train
https://github.com/wisp-x/hopephp/blob/5d4ec0fdb847772783259c16c97e9843b81df3c9/hopephp/library/hope/File.php#L139-L151
wisp-x/hopephp
hopephp/library/hope/File.php
File.createFile
public static function createFile($file, $content = '') { $folder = dirname($file); if (!is_dir($folder)) { self::createFolder($folder); } file_put_contents($file, $content); }
php
public static function createFile($file, $content = '') { $folder = dirname($file); if (!is_dir($folder)) { self::createFolder($folder); } file_put_contents($file, $content); }
[ "public", "static", "function", "createFile", "(", "$", "file", ",", "$", "content", "=", "''", ")", "{", "$", "folder", "=", "dirname", "(", "$", "file", ")", ";", "if", "(", "!", "is_dir", "(", "$", "folder", ")", ")", "{", "self", "::", "creat...
创建文件 @param unknown_type $file 文件名 @param string $content 文件内容
[ "创建文件" ]
train
https://github.com/wisp-x/hopephp/blob/5d4ec0fdb847772783259c16c97e9843b81df3c9/hopephp/library/hope/File.php#L160-L168
JustBlackBird/handlebars.php-helpers
src/Text/ReplaceHelper.php
ReplaceHelper.execute
public function execute(Template $template, Context $context, $args, $source) { $parsed_args = $template->parseArguments($args); if (count($parsed_args) != 2) { throw new \InvalidArgumentException( '"replace" helper expects exactly two arguments.' ); } $search = $context->get($parsed_args[0]); $replacement = $context->get($parsed_args[1]); $subject = (string)$template->render($context); return str_replace($search, $replacement, $subject); }
php
public function execute(Template $template, Context $context, $args, $source) { $parsed_args = $template->parseArguments($args); if (count($parsed_args) != 2) { throw new \InvalidArgumentException( '"replace" helper expects exactly two arguments.' ); } $search = $context->get($parsed_args[0]); $replacement = $context->get($parsed_args[1]); $subject = (string)$template->render($context); return str_replace($search, $replacement, $subject); }
[ "public", "function", "execute", "(", "Template", "$", "template", ",", "Context", "$", "context", ",", "$", "args", ",", "$", "source", ")", "{", "$", "parsed_args", "=", "$", "template", "->", "parseArguments", "(", "$", "args", ")", ";", "if", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/JustBlackBird/handlebars.php-helpers/blob/0971d1567d146dc0ba0e455d50d5db3462375261/src/Text/ReplaceHelper.php#L36-L50
vinterskogen/laravel-uploaded-image
src/UploadedImage.php
UploadedImage.getAdvancedUploadedImage
private function getAdvancedUploadedImage() { if (! isset($this->advancedUplodedImage)) { $this->advancedUplodedImage = $this->makeAdvancedUploadedImage(); } return $this->advancedUplodedImage; }
php
private function getAdvancedUploadedImage() { if (! isset($this->advancedUplodedImage)) { $this->advancedUplodedImage = $this->makeAdvancedUploadedImage(); } return $this->advancedUplodedImage; }
[ "private", "function", "getAdvancedUploadedImage", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "advancedUplodedImage", ")", ")", "{", "$", "this", "->", "advancedUplodedImage", "=", "$", "this", "->", "makeAdvancedUploadedImage", "(", ")", ...
Get AdvancedUploadedImage instance, that points the same (real) temporary file, as this uploaded image. @return \Vinterskogen\UploadedImage\AdvancedUploadedImage
[ "Get", "AdvancedUploadedImage", "instance", "that", "points", "the", "same", "(", "real", ")", "temporary", "file", "as", "this", "uploaded", "image", "." ]
train
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/UploadedImage.php#L96-L103
vinterskogen/laravel-uploaded-image
src/UploadedImage.php
UploadedImage.getInterventionImage
public function getInterventionImage() { if (! isset($this->interventionImage)) { $this->interventionImage = $this->makeInterventionImage(); } return $this->interventionImage; }
php
public function getInterventionImage() { if (! isset($this->interventionImage)) { $this->interventionImage = $this->makeInterventionImage(); } return $this->interventionImage; }
[ "public", "function", "getInterventionImage", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "interventionImage", ")", ")", "{", "$", "this", "->", "interventionImage", "=", "$", "this", "->", "makeInterventionImage", "(", ")", ";", "}", ...
Get InterventionImage instance, that points the same (real) temporary file, as this uploaded image. @return \Intervention\Image\Image
[ "Get", "InterventionImage", "instance", "that", "points", "the", "same", "(", "real", ")", "temporary", "file", "as", "this", "uploaded", "image", "." ]
train
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/UploadedImage.php#L121-L128
notthatbad/silverstripe-rest-api
code/controllers/BaseRestController.php
BaseRestController.handleAction
protected function handleAction($request, $action) { foreach($request->latestParams() as $k => $v) { if($v || !isset($this->urlParams[$k])) $this->urlParams[$k] = $v; } // set the action to the request method / for developing we could use an additional parameter to choose another method $action = $this->getMethodName($request); $this->action = $action; $this->requestParams = $request->requestVars(); $className = $this->class; // create serializer $serializer = SerializerFactory::create_from_request($request); $response = $this->getResponse(); // perform action try { if(!$this->hasAction($action)) { // method couldn't found on controller throw new RestUserException("Action '$action' isn't available on class $className.", 404); } if(!$this->checkAccessAction($action)) { throw new RestUserException("Action '$action' isn't allowed on class $className.", 404, 401); } $actionResult = null; if(method_exists($this, 'beforeCallActionHandler')) { // call before action hook $actionResult = $this->beforeCallActionHandler($request, $action); } // if action hook contains data it will be used as result, otherwise the action handler will be called if(!$actionResult) { // perform action $actionResult = $this->$action($request); } $body = $actionResult; } catch(RestUserException $ex) { // a user exception was caught $response->setStatusCode($ex->getHttpStatusCode()); $body = [ 'message' => $ex->getMessage(), 'code' => $ex->getCode() ]; // log all data SS_Log::log( json_encode(array_merge($body, ['file' => $ex->getFile(), 'line' => $ex->getLine()])), SS_Log::INFO); } catch(RestSystemException $ex) { // a system exception was caught $response->addHeader('Content-Type', $serializer->contentType()); $response->setStatusCode($ex->getHttpStatusCode()); $body = [ 'message' => $ex->getMessage(), 'code' => $ex->getCode() ]; if(Director::isDev()) { $body = array_merge($body, [ 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace() ]); } // log all data SS_Log::log( json_encode(array_merge($body, ['file' => $ex->getFile(), 'line' => $ex->getLine()])), SS_Log::WARN); } catch(Exception $ex) { // an unexpected exception was caught $response->addHeader('Content-Type', $serializer->contentType()); $response->setStatusCode("500"); $body = [ 'message' => $ex->getMessage(), 'code' => $ex->getCode() ]; if(Director::isDev()) { $body = array_merge($body, [ 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace() ]); } // log all data and the trace to get a better understanding of the exception SS_Log::log( json_encode(array_merge( $body, ['file' => $ex->getFile(), 'line' => $ex->getLine(),'trace' => $ex->getTrace()])), SS_Log::ERR); } // serialize content and set body of response $response->addHeader('Content-Type', $serializer->contentType()); // TODO: body could be an exception; check it before the response is generated $response->setBody($serializer->serialize($body)); // set CORS header from config $response = $this->addCORSHeaders($response); return $response; }
php
protected function handleAction($request, $action) { foreach($request->latestParams() as $k => $v) { if($v || !isset($this->urlParams[$k])) $this->urlParams[$k] = $v; } // set the action to the request method / for developing we could use an additional parameter to choose another method $action = $this->getMethodName($request); $this->action = $action; $this->requestParams = $request->requestVars(); $className = $this->class; // create serializer $serializer = SerializerFactory::create_from_request($request); $response = $this->getResponse(); // perform action try { if(!$this->hasAction($action)) { // method couldn't found on controller throw new RestUserException("Action '$action' isn't available on class $className.", 404); } if(!$this->checkAccessAction($action)) { throw new RestUserException("Action '$action' isn't allowed on class $className.", 404, 401); } $actionResult = null; if(method_exists($this, 'beforeCallActionHandler')) { // call before action hook $actionResult = $this->beforeCallActionHandler($request, $action); } // if action hook contains data it will be used as result, otherwise the action handler will be called if(!$actionResult) { // perform action $actionResult = $this->$action($request); } $body = $actionResult; } catch(RestUserException $ex) { // a user exception was caught $response->setStatusCode($ex->getHttpStatusCode()); $body = [ 'message' => $ex->getMessage(), 'code' => $ex->getCode() ]; // log all data SS_Log::log( json_encode(array_merge($body, ['file' => $ex->getFile(), 'line' => $ex->getLine()])), SS_Log::INFO); } catch(RestSystemException $ex) { // a system exception was caught $response->addHeader('Content-Type', $serializer->contentType()); $response->setStatusCode($ex->getHttpStatusCode()); $body = [ 'message' => $ex->getMessage(), 'code' => $ex->getCode() ]; if(Director::isDev()) { $body = array_merge($body, [ 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace() ]); } // log all data SS_Log::log( json_encode(array_merge($body, ['file' => $ex->getFile(), 'line' => $ex->getLine()])), SS_Log::WARN); } catch(Exception $ex) { // an unexpected exception was caught $response->addHeader('Content-Type', $serializer->contentType()); $response->setStatusCode("500"); $body = [ 'message' => $ex->getMessage(), 'code' => $ex->getCode() ]; if(Director::isDev()) { $body = array_merge($body, [ 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace() ]); } // log all data and the trace to get a better understanding of the exception SS_Log::log( json_encode(array_merge( $body, ['file' => $ex->getFile(), 'line' => $ex->getLine(),'trace' => $ex->getTrace()])), SS_Log::ERR); } // serialize content and set body of response $response->addHeader('Content-Type', $serializer->contentType()); // TODO: body could be an exception; check it before the response is generated $response->setBody($serializer->serialize($body)); // set CORS header from config $response = $this->addCORSHeaders($response); return $response; }
[ "protected", "function", "handleAction", "(", "$", "request", ",", "$", "action", ")", "{", "foreach", "(", "$", "request", "->", "latestParams", "(", ")", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "||", "!", "isset", "(", "$...
handleAction implementation for rest controllers. This handles the requested action differently then the standard implementation. @param SS_HTTPRequest $request @param string $action @return HTMLText|SS_HTTPResponse
[ "handleAction", "implementation", "for", "rest", "controllers", ".", "This", "handles", "the", "requested", "action", "differently", "then", "the", "standard", "implementation", "." ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/controllers/BaseRestController.php#L80-L170
notthatbad/silverstripe-rest-api
code/controllers/BaseRestController.php
BaseRestController.getMethodName
private function getMethodName($request) { $method = ''; if(Director::isDev() && ($varMethod = $request->getVar('method'))) { if(in_array(strtoupper($varMethod), ['GET','POST','PUT','DELETE','HEAD', 'PATCH'])) { $method = $varMethod; } } else { $method = $request->httpMethod(); } return strtolower($method); }
php
private function getMethodName($request) { $method = ''; if(Director::isDev() && ($varMethod = $request->getVar('method'))) { if(in_array(strtoupper($varMethod), ['GET','POST','PUT','DELETE','HEAD', 'PATCH'])) { $method = $varMethod; } } else { $method = $request->httpMethod(); } return strtolower($method); }
[ "private", "function", "getMethodName", "(", "$", "request", ")", "{", "$", "method", "=", "''", ";", "if", "(", "Director", "::", "isDev", "(", ")", "&&", "(", "$", "varMethod", "=", "$", "request", "->", "getVar", "(", "'method'", ")", ")", ")", ...
Returns the http method for this request. If the current environment is a development env, the method can be changed with a `method` variable. @param \SS_HTTPRequest $request the current request @return string the used http method as string
[ "Returns", "the", "http", "method", "for", "this", "request", ".", "If", "the", "current", "environment", "is", "a", "development", "env", "the", "method", "can", "be", "changed", "with", "a", "method", "variable", "." ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/controllers/BaseRestController.php#L179-L189
notthatbad/silverstripe-rest-api
code/controllers/BaseRestController.php
BaseRestController.isAdmin
protected function isAdmin() { $member = $this->currentUser(); return $member && \Injector::inst()->get('PermissionChecks')->isAdmin($member); }
php
protected function isAdmin() { $member = $this->currentUser(); return $member && \Injector::inst()->get('PermissionChecks')->isAdmin($member); }
[ "protected", "function", "isAdmin", "(", ")", "{", "$", "member", "=", "$", "this", "->", "currentUser", "(", ")", ";", "return", "$", "member", "&&", "\\", "Injector", "::", "inst", "(", ")", "->", "get", "(", "'PermissionChecks'", ")", "->", "isAdmin...
Check if the user has admin privileges. @return bool @throws RestSystemException
[ "Check", "if", "the", "user", "has", "admin", "privileges", "." ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/controllers/BaseRestController.php#L206-L209
CampaignChain/core
Controller/CampaignController.php
CampaignController.moveApiAction
public function moveApiAction(Request $request) { $serializer = $this->get('campaignchain.core.serializer.default'); $responseData = array(); $id = $request->request->get('id'); // Is this a campaign with interval? if($request->request->has('start_date')) { try { $newStartDate = new \DateTime($request->request->get('start_date')); } catch(\Exception $e){ return $this->apiErrorResponse($e->getMessage()); } } else { return $this->apiErrorResponse( 'Please provide a date time value for start_date' ); } $newStartDate = DateTimeUtil::roundMinutes( $newStartDate, $this->getParameter('campaignchain_core.scheduler.interval') ); /** @var CampaignService $campaignService */ $campaignService = $this->get('campaignchain.core.campaign'); /** @var Campaign $campaign */ $campaign = $campaignService->getCampaign($id); // Preserve old campaign data for response. $responseData['campaign']['id'] = $campaign->getId(); if(!$campaign->getInterval()) { $oldStartDate = clone $campaign->getStartDate(); $responseData['campaign']['old_start_date'] = $oldStartDate->format(\DateTime::ISO8601); $responseData['campaign']['old_end_date'] = $campaign->getEndDate()->format(\DateTime::ISO8601); } else { $responseData['campaign']['old_interval_start_date'] = $campaign->getIntervalStartDate()->format(\DateTime::ISO8601); $responseData['campaign']['old_interval_next_run'] = $campaign->getIntervalNextRun()->format(\DateTime::ISO8601); if($campaign->getIntervalEndDate()){ $responseData['campaign']['old_interval_end_date'] = $campaign->getIntervalEndDate()->format(\DateTime::ISO8601); } } // Move campaign's start date. $campaign = $campaignService->moveCampaign($campaign, $newStartDate); // Add new campaign dates to response. if(!$campaign->getInterval()) { $responseData['campaign']['new_start_date'] = $campaign->getStartDate()->format(\DateTime::ISO8601); $responseData['campaign']['new_end_date'] = $campaign->getEndDate()->format(\DateTime::ISO8601); } else { $responseData['campaign']['new_interval_start_date'] = $campaign->getIntervalStartDate()->format(\DateTime::ISO8601); $responseData['campaign']['new_interval_next_run'] = $campaign->getIntervalNextRun()->format(\DateTime::ISO8601); if($campaign->getIntervalEndDate()){ $responseData['campaign']['new_interval_end_date'] = $campaign->getIntervalEndDate()->format(\DateTime::ISO8601); } } return new Response($serializer->serialize($responseData, 'json')); }
php
public function moveApiAction(Request $request) { $serializer = $this->get('campaignchain.core.serializer.default'); $responseData = array(); $id = $request->request->get('id'); // Is this a campaign with interval? if($request->request->has('start_date')) { try { $newStartDate = new \DateTime($request->request->get('start_date')); } catch(\Exception $e){ return $this->apiErrorResponse($e->getMessage()); } } else { return $this->apiErrorResponse( 'Please provide a date time value for start_date' ); } $newStartDate = DateTimeUtil::roundMinutes( $newStartDate, $this->getParameter('campaignchain_core.scheduler.interval') ); /** @var CampaignService $campaignService */ $campaignService = $this->get('campaignchain.core.campaign'); /** @var Campaign $campaign */ $campaign = $campaignService->getCampaign($id); // Preserve old campaign data for response. $responseData['campaign']['id'] = $campaign->getId(); if(!$campaign->getInterval()) { $oldStartDate = clone $campaign->getStartDate(); $responseData['campaign']['old_start_date'] = $oldStartDate->format(\DateTime::ISO8601); $responseData['campaign']['old_end_date'] = $campaign->getEndDate()->format(\DateTime::ISO8601); } else { $responseData['campaign']['old_interval_start_date'] = $campaign->getIntervalStartDate()->format(\DateTime::ISO8601); $responseData['campaign']['old_interval_next_run'] = $campaign->getIntervalNextRun()->format(\DateTime::ISO8601); if($campaign->getIntervalEndDate()){ $responseData['campaign']['old_interval_end_date'] = $campaign->getIntervalEndDate()->format(\DateTime::ISO8601); } } // Move campaign's start date. $campaign = $campaignService->moveCampaign($campaign, $newStartDate); // Add new campaign dates to response. if(!$campaign->getInterval()) { $responseData['campaign']['new_start_date'] = $campaign->getStartDate()->format(\DateTime::ISO8601); $responseData['campaign']['new_end_date'] = $campaign->getEndDate()->format(\DateTime::ISO8601); } else { $responseData['campaign']['new_interval_start_date'] = $campaign->getIntervalStartDate()->format(\DateTime::ISO8601); $responseData['campaign']['new_interval_next_run'] = $campaign->getIntervalNextRun()->format(\DateTime::ISO8601); if($campaign->getIntervalEndDate()){ $responseData['campaign']['new_interval_end_date'] = $campaign->getIntervalEndDate()->format(\DateTime::ISO8601); } } return new Response($serializer->serialize($responseData, 'json')); }
[ "public", "function", "moveApiAction", "(", "Request", "$", "request", ")", "{", "$", "serializer", "=", "$", "this", "->", "get", "(", "'campaignchain.core.serializer.default'", ")", ";", "$", "responseData", "=", "array", "(", ")", ";", "$", "id", "=", "...
Move a Campaign to a new start date. @ApiDoc( section = "Core", views = { "private" }, requirements={ { "name"="id", "description" = "Campaign ID", "requirement"="\d+" }, { "name"="start_date", "description" = "Start date in ISO8601 format", "requirement"="/(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})[+-](\d{2})\:(\d{2})/" } } ) @param Request $request @return Response
[ "Move", "a", "Campaign", "to", "a", "new", "start", "date", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/CampaignController.php#L136-L197
CampaignChain/core
Controller/CampaignController.php
CampaignController.getNestedCampaignsForTimelineApiAction
public function getNestedCampaignsForTimelineApiAction(Request $request, $id) { $responseData = array(); /** @var CampaignService $campaignService */ $campaignService = $this->get('campaignchain.core.campaign'); /** @var Campaign $campaign */ $campaign = $campaignService->getCampaign($id); $ganttService = $this->get('campaignchain.core.model.dhtmlxgantt'); $serializer = $this->get('campaignchain.core.serializer.default'); return new Response($serializer->serialize( $ganttService->getCampaignWithChildren($campaign), 'json')); }
php
public function getNestedCampaignsForTimelineApiAction(Request $request, $id) { $responseData = array(); /** @var CampaignService $campaignService */ $campaignService = $this->get('campaignchain.core.campaign'); /** @var Campaign $campaign */ $campaign = $campaignService->getCampaign($id); $ganttService = $this->get('campaignchain.core.model.dhtmlxgantt'); $serializer = $this->get('campaignchain.core.serializer.default'); return new Response($serializer->serialize( $ganttService->getCampaignWithChildren($campaign), 'json')); }
[ "public", "function", "getNestedCampaignsForTimelineApiAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "responseData", "=", "array", "(", ")", ";", "/** @var CampaignService $campaignService */", "$", "campaignService", "=", "$", "this", "->"...
Returns a Campaign with its children (e.g. repeating campaign). @ApiDoc( section = "Core", views = { "private" }, requirements={ { "name"="id", "requirement"="\d+" } } ) @param Request $request @param $id Campaign ID @return Response
[ "Returns", "a", "Campaign", "with", "its", "children", "(", "e", ".", "g", ".", "repeating", "campaign", ")", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/CampaignController.php#L217-L232
opus-online/yii2-payment
lib/helpers/PaymentHelper.php
PaymentHelper.generateReference
public static function generateReference($transactionId) { $multipliers = array(7, 3, 1); $sum = 0; $multiplier = 0; $reference = (string)$transactionId; for ($digitPosition = strlen($reference) - 1; $digitPosition >= 0; $digitPosition--) { $digit = $reference{$digitPosition}; if (!is_numeric($digit)) { continue; } $digit = (int)$digit; $sum += $digit * $multipliers[$multiplier]; $multiplier = ($multiplier == 2) ? 0 : $multiplier + 1; } // Get the difference to the next highest ten $nextTen = (((int)($sum / 10)) + 1) * 10; $checkDigit = $nextTen - $sum; if ($checkDigit == 10) { $checkDigit = 0; } return (string)$transactionId . $checkDigit; }
php
public static function generateReference($transactionId) { $multipliers = array(7, 3, 1); $sum = 0; $multiplier = 0; $reference = (string)$transactionId; for ($digitPosition = strlen($reference) - 1; $digitPosition >= 0; $digitPosition--) { $digit = $reference{$digitPosition}; if (!is_numeric($digit)) { continue; } $digit = (int)$digit; $sum += $digit * $multipliers[$multiplier]; $multiplier = ($multiplier == 2) ? 0 : $multiplier + 1; } // Get the difference to the next highest ten $nextTen = (((int)($sum / 10)) + 1) * 10; $checkDigit = $nextTen - $sum; if ($checkDigit == 10) { $checkDigit = 0; } return (string)$transactionId . $checkDigit; }
[ "public", "static", "function", "generateReference", "(", "$", "transactionId", ")", "{", "$", "multipliers", "=", "array", "(", "7", ",", "3", ",", "1", ")", ";", "$", "sum", "=", "0", ";", "$", "multiplier", "=", "0", ";", "$", "reference", "=", ...
Generate a standard reference number Code borrowed from http://trac.midgard-project.org/browser/branches/branch-2_6/src/net.nemein.payment/handler/nordea.php?rev=14963 @author The Midgard Project, http://www.midgard-project.org @param int $transactionId @return string
[ "Generate", "a", "standard", "reference", "number", "Code", "borrowed", "from", "http", ":", "//", "trac", ".", "midgard", "-", "project", ".", "org", "/", "browser", "/", "branches", "/", "branch", "-", "2_6", "/", "src", "/", "net", ".", "nemein", "....
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/helpers/PaymentHelper.php#L27-L49
CampaignChain/core
Entity/OperationModule.php
OperationModule.addOperation
public function addOperation(\CampaignChain\CoreBundle\Entity\Operation $operations) { $this->operations[] = $operations; return $this; }
php
public function addOperation(\CampaignChain\CoreBundle\Entity\Operation $operations) { $this->operations[] = $operations; return $this; }
[ "public", "function", "addOperation", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Operation", "$", "operations", ")", "{", "$", "this", "->", "operations", "[", "]", "=", "$", "operations", ";", "return", "$", "this", ";", "}" ]
Add operations @param \CampaignChain\CoreBundle\Entity\Operation $operations @return OperationModule
[ "Add", "operations" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/OperationModule.php#L38-L43
CampaignChain/core
Entity/OperationModule.php
OperationModule.removeOperation
public function removeOperation(\CampaignChain\CoreBundle\Entity\Operation $operations) { $this->operations->removeElement($operations); }
php
public function removeOperation(\CampaignChain\CoreBundle\Entity\Operation $operations) { $this->operations->removeElement($operations); }
[ "public", "function", "removeOperation", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Operation", "$", "operations", ")", "{", "$", "this", "->", "operations", "->", "removeElement", "(", "$", "operations", ")", ";", "}" ]
Remove operations @param \CampaignChain\CoreBundle\Entity\Operation $operations
[ "Remove", "operations" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/OperationModule.php#L50-L53
gorriecoe/silverstripe-menu
src/models/MenuLink.php
MenuLink.getCMSFields
public function getCMSFields() { $fields = parent::getCMSFields(); if (!$this->isAllowedChildren()) { return $fields; } $fields->addFieldsToTab( 'Root.' . _t(__CLASS__ . '.CHILDREN', 'Children'), [ GridField::create( 'Children', _t(__CLASS__ . '.CHILDREN', 'Children'), $this->Children(), GridFieldConfig_RecordEditor::create() ->addComponent(new GridFieldOrderableRows()) ) ] ); return $fields; }
php
public function getCMSFields() { $fields = parent::getCMSFields(); if (!$this->isAllowedChildren()) { return $fields; } $fields->addFieldsToTab( 'Root.' . _t(__CLASS__ . '.CHILDREN', 'Children'), [ GridField::create( 'Children', _t(__CLASS__ . '.CHILDREN', 'Children'), $this->Children(), GridFieldConfig_RecordEditor::create() ->addComponent(new GridFieldOrderableRows()) ) ] ); return $fields; }
[ "public", "function", "getCMSFields", "(", ")", "{", "$", "fields", "=", "parent", "::", "getCMSFields", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isAllowedChildren", "(", ")", ")", "{", "return", "$", "fields", ";", "}", "$", "fields", "->"...
CMS Fields @return FieldList
[ "CMS", "Fields" ]
train
https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/models/MenuLink.php#L87-L107
gorriecoe/silverstripe-menu
src/models/MenuLink.php
MenuLink.onAfterWrite
public function onAfterWrite() { parent::onAfterWrite(); if ($this->ParentID > 0) { $this->MenuSetID = $this->Parent()->MenuSetID; } }
php
public function onAfterWrite() { parent::onAfterWrite(); if ($this->ParentID > 0) { $this->MenuSetID = $this->Parent()->MenuSetID; } }
[ "public", "function", "onAfterWrite", "(", ")", "{", "parent", "::", "onAfterWrite", "(", ")", ";", "if", "(", "$", "this", "->", "ParentID", ">", "0", ")", "{", "$", "this", "->", "MenuSetID", "=", "$", "this", "->", "Parent", "(", ")", "->", "Men...
Event handler called after writing to the database.
[ "Event", "handler", "called", "after", "writing", "to", "the", "database", "." ]
train
https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/models/MenuLink.php#L112-L118
gorriecoe/silverstripe-menu
src/models/MenuLink.php
MenuLink.canCreate
public function canCreate($member = null, $context = []) { if (isset($context['Parent'])) { return $context['Parent']->canEdit(); } return $this->MenuSet()->canEdit(); }
php
public function canCreate($member = null, $context = []) { if (isset($context['Parent'])) { return $context['Parent']->canEdit(); } return $this->MenuSet()->canEdit(); }
[ "public", "function", "canCreate", "(", "$", "member", "=", "null", ",", "$", "context", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "context", "[", "'Parent'", "]", ")", ")", "{", "return", "$", "context", "[", "'Parent'", "]", "->", ...
DataObject create permissions @param Member $member @param array $context Additional context-specific data which might affect whether (or where) this object could be created. @return boolean
[ "DataObject", "create", "permissions" ]
train
https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/models/MenuLink.php#L187-L193
rocketeers/rocketeer-laravel
src/Strategies/Framework/LaravelStrategy.php
LaravelStrategy.processCommand
public function processCommand($command) { // Add environment flag to commands $stage = $this->connections->getCurrentConnectionKey()->stage; if (Str::contains($command, 'artisan') && $stage) { $command .= ' --env="'.$stage.'"'; } return $command; }
php
public function processCommand($command) { // Add environment flag to commands $stage = $this->connections->getCurrentConnectionKey()->stage; if (Str::contains($command, 'artisan') && $stage) { $command .= ' --env="'.$stage.'"'; } return $command; }
[ "public", "function", "processCommand", "(", "$", "command", ")", "{", "// Add environment flag to commands", "$", "stage", "=", "$", "this", "->", "connections", "->", "getCurrentConnectionKey", "(", ")", "->", "stage", ";", "if", "(", "Str", "::", "contains", ...
Apply modifiers to some commands before they're executed @param string $command @return string
[ "Apply", "modifiers", "to", "some", "commands", "before", "they", "re", "executed" ]
train
https://github.com/rocketeers/rocketeer-laravel/blob/8ae4d95795f9a439c36e0e10a95c7480946b4bad/src/Strategies/Framework/LaravelStrategy.php#L28-L37
vinterskogen/laravel-uploaded-image
src/Concerns/SavesBeforeStoring.php
SavesBeforeStoring.storeAs
public function storeAs($path, $name, $options = []) { if ($this->isModified()) { $this->save(); } return parent::storeAs($path, $name, $options); }
php
public function storeAs($path, $name, $options = []) { if ($this->isModified()) { $this->save(); } return parent::storeAs($path, $name, $options); }
[ "public", "function", "storeAs", "(", "$", "path", ",", "$", "name", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isModified", "(", ")", ")", "{", "$", "this", "->", "save", "(", ")", ";", "}", "return", "parent"...
Store the uploaded file on a filesystem disk. @param string $path @param string $name @param array|string $options @return string|false
[ "Store", "the", "uploaded", "file", "on", "a", "filesystem", "disk", "." ]
train
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/Concerns/SavesBeforeStoring.php#L15-L22
malenkiki/aleavatar
src/Malenki/Aleavatar/Aleavatar.php
Aleavatar.generate
public function generate($size = self::SIZE) { $this->size = $size; $str_base = ''; // take 1 chars on 2 foreach (str_split($this->seed->hash) as $k => $c) { if ($k % 2 == 1) { $str_base .= $c; } } $arr_base = str_split($str_base, 2); $arr_order = $this->getFillOrder(hexdec($arr_base[7][0])); $bool_rotate_way = hexdec($arr_base[7][1]) <= 8; $q = new Quarter(Quarter::TOP_LEFT, $bool_rotate_way); $color_bg = new Primitive\Color('FFFFFF'); $color_fg = new Primitive\Color($arr_base[4].$arr_base[5].$arr_base[6]); $this->arr_colors[0] = $color_bg; $this->arr_colors[1] = $color_fg; foreach ($arr_order as $o) { list($rank1, $rank2) = str_split($arr_base[$o - 1]); $u = new Unit(); $u->background($color_bg); $u->foreground($color_fg); $u->generate(hexdec($rank1), hexdec($rank2)); $q->add($u); } // OK, first quarter is filled, so, let’s create the others! $this->arr_quarters[] = $q; $this->arr_quarters[] = $q->tr(); $this->arr_quarters[] = $q->br(); $this->arr_quarters[] = $q->bl(); return $this; }
php
public function generate($size = self::SIZE) { $this->size = $size; $str_base = ''; // take 1 chars on 2 foreach (str_split($this->seed->hash) as $k => $c) { if ($k % 2 == 1) { $str_base .= $c; } } $arr_base = str_split($str_base, 2); $arr_order = $this->getFillOrder(hexdec($arr_base[7][0])); $bool_rotate_way = hexdec($arr_base[7][1]) <= 8; $q = new Quarter(Quarter::TOP_LEFT, $bool_rotate_way); $color_bg = new Primitive\Color('FFFFFF'); $color_fg = new Primitive\Color($arr_base[4].$arr_base[5].$arr_base[6]); $this->arr_colors[0] = $color_bg; $this->arr_colors[1] = $color_fg; foreach ($arr_order as $o) { list($rank1, $rank2) = str_split($arr_base[$o - 1]); $u = new Unit(); $u->background($color_bg); $u->foreground($color_fg); $u->generate(hexdec($rank1), hexdec($rank2)); $q->add($u); } // OK, first quarter is filled, so, let’s create the others! $this->arr_quarters[] = $q; $this->arr_quarters[] = $q->tr(); $this->arr_quarters[] = $q->br(); $this->arr_quarters[] = $q->bl(); return $this; }
[ "public", "function", "generate", "(", "$", "size", "=", "self", "::", "SIZE", ")", "{", "$", "this", "->", "size", "=", "$", "size", ";", "$", "str_base", "=", "''", ";", "// take 1 chars on 2", "foreach", "(", "str_split", "(", "$", "this", "->", "...
Generate identicon internally. No image yet, but units are chosen, the way to place them and how to rotate quarters too. The color is fixed, and an optional size can be set here. If not set, the size will be 128 px. @param integer $size Size in pixels of the identicon @access public @return Aleavatar
[ "Generate", "identicon", "internally", "." ]
train
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Aleavatar.php#L186-L230
malenkiki/aleavatar
src/Malenki/Aleavatar/Aleavatar.php
Aleavatar.mapSvg
public static function mapSvg($bool_for_html5 = false) { $background = new Primitive\Color('FFFFFF'); $foreground = new Primitive\Color('000000'); $arr_out = array(); if (!$bool_for_html5) { $arr_out[] = '<?xml version="1.0" encoding="utf-8"?>'; } $arr_out[] = sprintf('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%1$d" height="%1$d">', 16 * Unit::SIZE); $arr_out[] = '<title>All available units to create identicons</title>'; $arr_out[] = '<desc>To learn more about this identicons, please visit https://github.com/malenkiki/aleavatar</desc>'; foreach (range(0, 15) as $row) { foreach (range(0, 15) as $col) { $u = new Unit(); $u->background($background); $u->foreground($foreground); try { $u->generate($row, $col); $arr_out[] = sprintf( '<g transform="translate(%d, %d)">%s</g>', $col * Unit::SIZE, $row * Unit::SIZE, $u->svg() ); } catch (\Exception $e) { echo $e->getMessage() . "\n"; } } } $arr_out[] = '</svg>'; return implode("\n", $arr_out); }
php
public static function mapSvg($bool_for_html5 = false) { $background = new Primitive\Color('FFFFFF'); $foreground = new Primitive\Color('000000'); $arr_out = array(); if (!$bool_for_html5) { $arr_out[] = '<?xml version="1.0" encoding="utf-8"?>'; } $arr_out[] = sprintf('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%1$d" height="%1$d">', 16 * Unit::SIZE); $arr_out[] = '<title>All available units to create identicons</title>'; $arr_out[] = '<desc>To learn more about this identicons, please visit https://github.com/malenkiki/aleavatar</desc>'; foreach (range(0, 15) as $row) { foreach (range(0, 15) as $col) { $u = new Unit(); $u->background($background); $u->foreground($foreground); try { $u->generate($row, $col); $arr_out[] = sprintf( '<g transform="translate(%d, %d)">%s</g>', $col * Unit::SIZE, $row * Unit::SIZE, $u->svg() ); } catch (\Exception $e) { echo $e->getMessage() . "\n"; } } } $arr_out[] = '</svg>'; return implode("\n", $arr_out); }
[ "public", "static", "function", "mapSvg", "(", "$", "bool_for_html5", "=", "false", ")", "{", "$", "background", "=", "new", "Primitive", "\\", "Color", "(", "'FFFFFF'", ")", ";", "$", "foreground", "=", "new", "Primitive", "\\", "Color", "(", "'000000'", ...
Output SVG map of all available units. Image output is a square of 16 × 16 units. @param boolean $bool_for_html5 If true, output SVG string ready to be included into HTML5 document (without XML header) @static @access public @return string
[ "Output", "SVG", "map", "of", "all", "available", "units", "." ]
train
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Aleavatar.php#L242-L280
malenkiki/aleavatar
src/Malenki/Aleavatar/Aleavatar.php
Aleavatar.svg
public function svg($str_filename = null) { $str_svg = $this->svgForHtml5(); $str_svg = '<?xml version="1.0" encoding="utf-8"?>'. "\n". $str_svg; if (!is_null($str_filename)) { file_put_contents($str_filename, $str_svg); } return $str_svg; }
php
public function svg($str_filename = null) { $str_svg = $this->svgForHtml5(); $str_svg = '<?xml version="1.0" encoding="utf-8"?>'. "\n". $str_svg; if (!is_null($str_filename)) { file_put_contents($str_filename, $str_svg); } return $str_svg; }
[ "public", "function", "svg", "(", "$", "str_filename", "=", "null", ")", "{", "$", "str_svg", "=", "$", "this", "->", "svgForHtml5", "(", ")", ";", "$", "str_svg", "=", "'<?xml version=\"1.0\" encoding=\"utf-8\"?>'", ".", "\"\\n\"", ".", "$", "str_svg", ";",...
Outputs identicon has SVG string, to be used standalone. This can create a file too, but in all case output SVG with XML header. @param string $str_filename Filename where to store it @access public @return string SVG code
[ "Outputs", "identicon", "has", "SVG", "string", "to", "be", "used", "standalone", "." ]
train
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Aleavatar.php#L445-L455
malenkiki/aleavatar
src/Malenki/Aleavatar/Aleavatar.php
Aleavatar.svgForHtml5
public function svgForHtml5() { $arr_svg = array(); $arr_svg[] = sprintf('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%1$d" height="%1$d">', $this->size); $arr_svg[] = sprintf('<title>Identicon of %s</title>', $this->seed->str); $arr_svg[] = sprintf('<desc>The hash string used to generate this identicon is %s.</desc>', $this->seed->hash); $arr_svg[] = sprintf( '<g transform="scale(%f)">', $this->size / self::SIZE ); foreach ($this->arr_quarters as $k => $q) { $arr_svg[] = $q->svg(); } $arr_svg[] = '</g>'; $arr_svg[] = '</svg>'; $str_svg = implode("\n", $arr_svg); return $str_svg; }
php
public function svgForHtml5() { $arr_svg = array(); $arr_svg[] = sprintf('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%1$d" height="%1$d">', $this->size); $arr_svg[] = sprintf('<title>Identicon of %s</title>', $this->seed->str); $arr_svg[] = sprintf('<desc>The hash string used to generate this identicon is %s.</desc>', $this->seed->hash); $arr_svg[] = sprintf( '<g transform="scale(%f)">', $this->size / self::SIZE ); foreach ($this->arr_quarters as $k => $q) { $arr_svg[] = $q->svg(); } $arr_svg[] = '</g>'; $arr_svg[] = '</svg>'; $str_svg = implode("\n", $arr_svg); return $str_svg; }
[ "public", "function", "svgForHtml5", "(", ")", "{", "$", "arr_svg", "=", "array", "(", ")", ";", "$", "arr_svg", "[", "]", "=", "sprintf", "(", "'<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"%1$d\" height=\"%1$d\">'", ",", "$", "this", "->", "si...
Outputs SVG string to used it into HTML5 document. Generated SVG is without XML header. @access public @return string SVG code
[ "Outputs", "SVG", "string", "to", "used", "it", "into", "HTML5", "document", "." ]
train
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Aleavatar.php#L465-L486
ionux/phactor
src/BC.php
BC.add
public function add($a, $b) { return bcadd($this->bcNormalize($a), $this->bcNormalize($b)); }
php
public function add($a, $b) { return bcadd($this->bcNormalize($a), $this->bcNormalize($b)); }
[ "public", "function", "add", "(", "$", "a", ",", "$", "b", ")", "{", "return", "bcadd", "(", "$", "this", "->", "bcNormalize", "(", "$", "a", ")", ",", "$", "this", "->", "bcNormalize", "(", "$", "b", ")", ")", ";", "}" ]
Adds two arbitrary precision numbers. @param string $a The first number. @param string $b The second number. @return string
[ "Adds", "two", "arbitrary", "precision", "numbers", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L52-L55
ionux/phactor
src/BC.php
BC.mul
public function mul($a, $b) { return bcmul($this->bcNormalize($a), $this->bcNormalize($b)); }
php
public function mul($a, $b) { return bcmul($this->bcNormalize($a), $this->bcNormalize($b)); }
[ "public", "function", "mul", "(", "$", "a", ",", "$", "b", ")", "{", "return", "bcmul", "(", "$", "this", "->", "bcNormalize", "(", "$", "a", ")", ",", "$", "this", "->", "bcNormalize", "(", "$", "b", ")", ")", ";", "}" ]
Multiplies two arbitrary precision numbers. @param string $a The first number. @param string $b The second number. @return string
[ "Multiplies", "two", "arbitrary", "precision", "numbers", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L64-L67
ionux/phactor
src/BC.php
BC.div
public function div($a, $b) { return bcdiv($this->bcNormalize($a), $this->bcNormalize($b)); }
php
public function div($a, $b) { return bcdiv($this->bcNormalize($a), $this->bcNormalize($b)); }
[ "public", "function", "div", "(", "$", "a", ",", "$", "b", ")", "{", "return", "bcdiv", "(", "$", "this", "->", "bcNormalize", "(", "$", "a", ")", ",", "$", "this", "->", "bcNormalize", "(", "$", "b", ")", ")", ";", "}" ]
Divides two arbitrary precision numbers. @param string $a The first number. @param string $b The second number. @return string
[ "Divides", "two", "arbitrary", "precision", "numbers", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L76-L79
ionux/phactor
src/BC.php
BC.sub
public function sub($a, $b) { return bcsub($this->bcNormalize($a), $this->bcNormalize($b)); }
php
public function sub($a, $b) { return bcsub($this->bcNormalize($a), $this->bcNormalize($b)); }
[ "public", "function", "sub", "(", "$", "a", ",", "$", "b", ")", "{", "return", "bcsub", "(", "$", "this", "->", "bcNormalize", "(", "$", "a", ")", ",", "$", "this", "->", "bcNormalize", "(", "$", "b", ")", ")", ";", "}" ]
Subtracts two arbitrary precision numbers. @param string $a The first number. @param string $b The second number. @return string
[ "Subtracts", "two", "arbitrary", "precision", "numbers", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L88-L91
ionux/phactor
src/BC.php
BC.mod
public function mod($a, $b) { return bcmod($this->bcNormalize($a), $this->bcNormalize($b)); }
php
public function mod($a, $b) { return bcmod($this->bcNormalize($a), $this->bcNormalize($b)); }
[ "public", "function", "mod", "(", "$", "a", ",", "$", "b", ")", "{", "return", "bcmod", "(", "$", "this", "->", "bcNormalize", "(", "$", "a", ")", ",", "$", "this", "->", "bcNormalize", "(", "$", "b", ")", ")", ";", "}" ]
Calculates the modulo 'b' of 'a'. @param string $a The first number. @param string $b The second number. @return string
[ "Calculates", "the", "modulo", "b", "of", "a", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L100-L103
ionux/phactor
src/BC.php
BC.powmod
public function powmod($a, $b, $c) { return bcpowmod($this->bcNormalize($a), $this->bcNormalize($b), $this->bcNormalize($c)); }
php
public function powmod($a, $b, $c) { return bcpowmod($this->bcNormalize($a), $this->bcNormalize($b), $this->bcNormalize($c)); }
[ "public", "function", "powmod", "(", "$", "a", ",", "$", "b", ",", "$", "c", ")", "{", "return", "bcpowmod", "(", "$", "this", "->", "bcNormalize", "(", "$", "a", ")", ",", "$", "this", "->", "bcNormalize", "(", "$", "b", ")", ",", "$", "this",...
Raises an arbitrary precision number to another, reduced by a specified modulus. @param string $a The first number. @param string $b The exponent. @param string $c The modulus. @return string The result of the operation.
[ "Raises", "an", "arbitrary", "precision", "number", "to", "another", "reduced", "by", "a", "specified", "modulus", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L114-L117
ionux/phactor
src/BC.php
BC.comp
public function comp($a, $b) { return bccomp($this->bcNormalize($a), $this->bcNormalize($b)); }
php
public function comp($a, $b) { return bccomp($this->bcNormalize($a), $this->bcNormalize($b)); }
[ "public", "function", "comp", "(", "$", "a", ",", "$", "b", ")", "{", "return", "bccomp", "(", "$", "this", "->", "bcNormalize", "(", "$", "a", ")", ",", "$", "this", "->", "bcNormalize", "(", "$", "b", ")", ")", ";", "}" ]
Compares two arbitrary precision numbers. @param string $a The first number. @param string $b The second number. @return integer
[ "Compares", "two", "arbitrary", "precision", "numbers", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L126-L129
ionux/phactor
src/BC.php
BC.power
public function power($a, $b) { return bcpow($this->bcNormalize($a), $this->bcNormalize($b)); }
php
public function power($a, $b) { return bcpow($this->bcNormalize($a), $this->bcNormalize($b)); }
[ "public", "function", "power", "(", "$", "a", ",", "$", "b", ")", "{", "return", "bcpow", "(", "$", "this", "->", "bcNormalize", "(", "$", "a", ")", ",", "$", "this", "->", "bcNormalize", "(", "$", "b", ")", ")", ";", "}" ]
Raises $a to the power of $b. @param string $a The first number. @param string $b The second number. @return string
[ "Raises", "$a", "to", "the", "power", "of", "$b", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L138-L141
ionux/phactor
src/BC.php
BC.inv
public function inv($number, $modulus) { if ($this->coprime($number, $modulus) === false) { return '0'; } $a = '1'; $b = '0'; $z = '0'; $c = '0'; list($modulus, $number) = array($this->bcNormalize($modulus), $this->bcNormalize($number)); list($mod, $num) = array($modulus, $number); try { do { list($z, $c) = $this->modDiv($num, $mod); list($mod, $num) = array($z, $mod); $z = $this->subMul($a, $b, $c); list($a, $b) = array($b, $z); } while (bccomp($mod, '0') > 0); return $this->addMod($a, $modulus); } catch (\Exception $e) { throw $e; } }
php
public function inv($number, $modulus) { if ($this->coprime($number, $modulus) === false) { return '0'; } $a = '1'; $b = '0'; $z = '0'; $c = '0'; list($modulus, $number) = array($this->bcNormalize($modulus), $this->bcNormalize($number)); list($mod, $num) = array($modulus, $number); try { do { list($z, $c) = $this->modDiv($num, $mod); list($mod, $num) = array($z, $mod); $z = $this->subMul($a, $b, $c); list($a, $b) = array($b, $z); } while (bccomp($mod, '0') > 0); return $this->addMod($a, $modulus); } catch (\Exception $e) { throw $e; } }
[ "public", "function", "inv", "(", "$", "number", ",", "$", "modulus", ")", "{", "if", "(", "$", "this", "->", "coprime", "(", "$", "number", ",", "$", "modulus", ")", "===", "false", ")", "{", "return", "'0'", ";", "}", "$", "a", "=", "'1'", ";...
Binary Calculator implementation of GMP's inverse modulo function, where ax = 1(mod p). @param string $number The number to inverse modulo. @param string $modulus The modulus. @return string $a The result. @throws \Exception
[ "Binary", "Calculator", "implementation", "of", "GMP", "s", "inverse", "modulo", "function", "where", "ax", "=", "1", "(", "mod", "p", ")", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L163-L193
ionux/phactor
src/BC.php
BC.coprime
public function coprime($a, $b) { list($a, $b) = array($this->bcNormalize($a), $this->bcNormalize($b)); try { while ($this->coCompare($a, $b)) { list($a, $b) = $this->coSwitch($a, $b); } } catch (\Exception $e) { throw $e; } return (bccomp($a, '1') == 0) ? true : false; }
php
public function coprime($a, $b) { list($a, $b) = array($this->bcNormalize($a), $this->bcNormalize($b)); try { while ($this->coCompare($a, $b)) { list($a, $b) = $this->coSwitch($a, $b); } } catch (\Exception $e) { throw $e; } return (bccomp($a, '1') == 0) ? true : false; }
[ "public", "function", "coprime", "(", "$", "a", ",", "$", "b", ")", "{", "list", "(", "$", "a", ",", "$", "b", ")", "=", "array", "(", "$", "this", "->", "bcNormalize", "(", "$", "a", ")", ",", "$", "this", "->", "bcNormalize", "(", "$", "b",...
Function to determine if two numbers are co-prime according to the Euclidean algo. @param string $a First param to check. @param string $b Second param to check. @return bool Whether the params are cp. @throws \Exception
[ "Function", "to", "determine", "if", "two", "numbers", "are", "co", "-", "prime", "according", "to", "the", "Euclidean", "algo", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L204-L219
ionux/phactor
src/BC.php
BC.bcNormalize
public function bcNormalize($a) { if (is_string($a)) { $a = (substr($a, 0, 2) == '0x') ? substr($a, 2) : $a; } /** For now... switch($this->Test($a)) { case 'hex': $a = $this->convertToDec($a); break; //case 'bin': // convert to hex, dec //break; case 'unk': throw new \Exception('Unknown number type in BC::bcNormalize(). Cannot process!'); } **/ return $a; }
php
public function bcNormalize($a) { if (is_string($a)) { $a = (substr($a, 0, 2) == '0x') ? substr($a, 2) : $a; } /** For now... switch($this->Test($a)) { case 'hex': $a = $this->convertToDec($a); break; //case 'bin': // convert to hex, dec //break; case 'unk': throw new \Exception('Unknown number type in BC::bcNormalize(). Cannot process!'); } **/ return $a; }
[ "public", "function", "bcNormalize", "(", "$", "a", ")", "{", "if", "(", "is_string", "(", "$", "a", ")", ")", "{", "$", "a", "=", "(", "substr", "(", "$", "a", ",", "0", ",", "2", ")", "==", "'0x'", ")", "?", "substr", "(", "$", "a", ",", ...
BC doesn't like the '0x' hex prefix that GMP prefers. @param string $a The value to bcNormalize. @return string
[ "BC", "doesn", "t", "like", "the", "0x", "hex", "prefix", "that", "GMP", "prefers", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L227-L247
ionux/phactor
src/BC.php
BC.convertHexToDec
public function convertHexToDec($hex) { if (strlen($hex) < 5) { return hexdec($hex); } list($remain, $last) = array(substr($hex, 0, -1), substr($hex, -1)); return bcadd(bcmul('16', $this->convertHexToDec($remain)), hexdec($last)); }
php
public function convertHexToDec($hex) { if (strlen($hex) < 5) { return hexdec($hex); } list($remain, $last) = array(substr($hex, 0, -1), substr($hex, -1)); return bcadd(bcmul('16', $this->convertHexToDec($remain)), hexdec($last)); }
[ "public", "function", "convertHexToDec", "(", "$", "hex", ")", "{", "if", "(", "strlen", "(", "$", "hex", ")", "<", "5", ")", "{", "return", "hexdec", "(", "$", "hex", ")", ";", "}", "list", "(", "$", "remain", ",", "$", "last", ")", "=", "arra...
BC utility for directly converting a hexadecimal number to decimal. @param string $hex Number to convert to dec. @return array Dec form of the number.
[ "BC", "utility", "for", "directly", "converting", "a", "hexadecimal", "number", "to", "decimal", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L256-L265
ionux/phactor
src/BC.php
BC.convertDecToHex
public function convertDecToHex($dec) { if (strlen($dec) < 5) { return dechex($dec); } list($remain, $last) = array(bcdiv(bcsub($dec, $last), '16'), bcmod($dec, '16')); return ($remain == 0) ? dechex($last) : $this->convertDecToHex($remain) . dechex($last); }
php
public function convertDecToHex($dec) { if (strlen($dec) < 5) { return dechex($dec); } list($remain, $last) = array(bcdiv(bcsub($dec, $last), '16'), bcmod($dec, '16')); return ($remain == 0) ? dechex($last) : $this->convertDecToHex($remain) . dechex($last); }
[ "public", "function", "convertDecToHex", "(", "$", "dec", ")", "{", "if", "(", "strlen", "(", "$", "dec", ")", "<", "5", ")", "{", "return", "dechex", "(", "$", "dec", ")", ";", "}", "list", "(", "$", "remain", ",", "$", "last", ")", "=", "arra...
BC utility for directly converting a decimal number to hexadecimal. @param string $dec Number to convert to hex. @return string Hex form of the number.
[ "BC", "utility", "for", "directly", "converting", "a", "decimal", "number", "to", "hexadecimal", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L274-L283
ionux/phactor
src/BC.php
BC.coSwitch
public function coSwitch($a, $b) { switch (bccomp($a, $b)) { case 0: // Fall through. case -1: return array($a, bcmod($b, $a)); case 1: return array($b, bcmod($a, $b)); } }
php
public function coSwitch($a, $b) { switch (bccomp($a, $b)) { case 0: // Fall through. case -1: return array($a, bcmod($b, $a)); case 1: return array($b, bcmod($a, $b)); } }
[ "public", "function", "coSwitch", "(", "$", "a", ",", "$", "b", ")", "{", "switch", "(", "bccomp", "(", "$", "a", ",", "$", "b", ")", ")", "{", "case", "0", ":", "// Fall through.", "case", "-", "1", ":", "return", "array", "(", "$", "a", ",", ...
Compares two numbers and returns an array consisting of the smaller number & the result of the larger number % smaller. @param string $a First param to check. @param string $b Second param to check. @return array Array of smaller, larger % smaller.
[ "Compares", "two", "numbers", "and", "returns", "an", "array", "consisting", "of", "the", "smaller", "number", "&", "the", "result", "of", "the", "larger", "number", "%", "smaller", "." ]
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L294-L304
prooph/link-process-manager
src/Api/Factory/WorkflowReleaseFactory.php
WorkflowReleaseFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $resource = new WorkflowRelease(); $resource->setWorkflowFinder($serviceLocator->getServiceLocator()->get(\Prooph\Link\ProcessManager\Projection\Workflow\WorkflowFinder::class)); return $resource; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $resource = new WorkflowRelease(); $resource->setWorkflowFinder($serviceLocator->getServiceLocator()->get(\Prooph\Link\ProcessManager\Projection\Workflow\WorkflowFinder::class)); return $resource; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "resource", "=", "new", "WorkflowRelease", "(", ")", ";", "$", "resource", "->", "setWorkflowFinder", "(", "$", "serviceLocator", "->", "getServiceLocator", ...
Create service @param ServiceLocatorInterface $serviceLocator @return WorkflowRelease
[ "Create", "service" ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Api/Factory/WorkflowReleaseFactory.php#L31-L38