id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
24,000
gedex/php-janrain-api
lib/Janrain/Api/Partner/App.php
App.create
public function create(array $params) { if (!isset($params['email'])) { throw new MissingArgumentException('email'); } if (!isset($params['name'])) { throw new MissingArgumentException('name'); } if (!isset($params['domain'])) { throw new MissingArgumentException('domain'); } return $this->post('app/create', $params); }
php
public function create(array $params) { if (!isset($params['email'])) { throw new MissingArgumentException('email'); } if (!isset($params['name'])) { throw new MissingArgumentException('name'); } if (!isset($params['domain'])) { throw new MissingArgumentException('domain'); } return $this->post('app/create', $params); }
[ "public", "function", "create", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'email'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'email'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'name'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'name'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'domain'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'domain'", ")", ";", "}", "return", "$", "this", "->", "post", "(", "'app/create'", ",", "$", "params", ")", ";", "}" ]
Creates a new Engage application. @param array $params @link http://developers.janrain.com/documentation/api-methods/partner/app/create/
[ "Creates", "a", "new", "Engage", "application", "." ]
6283f68454e0ad5211ac620f1d337df38cd49597
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Partner/App.php#L47-L62
24,001
gedex/php-janrain-api
lib/Janrain/Api/Partner/App.php
App.verifyDomain
public function verifyDomain(array $params) { if (!isset($params['provider'])) { throw new MissingArgumentException('provider'); } if (!isset($params['code'])) { throw new MissingArgumentException('code'); } if (!isset($params['filename'])) { throw new MissingArgumentException('filename'); } return $this->post('app/verify_domain', $params); }
php
public function verifyDomain(array $params) { if (!isset($params['provider'])) { throw new MissingArgumentException('provider'); } if (!isset($params['code'])) { throw new MissingArgumentException('code'); } if (!isset($params['filename'])) { throw new MissingArgumentException('filename'); } return $this->post('app/verify_domain', $params); }
[ "public", "function", "verifyDomain", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'provider'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'provider'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'code'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'code'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'filename'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'filename'", ")", ";", "}", "return", "$", "this", "->", "post", "(", "'app/verify_domain'", ",", "$", "params", ")", ";", "}" ]
Automates the server-side component of the provider-specific domain verification mechanism. @param array $params
[ "Automates", "the", "server", "-", "side", "component", "of", "the", "provider", "-", "specific", "domain", "verification", "mechanism", "." ]
6283f68454e0ad5211ac620f1d337df38cd49597
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Partner/App.php#L184-L199
24,002
ezsystems/ezcomments-ls-extension
classes/ezcomcookiemanager.php
ezcomCookieManager.storeCookie
public function storeCookie( $comment = null ) { $userData = array(); $sessionID = session_id(); $currentUser = eZUser::currentUser(); if( is_null( $comment ) ) { if( $currentUser->isAnonymous() ) { return ''; } else { $userData[$sessionID] = array( 'email' => $currentUser->attribute( 'email' ), 'name' => $currentUser->contentObject()->name() ); } } else { $userData[$sessionID] = array( 'email' => $comment->attribute( 'email' ), 'website' => $comment->attribute( 'url' ), 'name' => $comment->attribute( 'name' ) ); if ( !$currentUser->isAnonymous() ) { $userData[$sessionID]['email'] = $currentUser->attribute( 'email' ); } } setcookie( 'eZCommentsUserData', base64_encode( json_encode( $userData ) ), $this->expiryTime, '/' ); return $userData; }
php
public function storeCookie( $comment = null ) { $userData = array(); $sessionID = session_id(); $currentUser = eZUser::currentUser(); if( is_null( $comment ) ) { if( $currentUser->isAnonymous() ) { return ''; } else { $userData[$sessionID] = array( 'email' => $currentUser->attribute( 'email' ), 'name' => $currentUser->contentObject()->name() ); } } else { $userData[$sessionID] = array( 'email' => $comment->attribute( 'email' ), 'website' => $comment->attribute( 'url' ), 'name' => $comment->attribute( 'name' ) ); if ( !$currentUser->isAnonymous() ) { $userData[$sessionID]['email'] = $currentUser->attribute( 'email' ); } } setcookie( 'eZCommentsUserData', base64_encode( json_encode( $userData ) ), $this->expiryTime, '/' ); return $userData; }
[ "public", "function", "storeCookie", "(", "$", "comment", "=", "null", ")", "{", "$", "userData", "=", "array", "(", ")", ";", "$", "sessionID", "=", "session_id", "(", ")", ";", "$", "currentUser", "=", "eZUser", "::", "currentUser", "(", ")", ";", "if", "(", "is_null", "(", "$", "comment", ")", ")", "{", "if", "(", "$", "currentUser", "->", "isAnonymous", "(", ")", ")", "{", "return", "''", ";", "}", "else", "{", "$", "userData", "[", "$", "sessionID", "]", "=", "array", "(", "'email'", "=>", "$", "currentUser", "->", "attribute", "(", "'email'", ")", ",", "'name'", "=>", "$", "currentUser", "->", "contentObject", "(", ")", "->", "name", "(", ")", ")", ";", "}", "}", "else", "{", "$", "userData", "[", "$", "sessionID", "]", "=", "array", "(", "'email'", "=>", "$", "comment", "->", "attribute", "(", "'email'", ")", ",", "'website'", "=>", "$", "comment", "->", "attribute", "(", "'url'", ")", ",", "'name'", "=>", "$", "comment", "->", "attribute", "(", "'name'", ")", ")", ";", "if", "(", "!", "$", "currentUser", "->", "isAnonymous", "(", ")", ")", "{", "$", "userData", "[", "$", "sessionID", "]", "[", "'email'", "]", "=", "$", "currentUser", "->", "attribute", "(", "'email'", ")", ";", "}", "}", "setcookie", "(", "'eZCommentsUserData'", ",", "base64_encode", "(", "json_encode", "(", "$", "userData", ")", ")", ",", "$", "this", "->", "expiryTime", ",", "'/'", ")", ";", "return", "$", "userData", ";", "}" ]
store data into cookie if field is null, set cookie based on user data, other wise set cookie based on fields @param $comment comment object @return arrary stored data
[ "store", "data", "into", "cookie", "if", "field", "is", "null", "set", "cookie", "based", "on", "user", "data", "other", "wise", "set", "cookie", "based", "on", "fields" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcookiemanager.php#L33-L62
24,003
Speicher210/monsum-api
src/Service/Customer/CustomerService.php
CustomerService.getCustomers
public function getCustomers(Get\RequestData $requestData = null) { $request = new Get\Request($requestData); $apiResponse = $this->sendRequest($request, Get\ApiResponse::class); /** @var Get\Response $response */ $response = $apiResponse->getResponse(); foreach ($response->getCustomers() as $customer) { if ($customer->getBirthday() instanceof \DateTime) { $customer->getBirthday()->setTime(0, 0, 0); } } return $apiResponse; }
php
public function getCustomers(Get\RequestData $requestData = null) { $request = new Get\Request($requestData); $apiResponse = $this->sendRequest($request, Get\ApiResponse::class); /** @var Get\Response $response */ $response = $apiResponse->getResponse(); foreach ($response->getCustomers() as $customer) { if ($customer->getBirthday() instanceof \DateTime) { $customer->getBirthday()->setTime(0, 0, 0); } } return $apiResponse; }
[ "public", "function", "getCustomers", "(", "Get", "\\", "RequestData", "$", "requestData", "=", "null", ")", "{", "$", "request", "=", "new", "Get", "\\", "Request", "(", "$", "requestData", ")", ";", "$", "apiResponse", "=", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Get", "\\", "ApiResponse", "::", "class", ")", ";", "/** @var Get\\Response $response */", "$", "response", "=", "$", "apiResponse", "->", "getResponse", "(", ")", ";", "foreach", "(", "$", "response", "->", "getCustomers", "(", ")", "as", "$", "customer", ")", "{", "if", "(", "$", "customer", "->", "getBirthday", "(", ")", "instanceof", "\\", "DateTime", ")", "{", "$", "customer", "->", "getBirthday", "(", ")", "->", "setTime", "(", "0", ",", "0", ",", "0", ")", ";", "}", "}", "return", "$", "apiResponse", ";", "}" ]
Get the customers. @param Get\RequestData|null $requestData The request data. @return Get\ApiResponse
[ "Get", "the", "customers", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Customer/CustomerService.php#L19-L34
24,004
Speicher210/monsum-api
src/Service/Customer/CustomerService.php
CustomerService.getCustomer
public function getCustomer($customerId) { $requestData = new Get\RequestData(); $requestData->setCustomerId($customerId); $customers = $this->getCustomers($requestData)->getResponse()->getCustomers(); return isset($customers[0]) ? $customers[0] : null; }
php
public function getCustomer($customerId) { $requestData = new Get\RequestData(); $requestData->setCustomerId($customerId); $customers = $this->getCustomers($requestData)->getResponse()->getCustomers(); return isset($customers[0]) ? $customers[0] : null; }
[ "public", "function", "getCustomer", "(", "$", "customerId", ")", "{", "$", "requestData", "=", "new", "Get", "\\", "RequestData", "(", ")", ";", "$", "requestData", "->", "setCustomerId", "(", "$", "customerId", ")", ";", "$", "customers", "=", "$", "this", "->", "getCustomers", "(", "$", "requestData", ")", "->", "getResponse", "(", ")", "->", "getCustomers", "(", ")", ";", "return", "isset", "(", "$", "customers", "[", "0", "]", ")", "?", "$", "customers", "[", "0", "]", ":", "null", ";", "}" ]
Get one customer by ID. @param integer $customerId The customer ID. @return Customer|null
[ "Get", "one", "customer", "by", "ID", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Customer/CustomerService.php#L42-L50
24,005
Speicher210/monsum-api
src/Service/Customer/CustomerService.php
CustomerService.getCustomerByExternalUid
public function getCustomerByExternalUid($customerExternalUid) { $requestData = new Get\RequestData(); $requestData->setCustomerExternalUid($customerExternalUid); $customers = $this->getCustomers($requestData)->getResponse()->getCustomers(); return isset($customers[0]) ? $customers[0] : null; }
php
public function getCustomerByExternalUid($customerExternalUid) { $requestData = new Get\RequestData(); $requestData->setCustomerExternalUid($customerExternalUid); $customers = $this->getCustomers($requestData)->getResponse()->getCustomers(); return isset($customers[0]) ? $customers[0] : null; }
[ "public", "function", "getCustomerByExternalUid", "(", "$", "customerExternalUid", ")", "{", "$", "requestData", "=", "new", "Get", "\\", "RequestData", "(", ")", ";", "$", "requestData", "->", "setCustomerExternalUid", "(", "$", "customerExternalUid", ")", ";", "$", "customers", "=", "$", "this", "->", "getCustomers", "(", "$", "requestData", ")", "->", "getResponse", "(", ")", "->", "getCustomers", "(", ")", ";", "return", "isset", "(", "$", "customers", "[", "0", "]", ")", "?", "$", "customers", "[", "0", "]", ":", "null", ";", "}" ]
Get once customer by the external ID. @param string $customerExternalUid The external customer ID. @return Customer|null
[ "Get", "once", "customer", "by", "the", "external", "ID", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Customer/CustomerService.php#L58-L66
24,006
Speicher210/monsum-api
src/Service/Customer/CustomerService.php
CustomerService.deleteCustomer
public function deleteCustomer($customerId) { $requestData = new Delete\RequestData($customerId); $request = new Delete\Request($requestData); return $this->sendRequest($request, Delete\ApiResponse::class); }
php
public function deleteCustomer($customerId) { $requestData = new Delete\RequestData($customerId); $request = new Delete\Request($requestData); return $this->sendRequest($request, Delete\ApiResponse::class); }
[ "public", "function", "deleteCustomer", "(", "$", "customerId", ")", "{", "$", "requestData", "=", "new", "Delete", "\\", "RequestData", "(", "$", "customerId", ")", ";", "$", "request", "=", "new", "Delete", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Delete", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Delete a customer. @param integer $customerId The customer ID to delete. @return Delete\ApiResponse
[ "Delete", "a", "customer", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Customer/CustomerService.php#L100-L106
24,007
Speicher210/monsum-api
src/Service/Customer/CustomerService.php
CustomerService.addCredits
public function addCredits($customerId, $amount) { $requestData = new AddCredits\RequestData($customerId, $amount); $request = new AddCredits\Request($requestData); return $this->sendRequest($request, AddCredits\ApiResponse::class); }
php
public function addCredits($customerId, $amount) { $requestData = new AddCredits\RequestData($customerId, $amount); $request = new AddCredits\Request($requestData); return $this->sendRequest($request, AddCredits\ApiResponse::class); }
[ "public", "function", "addCredits", "(", "$", "customerId", ",", "$", "amount", ")", "{", "$", "requestData", "=", "new", "AddCredits", "\\", "RequestData", "(", "$", "customerId", ",", "$", "amount", ")", ";", "$", "request", "=", "new", "AddCredits", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "AddCredits", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Add credits to a customer. @param integer $customerId The customer ID. @param float $amount The amount of credit to add. @return AddCredits\ApiResponse
[ "Add", "credits", "to", "a", "customer", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Customer/CustomerService.php#L115-L121
24,008
mothership-ec/composer
src/Composer/Package/Archiver/BaseExcludeFilter.php
BaseExcludeFilter.parseLines
protected function parseLines(array $lines, $lineParser) { return array_filter( array_map( function ($line) use ($lineParser) { $line = trim($line); if (!$line || 0 === strpos($line, '#')) { return; } return call_user_func($lineParser, $line); }, $lines ), function ($pattern) { return $pattern !== null; } ); }
php
protected function parseLines(array $lines, $lineParser) { return array_filter( array_map( function ($line) use ($lineParser) { $line = trim($line); if (!$line || 0 === strpos($line, '#')) { return; } return call_user_func($lineParser, $line); }, $lines ), function ($pattern) { return $pattern !== null; } ); }
[ "protected", "function", "parseLines", "(", "array", "$", "lines", ",", "$", "lineParser", ")", "{", "return", "array_filter", "(", "array_map", "(", "function", "(", "$", "line", ")", "use", "(", "$", "lineParser", ")", "{", "$", "line", "=", "trim", "(", "$", "line", ")", ";", "if", "(", "!", "$", "line", "||", "0", "===", "strpos", "(", "$", "line", ",", "'#'", ")", ")", "{", "return", ";", "}", "return", "call_user_func", "(", "$", "lineParser", ",", "$", "line", ")", ";", "}", ",", "$", "lines", ")", ",", "function", "(", "$", "pattern", ")", "{", "return", "$", "pattern", "!==", "null", ";", "}", ")", ";", "}" ]
Processes a file containing exclude rules of different formats per line @param array $lines A set of lines to be parsed @param callback $lineParser The parser to be used on each line @return array Exclude patterns to be used in filter()
[ "Processes", "a", "file", "containing", "exclude", "rules", "of", "different", "formats", "per", "line" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Package/Archiver/BaseExcludeFilter.php#L78-L97
24,009
mikelgoig/nova-spotify-auth-tool
src/Http/Controllers/SpotifyAuthToolController.php
SpotifyAuthToolController.auth
public function auth() { $spotify = app() ->make('SpotifyWrapper', [ 'callback' => '/nova-vendor/nova-spotify-auth-tool/auth', 'scope' => [], 'show_dialog' => true, ]) ->requestAccessToken(); $spotify->api->setAccessToken($spotify->session->getAccessToken()); Spotify::updateOrCreate( ['key' => 'user_id'], ['value' => $spotify->api->me()->id] ); Spotify::updateOrCreate( ['key' => 'refresh_token'], ['value' => $spotify->session->getRefreshToken()] ); return redirect('nova/nova-spotify-auth-tool'); }
php
public function auth() { $spotify = app() ->make('SpotifyWrapper', [ 'callback' => '/nova-vendor/nova-spotify-auth-tool/auth', 'scope' => [], 'show_dialog' => true, ]) ->requestAccessToken(); $spotify->api->setAccessToken($spotify->session->getAccessToken()); Spotify::updateOrCreate( ['key' => 'user_id'], ['value' => $spotify->api->me()->id] ); Spotify::updateOrCreate( ['key' => 'refresh_token'], ['value' => $spotify->session->getRefreshToken()] ); return redirect('nova/nova-spotify-auth-tool'); }
[ "public", "function", "auth", "(", ")", "{", "$", "spotify", "=", "app", "(", ")", "->", "make", "(", "'SpotifyWrapper'", ",", "[", "'callback'", "=>", "'/nova-vendor/nova-spotify-auth-tool/auth'", ",", "'scope'", "=>", "[", "]", ",", "'show_dialog'", "=>", "true", ",", "]", ")", "->", "requestAccessToken", "(", ")", ";", "$", "spotify", "->", "api", "->", "setAccessToken", "(", "$", "spotify", "->", "session", "->", "getAccessToken", "(", ")", ")", ";", "Spotify", "::", "updateOrCreate", "(", "[", "'key'", "=>", "'user_id'", "]", ",", "[", "'value'", "=>", "$", "spotify", "->", "api", "->", "me", "(", ")", "->", "id", "]", ")", ";", "Spotify", "::", "updateOrCreate", "(", "[", "'key'", "=>", "'refresh_token'", "]", ",", "[", "'value'", "=>", "$", "spotify", "->", "session", "->", "getRefreshToken", "(", ")", "]", ")", ";", "return", "redirect", "(", "'nova/nova-spotify-auth-tool'", ")", ";", "}" ]
Spotify authentication. @return mixed
[ "Spotify", "authentication", "." ]
a5351c386206c45f77fe6ae833cdac51f2a030f4
https://github.com/mikelgoig/nova-spotify-auth-tool/blob/a5351c386206c45f77fe6ae833cdac51f2a030f4/src/Http/Controllers/SpotifyAuthToolController.php#L21-L44
24,010
webdevvie/pheanstalk-task-queue-bundle
Command/Tender/ChildProcessContainer.php
ChildProcessContainer.checkHealth
public function checkHealth() { if (!$this->process->isRunning()) { if ($this->status == self::STATUS_CLEANINGUP || $this->status == self::STATUS_CLEANEDUP) { //okay so we're ready to stop! $this->status = self::STATUS_DEAD; return true; } elseif ($this->status == ChildProcessContainer::STATUS_SLEEPY) { //okay so we're ready to stop! $this->status = self::STATUS_DEAD; return true; } $this->status = self::STATUS_DEAD; return false; } else { return true; } }
php
public function checkHealth() { if (!$this->process->isRunning()) { if ($this->status == self::STATUS_CLEANINGUP || $this->status == self::STATUS_CLEANEDUP) { //okay so we're ready to stop! $this->status = self::STATUS_DEAD; return true; } elseif ($this->status == ChildProcessContainer::STATUS_SLEEPY) { //okay so we're ready to stop! $this->status = self::STATUS_DEAD; return true; } $this->status = self::STATUS_DEAD; return false; } else { return true; } }
[ "public", "function", "checkHealth", "(", ")", "{", "if", "(", "!", "$", "this", "->", "process", "->", "isRunning", "(", ")", ")", "{", "if", "(", "$", "this", "->", "status", "==", "self", "::", "STATUS_CLEANINGUP", "||", "$", "this", "->", "status", "==", "self", "::", "STATUS_CLEANEDUP", ")", "{", "//okay so we're ready to stop!", "$", "this", "->", "status", "=", "self", "::", "STATUS_DEAD", ";", "return", "true", ";", "}", "elseif", "(", "$", "this", "->", "status", "==", "ChildProcessContainer", "::", "STATUS_SLEEPY", ")", "{", "//okay so we're ready to stop!", "$", "this", "->", "status", "=", "self", "::", "STATUS_DEAD", ";", "return", "true", ";", "}", "$", "this", "->", "status", "=", "self", "::", "STATUS_DEAD", ";", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Checks the health of this child and returns true if healthy otherwise marks it for cleanup @return boolean
[ "Checks", "the", "health", "of", "this", "child", "and", "returns", "true", "if", "healthy", "otherwise", "marks", "it", "for", "cleanup" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/Tender/ChildProcessContainer.php#L138-L156
24,011
webdevvie/pheanstalk-task-queue-bundle
Command/Tender/ChildProcessContainer.php
ChildProcessContainer.cleanUp
public function cleanUp() { $this->status = self::STATUS_CLEANINGUP; if ($this->process->isRunning()) { $this->sendTERMSignal(); } else { $this->status = self::STATUS_CLEANEDUP; } }
php
public function cleanUp() { $this->status = self::STATUS_CLEANINGUP; if ($this->process->isRunning()) { $this->sendTERMSignal(); } else { $this->status = self::STATUS_CLEANEDUP; } }
[ "public", "function", "cleanUp", "(", ")", "{", "$", "this", "->", "status", "=", "self", "::", "STATUS_CLEANINGUP", ";", "if", "(", "$", "this", "->", "process", "->", "isRunning", "(", ")", ")", "{", "$", "this", "->", "sendTERMSignal", "(", ")", ";", "}", "else", "{", "$", "this", "->", "status", "=", "self", "::", "STATUS_CLEANEDUP", ";", "}", "}" ]
Cleans up a process @return void
[ "Cleans", "up", "a", "process" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/Tender/ChildProcessContainer.php#L173-L182
24,012
webdevvie/pheanstalk-task-queue-bundle
Command/Tender/ChildProcessContainer.php
ChildProcessContainer.processOutput
public function processOutput($childName) { $output = $this->outputBuffer . $this->process->getIncrementalOutput(); $errorOutput = $this->errorOutputBuffer . $this->process->getIncrementalErrorOutput(); $outputLines = explode("\n", $output); $errorOutputLines = explode("\n", $errorOutput); if (count($outputLines) > 0) { $lastItem = array_pop($outputLines); $this->outputBuffer = $lastItem; $this->bufferLength += implode("\n", $outputLines); foreach ($outputLines as $line) { if (strstr($line, "[[CHILD::BUSY]]")) { $this->parent->verboseOutput('<info>' . $childName . ' BUSY</info>'); $this->status = ChildProcessContainer::STATUS_BUSY; } elseif (strstr($line, "[[CHILD::READY]]")) { $this->parent->verboseOutput('<info>' . $childName . ' READY</info>'); if ($this->status != ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY) { $this->status = ChildProcessContainer::STATUS_READY; } else { $this->status = ChildProcessContainer::STATUS_SLEEPY; } } elseif (strlen($line) > 0) { $this->parent->verboseOutput('<info>OUTPUT ' . $childName . ':</info>' . $line); } } } if (count($errorOutputLines) > 0) { $lastItemError = array_pop($errorOutputLines); $this->errorOutputBuffer = $lastItemError; $knownErrorOutput = implode("\n", $errorOutputLines); $this->bufferLength += strlen($knownErrorOutput); } }
php
public function processOutput($childName) { $output = $this->outputBuffer . $this->process->getIncrementalOutput(); $errorOutput = $this->errorOutputBuffer . $this->process->getIncrementalErrorOutput(); $outputLines = explode("\n", $output); $errorOutputLines = explode("\n", $errorOutput); if (count($outputLines) > 0) { $lastItem = array_pop($outputLines); $this->outputBuffer = $lastItem; $this->bufferLength += implode("\n", $outputLines); foreach ($outputLines as $line) { if (strstr($line, "[[CHILD::BUSY]]")) { $this->parent->verboseOutput('<info>' . $childName . ' BUSY</info>'); $this->status = ChildProcessContainer::STATUS_BUSY; } elseif (strstr($line, "[[CHILD::READY]]")) { $this->parent->verboseOutput('<info>' . $childName . ' READY</info>'); if ($this->status != ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY) { $this->status = ChildProcessContainer::STATUS_READY; } else { $this->status = ChildProcessContainer::STATUS_SLEEPY; } } elseif (strlen($line) > 0) { $this->parent->verboseOutput('<info>OUTPUT ' . $childName . ':</info>' . $line); } } } if (count($errorOutputLines) > 0) { $lastItemError = array_pop($errorOutputLines); $this->errorOutputBuffer = $lastItemError; $knownErrorOutput = implode("\n", $errorOutputLines); $this->bufferLength += strlen($knownErrorOutput); } }
[ "public", "function", "processOutput", "(", "$", "childName", ")", "{", "$", "output", "=", "$", "this", "->", "outputBuffer", ".", "$", "this", "->", "process", "->", "getIncrementalOutput", "(", ")", ";", "$", "errorOutput", "=", "$", "this", "->", "errorOutputBuffer", ".", "$", "this", "->", "process", "->", "getIncrementalErrorOutput", "(", ")", ";", "$", "outputLines", "=", "explode", "(", "\"\\n\"", ",", "$", "output", ")", ";", "$", "errorOutputLines", "=", "explode", "(", "\"\\n\"", ",", "$", "errorOutput", ")", ";", "if", "(", "count", "(", "$", "outputLines", ")", ">", "0", ")", "{", "$", "lastItem", "=", "array_pop", "(", "$", "outputLines", ")", ";", "$", "this", "->", "outputBuffer", "=", "$", "lastItem", ";", "$", "this", "->", "bufferLength", "+=", "implode", "(", "\"\\n\"", ",", "$", "outputLines", ")", ";", "foreach", "(", "$", "outputLines", "as", "$", "line", ")", "{", "if", "(", "strstr", "(", "$", "line", ",", "\"[[CHILD::BUSY]]\"", ")", ")", "{", "$", "this", "->", "parent", "->", "verboseOutput", "(", "'<info>'", ".", "$", "childName", ".", "' BUSY</info>'", ")", ";", "$", "this", "->", "status", "=", "ChildProcessContainer", "::", "STATUS_BUSY", ";", "}", "elseif", "(", "strstr", "(", "$", "line", ",", "\"[[CHILD::READY]]\"", ")", ")", "{", "$", "this", "->", "parent", "->", "verboseOutput", "(", "'<info>'", ".", "$", "childName", ".", "' READY</info>'", ")", ";", "if", "(", "$", "this", "->", "status", "!=", "ChildProcessContainer", "::", "STATUS_BUSY_BUT_SLEEPY", ")", "{", "$", "this", "->", "status", "=", "ChildProcessContainer", "::", "STATUS_READY", ";", "}", "else", "{", "$", "this", "->", "status", "=", "ChildProcessContainer", "::", "STATUS_SLEEPY", ";", "}", "}", "elseif", "(", "strlen", "(", "$", "line", ")", ">", "0", ")", "{", "$", "this", "->", "parent", "->", "verboseOutput", "(", "'<info>OUTPUT '", ".", "$", "childName", ".", "':</info>'", ".", "$", "line", ")", ";", "}", "}", "}", "if", "(", "count", "(", "$", "errorOutputLines", ")", ">", "0", ")", "{", "$", "lastItemError", "=", "array_pop", "(", "$", "errorOutputLines", ")", ";", "$", "this", "->", "errorOutputBuffer", "=", "$", "lastItemError", ";", "$", "knownErrorOutput", "=", "implode", "(", "\"\\n\"", ",", "$", "errorOutputLines", ")", ";", "$", "this", "->", "bufferLength", "+=", "strlen", "(", "$", "knownErrorOutput", ")", ";", "}", "}" ]
Looks into and processes the child's output @param string $childName @return void
[ "Looks", "into", "and", "processes", "the", "child", "s", "output" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/Tender/ChildProcessContainer.php#L211-L243
24,013
webdevvie/pheanstalk-task-queue-bundle
Command/Tender/ChildProcessContainer.php
ChildProcessContainer.start
public function start() { $cmd = 'app/console ' . $this->workerCommand; if ($this->tube != '') { $cmd .= ' --use-tube=' . escapeshellarg($this->tube); } if ($this->parent->isVerbose()) { $cmd .= ' -vvvv'; } $this->startTime = time(); $this->parent->verboseOutput('<info>Starting:</info>' . $cmd); $this->process = new Process('exec ' . $cmd, $this->consolePath, null, null, null); $this->process->start(); if ($this->process->isRunning()) { $this->status = ChildProcessContainer::STATUS_ALIVE; } else { $this->status = ChildProcessContainer::STATUS_DEAD; } }
php
public function start() { $cmd = 'app/console ' . $this->workerCommand; if ($this->tube != '') { $cmd .= ' --use-tube=' . escapeshellarg($this->tube); } if ($this->parent->isVerbose()) { $cmd .= ' -vvvv'; } $this->startTime = time(); $this->parent->verboseOutput('<info>Starting:</info>' . $cmd); $this->process = new Process('exec ' . $cmd, $this->consolePath, null, null, null); $this->process->start(); if ($this->process->isRunning()) { $this->status = ChildProcessContainer::STATUS_ALIVE; } else { $this->status = ChildProcessContainer::STATUS_DEAD; } }
[ "public", "function", "start", "(", ")", "{", "$", "cmd", "=", "'app/console '", ".", "$", "this", "->", "workerCommand", ";", "if", "(", "$", "this", "->", "tube", "!=", "''", ")", "{", "$", "cmd", ".=", "' --use-tube='", ".", "escapeshellarg", "(", "$", "this", "->", "tube", ")", ";", "}", "if", "(", "$", "this", "->", "parent", "->", "isVerbose", "(", ")", ")", "{", "$", "cmd", ".=", "' -vvvv'", ";", "}", "$", "this", "->", "startTime", "=", "time", "(", ")", ";", "$", "this", "->", "parent", "->", "verboseOutput", "(", "'<info>Starting:</info>'", ".", "$", "cmd", ")", ";", "$", "this", "->", "process", "=", "new", "Process", "(", "'exec '", ".", "$", "cmd", ",", "$", "this", "->", "consolePath", ",", "null", ",", "null", ",", "null", ")", ";", "$", "this", "->", "process", "->", "start", "(", ")", ";", "if", "(", "$", "this", "->", "process", "->", "isRunning", "(", ")", ")", "{", "$", "this", "->", "status", "=", "ChildProcessContainer", "::", "STATUS_ALIVE", ";", "}", "else", "{", "$", "this", "->", "status", "=", "ChildProcessContainer", "::", "STATUS_DEAD", ";", "}", "}" ]
Starts the child process @return void
[ "Starts", "the", "child", "process" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/Tender/ChildProcessContainer.php#L250-L268
24,014
webdevvie/pheanstalk-task-queue-bundle
Command/Tender/ChildProcessContainer.php
ChildProcessContainer.sendTERMSignal
private function sendTERMSignal() { if (!$this->hasReceivedHUP) { $this->hasReceivedHUP = true; try { $this->process->signal(SIGTERM); } catch (\Symfony\Component\Process\Exception\LogicException $e) { //In case the process ends between checking and actually sending the signal } } }
php
private function sendTERMSignal() { if (!$this->hasReceivedHUP) { $this->hasReceivedHUP = true; try { $this->process->signal(SIGTERM); } catch (\Symfony\Component\Process\Exception\LogicException $e) { //In case the process ends between checking and actually sending the signal } } }
[ "private", "function", "sendTERMSignal", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasReceivedHUP", ")", "{", "$", "this", "->", "hasReceivedHUP", "=", "true", ";", "try", "{", "$", "this", "->", "process", "->", "signal", "(", "SIGTERM", ")", ";", "}", "catch", "(", "\\", "Symfony", "\\", "Component", "\\", "Process", "\\", "Exception", "\\", "LogicException", "$", "e", ")", "{", "//In case the process ends between checking and actually sending the signal", "}", "}", "}" ]
Sends a signal to the process, this method prevents the signal from being sent twice @return void
[ "Sends", "a", "signal", "to", "the", "process", "this", "method", "prevents", "the", "signal", "from", "being", "sent", "twice" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/Tender/ChildProcessContainer.php#L286-L296
24,015
webdevvie/pheanstalk-task-queue-bundle
Command/Tender/ChildProcessContainer.php
ChildProcessContainer.getReadyForBed
public function getReadyForBed() { $busyStatusses = array(ChildProcessContainer::STATUS_SLEEPY, ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY ); if (in_array($this->status, $busyStatusses)) { //ready for bed return; } if($this->status == ChildProcessContainer::STATUS_DEAD) { // do nothing } else if ($this->status == ChildProcessContainer::STATUS_BUSY) { $this->status = ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY; } else { $this->status = ChildProcessContainer::STATUS_SLEEPY; } if ($this->process->isRunning()) { $this->sendTERMSignal(); } }
php
public function getReadyForBed() { $busyStatusses = array(ChildProcessContainer::STATUS_SLEEPY, ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY ); if (in_array($this->status, $busyStatusses)) { //ready for bed return; } if($this->status == ChildProcessContainer::STATUS_DEAD) { // do nothing } else if ($this->status == ChildProcessContainer::STATUS_BUSY) { $this->status = ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY; } else { $this->status = ChildProcessContainer::STATUS_SLEEPY; } if ($this->process->isRunning()) { $this->sendTERMSignal(); } }
[ "public", "function", "getReadyForBed", "(", ")", "{", "$", "busyStatusses", "=", "array", "(", "ChildProcessContainer", "::", "STATUS_SLEEPY", ",", "ChildProcessContainer", "::", "STATUS_BUSY_BUT_SLEEPY", ")", ";", "if", "(", "in_array", "(", "$", "this", "->", "status", ",", "$", "busyStatusses", ")", ")", "{", "//ready for bed", "return", ";", "}", "if", "(", "$", "this", "->", "status", "==", "ChildProcessContainer", "::", "STATUS_DEAD", ")", "{", "// do nothing", "}", "else", "if", "(", "$", "this", "->", "status", "==", "ChildProcessContainer", "::", "STATUS_BUSY", ")", "{", "$", "this", "->", "status", "=", "ChildProcessContainer", "::", "STATUS_BUSY_BUT_SLEEPY", ";", "}", "else", "{", "$", "this", "->", "status", "=", "ChildProcessContainer", "::", "STATUS_SLEEPY", ";", "}", "if", "(", "$", "this", "->", "process", "->", "isRunning", "(", ")", ")", "{", "$", "this", "->", "sendTERMSignal", "(", ")", ";", "}", "}" ]
Tells the child to not pick up any more work and go to bed @return void
[ "Tells", "the", "child", "to", "not", "pick", "up", "any", "more", "work", "and", "go", "to", "bed" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/Tender/ChildProcessContainer.php#L303-L324
24,016
mridang/magazine
lib/magento/Target.php
Mage_Connect_Package_Target._getTargetMap
protected function _getTargetMap() { if (is_null($this->_targetMap)) { $this->_targetMap = array(); $this->_targetMap[] = array('name'=>"magelocal" ,'label'=>"Magento Local module file" , 'uri'=>"./app/code/local"); $this->_targetMap[] = array('name'=>"magecommunity" ,'label'=>"Magento Community module file" , 'uri'=>"./app/code/community"); $this->_targetMap[] = array('name'=>"magecore" ,'label'=>"Magento Core team module file" , 'uri'=>"./app/code/core"); $this->_targetMap[] = array('name'=>"magedesign" ,'label'=>"Magento User Interface (layouts, templates)" , 'uri'=>"./app/design"); $this->_targetMap[] = array('name'=>"mageetc" ,'label'=>"Magento Global Configuration" , 'uri'=>"./app/etc"); $this->_targetMap[] = array('name'=>"magelib" ,'label'=>"Magento PHP Library file" , 'uri'=>"./lib"); $this->_targetMap[] = array('name'=>"magelocale" ,'label'=>"Magento Locale language file" , 'uri'=>"./app/locale"); $this->_targetMap[] = array('name'=>"magemedia" ,'label'=>"Magento Media library" , 'uri'=>"./media"); $this->_targetMap[] = array('name'=>"mageskin" ,'label'=>"Magento Theme Skin (Images, CSS, JS)" , 'uri'=>"./skin"); $this->_targetMap[] = array('name'=>"mageweb" ,'label'=>"Magento Other web accessible file" , 'uri'=>"."); $this->_targetMap[] = array('name'=>"magetest" ,'label'=>"Magento PHPUnit test" , 'uri'=>"./tests"); $this->_targetMap[] = array('name'=>"mage" ,'label'=>"Magento other" , 'uri'=>"."); } return $this->_targetMap; }
php
protected function _getTargetMap() { if (is_null($this->_targetMap)) { $this->_targetMap = array(); $this->_targetMap[] = array('name'=>"magelocal" ,'label'=>"Magento Local module file" , 'uri'=>"./app/code/local"); $this->_targetMap[] = array('name'=>"magecommunity" ,'label'=>"Magento Community module file" , 'uri'=>"./app/code/community"); $this->_targetMap[] = array('name'=>"magecore" ,'label'=>"Magento Core team module file" , 'uri'=>"./app/code/core"); $this->_targetMap[] = array('name'=>"magedesign" ,'label'=>"Magento User Interface (layouts, templates)" , 'uri'=>"./app/design"); $this->_targetMap[] = array('name'=>"mageetc" ,'label'=>"Magento Global Configuration" , 'uri'=>"./app/etc"); $this->_targetMap[] = array('name'=>"magelib" ,'label'=>"Magento PHP Library file" , 'uri'=>"./lib"); $this->_targetMap[] = array('name'=>"magelocale" ,'label'=>"Magento Locale language file" , 'uri'=>"./app/locale"); $this->_targetMap[] = array('name'=>"magemedia" ,'label'=>"Magento Media library" , 'uri'=>"./media"); $this->_targetMap[] = array('name'=>"mageskin" ,'label'=>"Magento Theme Skin (Images, CSS, JS)" , 'uri'=>"./skin"); $this->_targetMap[] = array('name'=>"mageweb" ,'label'=>"Magento Other web accessible file" , 'uri'=>"."); $this->_targetMap[] = array('name'=>"magetest" ,'label'=>"Magento PHPUnit test" , 'uri'=>"./tests"); $this->_targetMap[] = array('name'=>"mage" ,'label'=>"Magento other" , 'uri'=>"."); } return $this->_targetMap; }
[ "protected", "function", "_getTargetMap", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "_targetMap", ")", ")", "{", "$", "this", "->", "_targetMap", "=", "array", "(", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"magelocal\"", ",", "'label'", "=>", "\"Magento Local module file\"", ",", "'uri'", "=>", "\"./app/code/local\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"magecommunity\"", ",", "'label'", "=>", "\"Magento Community module file\"", ",", "'uri'", "=>", "\"./app/code/community\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"magecore\"", ",", "'label'", "=>", "\"Magento Core team module file\"", ",", "'uri'", "=>", "\"./app/code/core\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"magedesign\"", ",", "'label'", "=>", "\"Magento User Interface (layouts, templates)\"", ",", "'uri'", "=>", "\"./app/design\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"mageetc\"", ",", "'label'", "=>", "\"Magento Global Configuration\"", ",", "'uri'", "=>", "\"./app/etc\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"magelib\"", ",", "'label'", "=>", "\"Magento PHP Library file\"", ",", "'uri'", "=>", "\"./lib\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"magelocale\"", ",", "'label'", "=>", "\"Magento Locale language file\"", ",", "'uri'", "=>", "\"./app/locale\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"magemedia\"", ",", "'label'", "=>", "\"Magento Media library\"", ",", "'uri'", "=>", "\"./media\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"mageskin\"", ",", "'label'", "=>", "\"Magento Theme Skin (Images, CSS, JS)\"", ",", "'uri'", "=>", "\"./skin\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"mageweb\"", ",", "'label'", "=>", "\"Magento Other web accessible file\"", ",", "'uri'", "=>", "\".\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"magetest\"", ",", "'label'", "=>", "\"Magento PHPUnit test\"", ",", "'uri'", "=>", "\"./tests\"", ")", ";", "$", "this", "->", "_targetMap", "[", "]", "=", "array", "(", "'name'", "=>", "\"mage\"", ",", "'label'", "=>", "\"Magento other\"", ",", "'uri'", "=>", "\".\"", ")", ";", "}", "return", "$", "this", "->", "_targetMap", ";", "}" ]
Retrieve content from target.xml. @return SimpleXMLElement
[ "Retrieve", "content", "from", "target", ".", "xml", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Target.php#L57-L75
24,017
mridang/magazine
lib/magento/Target.php
Mage_Connect_Package_Target.getTargets
public function getTargets() { if (!is_array($this->_targets)) { $this->_targets = array(); if($this->_getTargetMap()) { foreach ($this->_getTargetMap() as $_target) { $this->_targets[$_target['name']] = (string)$_target['uri']; } } } return $this->_targets; }
php
public function getTargets() { if (!is_array($this->_targets)) { $this->_targets = array(); if($this->_getTargetMap()) { foreach ($this->_getTargetMap() as $_target) { $this->_targets[$_target['name']] = (string)$_target['uri']; } } } return $this->_targets; }
[ "public", "function", "getTargets", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "_targets", ")", ")", "{", "$", "this", "->", "_targets", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "_getTargetMap", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "_getTargetMap", "(", ")", "as", "$", "_target", ")", "{", "$", "this", "->", "_targets", "[", "$", "_target", "[", "'name'", "]", "]", "=", "(", "string", ")", "$", "_target", "[", "'uri'", "]", ";", "}", "}", "}", "return", "$", "this", "->", "_targets", ";", "}" ]
Retrieve targets as associative array from target.xml. @return array
[ "Retrieve", "targets", "as", "associative", "array", "from", "target", ".", "xml", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Target.php#L82-L93
24,018
mridang/magazine
lib/magento/Target.php
Mage_Connect_Package_Target.getLabelTargets
public function getLabelTargets() { $targets = array(); foreach ($this->_getTargetMap() as $_target) { $targets[$_target['name']] = $_target['label']; } return $targets; }
php
public function getLabelTargets() { $targets = array(); foreach ($this->_getTargetMap() as $_target) { $targets[$_target['name']] = $_target['label']; } return $targets; }
[ "public", "function", "getLabelTargets", "(", ")", "{", "$", "targets", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_getTargetMap", "(", ")", "as", "$", "_target", ")", "{", "$", "targets", "[", "$", "_target", "[", "'name'", "]", "]", "=", "$", "_target", "[", "'label'", "]", ";", "}", "return", "$", "targets", ";", "}" ]
Retrieve tragets with label for select options. @return array
[ "Retrieve", "tragets", "with", "label", "for", "select", "options", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Target.php#L100-L107
24,019
mridang/magazine
lib/magento/Target.php
Mage_Connect_Package_Target.getTargetUri
public function getTargetUri($name) { foreach ($this->getTargets() as $_name=>$_uri) { if ($name == $_name) { return $_uri; } } return ''; }
php
public function getTargetUri($name) { foreach ($this->getTargets() as $_name=>$_uri) { if ($name == $_name) { return $_uri; } } return ''; }
[ "public", "function", "getTargetUri", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "getTargets", "(", ")", "as", "$", "_name", "=>", "$", "_uri", ")", "{", "if", "(", "$", "name", "==", "$", "_name", ")", "{", "return", "$", "_uri", ";", "}", "}", "return", "''", ";", "}" ]
Get uri by target's name. @param string $name @return string
[ "Get", "uri", "by", "target", "s", "name", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Target.php#L115-L123
24,020
nabab/bbn
src/bbn/str.php
str.change_case
public static function change_case($st, $case = 'x'): string { $st = self::cast($st); $case = substr(strtolower((string)$case), 0, 1); switch ( $case ){ case "l": $case = MB_CASE_LOWER; break; case "u": $case = MB_CASE_UPPER; break; default: $case = MB_CASE_TITLE; } if ( !empty($st) ){ $st = mb_convert_case($st, $case); } return $st; }
php
public static function change_case($st, $case = 'x'): string { $st = self::cast($st); $case = substr(strtolower((string)$case), 0, 1); switch ( $case ){ case "l": $case = MB_CASE_LOWER; break; case "u": $case = MB_CASE_UPPER; break; default: $case = MB_CASE_TITLE; } if ( !empty($st) ){ $st = mb_convert_case($st, $case); } return $st; }
[ "public", "static", "function", "change_case", "(", "$", "st", ",", "$", "case", "=", "'x'", ")", ":", "string", "{", "$", "st", "=", "self", "::", "cast", "(", "$", "st", ")", ";", "$", "case", "=", "substr", "(", "strtolower", "(", "(", "string", ")", "$", "case", ")", ",", "0", ",", "1", ")", ";", "switch", "(", "$", "case", ")", "{", "case", "\"l\"", ":", "$", "case", "=", "MB_CASE_LOWER", ";", "break", ";", "case", "\"u\"", ":", "$", "case", "=", "MB_CASE_UPPER", ";", "break", ";", "default", ":", "$", "case", "=", "MB_CASE_TITLE", ";", "}", "if", "(", "!", "empty", "(", "$", "st", ")", ")", "{", "$", "st", "=", "mb_convert_case", "(", "$", "st", ",", "$", "case", ")", ";", "}", "return", "$", "st", ";", "}" ]
Converts the case of a string. ```php $st = 'TEST CASE'; \bbn\x::dump(\bbn\str::change_case($st, 'lower')); // (string) "test case" \bbn\x::dump(\bbn\str::change_case('TEsT Case', 'upper')); // (string) "TEST CASE" \bbn\x::dump(\bbn\str::change_case('test case')); // (string) "Test Case" ``` @param mixed $st The item to convert. @param mixed $case The case to convert to ("lower" or "upper"), default being the title case. @return string
[ "Converts", "the", "case", "of", "a", "string", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L62-L80
24,021
nabab/bbn
src/bbn/str.php
str.encode_filename
public static function encode_filename($st, $maxlength = 50, $extension = null, $is_path = false): string { $st = self::remove_accents(self::cast($st)); $allowed = '~\-_.,\(\[\)\]'; // Arguments order doesn't matter $args = \func_get_args(); foreach ( $args as $i => $a ){ if ( $i > 0 ){ if ( \is_string($a) ){ $extension = $a; } else if ( \is_int($a) ){ $maxlength = $a; } else if ( \is_bool($a) ){ $is_path = $a; } } } if ( !\is_int($maxlength) ){ $maxlength = mb_strlen($st); } if ( $is_path ){ $allowed .= '/'; } if ( $extension && (self::file_ext($st) === self::change_case($extension, 'lower')) ){ $st = substr($st, 0, -(\strlen($extension)+1)); } else if ( $extension = self::file_ext($st) ){ $st = substr($st, 0, -(\strlen($extension)+1)); } $st = mb_ereg_replace("([^\w\s\d".$allowed.".])", '', $st); $st = mb_ereg_replace("([\.]{2,})", '', $st); $res = mb_substr($st, 0, $maxlength); if ( $extension ){ $res .= '.' . $extension; } return $res; }
php
public static function encode_filename($st, $maxlength = 50, $extension = null, $is_path = false): string { $st = self::remove_accents(self::cast($st)); $allowed = '~\-_.,\(\[\)\]'; // Arguments order doesn't matter $args = \func_get_args(); foreach ( $args as $i => $a ){ if ( $i > 0 ){ if ( \is_string($a) ){ $extension = $a; } else if ( \is_int($a) ){ $maxlength = $a; } else if ( \is_bool($a) ){ $is_path = $a; } } } if ( !\is_int($maxlength) ){ $maxlength = mb_strlen($st); } if ( $is_path ){ $allowed .= '/'; } if ( $extension && (self::file_ext($st) === self::change_case($extension, 'lower')) ){ $st = substr($st, 0, -(\strlen($extension)+1)); } else if ( $extension = self::file_ext($st) ){ $st = substr($st, 0, -(\strlen($extension)+1)); } $st = mb_ereg_replace("([^\w\s\d".$allowed.".])", '', $st); $st = mb_ereg_replace("([\.]{2,})", '', $st); $res = mb_substr($st, 0, $maxlength); if ( $extension ){ $res .= '.' . $extension; } return $res; }
[ "public", "static", "function", "encode_filename", "(", "$", "st", ",", "$", "maxlength", "=", "50", ",", "$", "extension", "=", "null", ",", "$", "is_path", "=", "false", ")", ":", "string", "{", "$", "st", "=", "self", "::", "remove_accents", "(", "self", "::", "cast", "(", "$", "st", ")", ")", ";", "$", "allowed", "=", "'~\\-_.,\\(\\[\\)\\]'", ";", "// Arguments order doesn't matter", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "i", "=>", "$", "a", ")", "{", "if", "(", "$", "i", ">", "0", ")", "{", "if", "(", "\\", "is_string", "(", "$", "a", ")", ")", "{", "$", "extension", "=", "$", "a", ";", "}", "else", "if", "(", "\\", "is_int", "(", "$", "a", ")", ")", "{", "$", "maxlength", "=", "$", "a", ";", "}", "else", "if", "(", "\\", "is_bool", "(", "$", "a", ")", ")", "{", "$", "is_path", "=", "$", "a", ";", "}", "}", "}", "if", "(", "!", "\\", "is_int", "(", "$", "maxlength", ")", ")", "{", "$", "maxlength", "=", "mb_strlen", "(", "$", "st", ")", ";", "}", "if", "(", "$", "is_path", ")", "{", "$", "allowed", ".=", "'/'", ";", "}", "if", "(", "$", "extension", "&&", "(", "self", "::", "file_ext", "(", "$", "st", ")", "===", "self", "::", "change_case", "(", "$", "extension", ",", "'lower'", ")", ")", ")", "{", "$", "st", "=", "substr", "(", "$", "st", ",", "0", ",", "-", "(", "\\", "strlen", "(", "$", "extension", ")", "+", "1", ")", ")", ";", "}", "else", "if", "(", "$", "extension", "=", "self", "::", "file_ext", "(", "$", "st", ")", ")", "{", "$", "st", "=", "substr", "(", "$", "st", ",", "0", ",", "-", "(", "\\", "strlen", "(", "$", "extension", ")", "+", "1", ")", ")", ";", "}", "$", "st", "=", "mb_ereg_replace", "(", "\"([^\\w\\s\\d\"", ".", "$", "allowed", ".", "\".])\"", ",", "''", ",", "$", "st", ")", ";", "$", "st", "=", "mb_ereg_replace", "(", "\"([\\.]{2,})\"", ",", "''", ",", "$", "st", ")", ";", "$", "res", "=", "mb_substr", "(", "$", "st", ",", "0", ",", "$", "maxlength", ")", ";", "if", "(", "$", "extension", ")", "{", "$", "res", ".=", "'.'", ".", "$", "extension", ";", "}", "return", "$", "res", ";", "}" ]
Returns a cross-platform filename for the file. ```php \bbn\x::dump(\bbn\str::encode_filename('test file/,1', 15, 'txt')); // (string) "test_file_1.txt" ``` @param string $st The name as string. @param int $maxlength The maximum filename length (without extension), default: "50". @param string $extension The extension of the file. @param bool $is_path Tells if the slashes (/) are authorized in the string @return string
[ "Returns", "a", "cross", "-", "platform", "filename", "for", "the", "file", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L373-L419
24,022
nabab/bbn
src/bbn/str.php
str.encode_dbname
public static function encode_dbname($st, $maxlength = 50): string { $st = self::remove_accents(self::cast($st)); $res = ''; if ( !\is_int($maxlength) ){ $maxlength = mb_strlen($st); } for ( $i = 0; $i < $maxlength; $i++ ){ if ( mb_ereg_match('[A-z0-9]',mb_substr($st,$i,1)) ){ $res .= mb_substr($st,$i,1); } else if ( (mb_strlen($res) > 0) && (mb_substr($res,-1) != '_') && ($i < ( mb_strlen($st) - 1 )) ){ $res .= '_'; } } if ( substr($res, -1) === '_' ){ $res = substr($res, 0, -1); } return $res; }
php
public static function encode_dbname($st, $maxlength = 50): string { $st = self::remove_accents(self::cast($st)); $res = ''; if ( !\is_int($maxlength) ){ $maxlength = mb_strlen($st); } for ( $i = 0; $i < $maxlength; $i++ ){ if ( mb_ereg_match('[A-z0-9]',mb_substr($st,$i,1)) ){ $res .= mb_substr($st,$i,1); } else if ( (mb_strlen($res) > 0) && (mb_substr($res,-1) != '_') && ($i < ( mb_strlen($st) - 1 )) ){ $res .= '_'; } } if ( substr($res, -1) === '_' ){ $res = substr($res, 0, -1); } return $res; }
[ "public", "static", "function", "encode_dbname", "(", "$", "st", ",", "$", "maxlength", "=", "50", ")", ":", "string", "{", "$", "st", "=", "self", "::", "remove_accents", "(", "self", "::", "cast", "(", "$", "st", ")", ")", ";", "$", "res", "=", "''", ";", "if", "(", "!", "\\", "is_int", "(", "$", "maxlength", ")", ")", "{", "$", "maxlength", "=", "mb_strlen", "(", "$", "st", ")", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "maxlength", ";", "$", "i", "++", ")", "{", "if", "(", "mb_ereg_match", "(", "'[A-z0-9]'", ",", "mb_substr", "(", "$", "st", ",", "$", "i", ",", "1", ")", ")", ")", "{", "$", "res", ".=", "mb_substr", "(", "$", "st", ",", "$", "i", ",", "1", ")", ";", "}", "else", "if", "(", "(", "mb_strlen", "(", "$", "res", ")", ">", "0", ")", "&&", "(", "mb_substr", "(", "$", "res", ",", "-", "1", ")", "!=", "'_'", ")", "&&", "(", "$", "i", "<", "(", "mb_strlen", "(", "$", "st", ")", "-", "1", ")", ")", ")", "{", "$", "res", ".=", "'_'", ";", "}", "}", "if", "(", "substr", "(", "$", "res", ",", "-", "1", ")", "===", "'_'", ")", "{", "$", "res", "=", "substr", "(", "$", "res", ",", "0", ",", "-", "1", ")", ";", "}", "return", "$", "res", ";", "}" ]
Returns a corrected string for database naming. ```php \bbn\x::dump(\bbn\str::encode_dbname('my.database_name ? test :,; !plus')); // (string) "my_database_name_test_plus" ``` @param string $st The name as string. @param int $maxlength The maximum length, default: "50". @return string
[ "Returns", "a", "corrected", "string", "for", "database", "naming", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L433-L456
24,023
nabab/bbn
src/bbn/str.php
str.genpwd
public static function genpwd(int $int_max = 12, int $int_min = 6): string { mt_srand(); $len = ($int_min > 0) && ($int_min < $int_max) ? random_int($int_min, $int_max) : $int_max; $mdp = ''; for( $i = 0; $i < $len; $i++ ){ // First character is a letter $type = $i === 0 ? random_int(2, 3) : random_int(1, 3); switch ( $type ){ case 1: $mdp .= random_int(0,9); break; case 2: $mdp .= \chr(random_int(65,90)); break; case 3: $mdp .= \chr(random_int(97,122)); break; } } return $mdp; }
php
public static function genpwd(int $int_max = 12, int $int_min = 6): string { mt_srand(); $len = ($int_min > 0) && ($int_min < $int_max) ? random_int($int_min, $int_max) : $int_max; $mdp = ''; for( $i = 0; $i < $len; $i++ ){ // First character is a letter $type = $i === 0 ? random_int(2, 3) : random_int(1, 3); switch ( $type ){ case 1: $mdp .= random_int(0,9); break; case 2: $mdp .= \chr(random_int(65,90)); break; case 3: $mdp .= \chr(random_int(97,122)); break; } } return $mdp; }
[ "public", "static", "function", "genpwd", "(", "int", "$", "int_max", "=", "12", ",", "int", "$", "int_min", "=", "6", ")", ":", "string", "{", "mt_srand", "(", ")", ";", "$", "len", "=", "(", "$", "int_min", ">", "0", ")", "&&", "(", "$", "int_min", "<", "$", "int_max", ")", "?", "random_int", "(", "$", "int_min", ",", "$", "int_max", ")", ":", "$", "int_max", ";", "$", "mdp", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "// First character is a letter", "$", "type", "=", "$", "i", "===", "0", "?", "random_int", "(", "2", ",", "3", ")", ":", "random_int", "(", "1", ",", "3", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "1", ":", "$", "mdp", ".=", "random_int", "(", "0", ",", "9", ")", ";", "break", ";", "case", "2", ":", "$", "mdp", ".=", "\\", "chr", "(", "random_int", "(", "65", ",", "90", ")", ")", ";", "break", ";", "case", "3", ":", "$", "mdp", ".=", "\\", "chr", "(", "random_int", "(", "97", ",", "122", ")", ")", ";", "break", ";", "}", "}", "return", "$", "mdp", ";", "}" ]
Returns a random password. ```php \bbn\x::dump(\bbn\str::genpwd()); // (string) "khc9P871w" \bbn\x::dump(\bbn\str::genpwd(6, 4)); // (string) "dDEtxY" ``` @param int $int_max Maximum password characters, default: "12". @param int $int_min Minimum password characters, default: "6". @return string
[ "Returns", "a", "random", "password", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L501-L522
24,024
nabab/bbn
src/bbn/str.php
str.is_json
public static function is_json($st) { if ( \is_string($st) && !empty($st) && ( (substr($st, 0, 1) === '{') || (substr($st, 0, 1) === '[') )){ json_decode($st); return (json_last_error() == JSON_ERROR_NONE); } return false; }
php
public static function is_json($st) { if ( \is_string($st) && !empty($st) && ( (substr($st, 0, 1) === '{') || (substr($st, 0, 1) === '[') )){ json_decode($st); return (json_last_error() == JSON_ERROR_NONE); } return false; }
[ "public", "static", "function", "is_json", "(", "$", "st", ")", "{", "if", "(", "\\", "is_string", "(", "$", "st", ")", "&&", "!", "empty", "(", "$", "st", ")", "&&", "(", "(", "substr", "(", "$", "st", ",", "0", ",", "1", ")", "===", "'{'", ")", "||", "(", "substr", "(", "$", "st", ",", "0", ",", "1", ")", "===", "'['", ")", ")", ")", "{", "json_decode", "(", "$", "st", ")", ";", "return", "(", "json_last_error", "(", ")", "==", "JSON_ERROR_NONE", ")", ";", "}", "return", "false", ";", "}" ]
Checks if the string is a json string. ```php \bbn\x::dump(\bbn\str::is_json('{"firstName": "John", "lastName": "Smith", "age": 25}')); // (bool) true ``` @param string $st The string. @return bool
[ "Checks", "if", "the", "string", "is", "a", "json", "string", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L535-L543
24,025
nabab/bbn
src/bbn/str.php
str.is_number
public static function is_number(): bool { $args = \func_get_args(); foreach ( $args as $a ){ if ( \is_string($a) || (abs($a) > PHP_INT_MAX) ){ if ( !preg_match('/^-?(?:\d+|\d*\.\d+)$/', $a) ){ return false; } } else if ( !\is_int($a) && !\is_float($a) ){ return false; } } return 1; }
php
public static function is_number(): bool { $args = \func_get_args(); foreach ( $args as $a ){ if ( \is_string($a) || (abs($a) > PHP_INT_MAX) ){ if ( !preg_match('/^-?(?:\d+|\d*\.\d+)$/', $a) ){ return false; } } else if ( !\is_int($a) && !\is_float($a) ){ return false; } } return 1; }
[ "public", "static", "function", "is_number", "(", ")", ":", "bool", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "if", "(", "\\", "is_string", "(", "$", "a", ")", "||", "(", "abs", "(", "$", "a", ")", ">", "PHP_INT_MAX", ")", ")", "{", "if", "(", "!", "preg_match", "(", "'/^-?(?:\\d+|\\d*\\.\\d+)$/'", ",", "$", "a", ")", ")", "{", "return", "false", ";", "}", "}", "else", "if", "(", "!", "\\", "is_int", "(", "$", "a", ")", "&&", "!", "\\", "is_float", "(", "$", "a", ")", ")", "{", "return", "false", ";", "}", "}", "return", "1", ";", "}" ]
Checks if the item is a number. Can take as many arguments and will return false if one of them is not a number. ```php \bbn\x::dump(\bbn\str::is_number([1, 2])); // (bool) false \bbn\x::dump(\bbn\str::is_number(150); // (bool) 1 \bbn\x::dump(\bbn\str::is_number('150')); // (bool) 1 \bbn\x::dump(\bbn\str::is_number(1.5); // (bool) 1 ``` @param mixed $st The item to be tested. @return bool
[ "Checks", "if", "the", "item", "is", "a", "number", ".", "Can", "take", "as", "many", "arguments", "and", "will", "return", "false", "if", "one", "of", "them", "is", "not", "a", "number", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L563-L577
24,026
nabab/bbn
src/bbn/str.php
str.is_integer
public static function is_integer(): bool { $args = \func_get_args(); foreach ( $args as $a ){ if ( \is_string($a) || (abs($a) > PHP_INT_MAX) ){ if ( !preg_match('/^-?(\d+)$/', (string)$a) ){ return false; } } else if ( !\is_int($a) ){ return false; } } return true; }
php
public static function is_integer(): bool { $args = \func_get_args(); foreach ( $args as $a ){ if ( \is_string($a) || (abs($a) > PHP_INT_MAX) ){ if ( !preg_match('/^-?(\d+)$/', (string)$a) ){ return false; } } else if ( !\is_int($a) ){ return false; } } return true; }
[ "public", "static", "function", "is_integer", "(", ")", ":", "bool", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "if", "(", "\\", "is_string", "(", "$", "a", ")", "||", "(", "abs", "(", "$", "a", ")", ">", "PHP_INT_MAX", ")", ")", "{", "if", "(", "!", "preg_match", "(", "'/^-?(\\d+)$/'", ",", "(", "string", ")", "$", "a", ")", ")", "{", "return", "false", ";", "}", "}", "else", "if", "(", "!", "\\", "is_int", "(", "$", "a", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if the item is a integer. Can take as many arguments and will return false if one of them is not an integer or the string of an integer. ```php \bbn\x::dump(\bbn\str::is_integer(13.2)); // (bool) false \bbn\x::dump(\bbn\str::is_integer(14)); // (bool) true \bbn\x::dump(\bbn\str::is_integer('14')); // (bool) true ``` @param mixed $st The item to be tested. @return bool
[ "Checks", "if", "the", "item", "is", "a", "integer", ".", "Can", "take", "as", "many", "arguments", "and", "will", "return", "false", "if", "one", "of", "them", "is", "not", "an", "integer", "or", "the", "string", "of", "an", "integer", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L595-L609
24,027
nabab/bbn
src/bbn/str.php
str.is_buid
public static function is_buid($st): bool { if ( \is_string($st) && (\strlen($st) === 16) && !ctype_print($st) && !ctype_space($st) ){ $enc = mb_detect_encoding($st, ['8bit', 'UTF-8']); if ( !$enc || ($enc === '8bit') ){ return true; } } return false; }
php
public static function is_buid($st): bool { if ( \is_string($st) && (\strlen($st) === 16) && !ctype_print($st) && !ctype_space($st) ){ $enc = mb_detect_encoding($st, ['8bit', 'UTF-8']); if ( !$enc || ($enc === '8bit') ){ return true; } } return false; }
[ "public", "static", "function", "is_buid", "(", "$", "st", ")", ":", "bool", "{", "if", "(", "\\", "is_string", "(", "$", "st", ")", "&&", "(", "\\", "strlen", "(", "$", "st", ")", "===", "16", ")", "&&", "!", "ctype_print", "(", "$", "st", ")", "&&", "!", "ctype_space", "(", "$", "st", ")", ")", "{", "$", "enc", "=", "mb_detect_encoding", "(", "$", "st", ",", "[", "'8bit'", ",", "'UTF-8'", "]", ")", ";", "if", "(", "!", "$", "enc", "||", "(", "$", "enc", "===", "'8bit'", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if the string is a valid binary UID string. @param string $st @return boolean
[ "Checks", "if", "the", "string", "is", "a", "valid", "binary", "UID", "string", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L691-L700
24,028
nabab/bbn
src/bbn/str.php
str.is_email
public static function is_email($email): bool { if ( function_exists('filter_var') ){ return filter_var($email,FILTER_VALIDATE_EMAIL) ? true : false; } else { $isValid = true; $atIndex = mb_strrpos($email, "@"); if (\is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = mb_substr($email, $atIndex+1); $local = mb_substr($email, 0, $atIndex); $localLen = mb_strlen($local); $domainLen = mb_strlen($domain); // local part length exceeded if ($localLen < 1 || $localLen > 64) $isValid = false; // domain part length exceeded else if ($domainLen < 1 || $domainLen > 255) $isValid = false; // local part starts or ends with '.' else if ($local[0] == '.' || $local[$localLen-1] == '.') $isValid = false; // local part has two consecutive dots else if (mb_ereg_match('\\.\\.', $local)) $isValid = false; // character not valid in domain part else if (!mb_ereg_match('^[A-Za-z0-9\\-\\.]+$', $domain)) $isValid = false; // domain part has two consecutive dots else if (mb_ereg_match('\\.\\.', $domain)) $isValid = false; // character not valid in local part unless else if ( !mb_ereg_match('^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$' ,str_replace("\\\\","",$local))) { // local part is quoted if ( !mb_ereg_match('^"(\\\\"|[^"])+"$',str_replace("\\\\","",$local)) ) $isValid = false; } } return $isValid; } }
php
public static function is_email($email): bool { if ( function_exists('filter_var') ){ return filter_var($email,FILTER_VALIDATE_EMAIL) ? true : false; } else { $isValid = true; $atIndex = mb_strrpos($email, "@"); if (\is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = mb_substr($email, $atIndex+1); $local = mb_substr($email, 0, $atIndex); $localLen = mb_strlen($local); $domainLen = mb_strlen($domain); // local part length exceeded if ($localLen < 1 || $localLen > 64) $isValid = false; // domain part length exceeded else if ($domainLen < 1 || $domainLen > 255) $isValid = false; // local part starts or ends with '.' else if ($local[0] == '.' || $local[$localLen-1] == '.') $isValid = false; // local part has two consecutive dots else if (mb_ereg_match('\\.\\.', $local)) $isValid = false; // character not valid in domain part else if (!mb_ereg_match('^[A-Za-z0-9\\-\\.]+$', $domain)) $isValid = false; // domain part has two consecutive dots else if (mb_ereg_match('\\.\\.', $domain)) $isValid = false; // character not valid in local part unless else if ( !mb_ereg_match('^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$' ,str_replace("\\\\","",$local))) { // local part is quoted if ( !mb_ereg_match('^"(\\\\"|[^"])+"$',str_replace("\\\\","",$local)) ) $isValid = false; } } return $isValid; } }
[ "public", "static", "function", "is_email", "(", "$", "email", ")", ":", "bool", "{", "if", "(", "function_exists", "(", "'filter_var'", ")", ")", "{", "return", "filter_var", "(", "$", "email", ",", "FILTER_VALIDATE_EMAIL", ")", "?", "true", ":", "false", ";", "}", "else", "{", "$", "isValid", "=", "true", ";", "$", "atIndex", "=", "mb_strrpos", "(", "$", "email", ",", "\"@\"", ")", ";", "if", "(", "\\", "is_bool", "(", "$", "atIndex", ")", "&&", "!", "$", "atIndex", ")", "{", "$", "isValid", "=", "false", ";", "}", "else", "{", "$", "domain", "=", "mb_substr", "(", "$", "email", ",", "$", "atIndex", "+", "1", ")", ";", "$", "local", "=", "mb_substr", "(", "$", "email", ",", "0", ",", "$", "atIndex", ")", ";", "$", "localLen", "=", "mb_strlen", "(", "$", "local", ")", ";", "$", "domainLen", "=", "mb_strlen", "(", "$", "domain", ")", ";", "// local part length exceeded", "if", "(", "$", "localLen", "<", "1", "||", "$", "localLen", ">", "64", ")", "$", "isValid", "=", "false", ";", "// domain part length exceeded", "else", "if", "(", "$", "domainLen", "<", "1", "||", "$", "domainLen", ">", "255", ")", "$", "isValid", "=", "false", ";", "// local part starts or ends with '.'", "else", "if", "(", "$", "local", "[", "0", "]", "==", "'.'", "||", "$", "local", "[", "$", "localLen", "-", "1", "]", "==", "'.'", ")", "$", "isValid", "=", "false", ";", "// local part has two consecutive dots", "else", "if", "(", "mb_ereg_match", "(", "'\\\\.\\\\.'", ",", "$", "local", ")", ")", "$", "isValid", "=", "false", ";", "// character not valid in domain part", "else", "if", "(", "!", "mb_ereg_match", "(", "'^[A-Za-z0-9\\\\-\\\\.]+$'", ",", "$", "domain", ")", ")", "$", "isValid", "=", "false", ";", "// domain part has two consecutive dots", "else", "if", "(", "mb_ereg_match", "(", "'\\\\.\\\\.'", ",", "$", "domain", ")", ")", "$", "isValid", "=", "false", ";", "// character not valid in local part unless", "else", "if", "(", "!", "mb_ereg_match", "(", "'^(\\\\\\\\.|[A-Za-z0-9!#%&`_=\\\\/$\\'*+?^{}|~.-])+$'", ",", "str_replace", "(", "\"\\\\\\\\\"", ",", "\"\"", ",", "$", "local", ")", ")", ")", "{", "// local part is quoted", "if", "(", "!", "mb_ereg_match", "(", "'^\"(\\\\\\\\\"|[^\"])+\"$'", ",", "str_replace", "(", "\"\\\\\\\\\"", ",", "\"\"", ",", "$", "local", ")", ")", ")", "$", "isValid", "=", "false", ";", "}", "}", "return", "$", "isValid", ";", "}", "}" ]
Checks if the string is the correct type of e-mail address. ```php \bbn\x::dump(\bbn\str::is_email('test@email.com')); // (bool) true \bbn\x::dump(\bbn\str::is_email('test@email')); // (bool) false \bbn\x::dump(\bbn\str::is_email('test@.com')); // (bool) false \bbn\x::dump(\bbn\str::is_email('testemail.com')); // (bool) false ``` @param string $email E-mail address. @return bool
[ "Checks", "if", "the", "string", "is", "the", "correct", "type", "of", "e", "-", "mail", "address", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L719-L767
24,029
nabab/bbn
src/bbn/str.php
str.correct_types
public static function correct_types($st){ if ( \is_string($st) ){ if ( self::is_buid($st) ){ $st = bin2hex($st); } else{ if ( self::is_json($st) ){ if ( strpos($st, '": ') && ($json = json_decode($st)) ){ return json_encode($json); } return $st; } $st = trim($st); // Not starting with a zero or ending with a zero decimal if ( !preg_match('/^0[^.]+|\.[0-9]*0$/', $st) ){ if ( self::is_integer($st) && ((substr((string)$st, 0, 1) !== '0') || ($st === '0')) ){ $tmp = (int)$st; if ( ($tmp < PHP_INT_MAX) && ($tmp > -PHP_INT_MAX) ){ return $tmp; } } // If it is a decimal, not starting or ending with a zero else if ( self::is_decimal($st) ){ return (float)$st; } } } } else if ( \is_array($st) ){ foreach ( $st as $k => $v ){ $st[$k] = self::correct_types($v); } } else if ( \is_object($st) ){ $vs = get_object_vars($st); foreach ( $vs as $k => $v ){ $st->$k = self::correct_types($v); } } return $st; }
php
public static function correct_types($st){ if ( \is_string($st) ){ if ( self::is_buid($st) ){ $st = bin2hex($st); } else{ if ( self::is_json($st) ){ if ( strpos($st, '": ') && ($json = json_decode($st)) ){ return json_encode($json); } return $st; } $st = trim($st); // Not starting with a zero or ending with a zero decimal if ( !preg_match('/^0[^.]+|\.[0-9]*0$/', $st) ){ if ( self::is_integer($st) && ((substr((string)$st, 0, 1) !== '0') || ($st === '0')) ){ $tmp = (int)$st; if ( ($tmp < PHP_INT_MAX) && ($tmp > -PHP_INT_MAX) ){ return $tmp; } } // If it is a decimal, not starting or ending with a zero else if ( self::is_decimal($st) ){ return (float)$st; } } } } else if ( \is_array($st) ){ foreach ( $st as $k => $v ){ $st[$k] = self::correct_types($v); } } else if ( \is_object($st) ){ $vs = get_object_vars($st); foreach ( $vs as $k => $v ){ $st->$k = self::correct_types($v); } } return $st; }
[ "public", "static", "function", "correct_types", "(", "$", "st", ")", "{", "if", "(", "\\", "is_string", "(", "$", "st", ")", ")", "{", "if", "(", "self", "::", "is_buid", "(", "$", "st", ")", ")", "{", "$", "st", "=", "bin2hex", "(", "$", "st", ")", ";", "}", "else", "{", "if", "(", "self", "::", "is_json", "(", "$", "st", ")", ")", "{", "if", "(", "strpos", "(", "$", "st", ",", "'\": '", ")", "&&", "(", "$", "json", "=", "json_decode", "(", "$", "st", ")", ")", ")", "{", "return", "json_encode", "(", "$", "json", ")", ";", "}", "return", "$", "st", ";", "}", "$", "st", "=", "trim", "(", "$", "st", ")", ";", "// Not starting with a zero or ending with a zero decimal", "if", "(", "!", "preg_match", "(", "'/^0[^.]+|\\.[0-9]*0$/'", ",", "$", "st", ")", ")", "{", "if", "(", "self", "::", "is_integer", "(", "$", "st", ")", "&&", "(", "(", "substr", "(", "(", "string", ")", "$", "st", ",", "0", ",", "1", ")", "!==", "'0'", ")", "||", "(", "$", "st", "===", "'0'", ")", ")", ")", "{", "$", "tmp", "=", "(", "int", ")", "$", "st", ";", "if", "(", "(", "$", "tmp", "<", "PHP_INT_MAX", ")", "&&", "(", "$", "tmp", ">", "-", "PHP_INT_MAX", ")", ")", "{", "return", "$", "tmp", ";", "}", "}", "// If it is a decimal, not starting or ending with a zero", "else", "if", "(", "self", "::", "is_decimal", "(", "$", "st", ")", ")", "{", "return", "(", "float", ")", "$", "st", ";", "}", "}", "}", "}", "else", "if", "(", "\\", "is_array", "(", "$", "st", ")", ")", "{", "foreach", "(", "$", "st", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "st", "[", "$", "k", "]", "=", "self", "::", "correct_types", "(", "$", "v", ")", ";", "}", "}", "else", "if", "(", "\\", "is_object", "(", "$", "st", ")", ")", "{", "$", "vs", "=", "get_object_vars", "(", "$", "st", ")", ";", "foreach", "(", "$", "vs", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "st", "->", "$", "k", "=", "self", "::", "correct_types", "(", "$", "v", ")", ";", "}", "}", "return", "$", "st", ";", "}" ]
If it looks like an int or float type, the string variable is converted into the correct type. ```php \bbn\x::dump(\bbn\str::correct_types(1230)); // (int) 1230 \bbn\x::dump(\bbn\str::correct_types(12.30)); // (float) 12.3 \bbn\x::dump(\bbn\str::correct_types("12.3")); // (float) 12.3 \bbn\x::dump(\bbn\str::correct_types([1230])); // (int) [1230] ``` @param mixed $st @return mixed
[ "If", "it", "looks", "like", "an", "int", "or", "float", "type", "the", "string", "variable", "is", "converted", "into", "the", "correct", "type", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L851-L891
24,030
nabab/bbn
src/bbn/str.php
str.parse_url
public static function parse_url($url): array { $url = self::cast($url); $r = x::merge_arrays(parse_url($url), ['url' => $url,'query' => '','params' => []]); if ( strpos($url,'?') > 0 ) { $p = explode('?',$url); $r['url'] = $p[0]; $r['query'] = $p[1]; $ps = explode('&',$r['query']); foreach ( $ps as $p ){ $px = explode('=',$p); $r['params'][$px[0]] = $px[1]; } } return $r; }
php
public static function parse_url($url): array { $url = self::cast($url); $r = x::merge_arrays(parse_url($url), ['url' => $url,'query' => '','params' => []]); if ( strpos($url,'?') > 0 ) { $p = explode('?',$url); $r['url'] = $p[0]; $r['query'] = $p[1]; $ps = explode('&',$r['query']); foreach ( $ps as $p ){ $px = explode('=',$p); $r['params'][$px[0]] = $px[1]; } } return $r; }
[ "public", "static", "function", "parse_url", "(", "$", "url", ")", ":", "array", "{", "$", "url", "=", "self", "::", "cast", "(", "$", "url", ")", ";", "$", "r", "=", "x", "::", "merge_arrays", "(", "parse_url", "(", "$", "url", ")", ",", "[", "'url'", "=>", "$", "url", ",", "'query'", "=>", "''", ",", "'params'", "=>", "[", "]", "]", ")", ";", "if", "(", "strpos", "(", "$", "url", ",", "'?'", ")", ">", "0", ")", "{", "$", "p", "=", "explode", "(", "'?'", ",", "$", "url", ")", ";", "$", "r", "[", "'url'", "]", "=", "$", "p", "[", "0", "]", ";", "$", "r", "[", "'query'", "]", "=", "$", "p", "[", "1", "]", ";", "$", "ps", "=", "explode", "(", "'&'", ",", "$", "r", "[", "'query'", "]", ")", ";", "foreach", "(", "$", "ps", "as", "$", "p", ")", "{", "$", "px", "=", "explode", "(", "'='", ",", "$", "p", ")", ";", "$", "r", "[", "'params'", "]", "[", "$", "px", "[", "0", "]", "]", "=", "$", "px", "[", "1", "]", ";", "}", "}", "return", "$", "r", ";", "}" ]
Returns an array containing any of the various components of the URL that are present. ```php \bbn\x::hdump(\bbn\str::parse_url('http://localhost/phpmyadmin/?db=test&table=users&server=1&target=&token=e45a102c5672b2b4fe84ae75d9148981'); /* (array) [ 'scheme' => 'http', 'host' => 'localhost', 'path' => '/phpmyadmin/', 'query' => 'db=test&table=users&server=1&target=&token=e45a102c5672b2b4fe84ae75d9148981', 'url' => 'http://localhost/phpmyadmin/', 'params' => [ 'db' => 'test', 'table' => 'users', 'server' => '1', 'target' => '', 'token' => 'e45a102c5672b2b4fe84ae75d9148981', ], ] ``` @param string $url The url. @return array
[ "Returns", "an", "array", "containing", "any", "of", "the", "various", "components", "of", "the", "URL", "that", "are", "present", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L918-L934
24,031
nabab/bbn
src/bbn/str.php
str.check_name
public static function check_name(): bool { $args = \func_get_args(); // Each argument must be a string starting with a letter, and having only one character made of letters, numbers and underscores foreach ( $args as $a ){ $a = self::cast($a); $t = preg_match('#[A-z0-9_]+#',$a,$m); if ( $t !== 1 || $m[0] !== $a ){ return false; } } return true; }
php
public static function check_name(): bool { $args = \func_get_args(); // Each argument must be a string starting with a letter, and having only one character made of letters, numbers and underscores foreach ( $args as $a ){ $a = self::cast($a); $t = preg_match('#[A-z0-9_]+#',$a,$m); if ( $t !== 1 || $m[0] !== $a ){ return false; } } return true; }
[ "public", "static", "function", "check_name", "(", ")", ":", "bool", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "// Each argument must be a string starting with a letter, and having only one character made of letters, numbers and underscores", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "$", "a", "=", "self", "::", "cast", "(", "$", "a", ")", ";", "$", "t", "=", "preg_match", "(", "'#[A-z0-9_]+#'", ",", "$", "a", ",", "$", "m", ")", ";", "if", "(", "$", "t", "!==", "1", "||", "$", "m", "[", "0", "]", "!==", "$", "a", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if a string complies with SQL naming convention. ```php \bbn\x::dump(\bbn\str::check_name("Paul")); // (bool) true \bbn\x::dump(\bbn\str::check_name("Pa ul")); // (bool) false ``` @return bool
[ "Checks", "if", "a", "string", "complies", "with", "SQL", "naming", "convention", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L1012-L1026
24,032
nabab/bbn
src/bbn/str.php
str.check_filename
public static function check_filename(): bool { $args = \func_get_args(); // Each argument must be a string starting with a letter, and having than one character made of letters, numbers and underscores foreach ( $args as $a ){ if ( !\is_string($a) || (strpos($a, '/') !== false) || (strpos($a, '\\') !== false) ){ return false; } } return true; }
php
public static function check_filename(): bool { $args = \func_get_args(); // Each argument must be a string starting with a letter, and having than one character made of letters, numbers and underscores foreach ( $args as $a ){ if ( !\is_string($a) || (strpos($a, '/') !== false) || (strpos($a, '\\') !== false) ){ return false; } } return true; }
[ "public", "static", "function", "check_filename", "(", ")", ":", "bool", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "// Each argument must be a string starting with a letter, and having than one character made of letters, numbers and underscores", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "if", "(", "!", "\\", "is_string", "(", "$", "a", ")", "||", "(", "strpos", "(", "$", "a", ",", "'/'", ")", "!==", "false", ")", "||", "(", "strpos", "(", "$", "a", ",", "'\\\\'", ")", "!==", "false", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if a string doesn't contain a filesystem path. ```php \bbn\x::dump(\bbn\str::check_filename("Paul")); // (bool) true \bbn\x::dump(\bbn\str::check_filename("Paul/")); // (bool) false ``` @return bool
[ "Checks", "if", "a", "string", "doesn", "t", "contain", "a", "filesystem", "path", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L1039-L1050
24,033
nabab/bbn
src/bbn/str.php
str.has_slash
public static function has_slash(): bool { $args = \func_get_args(); // Each argument must be a string starting with a letter, and having than one character made of letters, numbers and underscores foreach ( $args as $a ){ if ( (strpos($a, '/') !== false) || (strpos($a, '\\') !== false) ){ return true; } } return false; }
php
public static function has_slash(): bool { $args = \func_get_args(); // Each argument must be a string starting with a letter, and having than one character made of letters, numbers and underscores foreach ( $args as $a ){ if ( (strpos($a, '/') !== false) || (strpos($a, '\\') !== false) ){ return true; } } return false; }
[ "public", "static", "function", "has_slash", "(", ")", ":", "bool", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "// Each argument must be a string starting with a letter, and having than one character made of letters, numbers and underscores", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "if", "(", "(", "strpos", "(", "$", "a", ",", "'/'", ")", "!==", "false", ")", "||", "(", "strpos", "(", "$", "a", ",", "'\\\\'", ")", "!==", "false", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if a string complies with SQL naming convention. Returns "true" if slash or backslash are present. ```php \bbn\x::dump(\bbn\str::has_slash("Paul")); // (bool) false \bbn\x::dump(\bbn\str::has_slash("Paul/"); // (bool) 1 \bbn\x::dump(\bbn\str::has_slash("Paul\\"); // (bool) 1 ``` @return bool
[ "Checks", "if", "a", "string", "complies", "with", "SQL", "naming", "convention", ".", "Returns", "true", "if", "slash", "or", "backslash", "are", "present", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L1068-L1080
24,034
nabab/bbn
src/bbn/str.php
str.say_size
public static function say_size($bytes, $unit = 'B', $stop = false): string { // pretty printer for byte values // $i = 0; $units = ['', 'K', 'M', 'G', 'T']; while ( $stop || ($bytes > 2000) ){ $i++; $bytes /= 1024; if ( $stop === $units[$i] ){ break; } } return sprintf("%5.2f %s".$unit, $bytes, $units[$i]); }
php
public static function say_size($bytes, $unit = 'B', $stop = false): string { // pretty printer for byte values // $i = 0; $units = ['', 'K', 'M', 'G', 'T']; while ( $stop || ($bytes > 2000) ){ $i++; $bytes /= 1024; if ( $stop === $units[$i] ){ break; } } return sprintf("%5.2f %s".$unit, $bytes, $units[$i]); }
[ "public", "static", "function", "say_size", "(", "$", "bytes", ",", "$", "unit", "=", "'B'", ",", "$", "stop", "=", "false", ")", ":", "string", "{", "// pretty printer for byte values", "//", "$", "i", "=", "0", ";", "$", "units", "=", "[", "''", ",", "'K'", ",", "'M'", ",", "'G'", ",", "'T'", "]", ";", "while", "(", "$", "stop", "||", "(", "$", "bytes", ">", "2000", ")", ")", "{", "$", "i", "++", ";", "$", "bytes", "/=", "1024", ";", "if", "(", "$", "stop", "===", "$", "units", "[", "$", "i", "]", ")", "{", "break", ";", "}", "}", "return", "sprintf", "(", "\"%5.2f %s\"", ".", "$", "unit", ",", "$", "bytes", ",", "$", "units", "[", "$", "i", "]", ")", ";", "}" ]
Converts the bytes to another unit form. @param int $bytes The bytes @param string The unit you want to convert ('B', 'K', 'M', 'G', 'T') @parma boolean $stop @return string
[ "Converts", "the", "bytes", "to", "another", "unit", "form", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/str.php#L1311-L1325
24,035
soloproyectos-php/text-parser
src/text/parser/exception/TextParserException.php
TextParserException.getPrintableMessage
public function getPrintableMessage() { $ret = $this->message; if ($this->_parser != null) { $string = rtrim($this->_parser->getString()); $offset = $this->_parser->getOffset(); $rightStr = substr($string, $offset); $offset0 = $offset + strlen($rightStr) - strlen(ltrim($rightStr)); $str1 = substr($string, 0, $offset0); $offset1 = strrpos($str1, "\n"); if ($offset1 !== false) { $offset1++; } $str2 = substr($string, $offset1); $offset2 = strpos($str2, "\n"); if ($offset2 === false) { $offset2 = strlen($str2); } $str3 = substr($str2, 0, $offset2); $line = $offset0 > 0? substr_count($string, "\n", 0, $offset0) : 0; $column = $offset0 - $offset1; $ret = "$str3\n" . str_repeat(" ", $column) . "^" . $this->message; if ($line > 0) { $ret .= " (line " . ($line + 1) . ")"; } } return $ret; }
php
public function getPrintableMessage() { $ret = $this->message; if ($this->_parser != null) { $string = rtrim($this->_parser->getString()); $offset = $this->_parser->getOffset(); $rightStr = substr($string, $offset); $offset0 = $offset + strlen($rightStr) - strlen(ltrim($rightStr)); $str1 = substr($string, 0, $offset0); $offset1 = strrpos($str1, "\n"); if ($offset1 !== false) { $offset1++; } $str2 = substr($string, $offset1); $offset2 = strpos($str2, "\n"); if ($offset2 === false) { $offset2 = strlen($str2); } $str3 = substr($str2, 0, $offset2); $line = $offset0 > 0? substr_count($string, "\n", 0, $offset0) : 0; $column = $offset0 - $offset1; $ret = "$str3\n" . str_repeat(" ", $column) . "^" . $this->message; if ($line > 0) { $ret .= " (line " . ($line + 1) . ")"; } } return $ret; }
[ "public", "function", "getPrintableMessage", "(", ")", "{", "$", "ret", "=", "$", "this", "->", "message", ";", "if", "(", "$", "this", "->", "_parser", "!=", "null", ")", "{", "$", "string", "=", "rtrim", "(", "$", "this", "->", "_parser", "->", "getString", "(", ")", ")", ";", "$", "offset", "=", "$", "this", "->", "_parser", "->", "getOffset", "(", ")", ";", "$", "rightStr", "=", "substr", "(", "$", "string", ",", "$", "offset", ")", ";", "$", "offset0", "=", "$", "offset", "+", "strlen", "(", "$", "rightStr", ")", "-", "strlen", "(", "ltrim", "(", "$", "rightStr", ")", ")", ";", "$", "str1", "=", "substr", "(", "$", "string", ",", "0", ",", "$", "offset0", ")", ";", "$", "offset1", "=", "strrpos", "(", "$", "str1", ",", "\"\\n\"", ")", ";", "if", "(", "$", "offset1", "!==", "false", ")", "{", "$", "offset1", "++", ";", "}", "$", "str2", "=", "substr", "(", "$", "string", ",", "$", "offset1", ")", ";", "$", "offset2", "=", "strpos", "(", "$", "str2", ",", "\"\\n\"", ")", ";", "if", "(", "$", "offset2", "===", "false", ")", "{", "$", "offset2", "=", "strlen", "(", "$", "str2", ")", ";", "}", "$", "str3", "=", "substr", "(", "$", "str2", ",", "0", ",", "$", "offset2", ")", ";", "$", "line", "=", "$", "offset0", ">", "0", "?", "substr_count", "(", "$", "string", ",", "\"\\n\"", ",", "0", ",", "$", "offset0", ")", ":", "0", ";", "$", "column", "=", "$", "offset0", "-", "$", "offset1", ";", "$", "ret", "=", "\"$str3\\n\"", ".", "str_repeat", "(", "\" \"", ",", "$", "column", ")", ".", "\"^\"", ".", "$", "this", "->", "message", ";", "if", "(", "$", "line", ">", "0", ")", "{", "$", "ret", ".=", "\" (line \"", ".", "(", "$", "line", "+", "1", ")", ".", "\")\"", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Gets a printable message. This function provides a method to get printable messages. @return string
[ "Gets", "a", "printable", "message", "." ]
3ef2e8a26f7c53b170383d74ccf4106b0f3dd8b1
https://github.com/soloproyectos-php/text-parser/blob/3ef2e8a26f7c53b170383d74ccf4106b0f3dd8b1/src/text/parser/exception/TextParserException.php#L48-L82
24,036
codezero-be/curl
src/ResponseFactory.php
ResponseFactory.make
public function make($responseBody, array $responseInfo) { $info = $this->makeResponseInfo($responseInfo); $response = $this->makeResponse($responseBody, $info); return $response; }
php
public function make($responseBody, array $responseInfo) { $info = $this->makeResponseInfo($responseInfo); $response = $this->makeResponse($responseBody, $info); return $response; }
[ "public", "function", "make", "(", "$", "responseBody", ",", "array", "$", "responseInfo", ")", "{", "$", "info", "=", "$", "this", "->", "makeResponseInfo", "(", "$", "responseInfo", ")", ";", "$", "response", "=", "$", "this", "->", "makeResponse", "(", "$", "responseBody", ",", "$", "info", ")", ";", "return", "$", "response", ";", "}" ]
Make a response @param $responseBody @param array $responseInfo @return Response
[ "Make", "a", "response" ]
c1385479886662b6276c18dd9140df529959d95c
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/ResponseFactory.php#L13-L19
24,037
hametuha/wpametu
src/WPametu/Http/Input.php
Input.file_error_message
public function file_error_message( $key ) { if ( $this->file_info( $key ) ) { return ''; } elseif ( ! isset( $_FILES[ $key ] ) ) { return $this->__( 'File is not specified.' ); } else { switch ( $_FILES[ $key ]['error'] ) { case UPLOAD_ERR_FORM_SIZE: case UPLOAD_ERR_INI_SIZE: return $this->__( 'Uploaded file size exceeds allowed limit.' ); break; default: return $this->__( 'Failed to upload' ); break; } } }
php
public function file_error_message( $key ) { if ( $this->file_info( $key ) ) { return ''; } elseif ( ! isset( $_FILES[ $key ] ) ) { return $this->__( 'File is not specified.' ); } else { switch ( $_FILES[ $key ]['error'] ) { case UPLOAD_ERR_FORM_SIZE: case UPLOAD_ERR_INI_SIZE: return $this->__( 'Uploaded file size exceeds allowed limit.' ); break; default: return $this->__( 'Failed to upload' ); break; } } }
[ "public", "function", "file_error_message", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "file_info", "(", "$", "key", ")", ")", "{", "return", "''", ";", "}", "elseif", "(", "!", "isset", "(", "$", "_FILES", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "__", "(", "'File is not specified.'", ")", ";", "}", "else", "{", "switch", "(", "$", "_FILES", "[", "$", "key", "]", "[", "'error'", "]", ")", "{", "case", "UPLOAD_ERR_FORM_SIZE", ":", "case", "UPLOAD_ERR_INI_SIZE", ":", "return", "$", "this", "->", "__", "(", "'Uploaded file size exceeds allowed limit.'", ")", ";", "break", ";", "default", ":", "return", "$", "this", "->", "__", "(", "'Failed to upload'", ")", ";", "break", ";", "}", "}", "}" ]
Get file upload error message @param string $key @return string
[ "Get", "file", "upload", "error", "message" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Http/Input.php#L98-L114
24,038
zyberspace/php-discovery-shell
lib/Zyberspace/DiscoveryShell.php
DiscoveryShell._runShell
protected function _runShell() { echo wordwrap('-- discovery-shell to help discover a class or library --' . PHP_EOL . PHP_EOL . 'Use TAB for autocompletion and your arrow-keys to navigate through your method-history.' . PHP_EOL . 'Beware! This is not a full-featured php-shell. The input gets parsed with PHP-Parser to avoid the usage' . ' of eval().' . PHP_EOL, exec('tput cols'), PHP_EOL); while (true) { $input = $this->_getInput(); list($method, $arguments) = $this->_parseInput($input); $answer = call_user_func_array(array($this->_object, $method), $arguments); $this->_outputAnswer($answer); } }
php
protected function _runShell() { echo wordwrap('-- discovery-shell to help discover a class or library --' . PHP_EOL . PHP_EOL . 'Use TAB for autocompletion and your arrow-keys to navigate through your method-history.' . PHP_EOL . 'Beware! This is not a full-featured php-shell. The input gets parsed with PHP-Parser to avoid the usage' . ' of eval().' . PHP_EOL, exec('tput cols'), PHP_EOL); while (true) { $input = $this->_getInput(); list($method, $arguments) = $this->_parseInput($input); $answer = call_user_func_array(array($this->_object, $method), $arguments); $this->_outputAnswer($answer); } }
[ "protected", "function", "_runShell", "(", ")", "{", "echo", "wordwrap", "(", "'-- discovery-shell to help discover a class or library --'", ".", "PHP_EOL", ".", "PHP_EOL", ".", "'Use TAB for autocompletion and your arrow-keys to navigate through your method-history.'", ".", "PHP_EOL", ".", "'Beware! This is not a full-featured php-shell. The input gets parsed with PHP-Parser to avoid the usage'", ".", "' of eval().'", ".", "PHP_EOL", ",", "exec", "(", "'tput cols'", ")", ",", "PHP_EOL", ")", ";", "while", "(", "true", ")", "{", "$", "input", "=", "$", "this", "->", "_getInput", "(", ")", ";", "list", "(", "$", "method", ",", "$", "arguments", ")", "=", "$", "this", "->", "_parseInput", "(", "$", "input", ")", ";", "$", "answer", "=", "call_user_func_array", "(", "array", "(", "$", "this", "->", "_object", ",", "$", "method", ")", ",", "$", "arguments", ")", ";", "$", "this", "->", "_outputAnswer", "(", "$", "answer", ")", ";", "}", "}" ]
Runs the shell
[ "Runs", "the", "shell" ]
a5b4bb268c06e2cafb25e0b0383435bf448263a8
https://github.com/zyberspace/php-discovery-shell/blob/a5b4bb268c06e2cafb25e0b0383435bf448263a8/lib/Zyberspace/DiscoveryShell.php#L90-L105
24,039
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/utilities_oracle.php
ezcDbUtilitiesOracle.createTemporaryTable
public function createTemporaryTable( $tableNamePattern, $tableDefinition ) { $tableNamePattern = $this->getPrefixedTableNames($tableNamePattern); if ( strpos( $tableNamePattern, '%' ) === false ) { $tableName = $tableNamePattern; } else // generate unique table name with the given pattern { $maxTries = 10; do { $num = rand( 10000000, 99999999 ); $tableName = strtoupper( str_replace( '%', $num, $tableNamePattern ) ); $query = "SELECT count(*) AS cnt FROM user_tables WHERE table_name='$tableName'"; $cnt = (int) $this->db->query( $query )->fetchColumn( 0 ); $maxTries--; } while ( $cnt > 0 && $maxTries > 0 ); if ( $maxTries == 0 ) { throw ezcDbException( ezcDbException::GENERIC_ERROR, "Tried to generate an uninque temp table name for {$maxTries} time with no luck." ); } } $this->db->exec( "CREATE GLOBAL TEMPORARY TABLE $tableName ($tableDefinition)" ); return $tableName; }
php
public function createTemporaryTable( $tableNamePattern, $tableDefinition ) { $tableNamePattern = $this->getPrefixedTableNames($tableNamePattern); if ( strpos( $tableNamePattern, '%' ) === false ) { $tableName = $tableNamePattern; } else // generate unique table name with the given pattern { $maxTries = 10; do { $num = rand( 10000000, 99999999 ); $tableName = strtoupper( str_replace( '%', $num, $tableNamePattern ) ); $query = "SELECT count(*) AS cnt FROM user_tables WHERE table_name='$tableName'"; $cnt = (int) $this->db->query( $query )->fetchColumn( 0 ); $maxTries--; } while ( $cnt > 0 && $maxTries > 0 ); if ( $maxTries == 0 ) { throw ezcDbException( ezcDbException::GENERIC_ERROR, "Tried to generate an uninque temp table name for {$maxTries} time with no luck." ); } } $this->db->exec( "CREATE GLOBAL TEMPORARY TABLE $tableName ($tableDefinition)" ); return $tableName; }
[ "public", "function", "createTemporaryTable", "(", "$", "tableNamePattern", ",", "$", "tableDefinition", ")", "{", "$", "tableNamePattern", "=", "$", "this", "->", "getPrefixedTableNames", "(", "$", "tableNamePattern", ")", ";", "if", "(", "strpos", "(", "$", "tableNamePattern", ",", "'%'", ")", "===", "false", ")", "{", "$", "tableName", "=", "$", "tableNamePattern", ";", "}", "else", "// generate unique table name with the given pattern", "{", "$", "maxTries", "=", "10", ";", "do", "{", "$", "num", "=", "rand", "(", "10000000", ",", "99999999", ")", ";", "$", "tableName", "=", "strtoupper", "(", "str_replace", "(", "'%'", ",", "$", "num", ",", "$", "tableNamePattern", ")", ")", ";", "$", "query", "=", "\"SELECT count(*) AS cnt FROM user_tables WHERE table_name='$tableName'\"", ";", "$", "cnt", "=", "(", "int", ")", "$", "this", "->", "db", "->", "query", "(", "$", "query", ")", "->", "fetchColumn", "(", "0", ")", ";", "$", "maxTries", "--", ";", "}", "while", "(", "$", "cnt", ">", "0", "&&", "$", "maxTries", ">", "0", ")", ";", "if", "(", "$", "maxTries", "==", "0", ")", "{", "throw", "ezcDbException", "(", "ezcDbException", "::", "GENERIC_ERROR", ",", "\"Tried to generate an uninque temp table name for {$maxTries} time with no luck.\"", ")", ";", "}", "}", "$", "this", "->", "db", "->", "exec", "(", "\"CREATE GLOBAL TEMPORARY TABLE $tableName ($tableDefinition)\"", ")", ";", "return", "$", "tableName", ";", "}" ]
Creates a new temporary table and returns the name. @throws ezcDbException::GENERIC_ERROR in case of inability to generate a unique temporary table name. @see ezcDbHandler::createTemporaryTable() @param string $tableNamePattern Name of temporary table user wants to create. @param string $tableDefinition Definition for the table, i.e. everything that goes between braces after CREATE TEMPORARY TABLE clause. @return string Table name, that might have been changed by the handler to guarantee its uniqueness. @todo move out
[ "Creates", "a", "new", "temporary", "table", "and", "returns", "the", "name", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/utilities_oracle.php#L89-L119
24,040
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/utilities_oracle.php
ezcDbUtilitiesOracle.dropTemporaryTable
public function dropTemporaryTable( $tableName ) { $tableName = $this->getPrefixedTableNames($tableName); $this->db->exec( "TRUNCATE TABLE $tableName" ); $this->db->exec( "DROP TABLE $tableName" ); }
php
public function dropTemporaryTable( $tableName ) { $tableName = $this->getPrefixedTableNames($tableName); $this->db->exec( "TRUNCATE TABLE $tableName" ); $this->db->exec( "DROP TABLE $tableName" ); }
[ "public", "function", "dropTemporaryTable", "(", "$", "tableName", ")", "{", "$", "tableName", "=", "$", "this", "->", "getPrefixedTableNames", "(", "$", "tableName", ")", ";", "$", "this", "->", "db", "->", "exec", "(", "\"TRUNCATE TABLE $tableName\"", ")", ";", "$", "this", "->", "db", "->", "exec", "(", "\"DROP TABLE $tableName\"", ")", ";", "}" ]
Drop specified temporary table in a portable way. Developers should use this method instead of dropping temporary tables with the appropriate SQL queries to maintain inter-DBMS portability. @see createTemporaryTable() @param string $tableName Name of temporary table to drop. @return void
[ "Drop", "specified", "temporary", "table", "in", "a", "portable", "way", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/utilities_oracle.php#L134-L139
24,041
ArrowSphere/Client
src/xAC/Entity.php
Entity.getBaseUri
public function getBaseUri() { return sprintf('%s%s' , $this->params['endpoint'] , ! empty($this->id) ? '/' . $this->id : null ); }
php
public function getBaseUri() { return sprintf('%s%s' , $this->params['endpoint'] , ! empty($this->id) ? '/' . $this->id : null ); }
[ "public", "function", "getBaseUri", "(", ")", "{", "return", "sprintf", "(", "'%s%s'", ",", "$", "this", "->", "params", "[", "'endpoint'", "]", ",", "!", "empty", "(", "$", "this", "->", "id", ")", "?", "'/'", ".", "$", "this", "->", "id", ":", "null", ")", ";", "}" ]
Return entity endpoint base uri
[ "Return", "entity", "endpoint", "base", "uri" ]
6608f8257060375e7d3a27c485b23268b73f6ef7
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Entity.php#L56-L62
24,042
i-lateral/silverstripe-users
code/extensions/Ext_Users_Member.php
Ext_Users_Member.Register
public function Register($data) { // If we have passed a confirm password field, clean the // data if (isset($data["Password"]) && is_array($data["Password"]) && isset($data["Password"]["_Password"])) { $data["Password"] = $data["Password"]["_Password"]; } $this->owner->update($data); // Set verification code for this user $this->owner->VerificationCode = sha1(mt_rand() . mt_rand()); $this->owner->write(); // Add member to any groups that have been specified if (count(Users::config()->new_user_groups)) { $groups = Group::get()->filter( array( "Code" => Users::config()->new_user_groups ) ); foreach ($groups as $group) { $group->Members()->add($this->owner); $group->write(); } } // Send a verification email, if needed if (Users::config()->send_verification_email) { $this->owner->sendVerificationEmail(); } // Login (if enabled) if (Users::config()->login_after_register) { $this->owner->LogIn(isset($data['Remember'])); } return $this->owner; }
php
public function Register($data) { // If we have passed a confirm password field, clean the // data if (isset($data["Password"]) && is_array($data["Password"]) && isset($data["Password"]["_Password"])) { $data["Password"] = $data["Password"]["_Password"]; } $this->owner->update($data); // Set verification code for this user $this->owner->VerificationCode = sha1(mt_rand() . mt_rand()); $this->owner->write(); // Add member to any groups that have been specified if (count(Users::config()->new_user_groups)) { $groups = Group::get()->filter( array( "Code" => Users::config()->new_user_groups ) ); foreach ($groups as $group) { $group->Members()->add($this->owner); $group->write(); } } // Send a verification email, if needed if (Users::config()->send_verification_email) { $this->owner->sendVerificationEmail(); } // Login (if enabled) if (Users::config()->login_after_register) { $this->owner->LogIn(isset($data['Remember'])); } return $this->owner; }
[ "public", "function", "Register", "(", "$", "data", ")", "{", "// If we have passed a confirm password field, clean the", "// data", "if", "(", "isset", "(", "$", "data", "[", "\"Password\"", "]", ")", "&&", "is_array", "(", "$", "data", "[", "\"Password\"", "]", ")", "&&", "isset", "(", "$", "data", "[", "\"Password\"", "]", "[", "\"_Password\"", "]", ")", ")", "{", "$", "data", "[", "\"Password\"", "]", "=", "$", "data", "[", "\"Password\"", "]", "[", "\"_Password\"", "]", ";", "}", "$", "this", "->", "owner", "->", "update", "(", "$", "data", ")", ";", "// Set verification code for this user", "$", "this", "->", "owner", "->", "VerificationCode", "=", "sha1", "(", "mt_rand", "(", ")", ".", "mt_rand", "(", ")", ")", ";", "$", "this", "->", "owner", "->", "write", "(", ")", ";", "// Add member to any groups that have been specified", "if", "(", "count", "(", "Users", "::", "config", "(", ")", "->", "new_user_groups", ")", ")", "{", "$", "groups", "=", "Group", "::", "get", "(", ")", "->", "filter", "(", "array", "(", "\"Code\"", "=>", "Users", "::", "config", "(", ")", "->", "new_user_groups", ")", ")", ";", "foreach", "(", "$", "groups", "as", "$", "group", ")", "{", "$", "group", "->", "Members", "(", ")", "->", "add", "(", "$", "this", "->", "owner", ")", ";", "$", "group", "->", "write", "(", ")", ";", "}", "}", "// Send a verification email, if needed", "if", "(", "Users", "::", "config", "(", ")", "->", "send_verification_email", ")", "{", "$", "this", "->", "owner", "->", "sendVerificationEmail", "(", ")", ";", "}", "// Login (if enabled)", "if", "(", "Users", "::", "config", "(", ")", "->", "login_after_register", ")", "{", "$", "this", "->", "owner", "->", "LogIn", "(", "isset", "(", "$", "data", "[", "'Remember'", "]", ")", ")", ";", "}", "return", "$", "this", "->", "owner", ";", "}" ]
Register a new user account using the provided data and then return the current member @param array $data Array of data to create member from @return Member
[ "Register", "a", "new", "user", "account", "using", "the", "provided", "data", "and", "then", "return", "the", "current", "member" ]
27ddc38890fa2709ac419eccf854ab6b439f0d9a
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/extensions/Ext_Users_Member.php#L33-L72
24,043
i-lateral/silverstripe-users
code/extensions/Ext_Users_Member.php
Ext_Users_Member.sendVerificationEmail
public function sendVerificationEmail() { if ($this->owner->exists()) { $controller = Injector::inst()->get("Users_Register_Controller"); $subject = _t("Users.PleaseVerify", "Please verify your account"); if (Users::config()->send_email_from) { $from = Users::config()->send_email_from; } else { $from = Email::config()->admin_email; } $email = Email::create(); $email ->setFrom($from) ->setTo($this->owner->Email) ->setSubject($subject) ->setTemplate('UsersAccountVerification') ->populateTemplate( ArrayData::create( array( "Link" => Controller::join_links( $controller->AbsoluteLink("verify"), $this->owner->ID, $this->owner->VerificationCode ) ) ) ); $email->send(); return true; } return false; }
php
public function sendVerificationEmail() { if ($this->owner->exists()) { $controller = Injector::inst()->get("Users_Register_Controller"); $subject = _t("Users.PleaseVerify", "Please verify your account"); if (Users::config()->send_email_from) { $from = Users::config()->send_email_from; } else { $from = Email::config()->admin_email; } $email = Email::create(); $email ->setFrom($from) ->setTo($this->owner->Email) ->setSubject($subject) ->setTemplate('UsersAccountVerification') ->populateTemplate( ArrayData::create( array( "Link" => Controller::join_links( $controller->AbsoluteLink("verify"), $this->owner->ID, $this->owner->VerificationCode ) ) ) ); $email->send(); return true; } return false; }
[ "public", "function", "sendVerificationEmail", "(", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "exists", "(", ")", ")", "{", "$", "controller", "=", "Injector", "::", "inst", "(", ")", "->", "get", "(", "\"Users_Register_Controller\"", ")", ";", "$", "subject", "=", "_t", "(", "\"Users.PleaseVerify\"", ",", "\"Please verify your account\"", ")", ";", "if", "(", "Users", "::", "config", "(", ")", "->", "send_email_from", ")", "{", "$", "from", "=", "Users", "::", "config", "(", ")", "->", "send_email_from", ";", "}", "else", "{", "$", "from", "=", "Email", "::", "config", "(", ")", "->", "admin_email", ";", "}", "$", "email", "=", "Email", "::", "create", "(", ")", ";", "$", "email", "->", "setFrom", "(", "$", "from", ")", "->", "setTo", "(", "$", "this", "->", "owner", "->", "Email", ")", "->", "setSubject", "(", "$", "subject", ")", "->", "setTemplate", "(", "'UsersAccountVerification'", ")", "->", "populateTemplate", "(", "ArrayData", "::", "create", "(", "array", "(", "\"Link\"", "=>", "Controller", "::", "join_links", "(", "$", "controller", "->", "AbsoluteLink", "(", "\"verify\"", ")", ",", "$", "this", "->", "owner", "->", "ID", ",", "$", "this", "->", "owner", "->", "VerificationCode", ")", ")", ")", ")", ";", "$", "email", "->", "send", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Send a verification email to this user account @return boolean
[ "Send", "a", "verification", "email", "to", "this", "user", "account" ]
27ddc38890fa2709ac419eccf854ab6b439f0d9a
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/extensions/Ext_Users_Member.php#L79-L115
24,044
surebert/surebert-framework
src/sb/PDO/Logger.php
Logger.exec
public function exec($sql) { $this->writeToLog("Exec: " . $sql); $result = parent::exec($sql); return $result; }
php
public function exec($sql) { $this->writeToLog("Exec: " . $sql); $result = parent::exec($sql); return $result; }
[ "public", "function", "exec", "(", "$", "sql", ")", "{", "$", "this", "->", "writeToLog", "(", "\"Exec: \"", ".", "$", "sql", ")", ";", "$", "result", "=", "parent", "::", "exec", "(", "$", "sql", ")", ";", "return", "$", "result", ";", "}" ]
Used to issue statements which return no results but rather the number of rows affected @param string $sql @return integer The number of rows affected
[ "Used", "to", "issue", "statements", "which", "return", "no", "results", "but", "rather", "the", "number", "of", "rows", "affected" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO/Logger.php#L114-L119
24,045
surebert/surebert-framework
src/sb/PDO/Logger.php
Logger.prepare
public function prepare($sql, $options = null) { $md5 = md5($sql); if (isset($this->prepared_sql[$md5])) { return $this->prepared_sql[$md5]; } //$this->writeToLog("Preparing: ".$sql); $stmt = parent::prepare($sql); $this->prepared_sql[$md5] = $stmt; return $stmt; }
php
public function prepare($sql, $options = null) { $md5 = md5($sql); if (isset($this->prepared_sql[$md5])) { return $this->prepared_sql[$md5]; } //$this->writeToLog("Preparing: ".$sql); $stmt = parent::prepare($sql); $this->prepared_sql[$md5] = $stmt; return $stmt; }
[ "public", "function", "prepare", "(", "$", "sql", ",", "$", "options", "=", "null", ")", "{", "$", "md5", "=", "md5", "(", "$", "sql", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "prepared_sql", "[", "$", "md5", "]", ")", ")", "{", "return", "$", "this", "->", "prepared_sql", "[", "$", "md5", "]", ";", "}", "//$this->writeToLog(\"Preparing: \".$sql);", "$", "stmt", "=", "parent", "::", "prepare", "(", "$", "sql", ")", ";", "$", "this", "->", "prepared_sql", "[", "$", "md5", "]", "=", "$", "stmt", ";", "return", "$", "stmt", ";", "}" ]
Used to prepare sql statements for value binding @param string $sql @return PDO_Statement A PDO_statment instance
[ "Used", "to", "prepare", "sql", "statements", "for", "value", "binding" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO/Logger.php#L127-L140
24,046
surebert/surebert-framework
src/sb/PDO/Logger.php
Logger.writeToLog
public function writeToLog($message) { if (is_null($this->logger)) { $this->setLogger(); } if (empty($this->sbf_id) || $this->sbf_id == \sb\Gateway::$cookie['SBF_ID']) { $message = preg_replace("~\t~", " ", $message); return $this->logger->{$this->log_str}($message); } }
php
public function writeToLog($message) { if (is_null($this->logger)) { $this->setLogger(); } if (empty($this->sbf_id) || $this->sbf_id == \sb\Gateway::$cookie['SBF_ID']) { $message = preg_replace("~\t~", " ", $message); return $this->logger->{$this->log_str}($message); } }
[ "public", "function", "writeToLog", "(", "$", "message", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "logger", ")", ")", "{", "$", "this", "->", "setLogger", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "sbf_id", ")", "||", "$", "this", "->", "sbf_id", "==", "\\", "sb", "\\", "Gateway", "::", "$", "cookie", "[", "'SBF_ID'", "]", ")", "{", "$", "message", "=", "preg_replace", "(", "\"~\\t~\"", ",", "\" \"", ",", "$", "message", ")", ";", "return", "$", "this", "->", "logger", "->", "{", "$", "this", "->", "log_str", "}", "(", "$", "message", ")", ";", "}", "}" ]
Logs all sql statements to a file, if the log file is specified @param string $message The string to log
[ "Logs", "all", "sql", "statements", "to", "a", "file", "if", "the", "log", "file", "is", "specified" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO/Logger.php#L147-L159
24,047
SachaMorard/phalcon-model-annotations
Library/Phalcon/Annotations/ModelStrategy.php
ModelStrategy.getMetaData
public function getMetaData(ModelInterface $model, DiInterface $di) { /** @var Reflection $reflection */ $reflection = $di->getAnnotations()->get($model); $properties = $reflection->getPropertiesAnnotations(); if (!$properties) { throw new \Exception('There are no properties defined on the class'); } $tableProperties = $reflection->getClassAnnotations(); if ($tableProperties && $tableProperties->has('Source')) { $source = $tableProperties->get('Source')->getArguments()[0]; } else { throw new \Exception('Model ' . get_class($model) . ' has no Source defined'); } /** @var \Phalcon\Db\Adapter $database */ $database = $di->get($source); $dbType = ucfirst($database->getType()); $indexes = $this->getIndexes($reflection); return call_user_func_array(['\Phalcon\Annotations\DbStrategies\\'.$dbType, 'getMetaData'], [$reflection, $properties, $indexes]); }
php
public function getMetaData(ModelInterface $model, DiInterface $di) { /** @var Reflection $reflection */ $reflection = $di->getAnnotations()->get($model); $properties = $reflection->getPropertiesAnnotations(); if (!$properties) { throw new \Exception('There are no properties defined on the class'); } $tableProperties = $reflection->getClassAnnotations(); if ($tableProperties && $tableProperties->has('Source')) { $source = $tableProperties->get('Source')->getArguments()[0]; } else { throw new \Exception('Model ' . get_class($model) . ' has no Source defined'); } /** @var \Phalcon\Db\Adapter $database */ $database = $di->get($source); $dbType = ucfirst($database->getType()); $indexes = $this->getIndexes($reflection); return call_user_func_array(['\Phalcon\Annotations\DbStrategies\\'.$dbType, 'getMetaData'], [$reflection, $properties, $indexes]); }
[ "public", "function", "getMetaData", "(", "ModelInterface", "$", "model", ",", "DiInterface", "$", "di", ")", "{", "/** @var Reflection $reflection */", "$", "reflection", "=", "$", "di", "->", "getAnnotations", "(", ")", "->", "get", "(", "$", "model", ")", ";", "$", "properties", "=", "$", "reflection", "->", "getPropertiesAnnotations", "(", ")", ";", "if", "(", "!", "$", "properties", ")", "{", "throw", "new", "\\", "Exception", "(", "'There are no properties defined on the class'", ")", ";", "}", "$", "tableProperties", "=", "$", "reflection", "->", "getClassAnnotations", "(", ")", ";", "if", "(", "$", "tableProperties", "&&", "$", "tableProperties", "->", "has", "(", "'Source'", ")", ")", "{", "$", "source", "=", "$", "tableProperties", "->", "get", "(", "'Source'", ")", "->", "getArguments", "(", ")", "[", "0", "]", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Model '", ".", "get_class", "(", "$", "model", ")", ".", "' has no Source defined'", ")", ";", "}", "/** @var \\Phalcon\\Db\\Adapter $database */", "$", "database", "=", "$", "di", "->", "get", "(", "$", "source", ")", ";", "$", "dbType", "=", "ucfirst", "(", "$", "database", "->", "getType", "(", ")", ")", ";", "$", "indexes", "=", "$", "this", "->", "getIndexes", "(", "$", "reflection", ")", ";", "return", "call_user_func_array", "(", "[", "'\\Phalcon\\Annotations\\DbStrategies\\\\'", ".", "$", "dbType", ",", "'getMetaData'", "]", ",", "[", "$", "reflection", ",", "$", "properties", ",", "$", "indexes", "]", ")", ";", "}" ]
Initializes the model's meta-data @param ModelInterface $model @param DiInterface $di @return mixed @throws \Exception
[ "Initializes", "the", "model", "s", "meta", "-", "data" ]
64cb04903f101c1fd85e8067c0dcdfc6ca133fb5
https://github.com/SachaMorard/phalcon-model-annotations/blob/64cb04903f101c1fd85e8067c0dcdfc6ca133fb5/Library/Phalcon/Annotations/ModelStrategy.php#L32-L55
24,048
SachaMorard/phalcon-model-annotations
Library/Phalcon/Annotations/ModelStrategy.php
ModelStrategy.getColumnMaps
public function getColumnMaps(ModelInterface $model, DiInterface $di) { $reflection = $di['annotations']->get($model); $columnMap = array(); $reverseColumnMap = array(); $renamed = false; foreach ($reflection->getPropertiesAnnotations() as $name => $collection) { if ($collection->has('Column')) { $arguments = $collection->get('Column')->getArguments(); /** * Get the column's name */ if (isset($arguments['column'])) { $columnName = $arguments['column']; } else { $columnName = $name; } $columnMap[$columnName] = $name; $reverseColumnMap[$name] = $columnName; if (!$renamed) { if ($columnName != $name) { $renamed = true; } } } } return array( MetaData::MODELS_COLUMN_MAP => $columnMap, MetaData::MODELS_REVERSE_COLUMN_MAP => $reverseColumnMap ); }
php
public function getColumnMaps(ModelInterface $model, DiInterface $di) { $reflection = $di['annotations']->get($model); $columnMap = array(); $reverseColumnMap = array(); $renamed = false; foreach ($reflection->getPropertiesAnnotations() as $name => $collection) { if ($collection->has('Column')) { $arguments = $collection->get('Column')->getArguments(); /** * Get the column's name */ if (isset($arguments['column'])) { $columnName = $arguments['column']; } else { $columnName = $name; } $columnMap[$columnName] = $name; $reverseColumnMap[$name] = $columnName; if (!$renamed) { if ($columnName != $name) { $renamed = true; } } } } return array( MetaData::MODELS_COLUMN_MAP => $columnMap, MetaData::MODELS_REVERSE_COLUMN_MAP => $reverseColumnMap ); }
[ "public", "function", "getColumnMaps", "(", "ModelInterface", "$", "model", ",", "DiInterface", "$", "di", ")", "{", "$", "reflection", "=", "$", "di", "[", "'annotations'", "]", "->", "get", "(", "$", "model", ")", ";", "$", "columnMap", "=", "array", "(", ")", ";", "$", "reverseColumnMap", "=", "array", "(", ")", ";", "$", "renamed", "=", "false", ";", "foreach", "(", "$", "reflection", "->", "getPropertiesAnnotations", "(", ")", "as", "$", "name", "=>", "$", "collection", ")", "{", "if", "(", "$", "collection", "->", "has", "(", "'Column'", ")", ")", "{", "$", "arguments", "=", "$", "collection", "->", "get", "(", "'Column'", ")", "->", "getArguments", "(", ")", ";", "/**\n * Get the column's name\n */", "if", "(", "isset", "(", "$", "arguments", "[", "'column'", "]", ")", ")", "{", "$", "columnName", "=", "$", "arguments", "[", "'column'", "]", ";", "}", "else", "{", "$", "columnName", "=", "$", "name", ";", "}", "$", "columnMap", "[", "$", "columnName", "]", "=", "$", "name", ";", "$", "reverseColumnMap", "[", "$", "name", "]", "=", "$", "columnName", ";", "if", "(", "!", "$", "renamed", ")", "{", "if", "(", "$", "columnName", "!=", "$", "name", ")", "{", "$", "renamed", "=", "true", ";", "}", "}", "}", "}", "return", "array", "(", "MetaData", "::", "MODELS_COLUMN_MAP", "=>", "$", "columnMap", ",", "MetaData", "::", "MODELS_REVERSE_COLUMN_MAP", "=>", "$", "reverseColumnMap", ")", ";", "}" ]
Initializes the model's column map @param \Phalcon\Mvc\ModelInterface $model @param \Phalcon\DiInterface $di @return array
[ "Initializes", "the", "model", "s", "column", "map" ]
64cb04903f101c1fd85e8067c0dcdfc6ca133fb5
https://github.com/SachaMorard/phalcon-model-annotations/blob/64cb04903f101c1fd85e8067c0dcdfc6ca133fb5/Library/Phalcon/Annotations/ModelStrategy.php#L106-L136
24,049
accompli/chrono
src/Process/ProcessExecutionResult.php
ProcessExecutionResult.getOutputAsArray
public function getOutputAsArray() { $output = trim($this->getOutput()); if (empty($output) === false) { return preg_split('{\r?\n}', $output); } return array(); }
php
public function getOutputAsArray() { $output = trim($this->getOutput()); if (empty($output) === false) { return preg_split('{\r?\n}', $output); } return array(); }
[ "public", "function", "getOutputAsArray", "(", ")", "{", "$", "output", "=", "trim", "(", "$", "this", "->", "getOutput", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "output", ")", "===", "false", ")", "{", "return", "preg_split", "(", "'{\\r?\\n}'", ",", "$", "output", ")", ";", "}", "return", "array", "(", ")", ";", "}" ]
Returns the output separated by newline as array. @return array
[ "Returns", "the", "output", "separated", "by", "newline", "as", "array", "." ]
5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc
https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Process/ProcessExecutionResult.php#L82-L90
24,050
gpupo/common-schema
src/ORM/Entity/Application/API/OAuth/Client/Client.php
Client.setAccessToken
public function setAccessToken(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\AccessToken $accessToken = null) { $this->access_token = $accessToken; return $this; }
php
public function setAccessToken(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\AccessToken $accessToken = null) { $this->access_token = $accessToken; return $this; }
[ "public", "function", "setAccessToken", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Application", "\\", "API", "\\", "OAuth", "\\", "Client", "\\", "AccessToken", "$", "accessToken", "=", "null", ")", "{", "$", "this", "->", "access_token", "=", "$", "accessToken", ";", "return", "$", "this", ";", "}" ]
Set accessToken. @param null|\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\AccessToken $accessToken @return Client
[ "Set", "accessToken", "." ]
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Application/API/OAuth/Client/Client.php#L281-L286
24,051
gpupo/common-schema
src/ORM/Entity/Application/API/OAuth/Client/Client.php
Client.setProvider
public function setProvider(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Provider $provider = null) { $this->provider = $provider; return $this; }
php
public function setProvider(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Provider $provider = null) { $this->provider = $provider; return $this; }
[ "public", "function", "setProvider", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Application", "\\", "API", "\\", "OAuth", "\\", "Provider", "$", "provider", "=", "null", ")", "{", "$", "this", "->", "provider", "=", "$", "provider", ";", "return", "$", "this", ";", "}" ]
Set provider. @param null|\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Provider $provider @return Client
[ "Set", "provider", "." ]
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Application/API/OAuth/Client/Client.php#L305-L310
24,052
nabab/bbn
src/bbn/parsers/doc.php
doc.set_tags
private function set_tags(){ if ( $this->mode ){ if ( $this->mode === 'vue' ){ $tags = \bbn\x::merge_arrays($this->all_tags['js'], $this->all_tags['vue']); } else { $tags = $this->all_tags[$this->mode]; } $this->tags = \bbn\x::merge_arrays($this->all_tags['common'], $tags); return $this->tags; } }
php
private function set_tags(){ if ( $this->mode ){ if ( $this->mode === 'vue' ){ $tags = \bbn\x::merge_arrays($this->all_tags['js'], $this->all_tags['vue']); } else { $tags = $this->all_tags[$this->mode]; } $this->tags = \bbn\x::merge_arrays($this->all_tags['common'], $tags); return $this->tags; } }
[ "private", "function", "set_tags", "(", ")", "{", "if", "(", "$", "this", "->", "mode", ")", "{", "if", "(", "$", "this", "->", "mode", "===", "'vue'", ")", "{", "$", "tags", "=", "\\", "bbn", "\\", "x", "::", "merge_arrays", "(", "$", "this", "->", "all_tags", "[", "'js'", "]", ",", "$", "this", "->", "all_tags", "[", "'vue'", "]", ")", ";", "}", "else", "{", "$", "tags", "=", "$", "this", "->", "all_tags", "[", "$", "this", "->", "mode", "]", ";", "}", "$", "this", "->", "tags", "=", "\\", "bbn", "\\", "x", "::", "merge_arrays", "(", "$", "this", "->", "all_tags", "[", "'common'", "]", ",", "$", "tags", ")", ";", "return", "$", "this", "->", "tags", ";", "}", "}" ]
Sets the tags list relative to the selected mode @return array
[ "Sets", "the", "tags", "list", "relative", "to", "the", "selected", "mode" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L172-L183
24,053
nabab/bbn
src/bbn/parsers/doc.php
doc.get_tags
private function get_tags(string $block){ preg_match_all($this->pattern['tag'], $block, $tags, PREG_OFFSET_CAPTURE); if ( !empty($tags[0]) ){ return $tags[0]; } return []; }
php
private function get_tags(string $block){ preg_match_all($this->pattern['tag'], $block, $tags, PREG_OFFSET_CAPTURE); if ( !empty($tags[0]) ){ return $tags[0]; } return []; }
[ "private", "function", "get_tags", "(", "string", "$", "block", ")", "{", "preg_match_all", "(", "$", "this", "->", "pattern", "[", "'tag'", "]", ",", "$", "block", ",", "$", "tags", ",", "PREG_OFFSET_CAPTURE", ")", ";", "if", "(", "!", "empty", "(", "$", "tags", "[", "0", "]", ")", ")", "{", "return", "$", "tags", "[", "0", "]", ";", "}", "return", "[", "]", ";", "}" ]
Gets te tags list of a docblock @param string $block The docblock @return array
[ "Gets", "te", "tags", "list", "of", "a", "docblock" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L279-L285
24,054
nabab/bbn
src/bbn/parsers/doc.php
doc.group_tags
private function group_tags(array $tags){ $res = []; if ( !empty($tags) ){ foreach ( $tags as $i => $tag ){ // Skip the 'memberof' tag if ( $tag['tag'] === 'memberof' ){ continue; } $t = $tag['tag']; unset($tag['tag']); $res[$t][] = $tag['text'] ?? $tag; } } return array_map(function($r){ if ( is_array($r) && (count($r) === 1) ){ return $r[0]; } return $r; }, $res); }
php
private function group_tags(array $tags){ $res = []; if ( !empty($tags) ){ foreach ( $tags as $i => $tag ){ // Skip the 'memberof' tag if ( $tag['tag'] === 'memberof' ){ continue; } $t = $tag['tag']; unset($tag['tag']); $res[$t][] = $tag['text'] ?? $tag; } } return array_map(function($r){ if ( is_array($r) && (count($r) === 1) ){ return $r[0]; } return $r; }, $res); }
[ "private", "function", "group_tags", "(", "array", "$", "tags", ")", "{", "$", "res", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "tags", ")", ")", "{", "foreach", "(", "$", "tags", "as", "$", "i", "=>", "$", "tag", ")", "{", "// Skip the 'memberof' tag", "if", "(", "$", "tag", "[", "'tag'", "]", "===", "'memberof'", ")", "{", "continue", ";", "}", "$", "t", "=", "$", "tag", "[", "'tag'", "]", ";", "unset", "(", "$", "tag", "[", "'tag'", "]", ")", ";", "$", "res", "[", "$", "t", "]", "[", "]", "=", "$", "tag", "[", "'text'", "]", "??", "$", "tag", ";", "}", "}", "return", "array_map", "(", "function", "(", "$", "r", ")", "{", "if", "(", "is_array", "(", "$", "r", ")", "&&", "(", "count", "(", "$", "r", ")", "===", "1", ")", ")", "{", "return", "$", "r", "[", "0", "]", ";", "}", "return", "$", "r", ";", "}", ",", "$", "res", ")", ";", "}" ]
Groups tags by name @param array $tags The tags list @return array
[ "Groups", "tags", "by", "name" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L293-L312
24,055
nabab/bbn
src/bbn/parsers/doc.php
doc.tag_has_type
private function tag_has_type(string $tag){ return in_array('type', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
php
private function tag_has_type(string $tag){ return in_array('type', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
[ "private", "function", "tag_has_type", "(", "string", "$", "tag", ")", "{", "return", "in_array", "(", "'type'", ",", "array_values", "(", "\\", "is_array", "(", "$", "this", "->", "tags", "[", "$", "tag", "]", ")", "?", "$", "this", "->", "tags", "[", "$", "tag", "]", ":", "$", "this", "->", "tags", "[", "$", "this", "->", "tags", "[", "$", "tag", "]", "]", ")", ")", ";", "}" ]
Cheks if a tag has 'type' @param string $tag The tag name @return boolean
[ "Cheks", "if", "a", "tag", "has", "type" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L320-L326
24,056
nabab/bbn
src/bbn/parsers/doc.php
doc.tag_has_default
private function tag_has_default(string $tag){ return in_array('default', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
php
private function tag_has_default(string $tag){ return in_array('default', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
[ "private", "function", "tag_has_default", "(", "string", "$", "tag", ")", "{", "return", "in_array", "(", "'default'", ",", "array_values", "(", "\\", "is_array", "(", "$", "this", "->", "tags", "[", "$", "tag", "]", ")", "?", "$", "this", "->", "tags", "[", "$", "tag", "]", ":", "$", "this", "->", "tags", "[", "$", "this", "->", "tags", "[", "$", "tag", "]", "]", ")", ")", ";", "}" ]
Cheks if a tag has 'default' @param string $tag The tag name @return boolean
[ "Cheks", "if", "a", "tag", "has", "default" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L334-L340
24,057
nabab/bbn
src/bbn/parsers/doc.php
doc.tag_has_name
private function tag_has_name(string $tag){ return in_array('name', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
php
private function tag_has_name(string $tag){ return in_array('name', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
[ "private", "function", "tag_has_name", "(", "string", "$", "tag", ")", "{", "return", "in_array", "(", "'name'", ",", "array_values", "(", "\\", "is_array", "(", "$", "this", "->", "tags", "[", "$", "tag", "]", ")", "?", "$", "this", "->", "tags", "[", "$", "tag", "]", ":", "$", "this", "->", "tags", "[", "$", "this", "->", "tags", "[", "$", "tag", "]", "]", ")", ")", ";", "}" ]
Cheks if a tag has 'name' @param string $tag The tag name @return boolean
[ "Cheks", "if", "a", "tag", "has", "name" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L348-L354
24,058
nabab/bbn
src/bbn/parsers/doc.php
doc.tag_has_desc
private function tag_has_desc(string $tag){ return in_array('description', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
php
private function tag_has_desc(string $tag){ return in_array('description', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
[ "private", "function", "tag_has_desc", "(", "string", "$", "tag", ")", "{", "return", "in_array", "(", "'description'", ",", "array_values", "(", "\\", "is_array", "(", "$", "this", "->", "tags", "[", "$", "tag", "]", ")", "?", "$", "this", "->", "tags", "[", "$", "tag", "]", ":", "$", "this", "->", "tags", "[", "$", "this", "->", "tags", "[", "$", "tag", "]", "]", ")", ")", ";", "}" ]
Cheks if a tag has 'description' @param string $tag The tag name @return boolean
[ "Cheks", "if", "a", "tag", "has", "description" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L362-L368
24,059
nabab/bbn
src/bbn/parsers/doc.php
doc.tag_has_text
private function tag_has_text(string $tag){ return in_array('text', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
php
private function tag_has_text(string $tag){ return in_array('text', array_values( \is_array($this->tags[$tag]) ? $this->tags[$tag] : $this->tags[$this->tags[$tag]] )); }
[ "private", "function", "tag_has_text", "(", "string", "$", "tag", ")", "{", "return", "in_array", "(", "'text'", ",", "array_values", "(", "\\", "is_array", "(", "$", "this", "->", "tags", "[", "$", "tag", "]", ")", "?", "$", "this", "->", "tags", "[", "$", "tag", "]", ":", "$", "this", "->", "tags", "[", "$", "this", "->", "tags", "[", "$", "tag", "]", "]", ")", ")", ";", "}" ]
Cheks if a tag has 'text' @param string $tag The tag name @return boolean
[ "Cheks", "if", "a", "tag", "has", "text" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L376-L382
24,060
nabab/bbn
src/bbn/parsers/doc.php
doc.tag_get_type
private function tag_get_type(string $text){ if ( ($this->mode === 'js') || ($this->mode === 'vue') ){ preg_match('/(?:\{)(.+)(?:\})/', $text, $type, PREG_OFFSET_CAPTURE); } else if ( $this->mode === 'php' ){ preg_match('/(?:\@[a-z]+\s{1})(.+)(?:\s{1}\$)/', $text, $type, PREG_OFFSET_CAPTURE); $type[0] = $type[1]; } return $type; }
php
private function tag_get_type(string $text){ if ( ($this->mode === 'js') || ($this->mode === 'vue') ){ preg_match('/(?:\{)(.+)(?:\})/', $text, $type, PREG_OFFSET_CAPTURE); } else if ( $this->mode === 'php' ){ preg_match('/(?:\@[a-z]+\s{1})(.+)(?:\s{1}\$)/', $text, $type, PREG_OFFSET_CAPTURE); $type[0] = $type[1]; } return $type; }
[ "private", "function", "tag_get_type", "(", "string", "$", "text", ")", "{", "if", "(", "(", "$", "this", "->", "mode", "===", "'js'", ")", "||", "(", "$", "this", "->", "mode", "===", "'vue'", ")", ")", "{", "preg_match", "(", "'/(?:\\{)(.+)(?:\\})/'", ",", "$", "text", ",", "$", "type", ",", "PREG_OFFSET_CAPTURE", ")", ";", "}", "else", "if", "(", "$", "this", "->", "mode", "===", "'php'", ")", "{", "preg_match", "(", "'/(?:\\@[a-z]+\\s{1})(.+)(?:\\s{1}\\$)/'", ",", "$", "text", ",", "$", "type", ",", "PREG_OFFSET_CAPTURE", ")", ";", "$", "type", "[", "0", "]", "=", "$", "type", "[", "1", "]", ";", "}", "return", "$", "type", ";", "}" ]
Gets tag 'type' @param string $text The tag text @return array
[ "Gets", "tag", "type" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L390-L402
24,061
nabab/bbn
src/bbn/parsers/doc.php
doc.tag_get_default
private function tag_get_default(string $text){ if ( ($this->mode === 'js') || ($this->mode === 'vue') ){ preg_match('/(?:\[)(.+)(?:\])/', $text, $def, PREG_OFFSET_CAPTURE); } return $def; }
php
private function tag_get_default(string $text){ if ( ($this->mode === 'js') || ($this->mode === 'vue') ){ preg_match('/(?:\[)(.+)(?:\])/', $text, $def, PREG_OFFSET_CAPTURE); } return $def; }
[ "private", "function", "tag_get_default", "(", "string", "$", "text", ")", "{", "if", "(", "(", "$", "this", "->", "mode", "===", "'js'", ")", "||", "(", "$", "this", "->", "mode", "===", "'vue'", ")", ")", "{", "preg_match", "(", "'/(?:\\[)(.+)(?:\\])/'", ",", "$", "text", ",", "$", "def", ",", "PREG_OFFSET_CAPTURE", ")", ";", "}", "return", "$", "def", ";", "}" ]
Gets tag 'default' @param string $text The tag text @return array
[ "Gets", "tag", "default" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L410-L418
24,062
nabab/bbn
src/bbn/parsers/doc.php
doc.tag_get_name
private function tag_get_name(string $text){ if ( ($this->mode === 'js') || ($this->mode === 'vue') ){ //preg_match('/\w+/', $text, $name, PREG_OFFSET_CAPTURE); preg_match('/[[:graph:]]+/', $text, $name, PREG_OFFSET_CAPTURE); } else if ( $this->mode === 'php' ){ preg_match('/\$[a-z]+/', $text, $name, PREG_OFFSET_CAPTURE); } return $name; }
php
private function tag_get_name(string $text){ if ( ($this->mode === 'js') || ($this->mode === 'vue') ){ //preg_match('/\w+/', $text, $name, PREG_OFFSET_CAPTURE); preg_match('/[[:graph:]]+/', $text, $name, PREG_OFFSET_CAPTURE); } else if ( $this->mode === 'php' ){ preg_match('/\$[a-z]+/', $text, $name, PREG_OFFSET_CAPTURE); } return $name; }
[ "private", "function", "tag_get_name", "(", "string", "$", "text", ")", "{", "if", "(", "(", "$", "this", "->", "mode", "===", "'js'", ")", "||", "(", "$", "this", "->", "mode", "===", "'vue'", ")", ")", "{", "//preg_match('/\\w+/', $text, $name, PREG_OFFSET_CAPTURE);", "preg_match", "(", "'/[[:graph:]]+/'", ",", "$", "text", ",", "$", "name", ",", "PREG_OFFSET_CAPTURE", ")", ";", "}", "else", "if", "(", "$", "this", "->", "mode", "===", "'php'", ")", "{", "preg_match", "(", "'/\\$[a-z]+/'", ",", "$", "text", ",", "$", "name", ",", "PREG_OFFSET_CAPTURE", ")", ";", "}", "return", "$", "name", ";", "}" ]
Gets tag 'name' @param string $text The tag text @return array
[ "Gets", "tag", "name" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L426-L438
24,063
nabab/bbn
src/bbn/parsers/doc.php
doc.get
private function get(string $tag, string $memberof = '', bool $grouped = true){ if ( empty($this->parsed) ){ $this->parse(); } if ( !empty($this->parsed) ){ $res = []; foreach ( $this->parsed as $p ){ if ( !empty($p['tags']) && (($i = \bbn\x::find($p['tags'], ['tag' => $tag])) !== false) && ( ( empty($memberof) && (\bbn\x::find($p['tags'], ['tag' => 'memberof']) === false) ) || ( !empty($memberof) && (($k = \bbn\x::find($p['tags'], ['tag' => 'memberof'])) !== false) && ($p['tags'][$k]['name'] === $memberof) ) ) ){ if ( $grouped ){ $tmp = $p['tags'][$i]; if ( $p['tags'][$i]['tag'] !== 'file' ){ $tmp['description'] = $p['description']; } unset($p['tags'][$i], $tmp['tag']); $res[] = array_merge($tmp, $this->group_tags($p['tags'])); } else { $res = array_map(function($t){ unset($t['tag']); return $t; }, $p['tags']); } } } return $res; } return false; }
php
private function get(string $tag, string $memberof = '', bool $grouped = true){ if ( empty($this->parsed) ){ $this->parse(); } if ( !empty($this->parsed) ){ $res = []; foreach ( $this->parsed as $p ){ if ( !empty($p['tags']) && (($i = \bbn\x::find($p['tags'], ['tag' => $tag])) !== false) && ( ( empty($memberof) && (\bbn\x::find($p['tags'], ['tag' => 'memberof']) === false) ) || ( !empty($memberof) && (($k = \bbn\x::find($p['tags'], ['tag' => 'memberof'])) !== false) && ($p['tags'][$k]['name'] === $memberof) ) ) ){ if ( $grouped ){ $tmp = $p['tags'][$i]; if ( $p['tags'][$i]['tag'] !== 'file' ){ $tmp['description'] = $p['description']; } unset($p['tags'][$i], $tmp['tag']); $res[] = array_merge($tmp, $this->group_tags($p['tags'])); } else { $res = array_map(function($t){ unset($t['tag']); return $t; }, $p['tags']); } } } return $res; } return false; }
[ "private", "function", "get", "(", "string", "$", "tag", ",", "string", "$", "memberof", "=", "''", ",", "bool", "$", "grouped", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "parsed", ")", ")", "{", "$", "this", "->", "parse", "(", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "parsed", ")", ")", "{", "$", "res", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "parsed", "as", "$", "p", ")", "{", "if", "(", "!", "empty", "(", "$", "p", "[", "'tags'", "]", ")", "&&", "(", "(", "$", "i", "=", "\\", "bbn", "\\", "x", "::", "find", "(", "$", "p", "[", "'tags'", "]", ",", "[", "'tag'", "=>", "$", "tag", "]", ")", ")", "!==", "false", ")", "&&", "(", "(", "empty", "(", "$", "memberof", ")", "&&", "(", "\\", "bbn", "\\", "x", "::", "find", "(", "$", "p", "[", "'tags'", "]", ",", "[", "'tag'", "=>", "'memberof'", "]", ")", "===", "false", ")", ")", "||", "(", "!", "empty", "(", "$", "memberof", ")", "&&", "(", "(", "$", "k", "=", "\\", "bbn", "\\", "x", "::", "find", "(", "$", "p", "[", "'tags'", "]", ",", "[", "'tag'", "=>", "'memberof'", "]", ")", ")", "!==", "false", ")", "&&", "(", "$", "p", "[", "'tags'", "]", "[", "$", "k", "]", "[", "'name'", "]", "===", "$", "memberof", ")", ")", ")", ")", "{", "if", "(", "$", "grouped", ")", "{", "$", "tmp", "=", "$", "p", "[", "'tags'", "]", "[", "$", "i", "]", ";", "if", "(", "$", "p", "[", "'tags'", "]", "[", "$", "i", "]", "[", "'tag'", "]", "!==", "'file'", ")", "{", "$", "tmp", "[", "'description'", "]", "=", "$", "p", "[", "'description'", "]", ";", "}", "unset", "(", "$", "p", "[", "'tags'", "]", "[", "$", "i", "]", ",", "$", "tmp", "[", "'tag'", "]", ")", ";", "$", "res", "[", "]", "=", "array_merge", "(", "$", "tmp", ",", "$", "this", "->", "group_tags", "(", "$", "p", "[", "'tags'", "]", ")", ")", ";", "}", "else", "{", "$", "res", "=", "array_map", "(", "function", "(", "$", "t", ")", "{", "unset", "(", "$", "t", "[", "'tag'", "]", ")", ";", "return", "$", "t", ";", "}", ",", "$", "p", "[", "'tags'", "]", ")", ";", "}", "}", "}", "return", "$", "res", ";", "}", "return", "false", ";", "}" ]
Parses the parsed array to get an array of the given tag @param string $tag The tag name @param string $memberof The parent tag name @return array|false
[ "Parses", "the", "parsed", "array", "to", "get", "an", "array", "of", "the", "given", "tag" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L447-L488
24,064
nabab/bbn
src/bbn/parsers/doc.php
doc.get_components
private function get_components(string $memberof = ''){ $res = []; if ( $components = $this->get('component', $memberof) ){ foreach ( $components as $comp ){ if ( !empty($comp['name']) ){ $res[] = array_merge($comp, $this->get_vue($comp['name'])); } } } return $res; }
php
private function get_components(string $memberof = ''){ $res = []; if ( $components = $this->get('component', $memberof) ){ foreach ( $components as $comp ){ if ( !empty($comp['name']) ){ $res[] = array_merge($comp, $this->get_vue($comp['name'])); } } } return $res; }
[ "private", "function", "get_components", "(", "string", "$", "memberof", "=", "''", ")", "{", "$", "res", "=", "[", "]", ";", "if", "(", "$", "components", "=", "$", "this", "->", "get", "(", "'component'", ",", "$", "memberof", ")", ")", "{", "foreach", "(", "$", "components", "as", "$", "comp", ")", "{", "if", "(", "!", "empty", "(", "$", "comp", "[", "'name'", "]", ")", ")", "{", "$", "res", "[", "]", "=", "array_merge", "(", "$", "comp", ",", "$", "this", "->", "get_vue", "(", "$", "comp", "[", "'name'", "]", ")", ")", ";", "}", "}", "}", "return", "$", "res", ";", "}" ]
Gets an array of 'component' tags @param string $memberof The parent tag name @return array|false
[ "Gets", "an", "array", "of", "component", "tags" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L566-L576
24,065
nabab/bbn
src/bbn/parsers/doc.php
doc.set_source
public function set_source(string $src){ $this->source = is_file($src) ? file_get_contents($src) : $src; $this->parsed = []; return $this; }
php
public function set_source(string $src){ $this->source = is_file($src) ? file_get_contents($src) : $src; $this->parsed = []; return $this; }
[ "public", "function", "set_source", "(", "string", "$", "src", ")", "{", "$", "this", "->", "source", "=", "is_file", "(", "$", "src", ")", "?", "file_get_contents", "(", "$", "src", ")", ":", "$", "src", ";", "$", "this", "->", "parsed", "=", "[", "]", ";", "return", "$", "this", ";", "}" ]
Sets the source to parse @param string $src The source code or an absolute file path @return \bbn\parsers\doc
[ "Sets", "the", "source", "to", "parse" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L616-L620
24,066
nabab/bbn
src/bbn/parsers/doc.php
doc.set_mode
public function set_mode(string $mode){ if ( !empty($mode) && in_array($mode, $this->modes) ){ $this->mode = $mode; return $this; } die(_('Error: mode not allowed.')); }
php
public function set_mode(string $mode){ if ( !empty($mode) && in_array($mode, $this->modes) ){ $this->mode = $mode; return $this; } die(_('Error: mode not allowed.')); }
[ "public", "function", "set_mode", "(", "string", "$", "mode", ")", "{", "if", "(", "!", "empty", "(", "$", "mode", ")", "&&", "in_array", "(", "$", "mode", ",", "$", "this", "->", "modes", ")", ")", "{", "$", "this", "->", "mode", "=", "$", "mode", ";", "return", "$", "this", ";", "}", "die", "(", "_", "(", "'Error: mode not allowed.'", ")", ")", ";", "}" ]
Sets the mode @param string $mode The mode to set @return \bbn\parsers\doc
[ "Sets", "the", "mode" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L628-L634
24,067
nabab/bbn
src/bbn/parsers/doc.php
doc.parse
public function parse(){ preg_match_all($this->pattern['start'], $this->source, $matches, PREG_OFFSET_CAPTURE); if ( isset($matches[0]) ){ foreach ( $matches[0] as $match ){ preg_match($this->pattern['end'], $this->source, $mat, PREG_OFFSET_CAPTURE, $match[1]); $start = $match[1]; $length = isset($mat[0]) ? ($mat[0][1] - $start) + 3 : 0; $this->parsed[] = $this->parse_docblock(substr($this->source, $start, $length)); } } return $this->parsed; }
php
public function parse(){ preg_match_all($this->pattern['start'], $this->source, $matches, PREG_OFFSET_CAPTURE); if ( isset($matches[0]) ){ foreach ( $matches[0] as $match ){ preg_match($this->pattern['end'], $this->source, $mat, PREG_OFFSET_CAPTURE, $match[1]); $start = $match[1]; $length = isset($mat[0]) ? ($mat[0][1] - $start) + 3 : 0; $this->parsed[] = $this->parse_docblock(substr($this->source, $start, $length)); } } return $this->parsed; }
[ "public", "function", "parse", "(", ")", "{", "preg_match_all", "(", "$", "this", "->", "pattern", "[", "'start'", "]", ",", "$", "this", "->", "source", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", ")", ";", "if", "(", "isset", "(", "$", "matches", "[", "0", "]", ")", ")", "{", "foreach", "(", "$", "matches", "[", "0", "]", "as", "$", "match", ")", "{", "preg_match", "(", "$", "this", "->", "pattern", "[", "'end'", "]", ",", "$", "this", "->", "source", ",", "$", "mat", ",", "PREG_OFFSET_CAPTURE", ",", "$", "match", "[", "1", "]", ")", ";", "$", "start", "=", "$", "match", "[", "1", "]", ";", "$", "length", "=", "isset", "(", "$", "mat", "[", "0", "]", ")", "?", "(", "$", "mat", "[", "0", "]", "[", "1", "]", "-", "$", "start", ")", "+", "3", ":", "0", ";", "$", "this", "->", "parsed", "[", "]", "=", "$", "this", "->", "parse_docblock", "(", "substr", "(", "$", "this", "->", "source", ",", "$", "start", ",", "$", "length", ")", ")", ";", "}", "}", "return", "$", "this", "->", "parsed", ";", "}" ]
Parses the current source @return array
[ "Parses", "the", "current", "source" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L641-L652
24,068
nabab/bbn
src/bbn/parsers/doc.php
doc.parse_docblock
public function parse_docblock(string $block){ $b = [ 'description' => '', 'tags' => [] ]; // Remove start pattern //$block = trim(substr($block, 3)); // Remove end pattern $block = trim(substr($block, 0, strlen($block) - 2)); // Tags $tags = $this->get_tags($block); foreach ( $tags as $i => $tag ){ if ( ( isset($tags[$i+1]) && ($t = $this->parse_tag(substr($block, $tag[1], $tags[$i+1][1] - $tag[1]))) ) || ($t = $this->parse_tag(substr($block, $tag[1]))) ){ $b['tags'][] = $t; } } // Get Description $b['description'] = $this->clear_text(isset($tags[0]) ? substr($block, 3, $tags[0][1]-1) : substr($block, 3)); return $b; }
php
public function parse_docblock(string $block){ $b = [ 'description' => '', 'tags' => [] ]; // Remove start pattern //$block = trim(substr($block, 3)); // Remove end pattern $block = trim(substr($block, 0, strlen($block) - 2)); // Tags $tags = $this->get_tags($block); foreach ( $tags as $i => $tag ){ if ( ( isset($tags[$i+1]) && ($t = $this->parse_tag(substr($block, $tag[1], $tags[$i+1][1] - $tag[1]))) ) || ($t = $this->parse_tag(substr($block, $tag[1]))) ){ $b['tags'][] = $t; } } // Get Description $b['description'] = $this->clear_text(isset($tags[0]) ? substr($block, 3, $tags[0][1]-1) : substr($block, 3)); return $b; }
[ "public", "function", "parse_docblock", "(", "string", "$", "block", ")", "{", "$", "b", "=", "[", "'description'", "=>", "''", ",", "'tags'", "=>", "[", "]", "]", ";", "// Remove start pattern", "//$block = trim(substr($block, 3));", "// Remove end pattern", "$", "block", "=", "trim", "(", "substr", "(", "$", "block", ",", "0", ",", "strlen", "(", "$", "block", ")", "-", "2", ")", ")", ";", "// Tags", "$", "tags", "=", "$", "this", "->", "get_tags", "(", "$", "block", ")", ";", "foreach", "(", "$", "tags", "as", "$", "i", "=>", "$", "tag", ")", "{", "if", "(", "(", "isset", "(", "$", "tags", "[", "$", "i", "+", "1", "]", ")", "&&", "(", "$", "t", "=", "$", "this", "->", "parse_tag", "(", "substr", "(", "$", "block", ",", "$", "tag", "[", "1", "]", ",", "$", "tags", "[", "$", "i", "+", "1", "]", "[", "1", "]", "-", "$", "tag", "[", "1", "]", ")", ")", ")", ")", "||", "(", "$", "t", "=", "$", "this", "->", "parse_tag", "(", "substr", "(", "$", "block", ",", "$", "tag", "[", "1", "]", ")", ")", ")", ")", "{", "$", "b", "[", "'tags'", "]", "[", "]", "=", "$", "t", ";", "}", "}", "// Get Description", "$", "b", "[", "'description'", "]", "=", "$", "this", "->", "clear_text", "(", "isset", "(", "$", "tags", "[", "0", "]", ")", "?", "substr", "(", "$", "block", ",", "3", ",", "$", "tags", "[", "0", "]", "[", "1", "]", "-", "1", ")", ":", "substr", "(", "$", "block", ",", "3", ")", ")", ";", "return", "$", "b", ";", "}" ]
Parses a given docblock @param string $block The docblock @return array
[ "Parses", "a", "given", "docblock" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L661-L686
24,069
nabab/bbn
src/bbn/parsers/doc.php
doc.get_vue
public function get_vue(string $memberof = ''){ return [ 'description' => $this->get_file($memberof), 'methods' => $this->get_methods($memberof), 'events' => $this->get_events($memberof), 'mixins' => $this->get_mixins($memberof), 'props' => $this->get_props($memberof), 'data' => $this->get_data($memberof), 'computed' => $this->get_computed($memberof), 'watch' => $this->get_watch($memberof), 'components' => $this->get_components($memberof), //'todo' => $this->get_todo($memberof) ]; }
php
public function get_vue(string $memberof = ''){ return [ 'description' => $this->get_file($memberof), 'methods' => $this->get_methods($memberof), 'events' => $this->get_events($memberof), 'mixins' => $this->get_mixins($memberof), 'props' => $this->get_props($memberof), 'data' => $this->get_data($memberof), 'computed' => $this->get_computed($memberof), 'watch' => $this->get_watch($memberof), 'components' => $this->get_components($memberof), //'todo' => $this->get_todo($memberof) ]; }
[ "public", "function", "get_vue", "(", "string", "$", "memberof", "=", "''", ")", "{", "return", "[", "'description'", "=>", "$", "this", "->", "get_file", "(", "$", "memberof", ")", ",", "'methods'", "=>", "$", "this", "->", "get_methods", "(", "$", "memberof", ")", ",", "'events'", "=>", "$", "this", "->", "get_events", "(", "$", "memberof", ")", ",", "'mixins'", "=>", "$", "this", "->", "get_mixins", "(", "$", "memberof", ")", ",", "'props'", "=>", "$", "this", "->", "get_props", "(", "$", "memberof", ")", ",", "'data'", "=>", "$", "this", "->", "get_data", "(", "$", "memberof", ")", ",", "'computed'", "=>", "$", "this", "->", "get_computed", "(", "$", "memberof", ")", ",", "'watch'", "=>", "$", "this", "->", "get_watch", "(", "$", "memberof", ")", ",", "'components'", "=>", "$", "this", "->", "get_components", "(", "$", "memberof", ")", ",", "//'todo' => $this->get_todo($memberof)", "]", ";", "}" ]
Gets Vue.js structure @param string $memberof The parent tag name @return array
[ "Gets", "Vue", ".", "js", "structure" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L708-L721
24,070
WellCommerce/AppBundle
Twig/ClientAddressFormatterExtension.php
ClientAddressFormatterExtension.formatBillingAddress
public function formatBillingAddress(ClientBillingAddress $address, $lineSeparator = self::LINES_SEPARATOR) { $lines = []; $lines[] = sprintf('%s %s', $address->getFirstName(), $address->getLastName()); if ('' !== $address->getCompanyName()) { $lines[] = $address->getCompanyName(); } $lines[] = $address->getLine1(); $lines[] = $address->getLine2(); $lines[] = sprintf('%s, %s %s', $address->getCountry(), $address->getPostalCode(), $address->getCity()); return implode($lineSeparator, $lines); }
php
public function formatBillingAddress(ClientBillingAddress $address, $lineSeparator = self::LINES_SEPARATOR) { $lines = []; $lines[] = sprintf('%s %s', $address->getFirstName(), $address->getLastName()); if ('' !== $address->getCompanyName()) { $lines[] = $address->getCompanyName(); } $lines[] = $address->getLine1(); $lines[] = $address->getLine2(); $lines[] = sprintf('%s, %s %s', $address->getCountry(), $address->getPostalCode(), $address->getCity()); return implode($lineSeparator, $lines); }
[ "public", "function", "formatBillingAddress", "(", "ClientBillingAddress", "$", "address", ",", "$", "lineSeparator", "=", "self", "::", "LINES_SEPARATOR", ")", "{", "$", "lines", "=", "[", "]", ";", "$", "lines", "[", "]", "=", "sprintf", "(", "'%s %s'", ",", "$", "address", "->", "getFirstName", "(", ")", ",", "$", "address", "->", "getLastName", "(", ")", ")", ";", "if", "(", "''", "!==", "$", "address", "->", "getCompanyName", "(", ")", ")", "{", "$", "lines", "[", "]", "=", "$", "address", "->", "getCompanyName", "(", ")", ";", "}", "$", "lines", "[", "]", "=", "$", "address", "->", "getLine1", "(", ")", ";", "$", "lines", "[", "]", "=", "$", "address", "->", "getLine2", "(", ")", ";", "$", "lines", "[", "]", "=", "sprintf", "(", "'%s, %s %s'", ",", "$", "address", "->", "getCountry", "(", ")", ",", "$", "address", "->", "getPostalCode", "(", ")", ",", "$", "address", "->", "getCity", "(", ")", ")", ";", "return", "implode", "(", "$", "lineSeparator", ",", "$", "lines", ")", ";", "}" ]
Formats the billing address @param ClientBillingAddress $address @param string $lineSeparator @return string
[ "Formats", "the", "billing", "address" ]
2add687d1c898dd0b24afd611d896e3811a0eac3
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Twig/ClientAddressFormatterExtension.php#L52-L64
24,071
xiewulong/yii2-fileupload
oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php
OauthPlugin.getStringToSign
public function getStringToSign(RequestInterface $request, $timestamp, $nonce) { $params = $this->getParamsToSign($request, $timestamp, $nonce); // Convert booleans to strings. $params = $this->prepareParameters($params); // Build signing string from combined params $parameterString = new QueryString($params); $url = Url::factory($request->getUrl())->setQuery('')->setFragment(null); return strtoupper($request->getMethod()) . '&' . rawurlencode($url) . '&' . rawurlencode((string) $parameterString); }
php
public function getStringToSign(RequestInterface $request, $timestamp, $nonce) { $params = $this->getParamsToSign($request, $timestamp, $nonce); // Convert booleans to strings. $params = $this->prepareParameters($params); // Build signing string from combined params $parameterString = new QueryString($params); $url = Url::factory($request->getUrl())->setQuery('')->setFragment(null); return strtoupper($request->getMethod()) . '&' . rawurlencode($url) . '&' . rawurlencode((string) $parameterString); }
[ "public", "function", "getStringToSign", "(", "RequestInterface", "$", "request", ",", "$", "timestamp", ",", "$", "nonce", ")", "{", "$", "params", "=", "$", "this", "->", "getParamsToSign", "(", "$", "request", ",", "$", "timestamp", ",", "$", "nonce", ")", ";", "// Convert booleans to strings.", "$", "params", "=", "$", "this", "->", "prepareParameters", "(", "$", "params", ")", ";", "// Build signing string from combined params", "$", "parameterString", "=", "new", "QueryString", "(", "$", "params", ")", ";", "$", "url", "=", "Url", "::", "factory", "(", "$", "request", "->", "getUrl", "(", ")", ")", "->", "setQuery", "(", "''", ")", "->", "setFragment", "(", "null", ")", ";", "return", "strtoupper", "(", "$", "request", "->", "getMethod", "(", ")", ")", ".", "'&'", ".", "rawurlencode", "(", "$", "url", ")", ".", "'&'", ".", "rawurlencode", "(", "(", "string", ")", "$", "parameterString", ")", ";", "}" ]
Calculate string to sign @param RequestInterface $request Request to generate a signature for @param int $timestamp Timestamp to use for nonce @param string $nonce @return string
[ "Calculate", "string", "to", "sign" ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php#L137-L152
24,072
xiewulong/yii2-fileupload
oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php
OauthPlugin.getParamsToSign
public function getParamsToSign(RequestInterface $request, $timestamp, $nonce) { $params = new Collection(array( 'oauth_consumer_key' => $this->config['consumer_key'], 'oauth_nonce' => $nonce, 'oauth_signature_method' => $this->config['signature_method'], 'oauth_timestamp' => $timestamp, 'oauth_token' => $this->config['token'], 'oauth_version' => $this->config['version'] )); if (array_key_exists('callback', $this->config) == true) { $params['oauth_callback'] = $this->config['callback']; } if (array_key_exists('verifier', $this->config) == true) { $params['oauth_verifier'] = $this->config['verifier']; } // Add query string parameters $params->merge($request->getQuery()); // Add POST fields to signing string if required if ($this->shouldPostFieldsBeSigned($request)) { $params->merge($request->getPostFields()); } // Sort params $params = $params->toArray(); ksort($params); return $params; }
php
public function getParamsToSign(RequestInterface $request, $timestamp, $nonce) { $params = new Collection(array( 'oauth_consumer_key' => $this->config['consumer_key'], 'oauth_nonce' => $nonce, 'oauth_signature_method' => $this->config['signature_method'], 'oauth_timestamp' => $timestamp, 'oauth_token' => $this->config['token'], 'oauth_version' => $this->config['version'] )); if (array_key_exists('callback', $this->config) == true) { $params['oauth_callback'] = $this->config['callback']; } if (array_key_exists('verifier', $this->config) == true) { $params['oauth_verifier'] = $this->config['verifier']; } // Add query string parameters $params->merge($request->getQuery()); // Add POST fields to signing string if required if ($this->shouldPostFieldsBeSigned($request)) { $params->merge($request->getPostFields()); } // Sort params $params = $params->toArray(); ksort($params); return $params; }
[ "public", "function", "getParamsToSign", "(", "RequestInterface", "$", "request", ",", "$", "timestamp", ",", "$", "nonce", ")", "{", "$", "params", "=", "new", "Collection", "(", "array", "(", "'oauth_consumer_key'", "=>", "$", "this", "->", "config", "[", "'consumer_key'", "]", ",", "'oauth_nonce'", "=>", "$", "nonce", ",", "'oauth_signature_method'", "=>", "$", "this", "->", "config", "[", "'signature_method'", "]", ",", "'oauth_timestamp'", "=>", "$", "timestamp", ",", "'oauth_token'", "=>", "$", "this", "->", "config", "[", "'token'", "]", ",", "'oauth_version'", "=>", "$", "this", "->", "config", "[", "'version'", "]", ")", ")", ";", "if", "(", "array_key_exists", "(", "'callback'", ",", "$", "this", "->", "config", ")", "==", "true", ")", "{", "$", "params", "[", "'oauth_callback'", "]", "=", "$", "this", "->", "config", "[", "'callback'", "]", ";", "}", "if", "(", "array_key_exists", "(", "'verifier'", ",", "$", "this", "->", "config", ")", "==", "true", ")", "{", "$", "params", "[", "'oauth_verifier'", "]", "=", "$", "this", "->", "config", "[", "'verifier'", "]", ";", "}", "// Add query string parameters", "$", "params", "->", "merge", "(", "$", "request", "->", "getQuery", "(", ")", ")", ";", "// Add POST fields to signing string if required", "if", "(", "$", "this", "->", "shouldPostFieldsBeSigned", "(", "$", "request", ")", ")", "{", "$", "params", "->", "merge", "(", "$", "request", "->", "getPostFields", "(", ")", ")", ";", "}", "// Sort params", "$", "params", "=", "$", "params", "->", "toArray", "(", ")", ";", "ksort", "(", "$", "params", ")", ";", "return", "$", "params", ";", "}" ]
Parameters sorted and filtered in order to properly sign a request @param RequestInterface $request Request to generate a signature for @param integer $timestamp Timestamp to use for nonce @param string $nonce @return array
[ "Parameters", "sorted", "and", "filtered", "in", "order", "to", "properly", "sign", "a", "request" ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php#L163-L196
24,073
OpenBuildings/monetary
src/OpenBuildings/Monetary/Cache.php
Cache.cache_driver
public function cache_driver() { if ( ! $this->_cache) { $adapter = new DCache_Adapter\File( realpath(__DIR__.'../../../'.static::CACHE_DIR) ); $adapter->setOption('ttl', static::CACHE_LIFETIME); $this->_cache = new DCache\Cache($adapter); } return $this->_cache; }
php
public function cache_driver() { if ( ! $this->_cache) { $adapter = new DCache_Adapter\File( realpath(__DIR__.'../../../'.static::CACHE_DIR) ); $adapter->setOption('ttl', static::CACHE_LIFETIME); $this->_cache = new DCache\Cache($adapter); } return $this->_cache; }
[ "public", "function", "cache_driver", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_cache", ")", "{", "$", "adapter", "=", "new", "DCache_Adapter", "\\", "File", "(", "realpath", "(", "__DIR__", ".", "'../../../'", ".", "static", "::", "CACHE_DIR", ")", ")", ";", "$", "adapter", "->", "setOption", "(", "'ttl'", ",", "static", "::", "CACHE_LIFETIME", ")", ";", "$", "this", "->", "_cache", "=", "new", "DCache", "\\", "Cache", "(", "$", "adapter", ")", ";", "}", "return", "$", "this", "->", "_cache", ";", "}" ]
Get an instance of the cache helper @return Desarrolla2\Cache\Cache
[ "Get", "an", "instance", "of", "the", "cache", "helper" ]
f7831ab055eaba7105f3f3530506b96de7fedd29
https://github.com/OpenBuildings/monetary/blob/f7831ab055eaba7105f3f3530506b96de7fedd29/src/OpenBuildings/Monetary/Cache.php#L32-L44
24,074
comodojo/daemon
src/Comodojo/Daemon/Process.php
Process.signalToEvent
public function signalToEvent($signal) { if ( $this->pid == ProcessTools::getPid() ) { $signame = $this->signals->signame($signal); $this->logger->debug("Received $signame ($signal) signal, firing associated event(s)"); $this->events->emit(new PosixEvent($signal, $this)); $this->events->emit(new PosixEvent($signame, $this)); } return $this; }
php
public function signalToEvent($signal) { if ( $this->pid == ProcessTools::getPid() ) { $signame = $this->signals->signame($signal); $this->logger->debug("Received $signame ($signal) signal, firing associated event(s)"); $this->events->emit(new PosixEvent($signal, $this)); $this->events->emit(new PosixEvent($signame, $this)); } return $this; }
[ "public", "function", "signalToEvent", "(", "$", "signal", ")", "{", "if", "(", "$", "this", "->", "pid", "==", "ProcessTools", "::", "getPid", "(", ")", ")", "{", "$", "signame", "=", "$", "this", "->", "signals", "->", "signame", "(", "$", "signal", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "\"Received $signame ($signal) signal, firing associated event(s)\"", ")", ";", "$", "this", "->", "events", "->", "emit", "(", "new", "PosixEvent", "(", "$", "signal", ",", "$", "this", ")", ")", ";", "$", "this", "->", "events", "->", "emit", "(", "new", "PosixEvent", "(", "$", "signame", ",", "$", "this", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
The generic signal handler. It transforms a signal into framework catchable event. @param int $signal @return self
[ "The", "generic", "signal", "handler", "." ]
361b0a3a91dc7720dd3bec448bb4ca47d0ef0292
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Process.php#L81-L96
24,075
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php
PhpVarsCheckRouter.getMinInConfiguration
private function getMinInConfiguration($val1, $val2) { if ($val1 && $val2) { return min(array($val1, $val2)); } if ($val1) { return $val1; } if ($val2) { return $val2; } return null; }
php
private function getMinInConfiguration($val1, $val2) { if ($val1 && $val2) { return min(array($val1, $val2)); } if ($val1) { return $val1; } if ($val2) { return $val2; } return null; }
[ "private", "function", "getMinInConfiguration", "(", "$", "val1", ",", "$", "val2", ")", "{", "if", "(", "$", "val1", "&&", "$", "val2", ")", "{", "return", "min", "(", "array", "(", "$", "val1", ",", "$", "val2", ")", ")", ";", "}", "if", "(", "$", "val1", ")", "{", "return", "$", "val1", ";", "}", "if", "(", "$", "val2", ")", "{", "return", "$", "val2", ";", "}", "return", "null", ";", "}" ]
Get the min in 2 values if there exist. @param int $val1 @param int $val2 @return int|NULL
[ "Get", "the", "min", "in", "2", "values", "if", "there", "exist", "." ]
eed0269ceda4d7d090a330a220490906a7aa60bd
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php#L39-L52
24,076
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php
PhpVarsCheckRouter.iniGetBytes
private static function iniGetBytes($val) { $val = trim(ini_get($val)); if ($val != '') { $last = strtolower( $val{strlen($val) - 1} ); } else { $last = ''; } $val = (int) $val; switch ($last) { // The 'G' modifier is available since PHP 5.1.0 case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; }
php
private static function iniGetBytes($val) { $val = trim(ini_get($val)); if ($val != '') { $last = strtolower( $val{strlen($val) - 1} ); } else { $last = ''; } $val = (int) $val; switch ($last) { // The 'G' modifier is available since PHP 5.1.0 case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; }
[ "private", "static", "function", "iniGetBytes", "(", "$", "val", ")", "{", "$", "val", "=", "trim", "(", "ini_get", "(", "$", "val", ")", ")", ";", "if", "(", "$", "val", "!=", "''", ")", "{", "$", "last", "=", "strtolower", "(", "$", "val", "{", "strlen", "(", "$", "val", ")", "-", "1", "}", ")", ";", "}", "else", "{", "$", "last", "=", "''", ";", "}", "$", "val", "=", "(", "int", ")", "$", "val", ";", "switch", "(", "$", "last", ")", "{", "// The 'G' modifier is available since PHP 5.1.0", "case", "'g'", ":", "$", "val", "*=", "1024", ";", "case", "'m'", ":", "$", "val", "*=", "1024", ";", "case", "'k'", ":", "$", "val", "*=", "1024", ";", "}", "return", "$", "val", ";", "}" ]
Returns the number of bytes from php.ini parameter. @param $val @return int|string
[ "Returns", "the", "number", "of", "bytes", "from", "php", ".", "ini", "parameter", "." ]
eed0269ceda4d7d090a330a220490906a7aa60bd
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php#L61-L83
24,077
mergado/mergado-api-client-php
src/mergadoclient/HttpClient.php
HttpClient.requestAsync
public function requestAsync($url, $method = 'GET', $data = []) { $stack = HandlerStack::create(); $stack->push(ApiMiddleware::auth()); $client = new Client(['handler' => $stack]); $promise = $client->requestAsync($method, $url, [ 'headers' => [ 'Authorization' => 'Bearer ' . $this->token ], 'json' => $data, 'content-type' => 'application/json' ]); return $promise; }
php
public function requestAsync($url, $method = 'GET', $data = []) { $stack = HandlerStack::create(); $stack->push(ApiMiddleware::auth()); $client = new Client(['handler' => $stack]); $promise = $client->requestAsync($method, $url, [ 'headers' => [ 'Authorization' => 'Bearer ' . $this->token ], 'json' => $data, 'content-type' => 'application/json' ]); return $promise; }
[ "public", "function", "requestAsync", "(", "$", "url", ",", "$", "method", "=", "'GET'", ",", "$", "data", "=", "[", "]", ")", "{", "$", "stack", "=", "HandlerStack", "::", "create", "(", ")", ";", "$", "stack", "->", "push", "(", "ApiMiddleware", "::", "auth", "(", ")", ")", ";", "$", "client", "=", "new", "Client", "(", "[", "'handler'", "=>", "$", "stack", "]", ")", ";", "$", "promise", "=", "$", "client", "->", "requestAsync", "(", "$", "method", ",", "$", "url", ",", "[", "'headers'", "=>", "[", "'Authorization'", "=>", "'Bearer '", ".", "$", "this", "->", "token", "]", ",", "'json'", "=>", "$", "data", ",", "'content-type'", "=>", "'application/json'", "]", ")", ";", "return", "$", "promise", ";", "}" ]
Guzzle async request @param $url @param string $method @param array $data @return \GuzzleHttp\Promise\PromiseInterface
[ "Guzzle", "async", "request" ]
6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f
https://github.com/mergado/mergado-api-client-php/blob/6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f/src/mergadoclient/HttpClient.php#L78-L95
24,078
mergado/mergado-api-client-php
src/mergadoclient/HttpClient.php
HttpClient.requestCurl
public function requestCurl($url, $method = 'GET', $data = []) { $data_string = json_encode($data); $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Authorization: Bearer ' . $this->token) ); $result = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $result = json_decode($result); $result = array_merge((array)$result, ["status_code" => $httpcode]); if ($httpcode == 401 || $httpcode == 403) { throw new UnauthorizedException("Unauthorized"); } elseif ($httpcode > 403) { throw new \Exception("Status_code: " . $httpcode); } return $result; }
php
public function requestCurl($url, $method = 'GET', $data = []) { $data_string = json_encode($data); $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Authorization: Bearer ' . $this->token) ); $result = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $result = json_decode($result); $result = array_merge((array)$result, ["status_code" => $httpcode]); if ($httpcode == 401 || $httpcode == 403) { throw new UnauthorizedException("Unauthorized"); } elseif ($httpcode > 403) { throw new \Exception("Status_code: " . $httpcode); } return $result; }
[ "public", "function", "requestCurl", "(", "$", "url", ",", "$", "method", "=", "'GET'", ",", "$", "data", "=", "[", "]", ")", "{", "$", "data_string", "=", "json_encode", "(", "$", "data", ")", ";", "$", "ch", "=", "curl_init", "(", "$", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CUSTOMREQUEST", ",", "$", "method", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "data_string", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEADER", ",", "array", "(", "'Content-Type: application/json'", ",", "'Authorization: Bearer '", ".", "$", "this", "->", "token", ")", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "ch", ")", ";", "$", "httpcode", "=", "curl_getinfo", "(", "$", "ch", ",", "CURLINFO_HTTP_CODE", ")", ";", "$", "result", "=", "json_decode", "(", "$", "result", ")", ";", "$", "result", "=", "array_merge", "(", "(", "array", ")", "$", "result", ",", "[", "\"status_code\"", "=>", "$", "httpcode", "]", ")", ";", "if", "(", "$", "httpcode", "==", "401", "||", "$", "httpcode", "==", "403", ")", "{", "throw", "new", "UnauthorizedException", "(", "\"Unauthorized\"", ")", ";", "}", "elseif", "(", "$", "httpcode", ">", "403", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Status_code: \"", ".", "$", "httpcode", ")", ";", "}", "return", "$", "result", ";", "}" ]
Curl request - instead of Guzzle @param $url @param string $method @param array $data @return array|mixed @throws UnauthorizedException @throws \Exception
[ "Curl", "request", "-", "instead", "of", "Guzzle" ]
6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f
https://github.com/mergado/mergado-api-client-php/blob/6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f/src/mergadoclient/HttpClient.php#L106-L132
24,079
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php
ezcMailDeliveryStatusParser.parseBody
public function parseBody( $line ) { $this->parseHeader( $line, $this->headers ); $this->size += strlen( $line ); }
php
public function parseBody( $line ) { $this->parseHeader( $line, $this->headers ); $this->size += strlen( $line ); }
[ "public", "function", "parseBody", "(", "$", "line", ")", "{", "$", "this", "->", "parseHeader", "(", "$", "line", ",", "$", "this", "->", "headers", ")", ";", "$", "this", "->", "size", "+=", "strlen", "(", "$", "line", ")", ";", "}" ]
Parses each line of the mail part. @param string $line
[ "Parses", "each", "line", "of", "the", "mail", "part", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php#L62-L66
24,080
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php
ezcMailDeliveryStatusParser.finish
public function finish() { unset( $this->part->recipients[$this->section - 1] ); // because one extra recipient is created in parseHeader() $this->part->size = $this->size; return $this->part; }
php
public function finish() { unset( $this->part->recipients[$this->section - 1] ); // because one extra recipient is created in parseHeader() $this->part->size = $this->size; return $this->part; }
[ "public", "function", "finish", "(", ")", "{", "unset", "(", "$", "this", "->", "part", "->", "recipients", "[", "$", "this", "->", "section", "-", "1", "]", ")", ";", "// because one extra recipient is created in parseHeader()", "$", "this", "->", "part", "->", "size", "=", "$", "this", "->", "size", ";", "return", "$", "this", "->", "part", ";", "}" ]
Returns the ezcMailDeliveryStatus part corresponding to the parsed message. @return ezcMailDeliveryStatus
[ "Returns", "the", "ezcMailDeliveryStatus", "part", "corresponding", "to", "the", "parsed", "message", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php#L108-L113
24,081
glynnforrest/active-doctrine
src/ActiveDoctrine/Schema/SchemaCreator.php
SchemaCreator.addEntityDirectory
public function addEntityDirectory($namespace, $directory) { if (!is_dir($directory)) { return; } $files = new \DirectoryIterator($directory); foreach ($files as $file) { if ($file->isDir() && !$file->isDot()) { $this->addEntityDirectory($namespace.'\\'.basename($file->getPathname()) , $file->getPathname()); continue; } if (!$file->isFile()) { continue; } $class = $namespace.'\\'.$file->getBasename('.php'); $r = new \ReflectionClass($class); if ($r->isSubclassOf('ActiveDoctrine\Entity\Entity') && !$r->isAbstract()) { $this->addEntityClass($class); } } }
php
public function addEntityDirectory($namespace, $directory) { if (!is_dir($directory)) { return; } $files = new \DirectoryIterator($directory); foreach ($files as $file) { if ($file->isDir() && !$file->isDot()) { $this->addEntityDirectory($namespace.'\\'.basename($file->getPathname()) , $file->getPathname()); continue; } if (!$file->isFile()) { continue; } $class = $namespace.'\\'.$file->getBasename('.php'); $r = new \ReflectionClass($class); if ($r->isSubclassOf('ActiveDoctrine\Entity\Entity') && !$r->isAbstract()) { $this->addEntityClass($class); } } }
[ "public", "function", "addEntityDirectory", "(", "$", "namespace", ",", "$", "directory", ")", "{", "if", "(", "!", "is_dir", "(", "$", "directory", ")", ")", "{", "return", ";", "}", "$", "files", "=", "new", "\\", "DirectoryIterator", "(", "$", "directory", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "$", "file", "->", "isDir", "(", ")", "&&", "!", "$", "file", "->", "isDot", "(", ")", ")", "{", "$", "this", "->", "addEntityDirectory", "(", "$", "namespace", ".", "'\\\\'", ".", "basename", "(", "$", "file", "->", "getPathname", "(", ")", ")", ",", "$", "file", "->", "getPathname", "(", ")", ")", ";", "continue", ";", "}", "if", "(", "!", "$", "file", "->", "isFile", "(", ")", ")", "{", "continue", ";", "}", "$", "class", "=", "$", "namespace", ".", "'\\\\'", ".", "$", "file", "->", "getBasename", "(", "'.php'", ")", ";", "$", "r", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "if", "(", "$", "r", "->", "isSubclassOf", "(", "'ActiveDoctrine\\Entity\\Entity'", ")", "&&", "!", "$", "r", "->", "isAbstract", "(", ")", ")", "{", "$", "this", "->", "addEntityClass", "(", "$", "class", ")", ";", "}", "}", "}" ]
Add all entity classes in a directory. @param string $namespace The base namespace of the entities @param string $directory The directory
[ "Add", "all", "entity", "classes", "in", "a", "directory", "." ]
fcf8c434c7df4704966107bf9a95c005a0b37168
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Schema/SchemaCreator.php#L62-L85
24,082
alevilar/ristorantino-vendor
Printers/Utility/Printaitor.php
Printaitor.__createOutput
public static function __createOutput ( $printerId ) { // cargar datos de la impresora $Printer = ClassRegistry::init("Printers.Printer"); $Printer->recursive = -1; $printer = $Printer->read(null, $printerId); if ( empty($printer['Printer']['output']) ) { return false; } $outputName = $printer['Printer']['output'] . 'PrinterOutput'; // cargar la Salida correspondiente segun la configuracion de la impresora App::uses($outputName, 'Printers.Lib/PrinterOutput'); self::$Output = new $outputName; return true; }
php
public static function __createOutput ( $printerId ) { // cargar datos de la impresora $Printer = ClassRegistry::init("Printers.Printer"); $Printer->recursive = -1; $printer = $Printer->read(null, $printerId); if ( empty($printer['Printer']['output']) ) { return false; } $outputName = $printer['Printer']['output'] . 'PrinterOutput'; // cargar la Salida correspondiente segun la configuracion de la impresora App::uses($outputName, 'Printers.Lib/PrinterOutput'); self::$Output = new $outputName; return true; }
[ "public", "static", "function", "__createOutput", "(", "$", "printerId", ")", "{", "// cargar datos de la impresora", "$", "Printer", "=", "ClassRegistry", "::", "init", "(", "\"Printers.Printer\"", ")", ";", "$", "Printer", "->", "recursive", "=", "-", "1", ";", "$", "printer", "=", "$", "Printer", "->", "read", "(", "null", ",", "$", "printerId", ")", ";", "if", "(", "empty", "(", "$", "printer", "[", "'Printer'", "]", "[", "'output'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "outputName", "=", "$", "printer", "[", "'Printer'", "]", "[", "'output'", "]", ".", "'PrinterOutput'", ";", "// cargar la Salida correspondiente segun la configuracion de la impresora", "App", "::", "uses", "(", "$", "outputName", ",", "'Printers.Lib/PrinterOutput'", ")", ";", "self", "::", "$", "Output", "=", "new", "$", "outputName", ";", "return", "true", ";", "}" ]
Gets the name of the printer engine @return boolean true si hay outut false si no la hay
[ "Gets", "the", "name", "of", "the", "printer", "engine" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Utility/Printaitor.php#L151-L166
24,083
alevilar/ristorantino-vendor
Printers/Utility/Printaitor.php
Printaitor._loadPrinterOutput
public static function _loadPrinterOutput( $outputType ) { $outputType = ucfirst(strtolower( $outputType )); $printerOutputName = $outputType."PrinterOutput"; App::uses($printerOutputName, "Printers.PrinterOutput"); self::$PrinterOutput = new $printerOutputName(); }
php
public static function _loadPrinterOutput( $outputType ) { $outputType = ucfirst(strtolower( $outputType )); $printerOutputName = $outputType."PrinterOutput"; App::uses($printerOutputName, "Printers.PrinterOutput"); self::$PrinterOutput = new $printerOutputName(); }
[ "public", "static", "function", "_loadPrinterOutput", "(", "$", "outputType", ")", "{", "$", "outputType", "=", "ucfirst", "(", "strtolower", "(", "$", "outputType", ")", ")", ";", "$", "printerOutputName", "=", "$", "outputType", ".", "\"PrinterOutput\"", ";", "App", "::", "uses", "(", "$", "printerOutputName", ",", "\"Printers.PrinterOutput\"", ")", ";", "self", "::", "$", "PrinterOutput", "=", "new", "$", "printerOutputName", "(", ")", ";", "}" ]
Instanciates an Engine for change Output Printing @param string $outputType Actualmente pueden ser la opciones: "cups" o "file" @return PrinterOutput or false
[ "Instanciates", "an", "Engine", "for", "change", "Output", "Printing" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Utility/Printaitor.php#L188-L194
24,084
alevilar/ristorantino-vendor
Printers/Utility/Printaitor.php
Printaitor.getView
public static function getView( PrintaitorViewObj $printViewObj ) { $data = $printViewObj->dataToView; $printer_id = $printViewObj->printerId; $templateName = $printViewObj->viewName; if (empty($printer_id)) { return -1; } $pluginPath = App::path('Lib', 'Printers'); $driverName = $printViewObj->printer['Printer']['driver']; $driverModelName = $printViewObj->printer['Printer']['driver_model']; App::build(array('View' => array( $pluginPath[0] . '/DriverView'))); $viewName = $driverName."Printer/$templateName"; $View = new View(); $View->set($data); $helperName = $driverModelName . $driverName.'Helper' ; App::uses($helperName, 'Printers.Lib/DriverView/Helper'); if (!class_exists($helperName)) { throw new MissingHelperException(array( 'class' => $helperName, 'plugin' => substr('Printers', 0, -1) )); } $View->PE = new $helperName($View); $View->printaitorObj = $printViewObj; $view = null; try { $view = $View->render( $viewName, false ); } catch (Exception $e) { CakeLog::write('debug','No existe la vista de Plugin Printer para '.$e->getMessage() ); } return $view; }
php
public static function getView( PrintaitorViewObj $printViewObj ) { $data = $printViewObj->dataToView; $printer_id = $printViewObj->printerId; $templateName = $printViewObj->viewName; if (empty($printer_id)) { return -1; } $pluginPath = App::path('Lib', 'Printers'); $driverName = $printViewObj->printer['Printer']['driver']; $driverModelName = $printViewObj->printer['Printer']['driver_model']; App::build(array('View' => array( $pluginPath[0] . '/DriverView'))); $viewName = $driverName."Printer/$templateName"; $View = new View(); $View->set($data); $helperName = $driverModelName . $driverName.'Helper' ; App::uses($helperName, 'Printers.Lib/DriverView/Helper'); if (!class_exists($helperName)) { throw new MissingHelperException(array( 'class' => $helperName, 'plugin' => substr('Printers', 0, -1) )); } $View->PE = new $helperName($View); $View->printaitorObj = $printViewObj; $view = null; try { $view = $View->render( $viewName, false ); } catch (Exception $e) { CakeLog::write('debug','No existe la vista de Plugin Printer para '.$e->getMessage() ); } return $view; }
[ "public", "static", "function", "getView", "(", "PrintaitorViewObj", "$", "printViewObj", ")", "{", "$", "data", "=", "$", "printViewObj", "->", "dataToView", ";", "$", "printer_id", "=", "$", "printViewObj", "->", "printerId", ";", "$", "templateName", "=", "$", "printViewObj", "->", "viewName", ";", "if", "(", "empty", "(", "$", "printer_id", ")", ")", "{", "return", "-", "1", ";", "}", "$", "pluginPath", "=", "App", "::", "path", "(", "'Lib'", ",", "'Printers'", ")", ";", "$", "driverName", "=", "$", "printViewObj", "->", "printer", "[", "'Printer'", "]", "[", "'driver'", "]", ";", "$", "driverModelName", "=", "$", "printViewObj", "->", "printer", "[", "'Printer'", "]", "[", "'driver_model'", "]", ";", "App", "::", "build", "(", "array", "(", "'View'", "=>", "array", "(", "$", "pluginPath", "[", "0", "]", ".", "'/DriverView'", ")", ")", ")", ";", "$", "viewName", "=", "$", "driverName", ".", "\"Printer/$templateName\"", ";", "$", "View", "=", "new", "View", "(", ")", ";", "$", "View", "->", "set", "(", "$", "data", ")", ";", "$", "helperName", "=", "$", "driverModelName", ".", "$", "driverName", ".", "'Helper'", ";", "App", "::", "uses", "(", "$", "helperName", ",", "'Printers.Lib/DriverView/Helper'", ")", ";", "if", "(", "!", "class_exists", "(", "$", "helperName", ")", ")", "{", "throw", "new", "MissingHelperException", "(", "array", "(", "'class'", "=>", "$", "helperName", ",", "'plugin'", "=>", "substr", "(", "'Printers'", ",", "0", ",", "-", "1", ")", ")", ")", ";", "}", "$", "View", "->", "PE", "=", "new", "$", "helperName", "(", "$", "View", ")", ";", "$", "View", "->", "printaitorObj", "=", "$", "printViewObj", ";", "$", "view", "=", "null", ";", "try", "{", "$", "view", "=", "$", "View", "->", "render", "(", "$", "viewName", ",", "false", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "CakeLog", "::", "write", "(", "'debug'", ",", "'No existe la vista de Plugin Printer para '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "view", ";", "}" ]
Logic for creating the view rendered. @param PrintaitorViewObj $printViewObj
[ "Logic", "for", "creating", "the", "view", "rendered", "." ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Utility/Printaitor.php#L204-L246
24,085
alchemy-fr/GeonamesServer-PHP-Plugin
src/Alchemy/Geonames/Connector.php
Connector.search
public function search($place, $limit = 40, $clientIp = null) { $parameters = array( 'sort' => 'closeness', 'name' => $place, 'limit' => $limit, ); if ($clientIp) { $parameters['client-ip'] = $clientIp; } $result = $this->get('city', $parameters); return array_map(function ($geoname) { return new Geoname($geoname); }, $result); }
php
public function search($place, $limit = 40, $clientIp = null) { $parameters = array( 'sort' => 'closeness', 'name' => $place, 'limit' => $limit, ); if ($clientIp) { $parameters['client-ip'] = $clientIp; } $result = $this->get('city', $parameters); return array_map(function ($geoname) { return new Geoname($geoname); }, $result); }
[ "public", "function", "search", "(", "$", "place", ",", "$", "limit", "=", "40", ",", "$", "clientIp", "=", "null", ")", "{", "$", "parameters", "=", "array", "(", "'sort'", "=>", "'closeness'", ",", "'name'", "=>", "$", "place", ",", "'limit'", "=>", "$", "limit", ",", ")", ";", "if", "(", "$", "clientIp", ")", "{", "$", "parameters", "[", "'client-ip'", "]", "=", "$", "clientIp", ";", "}", "$", "result", "=", "$", "this", "->", "get", "(", "'city'", ",", "$", "parameters", ")", ";", "return", "array_map", "(", "function", "(", "$", "geoname", ")", "{", "return", "new", "Geoname", "(", "$", "geoname", ")", ";", "}", ",", "$", "result", ")", ";", "}" ]
Search for a place by its name. @param string $place @param integer $limit @param string $clientIp @return array @throws Exception
[ "Search", "for", "a", "place", "by", "its", "name", "." ]
a14bd64b2badaf65ff03cca37ca52bff65f31152
https://github.com/alchemy-fr/GeonamesServer-PHP-Plugin/blob/a14bd64b2badaf65ff03cca37ca52bff65f31152/src/Alchemy/Geonames/Connector.php#L43-L60
24,086
alchemy-fr/GeonamesServer-PHP-Plugin
src/Alchemy/Geonames/Connector.php
Connector.get
private function get($endPoint, array $queryParameters = array()) { $request = $this->client->get($this->serverUri . $endPoint, array( 'accept' => 'application/json' )); foreach ($queryParameters as $key => $value) { $request->getQuery()->add($key, $value); } try { $result = json_decode($request->send()->getBody(true), true); } catch (ClientErrorResponseException $e) { if (404 === $e->getResponse()->getStatusCode()) { throw new NotFoundException('Resource not found', $e->getCode(), $e); } throw new TransportException('Failed to execute query', $e->getCode(), $e); } catch (GuzzleException $e) { throw new TransportException('Failed to execute query', $e->getCode(), $e); } if (JSON_ERROR_NONE !== json_last_error()) { throw new TransportException('Unable to parse result'); } return $result; }
php
private function get($endPoint, array $queryParameters = array()) { $request = $this->client->get($this->serverUri . $endPoint, array( 'accept' => 'application/json' )); foreach ($queryParameters as $key => $value) { $request->getQuery()->add($key, $value); } try { $result = json_decode($request->send()->getBody(true), true); } catch (ClientErrorResponseException $e) { if (404 === $e->getResponse()->getStatusCode()) { throw new NotFoundException('Resource not found', $e->getCode(), $e); } throw new TransportException('Failed to execute query', $e->getCode(), $e); } catch (GuzzleException $e) { throw new TransportException('Failed to execute query', $e->getCode(), $e); } if (JSON_ERROR_NONE !== json_last_error()) { throw new TransportException('Unable to parse result'); } return $result; }
[ "private", "function", "get", "(", "$", "endPoint", ",", "array", "$", "queryParameters", "=", "array", "(", ")", ")", "{", "$", "request", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "serverUri", ".", "$", "endPoint", ",", "array", "(", "'accept'", "=>", "'application/json'", ")", ")", ";", "foreach", "(", "$", "queryParameters", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "request", "->", "getQuery", "(", ")", "->", "add", "(", "$", "key", ",", "$", "value", ")", ";", "}", "try", "{", "$", "result", "=", "json_decode", "(", "$", "request", "->", "send", "(", ")", "->", "getBody", "(", "true", ")", ",", "true", ")", ";", "}", "catch", "(", "ClientErrorResponseException", "$", "e", ")", "{", "if", "(", "404", "===", "$", "e", "->", "getResponse", "(", ")", "->", "getStatusCode", "(", ")", ")", "{", "throw", "new", "NotFoundException", "(", "'Resource not found'", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "throw", "new", "TransportException", "(", "'Failed to execute query'", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "catch", "(", "GuzzleException", "$", "e", ")", "{", "throw", "new", "TransportException", "(", "'Failed to execute query'", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "if", "(", "JSON_ERROR_NONE", "!==", "json_last_error", "(", ")", ")", "{", "throw", "new", "TransportException", "(", "'Unable to parse result'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Executes a GET HTTP query. @param string $endPoint @param array $queryParameters @return array @throws NotFoundException @throws TransportException
[ "Executes", "a", "GET", "HTTP", "query", "." ]
a14bd64b2badaf65ff03cca37ca52bff65f31152
https://github.com/alchemy-fr/GeonamesServer-PHP-Plugin/blob/a14bd64b2badaf65ff03cca37ca52bff65f31152/src/Alchemy/Geonames/Connector.php#L113-L139
24,087
heidelpay/PhpDoc
src/phpDocumentor/Parser/Parser.php
Parser.getFilenames
protected function getFilenames(Collection $files) { $paths = $files->getFilenames(); if (count($paths) < 1) { throw new FilesNotFoundException(); } $this->log('Starting to process ' . count($paths) . ' files'); return $paths; }
php
protected function getFilenames(Collection $files) { $paths = $files->getFilenames(); if (count($paths) < 1) { throw new FilesNotFoundException(); } $this->log('Starting to process ' . count($paths) . ' files'); return $paths; }
[ "protected", "function", "getFilenames", "(", "Collection", "$", "files", ")", "{", "$", "paths", "=", "$", "files", "->", "getFilenames", "(", ")", ";", "if", "(", "count", "(", "$", "paths", ")", "<", "1", ")", "{", "throw", "new", "FilesNotFoundException", "(", ")", ";", "}", "$", "this", "->", "log", "(", "'Starting to process '", ".", "count", "(", "$", "paths", ")", ".", "' files'", ")", ";", "return", "$", "paths", ";", "}" ]
Extract all filenames from the given collection and output the amount of files. @param Collection $files @throws FilesNotFoundException if no files were found. @return string[]
[ "Extract", "all", "filenames", "from", "the", "given", "collection", "and", "output", "the", "amount", "of", "files", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/Parser.php#L337-L346
24,088
heidelpay/PhpDoc
src/phpDocumentor/Parser/Parser.php
Parser.parseFileIntoDescriptor
protected function parseFileIntoDescriptor(ProjectDescriptorBuilder $builder, $filename) { $parser = new File($this); $parser->parse($filename, $builder); }
php
protected function parseFileIntoDescriptor(ProjectDescriptorBuilder $builder, $filename) { $parser = new File($this); $parser->parse($filename, $builder); }
[ "protected", "function", "parseFileIntoDescriptor", "(", "ProjectDescriptorBuilder", "$", "builder", ",", "$", "filename", ")", "{", "$", "parser", "=", "new", "File", "(", "$", "this", ")", ";", "$", "parser", "->", "parse", "(", "$", "filename", ",", "$", "builder", ")", ";", "}" ]
Parses a file and creates a Descriptor for it in the project. @param ProjectDescriptorBuilder $builder @param string $filename @return void
[ "Parses", "a", "file", "and", "creates", "a", "Descriptor", "for", "it", "in", "the", "project", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/Parser.php#L356-L360
24,089
heidelpay/PhpDoc
src/phpDocumentor/Parser/Parser.php
Parser.logAfterParsingAFile
protected function logAfterParsingAFile($memory) { if (!$this->stopwatch) { return $memory; } $lap = $this->stopwatch->lap('parser.parse'); $oldMemory = $memory; $periods = $lap->getPeriods(); $memory = end($periods)->getMemory(); $this->log( '>> Memory after processing of file: ' . number_format($memory / 1024 / 1024, 2) . ' megabytes (' . (($memory - $oldMemory >= 0) ? '+' : '-') . number_format(($memory - $oldMemory) / 1024) . ' kilobytes)', LogLevel::DEBUG ); return $memory; }
php
protected function logAfterParsingAFile($memory) { if (!$this->stopwatch) { return $memory; } $lap = $this->stopwatch->lap('parser.parse'); $oldMemory = $memory; $periods = $lap->getPeriods(); $memory = end($periods)->getMemory(); $this->log( '>> Memory after processing of file: ' . number_format($memory / 1024 / 1024, 2) . ' megabytes (' . (($memory - $oldMemory >= 0) ? '+' : '-') . number_format(($memory - $oldMemory) / 1024) . ' kilobytes)', LogLevel::DEBUG ); return $memory; }
[ "protected", "function", "logAfterParsingAFile", "(", "$", "memory", ")", "{", "if", "(", "!", "$", "this", "->", "stopwatch", ")", "{", "return", "$", "memory", ";", "}", "$", "lap", "=", "$", "this", "->", "stopwatch", "->", "lap", "(", "'parser.parse'", ")", ";", "$", "oldMemory", "=", "$", "memory", ";", "$", "periods", "=", "$", "lap", "->", "getPeriods", "(", ")", ";", "$", "memory", "=", "end", "(", "$", "periods", ")", "->", "getMemory", "(", ")", ";", "$", "this", "->", "log", "(", "'>> Memory after processing of file: '", ".", "number_format", "(", "$", "memory", "/", "1024", "/", "1024", ",", "2", ")", ".", "' megabytes ('", ".", "(", "(", "$", "memory", "-", "$", "oldMemory", ">=", "0", ")", "?", "'+'", ":", "'-'", ")", ".", "number_format", "(", "(", "$", "memory", "-", "$", "oldMemory", ")", "/", "1024", ")", ".", "' kilobytes)'", ",", "LogLevel", "::", "DEBUG", ")", ";", "return", "$", "memory", ";", "}" ]
Collects the time and duration of processing a file, logs it and returns the new amount of memory in use. @param integer $memory @return integer
[ "Collects", "the", "time", "and", "duration", "of", "processing", "a", "file", "logs", "it", "and", "returns", "the", "new", "amount", "of", "memory", "in", "use", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/Parser.php#L384-L405
24,090
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Node/Host.php
Host.serverGetByName
public function serverGetByName($name) { foreach($this->serverList() as $server) { if($server["virtualserver_name"] == $name) return $server; } throw new Exception("invalid serverID", 0x400); }
php
public function serverGetByName($name) { foreach($this->serverList() as $server) { if($server["virtualserver_name"] == $name) return $server; } throw new Exception("invalid serverID", 0x400); }
[ "public", "function", "serverGetByName", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "serverList", "(", ")", "as", "$", "server", ")", "{", "if", "(", "$", "server", "[", "\"virtualserver_name\"", "]", "==", "$", "name", ")", "return", "$", "server", ";", "}", "throw", "new", "Exception", "(", "\"invalid serverID\"", ",", "0x400", ")", ";", "}" ]
Returns the first Server object matching the given name. @param string $name @throws Exception @return Server
[ "Returns", "the", "first", "Server", "object", "matching", "the", "given", "name", "." ]
39a56eca608da6b56b6aa386a7b5b31dc576c41a
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L292-L300
24,091
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Node/Host.php
Host.serverGetByUid
public function serverGetByUid($uid) { foreach($this->serverList() as $server) { if($server["virtualserver_unique_identifier"] == $uid) return $server; } throw new Exception("invalid serverID", 0x400); }
php
public function serverGetByUid($uid) { foreach($this->serverList() as $server) { if($server["virtualserver_unique_identifier"] == $uid) return $server; } throw new Exception("invalid serverID", 0x400); }
[ "public", "function", "serverGetByUid", "(", "$", "uid", ")", "{", "foreach", "(", "$", "this", "->", "serverList", "(", ")", "as", "$", "server", ")", "{", "if", "(", "$", "server", "[", "\"virtualserver_unique_identifier\"", "]", "==", "$", "uid", ")", "return", "$", "server", ";", "}", "throw", "new", "Exception", "(", "\"invalid serverID\"", ",", "0x400", ")", ";", "}" ]
Returns the first Server object matching the given unique identifier. @param string $uid @throws Exception @return Server
[ "Returns", "the", "first", "Server", "object", "matching", "the", "given", "unique", "identifier", "." ]
39a56eca608da6b56b6aa386a7b5b31dc576c41a
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L309-L317
24,092
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Node/Host.php
Host.permissionList
public function permissionList() { if($this->permissionList === null) { $this->fetchPermissionList(); } foreach($this->permissionList as $permname => $permdata) { if(isset($permdata["permcatid"]) && $permdata["permgrant"]) { continue; } $this->permissionList[$permname]["permcatid"] = $this->permissionGetCategoryById($permdata["permid"]); $this->permissionList[$permname]["permgrant"] = $this->permissionGetGrantById($permdata["permid"]); $grantsid = "i_needed_modify_power_" . substr($permname, 2); if(!$permdata["permname"]->startsWith("i_needed_modify_power_") && !isset($this->permissionList[$grantsid])) { $this->permissionList[$grantsid]["permid"] = $this->permissionList[$permname]["permgrant"]; $this->permissionList[$grantsid]["permname"] = Str::factory($grantsid); $this->permissionList[$grantsid]["permdesc"] = null; $this->permissionList[$grantsid]["permcatid"] = 0xFF; $this->permissionList[$grantsid]["permgrant"] = $this->permissionList[$permname]["permgrant"]; } } return $this->permissionList; }
php
public function permissionList() { if($this->permissionList === null) { $this->fetchPermissionList(); } foreach($this->permissionList as $permname => $permdata) { if(isset($permdata["permcatid"]) && $permdata["permgrant"]) { continue; } $this->permissionList[$permname]["permcatid"] = $this->permissionGetCategoryById($permdata["permid"]); $this->permissionList[$permname]["permgrant"] = $this->permissionGetGrantById($permdata["permid"]); $grantsid = "i_needed_modify_power_" . substr($permname, 2); if(!$permdata["permname"]->startsWith("i_needed_modify_power_") && !isset($this->permissionList[$grantsid])) { $this->permissionList[$grantsid]["permid"] = $this->permissionList[$permname]["permgrant"]; $this->permissionList[$grantsid]["permname"] = Str::factory($grantsid); $this->permissionList[$grantsid]["permdesc"] = null; $this->permissionList[$grantsid]["permcatid"] = 0xFF; $this->permissionList[$grantsid]["permgrant"] = $this->permissionList[$permname]["permgrant"]; } } return $this->permissionList; }
[ "public", "function", "permissionList", "(", ")", "{", "if", "(", "$", "this", "->", "permissionList", "===", "null", ")", "{", "$", "this", "->", "fetchPermissionList", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "permissionList", "as", "$", "permname", "=>", "$", "permdata", ")", "{", "if", "(", "isset", "(", "$", "permdata", "[", "\"permcatid\"", "]", ")", "&&", "$", "permdata", "[", "\"permgrant\"", "]", ")", "{", "continue", ";", "}", "$", "this", "->", "permissionList", "[", "$", "permname", "]", "[", "\"permcatid\"", "]", "=", "$", "this", "->", "permissionGetCategoryById", "(", "$", "permdata", "[", "\"permid\"", "]", ")", ";", "$", "this", "->", "permissionList", "[", "$", "permname", "]", "[", "\"permgrant\"", "]", "=", "$", "this", "->", "permissionGetGrantById", "(", "$", "permdata", "[", "\"permid\"", "]", ")", ";", "$", "grantsid", "=", "\"i_needed_modify_power_\"", ".", "substr", "(", "$", "permname", ",", "2", ")", ";", "if", "(", "!", "$", "permdata", "[", "\"permname\"", "]", "->", "startsWith", "(", "\"i_needed_modify_power_\"", ")", "&&", "!", "isset", "(", "$", "this", "->", "permissionList", "[", "$", "grantsid", "]", ")", ")", "{", "$", "this", "->", "permissionList", "[", "$", "grantsid", "]", "[", "\"permid\"", "]", "=", "$", "this", "->", "permissionList", "[", "$", "permname", "]", "[", "\"permgrant\"", "]", ";", "$", "this", "->", "permissionList", "[", "$", "grantsid", "]", "[", "\"permname\"", "]", "=", "Str", "::", "factory", "(", "$", "grantsid", ")", ";", "$", "this", "->", "permissionList", "[", "$", "grantsid", "]", "[", "\"permdesc\"", "]", "=", "null", ";", "$", "this", "->", "permissionList", "[", "$", "grantsid", "]", "[", "\"permcatid\"", "]", "=", "0xFF", ";", "$", "this", "->", "permissionList", "[", "$", "grantsid", "]", "[", "\"permgrant\"", "]", "=", "$", "this", "->", "permissionList", "[", "$", "permname", "]", "[", "\"permgrant\"", "]", ";", "}", "}", "return", "$", "this", "->", "permissionList", ";", "}" ]
Returns a list of permissions available on the server instance. @return array
[ "Returns", "a", "list", "of", "permissions", "available", "on", "the", "server", "instance", "." ]
39a56eca608da6b56b6aa386a7b5b31dc576c41a
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L457-L487
24,093
siad007/versioncontrol_hg
src/Command/AbstractCommand.php
AbstractCommand.execute
public function execute() { $output = []; $code = 0; exec(sprintf($this->command, $this->hgPath, $this) . " 2>&1", $output, $code); if ($code != 0) { throw new \RuntimeException( 'An error occurred while using VersionControl_HG; hg returned: ' . implode(PHP_EOL, $output), $code ); } return implode(PHP_EOL, $output); }
php
public function execute() { $output = []; $code = 0; exec(sprintf($this->command, $this->hgPath, $this) . " 2>&1", $output, $code); if ($code != 0) { throw new \RuntimeException( 'An error occurred while using VersionControl_HG; hg returned: ' . implode(PHP_EOL, $output), $code ); } return implode(PHP_EOL, $output); }
[ "public", "function", "execute", "(", ")", "{", "$", "output", "=", "[", "]", ";", "$", "code", "=", "0", ";", "exec", "(", "sprintf", "(", "$", "this", "->", "command", ",", "$", "this", "->", "hgPath", ",", "$", "this", ")", ".", "\" 2>&1\"", ",", "$", "output", ",", "$", "code", ")", ";", "if", "(", "$", "code", "!=", "0", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'An error occurred while using VersionControl_HG; hg returned: '", ".", "implode", "(", "PHP_EOL", ",", "$", "output", ")", ",", "$", "code", ")", ";", "}", "return", "implode", "(", "PHP_EOL", ",", "$", "output", ")", ";", "}" ]
Execute mercurial command. @return string @throws \RuntimeException
[ "Execute", "mercurial", "command", "." ]
e02ec9f1e88efae48f0e3296f65b1d99718b27cd
https://github.com/siad007/versioncontrol_hg/blob/e02ec9f1e88efae48f0e3296f65b1d99718b27cd/src/Command/AbstractCommand.php#L146-L162
24,094
siad007/versioncontrol_hg
src/Command/AbstractCommand.php
AbstractCommand.assembleOptionString
protected function assembleOptionString() { $optionString = ''; foreach ($this->options as $name => $option) { if ($option === true) { $optionString .= " {$name}"; } elseif (is_string($option) && $option !== '') { $optionString .= " {$name} " . escapeshellarg($option); } elseif (is_array($option) && !empty($option)) { $optionString .= " {$name} " . implode(' ', $option); } } return $optionString !== '' ? $optionString . '' : ' '; }
php
protected function assembleOptionString() { $optionString = ''; foreach ($this->options as $name => $option) { if ($option === true) { $optionString .= " {$name}"; } elseif (is_string($option) && $option !== '') { $optionString .= " {$name} " . escapeshellarg($option); } elseif (is_array($option) && !empty($option)) { $optionString .= " {$name} " . implode(' ', $option); } } return $optionString !== '' ? $optionString . '' : ' '; }
[ "protected", "function", "assembleOptionString", "(", ")", "{", "$", "optionString", "=", "''", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "name", "=>", "$", "option", ")", "{", "if", "(", "$", "option", "===", "true", ")", "{", "$", "optionString", ".=", "\" {$name}\"", ";", "}", "elseif", "(", "is_string", "(", "$", "option", ")", "&&", "$", "option", "!==", "''", ")", "{", "$", "optionString", ".=", "\" {$name} \"", ".", "escapeshellarg", "(", "$", "option", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "option", ")", "&&", "!", "empty", "(", "$", "option", ")", ")", "{", "$", "optionString", ".=", "\" {$name} \"", ".", "implode", "(", "' '", ",", "$", "option", ")", ";", "}", "}", "return", "$", "optionString", "!==", "''", "?", "$", "optionString", ".", "''", ":", "' '", ";", "}" ]
Concatinates string options. @return string
[ "Concatinates", "string", "options", "." ]
e02ec9f1e88efae48f0e3296f65b1d99718b27cd
https://github.com/siad007/versioncontrol_hg/blob/e02ec9f1e88efae48f0e3296f65b1d99718b27cd/src/Command/AbstractCommand.php#L235-L250
24,095
siad007/versioncontrol_hg
src/Command/AbstractCommand.php
AbstractCommand.getCommandName
private function getCommandName() { $className = implode('', array_slice(explode('\\', get_class($this)), -1)); $commandName = str_replace('command', '', strtolower($className)); return $commandName; }
php
private function getCommandName() { $className = implode('', array_slice(explode('\\', get_class($this)), -1)); $commandName = str_replace('command', '', strtolower($className)); return $commandName; }
[ "private", "function", "getCommandName", "(", ")", "{", "$", "className", "=", "implode", "(", "''", ",", "array_slice", "(", "explode", "(", "'\\\\'", ",", "get_class", "(", "$", "this", ")", ")", ",", "-", "1", ")", ")", ";", "$", "commandName", "=", "str_replace", "(", "'command'", ",", "''", ",", "strtolower", "(", "$", "className", ")", ")", ";", "return", "$", "commandName", ";", "}" ]
Returns the concrete commands name. @return string
[ "Returns", "the", "concrete", "commands", "name", "." ]
e02ec9f1e88efae48f0e3296f65b1d99718b27cd
https://github.com/siad007/versioncontrol_hg/blob/e02ec9f1e88efae48f0e3296f65b1d99718b27cd/src/Command/AbstractCommand.php#L257-L263
24,096
comodojo/daemon
src/Comodojo/Daemon/Worker/Manager.php
Manager.install
public function install( WorkerInterface $worker, $looptime = 1, $forever = false ) { $name = $worker->getName(); if ( $this->isInstalled($name) ) { throw new Exception("Worker already installed"); } $w = Worker::create() ->setInstance($worker) ->setLooptime($looptime) ->setForever($forever) ->setInputChannel(new SharedMemory((int) '1'.hexdec($worker->getId()))) ->setOutputChannel(new SharedMemory((int) '2'.hexdec($worker->getId()))); $this->data[$name] = $w; return $this; }
php
public function install( WorkerInterface $worker, $looptime = 1, $forever = false ) { $name = $worker->getName(); if ( $this->isInstalled($name) ) { throw new Exception("Worker already installed"); } $w = Worker::create() ->setInstance($worker) ->setLooptime($looptime) ->setForever($forever) ->setInputChannel(new SharedMemory((int) '1'.hexdec($worker->getId()))) ->setOutputChannel(new SharedMemory((int) '2'.hexdec($worker->getId()))); $this->data[$name] = $w; return $this; }
[ "public", "function", "install", "(", "WorkerInterface", "$", "worker", ",", "$", "looptime", "=", "1", ",", "$", "forever", "=", "false", ")", "{", "$", "name", "=", "$", "worker", "->", "getName", "(", ")", ";", "if", "(", "$", "this", "->", "isInstalled", "(", "$", "name", ")", ")", "{", "throw", "new", "Exception", "(", "\"Worker already installed\"", ")", ";", "}", "$", "w", "=", "Worker", "::", "create", "(", ")", "->", "setInstance", "(", "$", "worker", ")", "->", "setLooptime", "(", "$", "looptime", ")", "->", "setForever", "(", "$", "forever", ")", "->", "setInputChannel", "(", "new", "SharedMemory", "(", "(", "int", ")", "'1'", ".", "hexdec", "(", "$", "worker", "->", "getId", "(", ")", ")", ")", ")", "->", "setOutputChannel", "(", "new", "SharedMemory", "(", "(", "int", ")", "'2'", ".", "hexdec", "(", "$", "worker", "->", "getId", "(", ")", ")", ")", ")", ";", "$", "this", "->", "data", "[", "$", "name", "]", "=", "$", "w", ";", "return", "$", "this", ";", "}" ]
Install a worker into the stack @param WorkerInterface $worker @param int $looptime @param bool $forever @return Manager
[ "Install", "a", "worker", "into", "the", "stack" ]
361b0a3a91dc7720dd3bec448bb4ca47d0ef0292
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Worker/Manager.php#L80-L103
24,097
dragonmantank/fillet
src/Fillet/TextUtils/GenerateSlug.php
GenerateSlug.generateSlug
public function generateSlug($title) { $title = strtolower($title); $title = preg_replace('/[^%a-z0-9 _-]/', '', $title); $title = preg_replace('/\s+/', '-', $title); $title = preg_replace('|-+|', '-', $title); $title = trim($title, '-'); return $title; }
php
public function generateSlug($title) { $title = strtolower($title); $title = preg_replace('/[^%a-z0-9 _-]/', '', $title); $title = preg_replace('/\s+/', '-', $title); $title = preg_replace('|-+|', '-', $title); $title = trim($title, '-'); return $title; }
[ "public", "function", "generateSlug", "(", "$", "title", ")", "{", "$", "title", "=", "strtolower", "(", "$", "title", ")", ";", "$", "title", "=", "preg_replace", "(", "'/[^%a-z0-9 _-]/'", ",", "''", ",", "$", "title", ")", ";", "$", "title", "=", "preg_replace", "(", "'/\\s+/'", ",", "'-'", ",", "$", "title", ")", ";", "$", "title", "=", "preg_replace", "(", "'|-+|'", ",", "'-'", ",", "$", "title", ")", ";", "$", "title", "=", "trim", "(", "$", "title", ",", "'-'", ")", ";", "return", "$", "title", ";", "}" ]
Generate an appropriate slug from a title This function will turn a title into a lowercase and hyphenated title that is compatible with how Sculpin expects slugs. @param string $title Raw title @return string
[ "Generate", "an", "appropriate", "slug", "from", "a", "title", "This", "function", "will", "turn", "a", "title", "into", "a", "lowercase", "and", "hyphenated", "title", "that", "is", "compatible", "with", "how", "Sculpin", "expects", "slugs", "." ]
b197947608c05ac2318e8f6b296345494004d9c6
https://github.com/dragonmantank/fillet/blob/b197947608c05ac2318e8f6b296345494004d9c6/src/Fillet/TextUtils/GenerateSlug.php#L21-L30
24,098
sciactive/nymph-server
src/Drivers/DriverTrait.php
DriverTrait.entityReferenceSearch
protected function entityReferenceSearch($value, $entity) { if (!is_array($value) && !($value instanceof Traversable)) { return false; } if (!isset($entity)) { throw new Exceptions\InvalidParametersException(); } // Get the GUID, if the passed $entity is an object. if (is_array($entity)) { foreach ($entity as &$curEntity) { if (is_object($curEntity)) { $curEntity = $curEntity->guid; } } unset($curEntity); } elseif (is_object($entity)) { $entity = [$entity->guid]; } else { $entity = [(int) $entity]; } if (isset($value[0]) && $value[0] === 'nymph_entity_reference') { return in_array($value[1], $entity); } else { // Search through multidimensional arrays looking for the reference. foreach ($value as $curValue) { if ($this->entityReferenceSearch($curValue, $entity)) { return true; } } } return false; }
php
protected function entityReferenceSearch($value, $entity) { if (!is_array($value) && !($value instanceof Traversable)) { return false; } if (!isset($entity)) { throw new Exceptions\InvalidParametersException(); } // Get the GUID, if the passed $entity is an object. if (is_array($entity)) { foreach ($entity as &$curEntity) { if (is_object($curEntity)) { $curEntity = $curEntity->guid; } } unset($curEntity); } elseif (is_object($entity)) { $entity = [$entity->guid]; } else { $entity = [(int) $entity]; } if (isset($value[0]) && $value[0] === 'nymph_entity_reference') { return in_array($value[1], $entity); } else { // Search through multidimensional arrays looking for the reference. foreach ($value as $curValue) { if ($this->entityReferenceSearch($curValue, $entity)) { return true; } } } return false; }
[ "protected", "function", "entityReferenceSearch", "(", "$", "value", ",", "$", "entity", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", "&&", "!", "(", "$", "value", "instanceof", "Traversable", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "entity", ")", ")", "{", "throw", "new", "Exceptions", "\\", "InvalidParametersException", "(", ")", ";", "}", "// Get the GUID, if the passed $entity is an object.", "if", "(", "is_array", "(", "$", "entity", ")", ")", "{", "foreach", "(", "$", "entity", "as", "&", "$", "curEntity", ")", "{", "if", "(", "is_object", "(", "$", "curEntity", ")", ")", "{", "$", "curEntity", "=", "$", "curEntity", "->", "guid", ";", "}", "}", "unset", "(", "$", "curEntity", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "entity", ")", ")", "{", "$", "entity", "=", "[", "$", "entity", "->", "guid", "]", ";", "}", "else", "{", "$", "entity", "=", "[", "(", "int", ")", "$", "entity", "]", ";", "}", "if", "(", "isset", "(", "$", "value", "[", "0", "]", ")", "&&", "$", "value", "[", "0", "]", "===", "'nymph_entity_reference'", ")", "{", "return", "in_array", "(", "$", "value", "[", "1", "]", ",", "$", "entity", ")", ";", "}", "else", "{", "// Search through multidimensional arrays looking for the reference.", "foreach", "(", "$", "value", "as", "$", "curValue", ")", "{", "if", "(", "$", "this", "->", "entityReferenceSearch", "(", "$", "curValue", ",", "$", "entity", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Search through a value for an entity reference. @param mixed $value Any value to search. @param array|Entity|int $entity An entity, GUID, or array of either to search for. @return bool True if the reference is found, false otherwise. @access protected
[ "Search", "through", "a", "value", "for", "an", "entity", "reference", "." ]
3c18dbf45c2750d07c798e14534dba87387beeba
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/DriverTrait.php#L469-L500
24,099
sciactive/nymph-server
src/Drivers/DriverTrait.php
DriverTrait.pullCache
protected function pullCache($guid, $className) { // Increment the entity access count. if (!isset($this->entityCount[$guid])) { $this->entityCount[$guid] = 0; } $this->entityCount[$guid]++; if (isset($this->entityCache[$guid][$className])) { return (clone $this->entityCache[$guid][$className]); } return null; }
php
protected function pullCache($guid, $className) { // Increment the entity access count. if (!isset($this->entityCount[$guid])) { $this->entityCount[$guid] = 0; } $this->entityCount[$guid]++; if (isset($this->entityCache[$guid][$className])) { return (clone $this->entityCache[$guid][$className]); } return null; }
[ "protected", "function", "pullCache", "(", "$", "guid", ",", "$", "className", ")", "{", "// Increment the entity access count.", "if", "(", "!", "isset", "(", "$", "this", "->", "entityCount", "[", "$", "guid", "]", ")", ")", "{", "$", "this", "->", "entityCount", "[", "$", "guid", "]", "=", "0", ";", "}", "$", "this", "->", "entityCount", "[", "$", "guid", "]", "++", ";", "if", "(", "isset", "(", "$", "this", "->", "entityCache", "[", "$", "guid", "]", "[", "$", "className", "]", ")", ")", "{", "return", "(", "clone", "$", "this", "->", "entityCache", "[", "$", "guid", "]", "[", "$", "className", "]", ")", ";", "}", "return", "null", ";", "}" ]
Pull an entity from the cache. @param int $guid The entity's GUID. @param string $className The entity's class. @return Entity|null The entity or null if it's not cached. @access protected
[ "Pull", "an", "entity", "from", "the", "cache", "." ]
3c18dbf45c2750d07c798e14534dba87387beeba
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/DriverTrait.php#L839-L849