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
238,500
strident/Trident
src/Trident/Module/FrameworkModule/Debug/Toolbar/Extension/TridentMemoryUsageExtension.php
TridentMemoryUsageExtension.convertToBytes
private function convertToBytes($memoryLimit) { if ('-1' === $memoryLimit) { return -1; } $memoryLimit = strtolower($memoryLimit); $max = strtolower(ltrim($memoryLimit, '+')); if (0 === strpos($max, '0x')) { $max = intval($max, 16); } elseif (0 === strpos($max, '0')) { $max = intval($max, 8); } else { $max = intval($max); } switch (substr($memoryLimit, -1)) { case 't': $max *= 1024; case 'g': $max *= 1024; case 'm': $max *= 1024; case 'k': $max *= 1024; } return $max; }
php
private function convertToBytes($memoryLimit) { if ('-1' === $memoryLimit) { return -1; } $memoryLimit = strtolower($memoryLimit); $max = strtolower(ltrim($memoryLimit, '+')); if (0 === strpos($max, '0x')) { $max = intval($max, 16); } elseif (0 === strpos($max, '0')) { $max = intval($max, 8); } else { $max = intval($max); } switch (substr($memoryLimit, -1)) { case 't': $max *= 1024; case 'g': $max *= 1024; case 'm': $max *= 1024; case 'k': $max *= 1024; } return $max; }
[ "private", "function", "convertToBytes", "(", "$", "memoryLimit", ")", "{", "if", "(", "'-1'", "===", "$", "memoryLimit", ")", "{", "return", "-", "1", ";", "}", "$", "memoryLimit", "=", "strtolower", "(", "$", "memoryLimit", ")", ";", "$", "max", "=", "strtolower", "(", "ltrim", "(", "$", "memoryLimit", ",", "'+'", ")", ")", ";", "if", "(", "0", "===", "strpos", "(", "$", "max", ",", "'0x'", ")", ")", "{", "$", "max", "=", "intval", "(", "$", "max", ",", "16", ")", ";", "}", "elseif", "(", "0", "===", "strpos", "(", "$", "max", ",", "'0'", ")", ")", "{", "$", "max", "=", "intval", "(", "$", "max", ",", "8", ")", ";", "}", "else", "{", "$", "max", "=", "intval", "(", "$", "max", ")", ";", "}", "switch", "(", "substr", "(", "$", "memoryLimit", ",", "-", "1", ")", ")", "{", "case", "'t'", ":", "$", "max", "*=", "1024", ";", "case", "'g'", ":", "$", "max", "*=", "1024", ";", "case", "'m'", ":", "$", "max", "*=", "1024", ";", "case", "'k'", ":", "$", "max", "*=", "1024", ";", "}", "return", "$", "max", ";", "}" ]
Convert mixed to bytes. @param mixed $memoryLimit @return integer
[ "Convert", "mixed", "to", "bytes", "." ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Module/FrameworkModule/Debug/Toolbar/Extension/TridentMemoryUsageExtension.php#L51-L75
238,501
n0m4dz/laracasa
src/N0m4dz/Laracasa/Laracasa.php
Laracasa.getAlbum
function getAlbum() { $photos = new Zend_Gdata_Photos($this->client); $query = new Zend_Gdata_Photos_AlbumQuery(); $query->setUser($this->user); $query->setAlbumId($this->album); $albumFeed = $photos->getAlbumFeed($query); return $albumFeed; }
php
function getAlbum() { $photos = new Zend_Gdata_Photos($this->client); $query = new Zend_Gdata_Photos_AlbumQuery(); $query->setUser($this->user); $query->setAlbumId($this->album); $albumFeed = $photos->getAlbumFeed($query); return $albumFeed; }
[ "function", "getAlbum", "(", ")", "{", "$", "photos", "=", "new", "Zend_Gdata_Photos", "(", "$", "this", "->", "client", ")", ";", "$", "query", "=", "new", "Zend_Gdata_Photos_AlbumQuery", "(", ")", ";", "$", "query", "->", "setUser", "(", "$", "this", "->", "user", ")", ";", "$", "query", "->", "setAlbumId", "(", "$", "this", "->", "album", ")", ";", "$", "albumFeed", "=", "$", "photos", "->", "getAlbumFeed", "(", "$", "query", ")", ";", "return", "$", "albumFeed", ";", "}" ]
Retrieve photos from specified album
[ "Retrieve", "photos", "from", "specified", "album" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/src/N0m4dz/Laracasa/Laracasa.php#L92-L99
238,502
n0m4dz/laracasa
src/N0m4dz/Laracasa/Laracasa.php
Laracasa.getPhotoById
function getPhotoById($photoId) { $photos = new Zend_Gdata_Photos($this->client); $query = new Zend_Gdata_Photos_PhotoQuery(); $query->setUser($this->user); $query->setAlbumId($this->album); $query->setPhotoId($photoId); $query = $query->getQueryUrl() . "?kind=comment,tag&imgmax=1600"; $photoFeed = $photos->getPhotoFeed($query); return $photoFeed; }
php
function getPhotoById($photoId) { $photos = new Zend_Gdata_Photos($this->client); $query = new Zend_Gdata_Photos_PhotoQuery(); $query->setUser($this->user); $query->setAlbumId($this->album); $query->setPhotoId($photoId); $query = $query->getQueryUrl() . "?kind=comment,tag&imgmax=1600"; $photoFeed = $photos->getPhotoFeed($query); return $photoFeed; }
[ "function", "getPhotoById", "(", "$", "photoId", ")", "{", "$", "photos", "=", "new", "Zend_Gdata_Photos", "(", "$", "this", "->", "client", ")", ";", "$", "query", "=", "new", "Zend_Gdata_Photos_PhotoQuery", "(", ")", ";", "$", "query", "->", "setUser", "(", "$", "this", "->", "user", ")", ";", "$", "query", "->", "setAlbumId", "(", "$", "this", "->", "album", ")", ";", "$", "query", "->", "setPhotoId", "(", "$", "photoId", ")", ";", "$", "query", "=", "$", "query", "->", "getQueryUrl", "(", ")", ".", "\"?kind=comment,tag&imgmax=1600\"", ";", "$", "photoFeed", "=", "$", "photos", "->", "getPhotoFeed", "(", "$", "query", ")", ";", "return", "$", "photoFeed", ";", "}" ]
Select a photo from specified album @param [string] $photoId [photo ID] @return [object] [return photo object]
[ "Select", "a", "photo", "from", "specified", "album" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/src/N0m4dz/Laracasa/Laracasa.php#L106-L116
238,503
n0m4dz/laracasa
src/N0m4dz/Laracasa/Laracasa.php
Laracasa.addPhoto
function addPhoto($photo) { if (!file_exists($photo['tmp_name']) || !is_uploaded_file($photo['tmp_name'])) { $o = array('state' => false); } else { $photos = new Zend_Gdata_Photos($this->client); $fd = $photos->newMediaFileSource($photo["tmp_name"]); $fd->setContentType($photo["type"]); $entry = new Zend_Gdata_Photos_PhotoEntry(); $entry->setMediaSource($fd); $entry->setTitle($photos->newTitle($photo["name"])); $albumQuery = new Zend_Gdata_Photos_AlbumQuery; $albumQuery->setUser($this->user); $albumQuery->setAlbumId($this->album); $albumEntry = $photos->getAlbumEntry($albumQuery); $result = $photos->insertPhotoEntry($entry, $albumEntry); if ($result) { $o = array('state' => true, 'id' => $result->getGphotoId()); } else { $o = array('state' => false); } } return $o; }
php
function addPhoto($photo) { if (!file_exists($photo['tmp_name']) || !is_uploaded_file($photo['tmp_name'])) { $o = array('state' => false); } else { $photos = new Zend_Gdata_Photos($this->client); $fd = $photos->newMediaFileSource($photo["tmp_name"]); $fd->setContentType($photo["type"]); $entry = new Zend_Gdata_Photos_PhotoEntry(); $entry->setMediaSource($fd); $entry->setTitle($photos->newTitle($photo["name"])); $albumQuery = new Zend_Gdata_Photos_AlbumQuery; $albumQuery->setUser($this->user); $albumQuery->setAlbumId($this->album); $albumEntry = $photos->getAlbumEntry($albumQuery); $result = $photos->insertPhotoEntry($entry, $albumEntry); if ($result) { $o = array('state' => true, 'id' => $result->getGphotoId()); } else { $o = array('state' => false); } } return $o; }
[ "function", "addPhoto", "(", "$", "photo", ")", "{", "if", "(", "!", "file_exists", "(", "$", "photo", "[", "'tmp_name'", "]", ")", "||", "!", "is_uploaded_file", "(", "$", "photo", "[", "'tmp_name'", "]", ")", ")", "{", "$", "o", "=", "array", "(", "'state'", "=>", "false", ")", ";", "}", "else", "{", "$", "photos", "=", "new", "Zend_Gdata_Photos", "(", "$", "this", "->", "client", ")", ";", "$", "fd", "=", "$", "photos", "->", "newMediaFileSource", "(", "$", "photo", "[", "\"tmp_name\"", "]", ")", ";", "$", "fd", "->", "setContentType", "(", "$", "photo", "[", "\"type\"", "]", ")", ";", "$", "entry", "=", "new", "Zend_Gdata_Photos_PhotoEntry", "(", ")", ";", "$", "entry", "->", "setMediaSource", "(", "$", "fd", ")", ";", "$", "entry", "->", "setTitle", "(", "$", "photos", "->", "newTitle", "(", "$", "photo", "[", "\"name\"", "]", ")", ")", ";", "$", "albumQuery", "=", "new", "Zend_Gdata_Photos_AlbumQuery", ";", "$", "albumQuery", "->", "setUser", "(", "$", "this", "->", "user", ")", ";", "$", "albumQuery", "->", "setAlbumId", "(", "$", "this", "->", "album", ")", ";", "$", "albumEntry", "=", "$", "photos", "->", "getAlbumEntry", "(", "$", "albumQuery", ")", ";", "$", "result", "=", "$", "photos", "->", "insertPhotoEntry", "(", "$", "entry", ",", "$", "albumEntry", ")", ";", "if", "(", "$", "result", ")", "{", "$", "o", "=", "array", "(", "'state'", "=>", "true", ",", "'id'", "=>", "$", "result", "->", "getGphotoId", "(", ")", ")", ";", "}", "else", "{", "$", "o", "=", "array", "(", "'state'", "=>", "false", ")", ";", "}", "}", "return", "$", "o", ";", "}" ]
Add a photo to specific picasa web album @param [file] $photo [uploaded photo file object]
[ "Add", "a", "photo", "to", "specific", "picasa", "web", "album" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/src/N0m4dz/Laracasa/Laracasa.php#L122-L150
238,504
n0m4dz/laracasa
src/N0m4dz/Laracasa/Laracasa.php
Laracasa.deletePhoto
function deletePhoto($photoId) { $photos = new Zend_Gdata_Photos($this->client); $photoQuery = new Zend_Gdata_Photos_PhotoQuery; $photoQuery->setUser($this->user); $photoQuery->setAlbumId($this->album); $photoQuery->setPhotoId($photoId); $photoQuery->setType('entry'); $entry = $photos->getPhotoEntry($photoQuery); $photos->deletePhotoEntry($entry, true); }
php
function deletePhoto($photoId) { $photos = new Zend_Gdata_Photos($this->client); $photoQuery = new Zend_Gdata_Photos_PhotoQuery; $photoQuery->setUser($this->user); $photoQuery->setAlbumId($this->album); $photoQuery->setPhotoId($photoId); $photoQuery->setType('entry'); $entry = $photos->getPhotoEntry($photoQuery); $photos->deletePhotoEntry($entry, true); }
[ "function", "deletePhoto", "(", "$", "photoId", ")", "{", "$", "photos", "=", "new", "Zend_Gdata_Photos", "(", "$", "this", "->", "client", ")", ";", "$", "photoQuery", "=", "new", "Zend_Gdata_Photos_PhotoQuery", ";", "$", "photoQuery", "->", "setUser", "(", "$", "this", "->", "user", ")", ";", "$", "photoQuery", "->", "setAlbumId", "(", "$", "this", "->", "album", ")", ";", "$", "photoQuery", "->", "setPhotoId", "(", "$", "photoId", ")", ";", "$", "photoQuery", "->", "setType", "(", "'entry'", ")", ";", "$", "entry", "=", "$", "photos", "->", "getPhotoEntry", "(", "$", "photoQuery", ")", ";", "$", "photos", "->", "deletePhotoEntry", "(", "$", "entry", ",", "true", ")", ";", "}" ]
Deletes the specified photo @param Zend_Http_Client $client The authenticated client @param string $user The user's account name @param integer $albumId The album's id @param integer $photoId The photo's id @return void
[ "Deletes", "the", "specified", "photo" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/src/N0m4dz/Laracasa/Laracasa.php#L161-L173
238,505
native5/native5-sdk-common-php
src/Native5/Core/Configuration/YamlConfigFactory.php
YamlConfigFactory.override
public function override($configFile, $strict = false) { parent::override($this->_parse($configFile, $strict)); }
php
public function override($configFile, $strict = false) { parent::override($this->_parse($configFile, $strict)); }
[ "public", "function", "override", "(", "$", "configFile", ",", "$", "strict", "=", "false", ")", "{", "parent", "::", "override", "(", "$", "this", "->", "_parse", "(", "$", "configFile", ",", "$", "strict", ")", ")", ";", "}" ]
override Merges the configuration from this yaml file with the base configuration, override values @param mixed $config path to config file @param mixed $strict whether to throw an exception if file is not found @access public @return void
[ "override", "Merges", "the", "configuration", "from", "this", "yaml", "file", "with", "the", "base", "configuration", "override", "values" ]
c8bd5b219bd05ea4d317d21ae9c0c8dddcede7fe
https://github.com/native5/native5-sdk-common-php/blob/c8bd5b219bd05ea4d317d21ae9c0c8dddcede7fe/src/Native5/Core/Configuration/YamlConfigFactory.php#L68-L70
238,506
AnonymPHP/Anonym-Library
src/Anonym/Mail/PhpMailerDriver.php
PhpMailerDriver.from
public function from($mail, $name = null) { $this->mailer->setFrom($mail, $name); return $this; }
php
public function from($mail, $name = null) { $this->mailer->setFrom($mail, $name); return $this; }
[ "public", "function", "from", "(", "$", "mail", ",", "$", "name", "=", "null", ")", "{", "$", "this", "->", "mailer", "->", "setFrom", "(", "$", "mail", ",", "$", "name", ")", ";", "return", "$", "this", ";", "}" ]
Set the address information sent by mail. @param string $mail the address of mail @param string $name the real name of mail sender @return $this
[ "Set", "the", "address", "information", "sent", "by", "mail", "." ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Mail/PhpMailerDriver.php#L90-L94
238,507
AnonymPHP/Anonym-Library
src/Anonym/Mail/PhpMailerDriver.php
PhpMailerDriver.body
public function body($body = '', $contentType = 'text/html') { $this->mailer->Body = $body; $this->mailer->ContentType = $contentType; return $this; }
php
public function body($body = '', $contentType = 'text/html') { $this->mailer->Body = $body; $this->mailer->ContentType = $contentType; return $this; }
[ "public", "function", "body", "(", "$", "body", "=", "''", ",", "$", "contentType", "=", "'text/html'", ")", "{", "$", "this", "->", "mailer", "->", "Body", "=", "$", "body", ";", "$", "this", "->", "mailer", "->", "ContentType", "=", "$", "contentType", ";", "return", "$", "this", ";", "}" ]
register the message body @param string $body the message body @param string $contentType the type of message content @return $this
[ "register", "the", "message", "body" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Mail/PhpMailerDriver.php#L116-L121
238,508
eix/core
src/php/main/Eix/Core/Responses/Http.php
Http.issue
public function issue() { // If there is no next URL, just output the headers as expected. foreach ($this->headers as $key => $value) { header("{$key}: {$value}", true); } // Output content type. if ($this->contentType) { header("content-type: {$this->contentType}; charset={$this->encoding}"); } // Output status code. $statusMessage = sprintf('%d %s', $this->status, HttpClient::getStatusCodeMessage($this->status) ); header('Status: ' . $statusMessage); }
php
public function issue() { // If there is no next URL, just output the headers as expected. foreach ($this->headers as $key => $value) { header("{$key}: {$value}", true); } // Output content type. if ($this->contentType) { header("content-type: {$this->contentType}; charset={$this->encoding}"); } // Output status code. $statusMessage = sprintf('%d %s', $this->status, HttpClient::getStatusCodeMessage($this->status) ); header('Status: ' . $statusMessage); }
[ "public", "function", "issue", "(", ")", "{", "// If there is no next URL, just output the headers as expected.", "foreach", "(", "$", "this", "->", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "header", "(", "\"{$key}: {$value}\"", ",", "true", ")", ";", "}", "// Output content type.", "if", "(", "$", "this", "->", "contentType", ")", "{", "header", "(", "\"content-type: {$this->contentType}; charset={$this->encoding}\"", ")", ";", "}", "// Output status code.", "$", "statusMessage", "=", "sprintf", "(", "'%d %s'", ",", "$", "this", "->", "status", ",", "HttpClient", "::", "getStatusCodeMessage", "(", "$", "this", "->", "status", ")", ")", ";", "header", "(", "'Status: '", ".", "$", "statusMessage", ")", ";", "}" ]
The default output of an HTTP response is composed of the headers.
[ "The", "default", "output", "of", "an", "HTTP", "response", "is", "composed", "of", "the", "headers", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Http.php#L36-L54
238,509
eix/core
src/php/main/Eix/Core/Responses/Http.php
Http.setStatus
public function setStatus($status) { $result = \Eix\Services\Net\Http::isStatusCodeValid($status); if ($result) { $this->status = $status; } return $result; }
php
public function setStatus($status) { $result = \Eix\Services\Net\Http::isStatusCodeValid($status); if ($result) { $this->status = $status; } return $result; }
[ "public", "function", "setStatus", "(", "$", "status", ")", "{", "$", "result", "=", "\\", "Eix", "\\", "Services", "\\", "Net", "\\", "Http", "::", "isStatusCodeValid", "(", "$", "status", ")", ";", "if", "(", "$", "result", ")", "{", "$", "this", "->", "status", "=", "$", "status", ";", "}", "return", "$", "result", ";", "}" ]
Sets the status, if it is a valid HTTP status code. @param int $status an integer representing a valid HTTP status code. @return boolean whether the status was set or not.
[ "Sets", "the", "status", "if", "it", "is", "a", "valid", "HTTP", "status", "code", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Http.php#L102-L110
238,510
eix/core
src/php/main/Eix/Core/Responses/Http.php
Http.addStatusMessage
protected function addStatusMessage($type, $messages) { if (!is_array($messages)) { $messages = array($messages); } $this->addData('status', array($type => $messages)); }
php
protected function addStatusMessage($type, $messages) { if (!is_array($messages)) { $messages = array($messages); } $this->addData('status', array($type => $messages)); }
[ "protected", "function", "addStatusMessage", "(", "$", "type", ",", "$", "messages", ")", "{", "if", "(", "!", "is_array", "(", "$", "messages", ")", ")", "{", "$", "messages", "=", "array", "(", "$", "messages", ")", ";", "}", "$", "this", "->", "addData", "(", "'status'", ",", "array", "(", "$", "type", "=>", "$", "messages", ")", ")", ";", "}" ]
Adds one or more status messages to the response data. @param string $messages
[ "Adds", "one", "or", "more", "status", "messages", "to", "the", "response", "data", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Http.php#L147-L153
238,511
yinheark/yincart2-framework
customer/models/Customer.php
Customer.findByPasswordResetToken
public static function findByPasswordResetToken($token) { $expire = Yii::$app->params['user.passwordResetTokenExpire']; $parts = explode('_', $token); $timestamp = (int) end($parts); if ($timestamp + $expire < time()) { // token expired return null; } return static::findOne([ 'password_reset_token' => $token, 'status' => self::STATUS_ACTIVE, ]); }
php
public static function findByPasswordResetToken($token) { $expire = Yii::$app->params['user.passwordResetTokenExpire']; $parts = explode('_', $token); $timestamp = (int) end($parts); if ($timestamp + $expire < time()) { // token expired return null; } return static::findOne([ 'password_reset_token' => $token, 'status' => self::STATUS_ACTIVE, ]); }
[ "public", "static", "function", "findByPasswordResetToken", "(", "$", "token", ")", "{", "$", "expire", "=", "Yii", "::", "$", "app", "->", "params", "[", "'user.passwordResetTokenExpire'", "]", ";", "$", "parts", "=", "explode", "(", "'_'", ",", "$", "token", ")", ";", "$", "timestamp", "=", "(", "int", ")", "end", "(", "$", "parts", ")", ";", "if", "(", "$", "timestamp", "+", "$", "expire", "<", "time", "(", ")", ")", "{", "// token expired", "return", "null", ";", "}", "return", "static", "::", "findOne", "(", "[", "'password_reset_token'", "=>", "$", "token", ",", "'status'", "=>", "self", "::", "STATUS_ACTIVE", ",", "]", ")", ";", "}" ]
Finds user by password reset token @param string $token password reset token @return static|null
[ "Finds", "user", "by", "password", "reset", "token" ]
c37421924abeba63337c685bfa31ece9997ac27d
https://github.com/yinheark/yincart2-framework/blob/c37421924abeba63337c685bfa31ece9997ac27d/customer/models/Customer.php#L170-L184
238,512
phox-pro/pulsar-core
src/database/migrations/2018_07_06_105139_create_configs_tables.php
CreateConfigsTables.categories
private function categories() { $package = Package::where('name', 'Core')->first(); $core = ConfigCategory::create([ 'key' => 'core', 'package_id' => $package->id ]); ConfigCategory::create([ 'key' => 'core_mail', 'parent_id' => $core->id, 'package_id' => $core->package_id ]); ConfigCategory::create([ 'key' => 'core_general', 'parent_id' => $core->id, 'package_id' => $core->package_id ]); $this->general(); $this->mail(); }
php
private function categories() { $package = Package::where('name', 'Core')->first(); $core = ConfigCategory::create([ 'key' => 'core', 'package_id' => $package->id ]); ConfigCategory::create([ 'key' => 'core_mail', 'parent_id' => $core->id, 'package_id' => $core->package_id ]); ConfigCategory::create([ 'key' => 'core_general', 'parent_id' => $core->id, 'package_id' => $core->package_id ]); $this->general(); $this->mail(); }
[ "private", "function", "categories", "(", ")", "{", "$", "package", "=", "Package", "::", "where", "(", "'name'", ",", "'Core'", ")", "->", "first", "(", ")", ";", "$", "core", "=", "ConfigCategory", "::", "create", "(", "[", "'key'", "=>", "'core'", ",", "'package_id'", "=>", "$", "package", "->", "id", "]", ")", ";", "ConfigCategory", "::", "create", "(", "[", "'key'", "=>", "'core_mail'", ",", "'parent_id'", "=>", "$", "core", "->", "id", ",", "'package_id'", "=>", "$", "core", "->", "package_id", "]", ")", ";", "ConfigCategory", "::", "create", "(", "[", "'key'", "=>", "'core_general'", ",", "'parent_id'", "=>", "$", "core", "->", "id", ",", "'package_id'", "=>", "$", "core", "->", "package_id", "]", ")", ";", "$", "this", "->", "general", "(", ")", ";", "$", "this", "->", "mail", "(", ")", ";", "}" ]
Method for creating configuration categories @return void
[ "Method", "for", "creating", "configuration", "categories" ]
fa9c66f6578180253a65c91edf422fc3c51b32ba
https://github.com/phox-pro/pulsar-core/blob/fa9c66f6578180253a65c91edf422fc3c51b32ba/src/database/migrations/2018_07_06_105139_create_configs_tables.php#L62-L81
238,513
extendsframework/extends-router
src/Framework/ServiceLocator/Factory/RouterFactory.php
RouterFactory.createService
public function createService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object { $config = $serviceLocator->getConfig(); $config = $config[RouterInterface::class] ?? []; $router = new Router(); foreach ($config['routes'] ?? [] as $name => $config) { $router->addRoute( $this->createRoute($serviceLocator, $config), $name ); } return $router; }
php
public function createService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object { $config = $serviceLocator->getConfig(); $config = $config[RouterInterface::class] ?? []; $router = new Router(); foreach ($config['routes'] ?? [] as $name => $config) { $router->addRoute( $this->createRoute($serviceLocator, $config), $name ); } return $router; }
[ "public", "function", "createService", "(", "string", "$", "key", ",", "ServiceLocatorInterface", "$", "serviceLocator", ",", "array", "$", "extra", "=", "null", ")", ":", "object", "{", "$", "config", "=", "$", "serviceLocator", "->", "getConfig", "(", ")", ";", "$", "config", "=", "$", "config", "[", "RouterInterface", "::", "class", "]", "??", "[", "]", ";", "$", "router", "=", "new", "Router", "(", ")", ";", "foreach", "(", "$", "config", "[", "'routes'", "]", "??", "[", "]", "as", "$", "name", "=>", "$", "config", ")", "{", "$", "router", "->", "addRoute", "(", "$", "this", "->", "createRoute", "(", "$", "serviceLocator", ",", "$", "config", ")", ",", "$", "name", ")", ";", "}", "return", "$", "router", ";", "}" ]
Create router. @param string $key @param ServiceLocatorInterface $serviceLocator @param array|null $extra @return RouterInterface @throws ServiceLocatorException
[ "Create", "router", "." ]
7c142749635c6fb1c58508bf3c8f594529e136d9
https://github.com/extendsframework/extends-router/blob/7c142749635c6fb1c58508bf3c8f594529e136d9/src/Framework/ServiceLocator/Factory/RouterFactory.php#L25-L39
238,514
extendsframework/extends-router
src/Framework/ServiceLocator/Factory/RouterFactory.php
RouterFactory.createGroup
protected function createGroup( ServiceLocatorInterface $serviceLocator, RouteInterface $route, array $children, bool $abstract = null ): RouteInterface { /** @var GroupRoute $group */ $group = $serviceLocator->getService(GroupRoute::class, [ 'route' => $route, 'abstract' => $abstract, ]); foreach ($children as $name => $child) { $group->addRoute( $this->createRoute($serviceLocator, $child), $name ); } return $group; }
php
protected function createGroup( ServiceLocatorInterface $serviceLocator, RouteInterface $route, array $children, bool $abstract = null ): RouteInterface { /** @var GroupRoute $group */ $group = $serviceLocator->getService(GroupRoute::class, [ 'route' => $route, 'abstract' => $abstract, ]); foreach ($children as $name => $child) { $group->addRoute( $this->createRoute($serviceLocator, $child), $name ); } return $group; }
[ "protected", "function", "createGroup", "(", "ServiceLocatorInterface", "$", "serviceLocator", ",", "RouteInterface", "$", "route", ",", "array", "$", "children", ",", "bool", "$", "abstract", "=", "null", ")", ":", "RouteInterface", "{", "/** @var GroupRoute $group */", "$", "group", "=", "$", "serviceLocator", "->", "getService", "(", "GroupRoute", "::", "class", ",", "[", "'route'", "=>", "$", "route", ",", "'abstract'", "=>", "$", "abstract", ",", "]", ")", ";", "foreach", "(", "$", "children", "as", "$", "name", "=>", "$", "child", ")", "{", "$", "group", "->", "addRoute", "(", "$", "this", "->", "createRoute", "(", "$", "serviceLocator", ",", "$", "child", ")", ",", "$", "name", ")", ";", "}", "return", "$", "group", ";", "}" ]
Create group route. @param ServiceLocatorInterface $serviceLocator @param RouteInterface $route @param array $children @param bool|null $abstract @return RouteInterface @throws ServiceLocatorException
[ "Create", "group", "route", "." ]
7c142749635c6fb1c58508bf3c8f594529e136d9
https://github.com/extendsframework/extends-router/blob/7c142749635c6fb1c58508bf3c8f594529e136d9/src/Framework/ServiceLocator/Factory/RouterFactory.php#L69-L89
238,515
malenkiki/argile
src/Malenki/Argile/Options.php
Options.addGroup
public function addGroup($str_alias, $str_name = null) { if (!isset(self::$arr_group[$str_alias])) { $grp = new \stdClass(); $grp->name = (strlen($str_name)) ? $str_name : null; $grp->args = array(); self::$arr_group[$str_alias] = $grp; } return $this; }
php
public function addGroup($str_alias, $str_name = null) { if (!isset(self::$arr_group[$str_alias])) { $grp = new \stdClass(); $grp->name = (strlen($str_name)) ? $str_name : null; $grp->args = array(); self::$arr_group[$str_alias] = $grp; } return $this; }
[ "public", "function", "addGroup", "(", "$", "str_alias", ",", "$", "str_name", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "arr_group", "[", "$", "str_alias", "]", ")", ")", "{", "$", "grp", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "grp", "->", "name", "=", "(", "strlen", "(", "$", "str_name", ")", ")", "?", "$", "str_name", ":", "null", ";", "$", "grp", "->", "args", "=", "array", "(", ")", ";", "self", "::", "$", "arr_group", "[", "$", "str_alias", "]", "=", "$", "grp", ";", "}", "return", "$", "this", ";", "}" ]
Adds a new group for options. @param string $str_alias Conding name of the group, to identify it when defining options. @param string $str_name Optional name to display while rendering help. @access public @return Options
[ "Adds", "a", "new", "group", "for", "options", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L350-L361
238,516
malenkiki/argile
src/Malenki/Argile/Options.php
Options.add
public static function add(OptionItem $opt, $str_alias = null) { // tester ici si version ou aide : à ne pas mettre if( !in_array($opt->getShort(true), self::$arr_prohibited, true) && !in_array($opt->getLong(true), self::$arr_prohibited, true) ) { if (is_string($str_alias) && isset(self::$arr_group[$str_alias])) { self::$arr_group[$str_alias]->args[$opt->getName()] = $opt; } else { self::$arr_opt[$opt->getName()] = $opt; } } }
php
public static function add(OptionItem $opt, $str_alias = null) { // tester ici si version ou aide : à ne pas mettre if( !in_array($opt->getShort(true), self::$arr_prohibited, true) && !in_array($opt->getLong(true), self::$arr_prohibited, true) ) { if (is_string($str_alias) && isset(self::$arr_group[$str_alias])) { self::$arr_group[$str_alias]->args[$opt->getName()] = $opt; } else { self::$arr_opt[$opt->getName()] = $opt; } } }
[ "public", "static", "function", "add", "(", "OptionItem", "$", "opt", ",", "$", "str_alias", "=", "null", ")", "{", "// tester ici si version ou aide : à ne pas mettre", "if", "(", "!", "in_array", "(", "$", "opt", "->", "getShort", "(", "true", ")", ",", "self", "::", "$", "arr_prohibited", ",", "true", ")", "&&", "!", "in_array", "(", "$", "opt", "->", "getLong", "(", "true", ")", ",", "self", "::", "$", "arr_prohibited", ",", "true", ")", ")", "{", "if", "(", "is_string", "(", "$", "str_alias", ")", "&&", "isset", "(", "self", "::", "$", "arr_group", "[", "$", "str_alias", "]", ")", ")", "{", "self", "::", "$", "arr_group", "[", "$", "str_alias", "]", "->", "args", "[", "$", "opt", "->", "getName", "(", ")", "]", "=", "$", "opt", ";", "}", "else", "{", "self", "::", "$", "arr_opt", "[", "$", "opt", "->", "getName", "(", ")", "]", "=", "$", "opt", ";", "}", "}", "}" ]
Adds one new option. @param OptionItem $opt The option. @param mixed $str_alias Its optional group's alias. @static @access public @return void
[ "Adds", "one", "new", "option", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L372-L387
238,517
malenkiki/argile
src/Malenki/Argile/Options.php
Options.newSwitch
public function newSwitch($name, $group = null) { $arg = OptionItem::createSwitch($name); if ($this->obj_color->opt) { $arg->color($this->obj_color->opt); } if ($this->obj_color->bold) { $arg->bold(); } self::add($arg, $group); return self::getOpt($name); }
php
public function newSwitch($name, $group = null) { $arg = OptionItem::createSwitch($name); if ($this->obj_color->opt) { $arg->color($this->obj_color->opt); } if ($this->obj_color->bold) { $arg->bold(); } self::add($arg, $group); return self::getOpt($name); }
[ "public", "function", "newSwitch", "(", "$", "name", ",", "$", "group", "=", "null", ")", "{", "$", "arg", "=", "OptionItem", "::", "createSwitch", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "obj_color", "->", "opt", ")", "{", "$", "arg", "->", "color", "(", "$", "this", "->", "obj_color", "->", "opt", ")", ";", "}", "if", "(", "$", "this", "->", "obj_color", "->", "bold", ")", "{", "$", "arg", "->", "bold", "(", ")", ";", "}", "self", "::", "add", "(", "$", "arg", ",", "$", "group", ")", ";", "return", "self", "::", "getOpt", "(", "$", "name", ")", ";", "}" ]
Adds a new option switch. @param string $name The string to identify and call this option. @param string $group Optional group's name @access public @return OptionItem The newly created option, to chain methods.
[ "Adds", "a", "new", "option", "switch", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L442-L457
238,518
malenkiki/argile
src/Malenki/Argile/Options.php
Options.newValue
public function newValue($name, $group = null) { $arg = OptionItem::createValue($name); if ($this->obj_color->opt) { $arg->color($this->obj_color->opt); } if ($this->obj_color->bold) { $arg->bold(); } self::add($arg, $group); return self::getOpt($name); }
php
public function newValue($name, $group = null) { $arg = OptionItem::createValue($name); if ($this->obj_color->opt) { $arg->color($this->obj_color->opt); } if ($this->obj_color->bold) { $arg->bold(); } self::add($arg, $group); return self::getOpt($name); }
[ "public", "function", "newValue", "(", "$", "name", ",", "$", "group", "=", "null", ")", "{", "$", "arg", "=", "OptionItem", "::", "createValue", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "obj_color", "->", "opt", ")", "{", "$", "arg", "->", "color", "(", "$", "this", "->", "obj_color", "->", "opt", ")", ";", "}", "if", "(", "$", "this", "->", "obj_color", "->", "bold", ")", "{", "$", "arg", "->", "bold", "(", ")", ";", "}", "self", "::", "add", "(", "$", "arg", ",", "$", "group", ")", ";", "return", "self", "::", "getOpt", "(", "$", "name", ")", ";", "}" ]
Adds a new option's value. @param string $name Option's name. @param string $group Optional group's name. @access public @return OptionItem
[ "Adds", "a", "new", "option", "s", "value", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L467-L482
238,519
malenkiki/argile
src/Malenki/Argile/Options.php
Options.getDescription
public function getDescription() { if (is_string($this->str_description)) { $description = new S($this->str_description); return $description->wrap(OptionItem::getWidth()); } else { return null; } }
php
public function getDescription() { if (is_string($this->str_description)) { $description = new S($this->str_description); return $description->wrap(OptionItem::getWidth()); } else { return null; } }
[ "public", "function", "getDescription", "(", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "str_description", ")", ")", "{", "$", "description", "=", "new", "S", "(", "$", "this", "->", "str_description", ")", ";", "return", "$", "description", "->", "wrap", "(", "OptionItem", "::", "getWidth", "(", ")", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Getsthe description part. This follows terminal size or not if `flexible()` method was called or not before. @access public @return string
[ "Getsthe", "description", "part", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L533-L542
238,520
malenkiki/argile
src/Malenki/Argile/Options.php
Options.displayHelp
public function displayHelp() { printf("%s\n", $this->getUsage()); printf("%s\n", $this->getDescription()); // Les options non incluses dans un groupe if (count(self::$arr_opt)) { foreach (self::$arr_opt as $arg) { printf("%s\n", rtrim($arg)); } } // Options faisant partie d’un groupe if (count(self::$arr_group)) { foreach (self::$arr_group as $group) { if (count($group->args)) { print("\n\n"); if ($group->name) { $name = $group->name; if ($this->obj_color->label || $this->obj_color->bold) { $name = new Ansi($name); if ($this->obj_color->label) { $name->fg($this->obj_color->label); } if ($this->obj_color->bold) { $name->bold; } } printf("%s\n", $name); } foreach ($group->args as $arg) { printf("%s\n", rtrim($arg)); } } } } exit(); }
php
public function displayHelp() { printf("%s\n", $this->getUsage()); printf("%s\n", $this->getDescription()); // Les options non incluses dans un groupe if (count(self::$arr_opt)) { foreach (self::$arr_opt as $arg) { printf("%s\n", rtrim($arg)); } } // Options faisant partie d’un groupe if (count(self::$arr_group)) { foreach (self::$arr_group as $group) { if (count($group->args)) { print("\n\n"); if ($group->name) { $name = $group->name; if ($this->obj_color->label || $this->obj_color->bold) { $name = new Ansi($name); if ($this->obj_color->label) { $name->fg($this->obj_color->label); } if ($this->obj_color->bold) { $name->bold; } } printf("%s\n", $name); } foreach ($group->args as $arg) { printf("%s\n", rtrim($arg)); } } } } exit(); }
[ "public", "function", "displayHelp", "(", ")", "{", "printf", "(", "\"%s\\n\"", ",", "$", "this", "->", "getUsage", "(", ")", ")", ";", "printf", "(", "\"%s\\n\"", ",", "$", "this", "->", "getDescription", "(", ")", ")", ";", "// Les options non incluses dans un groupe", "if", "(", "count", "(", "self", "::", "$", "arr_opt", ")", ")", "{", "foreach", "(", "self", "::", "$", "arr_opt", "as", "$", "arg", ")", "{", "printf", "(", "\"%s\\n\"", ",", "rtrim", "(", "$", "arg", ")", ")", ";", "}", "}", "// Options faisant partie d’un groupe", "if", "(", "count", "(", "self", "::", "$", "arr_group", ")", ")", "{", "foreach", "(", "self", "::", "$", "arr_group", "as", "$", "group", ")", "{", "if", "(", "count", "(", "$", "group", "->", "args", ")", ")", "{", "print", "(", "\"\\n\\n\"", ")", ";", "if", "(", "$", "group", "->", "name", ")", "{", "$", "name", "=", "$", "group", "->", "name", ";", "if", "(", "$", "this", "->", "obj_color", "->", "label", "||", "$", "this", "->", "obj_color", "->", "bold", ")", "{", "$", "name", "=", "new", "Ansi", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "obj_color", "->", "label", ")", "{", "$", "name", "->", "fg", "(", "$", "this", "->", "obj_color", "->", "label", ")", ";", "}", "if", "(", "$", "this", "->", "obj_color", "->", "bold", ")", "{", "$", "name", "->", "bold", ";", "}", "}", "printf", "(", "\"%s\\n\"", ",", "$", "name", ")", ";", "}", "foreach", "(", "$", "group", "->", "args", "as", "$", "arg", ")", "{", "printf", "(", "\"%s\\n\"", ",", "rtrim", "(", "$", "arg", ")", ")", ";", "}", "}", "}", "}", "exit", "(", ")", ";", "}" ]
Displays full help message. This follows terminal size or not if `flexible()` method was called or not before. @access public @return void
[ "Displays", "full", "help", "message", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L554-L598
238,521
unyx/connect
streams/Stream.php
Stream.refresh
protected function refresh() : bool { // Without a resource to grab the metadata for, let invokers know there's no data // to work with presently. if (!$this->resource) { return false; } // Prepare the status mask if necessary. Might as well give it a value to begin with. if (!$this->status) { $this->status = new core\Mask(stream_is_local($this->resource) ? interfaces\Stream::LOCAL : 0); } // The call results of metadata() are cached so we can just use the class property. $this->getMetadata(); if (isset(self::$rwh['read'][$this->metadata['mode']])) { $this->status->set(interfaces\Stream::READABLE); } if (isset(self::$rwh['write'][$this->metadata['mode']])) { $this->status->set(interfaces\Stream::WRITABLE); } // Those may change, so... besides - fancy syntax, eh chaps? $this->status->{((isset($this->metadata['seekable']) && $this->metadata['seekable']) ? 'set' : 'remove')}(interfaces\Stream::SEEKABLE); $this->status->{((isset($this->metadata['blocked']) && $this->metadata['blocked']) ? 'set' : 'remove')}(interfaces\Stream::BLOCKED); return true; }
php
protected function refresh() : bool { // Without a resource to grab the metadata for, let invokers know there's no data // to work with presently. if (!$this->resource) { return false; } // Prepare the status mask if necessary. Might as well give it a value to begin with. if (!$this->status) { $this->status = new core\Mask(stream_is_local($this->resource) ? interfaces\Stream::LOCAL : 0); } // The call results of metadata() are cached so we can just use the class property. $this->getMetadata(); if (isset(self::$rwh['read'][$this->metadata['mode']])) { $this->status->set(interfaces\Stream::READABLE); } if (isset(self::$rwh['write'][$this->metadata['mode']])) { $this->status->set(interfaces\Stream::WRITABLE); } // Those may change, so... besides - fancy syntax, eh chaps? $this->status->{((isset($this->metadata['seekable']) && $this->metadata['seekable']) ? 'set' : 'remove')}(interfaces\Stream::SEEKABLE); $this->status->{((isset($this->metadata['blocked']) && $this->metadata['blocked']) ? 'set' : 'remove')}(interfaces\Stream::BLOCKED); return true; }
[ "protected", "function", "refresh", "(", ")", ":", "bool", "{", "// Without a resource to grab the metadata for, let invokers know there's no data", "// to work with presently.", "if", "(", "!", "$", "this", "->", "resource", ")", "{", "return", "false", ";", "}", "// Prepare the status mask if necessary. Might as well give it a value to begin with.", "if", "(", "!", "$", "this", "->", "status", ")", "{", "$", "this", "->", "status", "=", "new", "core", "\\", "Mask", "(", "stream_is_local", "(", "$", "this", "->", "resource", ")", "?", "interfaces", "\\", "Stream", "::", "LOCAL", ":", "0", ")", ";", "}", "// The call results of metadata() are cached so we can just use the class property.", "$", "this", "->", "getMetadata", "(", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "rwh", "[", "'read'", "]", "[", "$", "this", "->", "metadata", "[", "'mode'", "]", "]", ")", ")", "{", "$", "this", "->", "status", "->", "set", "(", "interfaces", "\\", "Stream", "::", "READABLE", ")", ";", "}", "if", "(", "isset", "(", "self", "::", "$", "rwh", "[", "'write'", "]", "[", "$", "this", "->", "metadata", "[", "'mode'", "]", "]", ")", ")", "{", "$", "this", "->", "status", "->", "set", "(", "interfaces", "\\", "Stream", "::", "WRITABLE", ")", ";", "}", "// Those may change, so... besides - fancy syntax, eh chaps?", "$", "this", "->", "status", "->", "{", "(", "(", "isset", "(", "$", "this", "->", "metadata", "[", "'seekable'", "]", ")", "&&", "$", "this", "->", "metadata", "[", "'seekable'", "]", ")", "?", "'set'", ":", "'remove'", ")", "}", "(", "interfaces", "\\", "Stream", "::", "SEEKABLE", ")", ";", "$", "this", "->", "status", "->", "{", "(", "(", "isset", "(", "$", "this", "->", "metadata", "[", "'blocked'", "]", ")", "&&", "$", "this", "->", "metadata", "[", "'blocked'", "]", ")", "?", "'set'", ":", "'remove'", ")", "}", "(", "interfaces", "\\", "Stream", "::", "BLOCKED", ")", ";", "return", "true", ";", "}" ]
Refreshes the status mask based on the current metadata of the stream. @return bool True if we successfully refreshed all relevant data, false otherwise.
[ "Refreshes", "the", "status", "mask", "based", "on", "the", "current", "metadata", "of", "the", "stream", "." ]
462b9e1318af3a7db28ddc89cd2a49ef71439c1b
https://github.com/unyx/connect/blob/462b9e1318af3a7db28ddc89cd2a49ef71439c1b/streams/Stream.php#L436-L465
238,522
Sowapps/orpheus-inputcontroller
src/InputController/HTTPController/JSONHTTPResponse.php
JSONHTTPResponse.render
public static function render($textCode, $other=null, $domain='global', $description=null) { $response = new static(); $response->collectFrom($textCode, $other, $domain, $description); return $response; }
php
public static function render($textCode, $other=null, $domain='global', $description=null) { $response = new static(); $response->collectFrom($textCode, $other, $domain, $description); return $response; }
[ "public", "static", "function", "render", "(", "$", "textCode", ",", "$", "other", "=", "null", ",", "$", "domain", "=", "'global'", ",", "$", "description", "=", "null", ")", "{", "$", "response", "=", "new", "static", "(", ")", ";", "$", "response", "->", "collectFrom", "(", "$", "textCode", ",", "$", "other", ",", "$", "domain", ",", "$", "description", ")", ";", "return", "$", "response", ";", "}" ]
Render the given data @param string $textCode @param mixed $other @param string $domain @param string $description @return \Orpheus\InputController\HTTPController\JSONHTTPResponse @see \Orpheus\InputController\HTTPController\JSONHTTPResponse::returnData() We recommend to use returnData() to return data, that is more RESTful and to use this method only for errors
[ "Render", "the", "given", "data" ]
91f848a42ac02ae4009ffb3e9a9b4e8c0731455e
https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/HTTPController/JSONHTTPResponse.php#L78-L82
238,523
dflydev/dflydev-identity-generator
src/Dflydev/IdentityGenerator/IdentityGenerator.php
IdentityGenerator.generate
public function generate($suggestion = null) { if (null !== $suggestion) { $this->dataStore->storeIdentity($suggestion, $this->mob); return $suggestion; } $exceptions = array(); for ($i = 0; $i <= $this->maxRetries; $i++) { $generatedIdentity = null; try { $generatedIdentity = $this->generator->generateIdentity(); $this->dataStore->storeIdentity($generatedIdentity, $this->mob); return $generatedIdentity; } catch (NonUniqueIdentityException $e) { // We expect non unique identity exceptions so this is fine. // Collect them and move on and try again if we still have // some tries left. $exceptions[] = $e; } catch (\Exception $e) { // All other exceptions are unexpected. throw new GenerateException($generatedIdentity, $this->mob, $exceptions, $e); } } throw new GenerateException(null, $this->mob, $exceptions); }
php
public function generate($suggestion = null) { if (null !== $suggestion) { $this->dataStore->storeIdentity($suggestion, $this->mob); return $suggestion; } $exceptions = array(); for ($i = 0; $i <= $this->maxRetries; $i++) { $generatedIdentity = null; try { $generatedIdentity = $this->generator->generateIdentity(); $this->dataStore->storeIdentity($generatedIdentity, $this->mob); return $generatedIdentity; } catch (NonUniqueIdentityException $e) { // We expect non unique identity exceptions so this is fine. // Collect them and move on and try again if we still have // some tries left. $exceptions[] = $e; } catch (\Exception $e) { // All other exceptions are unexpected. throw new GenerateException($generatedIdentity, $this->mob, $exceptions, $e); } } throw new GenerateException(null, $this->mob, $exceptions); }
[ "public", "function", "generate", "(", "$", "suggestion", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "suggestion", ")", "{", "$", "this", "->", "dataStore", "->", "storeIdentity", "(", "$", "suggestion", ",", "$", "this", "->", "mob", ")", ";", "return", "$", "suggestion", ";", "}", "$", "exceptions", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<=", "$", "this", "->", "maxRetries", ";", "$", "i", "++", ")", "{", "$", "generatedIdentity", "=", "null", ";", "try", "{", "$", "generatedIdentity", "=", "$", "this", "->", "generator", "->", "generateIdentity", "(", ")", ";", "$", "this", "->", "dataStore", "->", "storeIdentity", "(", "$", "generatedIdentity", ",", "$", "this", "->", "mob", ")", ";", "return", "$", "generatedIdentity", ";", "}", "catch", "(", "NonUniqueIdentityException", "$", "e", ")", "{", "// We expect non unique identity exceptions so this is fine.", "// Collect them and move on and try again if we still have", "// some tries left.", "$", "exceptions", "[", "]", "=", "$", "e", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// All other exceptions are unexpected.", "throw", "new", "GenerateException", "(", "$", "generatedIdentity", ",", "$", "this", "->", "mob", ",", "$", "exceptions", ",", "$", "e", ")", ";", "}", "}", "throw", "new", "GenerateException", "(", "null", ",", "$", "this", "->", "mob", ",", "$", "exceptions", ")", ";", "}" ]
Generate an identity string @param string|null $suggestion @return string @throws \Dflydev\IdentityGenerator\Exception\Exception
[ "Generate", "an", "identity", "string" ]
2479dad10002f26229d08899142d46d6f6b2dc0b
https://github.com/dflydev/dflydev-identity-generator/blob/2479dad10002f26229d08899142d46d6f6b2dc0b/src/Dflydev/IdentityGenerator/IdentityGenerator.php#L52-L80
238,524
sndatabase/core
src/Transaction.php
Transaction.rollBack
public function rollBack() { return $this->inTransaction ? ($this->in = $this->doRollBack($this->name)) : false; }
php
public function rollBack() { return $this->inTransaction ? ($this->in = $this->doRollBack($this->name)) : false; }
[ "public", "function", "rollBack", "(", ")", "{", "return", "$", "this", "->", "inTransaction", "?", "(", "$", "this", "->", "in", "=", "$", "this", "->", "doRollBack", "(", "$", "this", "->", "name", ")", ")", ":", "false", ";", "}" ]
Rolls back changes @return boolean Rollback success @throws DBException
[ "Rolls", "back", "changes" ]
8645b71f1cb437a845fcf12ae742655dd874b229
https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/Transaction.php#L113-L115
238,525
znframework/package-language
Insert.php
Insert.do
public function do(String $app, $key, String $data = NULL) : Bool { $datas = []; $createFile = $this->_langFile($app); if( ! is_file($createFile) ) { file_put_contents($createFile, json_encode([])); } $datas = json_decode(file_get_contents($createFile), true); if( ! empty($datas) ) { $json = $datas; } if( ! is_array($key) ) { $json[$key] = $data; } else { foreach( $key as $k => $v ) { $json[$k] = $v; } } if( $json !== $datas ) { return file_put_contents($createFile, json_encode($json, JSON_UNESCAPED_UNICODE)); } else { return false; } }
php
public function do(String $app, $key, String $data = NULL) : Bool { $datas = []; $createFile = $this->_langFile($app); if( ! is_file($createFile) ) { file_put_contents($createFile, json_encode([])); } $datas = json_decode(file_get_contents($createFile), true); if( ! empty($datas) ) { $json = $datas; } if( ! is_array($key) ) { $json[$key] = $data; } else { foreach( $key as $k => $v ) { $json[$k] = $v; } } if( $json !== $datas ) { return file_put_contents($createFile, json_encode($json, JSON_UNESCAPED_UNICODE)); } else { return false; } }
[ "public", "function", "do", "(", "String", "$", "app", ",", "$", "key", ",", "String", "$", "data", "=", "NULL", ")", ":", "Bool", "{", "$", "datas", "=", "[", "]", ";", "$", "createFile", "=", "$", "this", "->", "_langFile", "(", "$", "app", ")", ";", "if", "(", "!", "is_file", "(", "$", "createFile", ")", ")", "{", "file_put_contents", "(", "$", "createFile", ",", "json_encode", "(", "[", "]", ")", ")", ";", "}", "$", "datas", "=", "json_decode", "(", "file_get_contents", "(", "$", "createFile", ")", ",", "true", ")", ";", "if", "(", "!", "empty", "(", "$", "datas", ")", ")", "{", "$", "json", "=", "$", "datas", ";", "}", "if", "(", "!", "is_array", "(", "$", "key", ")", ")", "{", "$", "json", "[", "$", "key", "]", "=", "$", "data", ";", "}", "else", "{", "foreach", "(", "$", "key", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "json", "[", "$", "k", "]", "=", "$", "v", ";", "}", "}", "if", "(", "$", "json", "!==", "$", "datas", ")", "{", "return", "file_put_contents", "(", "$", "createFile", ",", "json_encode", "(", "$", "json", ",", "JSON_UNESCAPED_UNICODE", ")", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Insert language key @param string $app = NULL @param mixed $key @param string $data = NULL @return bool
[ "Insert", "language", "key" ]
f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09
https://github.com/znframework/package-language/blob/f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09/Insert.php#L23-L61
238,526
mszewcz/php-light-framework
src/Db/MySQL/Query/Utilities/Escape.php
Escape.doNotEscape
public function doNotEscape($doNotEscape = []): void { $this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape)); }
php
public function doNotEscape($doNotEscape = []): void { $this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape)); }
[ "public", "function", "doNotEscape", "(", "$", "doNotEscape", "=", "[", "]", ")", ":", "void", "{", "$", "this", "->", "doNotEscape", "=", "\\", "array_unique", "(", "\\", "array_merge", "(", "$", "this", "->", "doNotEscape", ",", "$", "doNotEscape", ")", ")", ";", "}" ]
Adds no quotable expressions @param array $doNotEscape
[ "Adds", "no", "quotable", "expressions" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/Query/Utilities/Escape.php#L45-L48
238,527
mszewcz/php-light-framework
src/Db/MySQL/Query/Utilities/Escape.php
Escape.escape
public function escape($value = null, array $doNotEscape = []) { $this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape)); if (\is_null($value)) { return 'NULL'; } if (\is_int($value) || \is_float($value)) { return $value; } if (\is_array($value) || \is_object($value)) { return $this->dbClass->escape(\serialize($value)); } foreach ($this->doNotEscape as $doNotEscape) { if (\preg_match('/^'.\str_replace('*', '\\*', $doNotEscape).'/i', (string)$value)) { return $value; } } return $this->dbClass->escape($value); }
php
public function escape($value = null, array $doNotEscape = []) { $this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape)); if (\is_null($value)) { return 'NULL'; } if (\is_int($value) || \is_float($value)) { return $value; } if (\is_array($value) || \is_object($value)) { return $this->dbClass->escape(\serialize($value)); } foreach ($this->doNotEscape as $doNotEscape) { if (\preg_match('/^'.\str_replace('*', '\\*', $doNotEscape).'/i', (string)$value)) { return $value; } } return $this->dbClass->escape($value); }
[ "public", "function", "escape", "(", "$", "value", "=", "null", ",", "array", "$", "doNotEscape", "=", "[", "]", ")", "{", "$", "this", "->", "doNotEscape", "=", "\\", "array_unique", "(", "\\", "array_merge", "(", "$", "this", "->", "doNotEscape", ",", "$", "doNotEscape", ")", ")", ";", "if", "(", "\\", "is_null", "(", "$", "value", ")", ")", "{", "return", "'NULL'", ";", "}", "if", "(", "\\", "is_int", "(", "$", "value", ")", "||", "\\", "is_float", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "\\", "is_array", "(", "$", "value", ")", "||", "\\", "is_object", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "dbClass", "->", "escape", "(", "\\", "serialize", "(", "$", "value", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "doNotEscape", "as", "$", "doNotEscape", ")", "{", "if", "(", "\\", "preg_match", "(", "'/^'", ".", "\\", "str_replace", "(", "'*'", ",", "'\\\\*'", ",", "$", "doNotEscape", ")", ".", "'/i'", ",", "(", "string", ")", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "}", "return", "$", "this", "->", "dbClass", "->", "escape", "(", "$", "value", ")", ";", "}" ]
Escapes value using database specific method @param mixed|null $value @param array $doNotEscape @return mixed
[ "Escapes", "value", "using", "database", "specific", "method" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/Query/Utilities/Escape.php#L57-L77
238,528
zepi/turbo-base
Zepi/Web/UserInterface/src/Form/Field/DynamicZone.php
DynamicZone.getTriggerHtmlId
public function getTriggerHtmlId() { $form = $this->getParentOfType('\\Zepi\\Web\\UserInterface\\Form\Form'); if (is_object($form)) { $part = $form->searchPartByKeyAndType($this->triggerKey); return $part->getHtmlId(); } return ''; }
php
public function getTriggerHtmlId() { $form = $this->getParentOfType('\\Zepi\\Web\\UserInterface\\Form\Form'); if (is_object($form)) { $part = $form->searchPartByKeyAndType($this->triggerKey); return $part->getHtmlId(); } return ''; }
[ "public", "function", "getTriggerHtmlId", "(", ")", "{", "$", "form", "=", "$", "this", "->", "getParentOfType", "(", "'\\\\Zepi\\\\Web\\\\UserInterface\\\\Form\\Form'", ")", ";", "if", "(", "is_object", "(", "$", "form", ")", ")", "{", "$", "part", "=", "$", "form", "->", "searchPartByKeyAndType", "(", "$", "this", "->", "triggerKey", ")", ";", "return", "$", "part", "->", "getHtmlId", "(", ")", ";", "}", "return", "''", ";", "}" ]
Returns the html id of the trigger element @access public @return string
[ "Returns", "the", "html", "id", "of", "the", "trigger", "element" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Form/Field/DynamicZone.php#L131-L141
238,529
flowcode/ceibo
src/flowcode/ceibo/domain/Query.php
Query.AndWhere
public function AndWhere($condition, array $values) { $this->andWheres[] = $condition; $this->addBindValues($values); return $this; }
php
public function AndWhere($condition, array $values) { $this->andWheres[] = $condition; $this->addBindValues($values); return $this; }
[ "public", "function", "AndWhere", "(", "$", "condition", ",", "array", "$", "values", ")", "{", "$", "this", "->", "andWheres", "[", "]", "=", "$", "condition", ";", "$", "this", "->", "addBindValues", "(", "$", "values", ")", ";", "return", "$", "this", ";", "}" ]
Add an And Where condition to the query. @param string $condition @param array $values @return Query same instace.
[ "Add", "an", "And", "Where", "condition", "to", "the", "query", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Query.php#L39-L43
238,530
flowcode/ceibo
src/flowcode/ceibo/domain/Query.php
Query.Where
public function Where($condition, $values) { $this->setWhere($condition); $this->addBindValues($values); return $this; }
php
public function Where($condition, $values) { $this->setWhere($condition); $this->addBindValues($values); return $this; }
[ "public", "function", "Where", "(", "$", "condition", ",", "$", "values", ")", "{", "$", "this", "->", "setWhere", "(", "$", "condition", ")", ";", "$", "this", "->", "addBindValues", "(", "$", "values", ")", ";", "return", "$", "this", ";", "}" ]
Set where condition of the query. @param string $condition @param array $values @return Query same instace.
[ "Set", "where", "condition", "of", "the", "query", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Query.php#L68-L72
238,531
flowcode/ceibo
src/flowcode/ceibo/domain/Query.php
Query.execute
public function execute() { $statement = $this->buildStatement(); $result = $this->getDataSource()->query($statement, $this->getBindValues()); if ($result) { $collection = new Collection($this->getMapper()->getClass(), $result, $this->getMapper()); } else { $collection = new Collection($this->getMapper()->getClass(), array(), $this->getMapper()); } return $collection; }
php
public function execute() { $statement = $this->buildStatement(); $result = $this->getDataSource()->query($statement, $this->getBindValues()); if ($result) { $collection = new Collection($this->getMapper()->getClass(), $result, $this->getMapper()); } else { $collection = new Collection($this->getMapper()->getClass(), array(), $this->getMapper()); } return $collection; }
[ "public", "function", "execute", "(", ")", "{", "$", "statement", "=", "$", "this", "->", "buildStatement", "(", ")", ";", "$", "result", "=", "$", "this", "->", "getDataSource", "(", ")", "->", "query", "(", "$", "statement", ",", "$", "this", "->", "getBindValues", "(", ")", ")", ";", "if", "(", "$", "result", ")", "{", "$", "collection", "=", "new", "Collection", "(", "$", "this", "->", "getMapper", "(", ")", "->", "getClass", "(", ")", ",", "$", "result", ",", "$", "this", "->", "getMapper", "(", ")", ")", ";", "}", "else", "{", "$", "collection", "=", "new", "Collection", "(", "$", "this", "->", "getMapper", "(", ")", "->", "getClass", "(", ")", ",", "array", "(", ")", ",", "$", "this", "->", "getMapper", "(", ")", ")", ";", "}", "return", "$", "collection", ";", "}" ]
Execute query and return a collection. @return Collection collection.
[ "Execute", "query", "and", "return", "a", "collection", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Query.php#L100-L110
238,532
yii2-tools/yii2-base
components/DbCommand.php
DbCommand.queryInternal
protected function queryInternal($method, $fetchMode = null) { if ($method !== '') { $rawSql = $this->getRawSql(); $requestLocalCacheKey = implode('', [ __CLASS__, $method, $fetchMode, $this->db->dsn, $this->db->username, preg_replace('/\s+/', '', $rawSql) ]); mb_convert_encoding($requestLocalCacheKey, 'UTF-8', 'UTF-8'); if (($result = static::$requestLocalCache->get($requestLocalCacheKey)) !== false) { Yii::info('Query result served from request local cache' . PHP_EOL . 'Query: ' . VarDumper::dumpAsString($rawSql) . PHP_EOL . 'Result: ' . VarDumper::dumpAsString($result), __METHOD__); return $result; } static::$requestLocalCache->set('rawSql', $rawSql); } $result = parent::queryInternal($method, $fetchMode); if ($method !== '') { static::$requestLocalCache->set($requestLocalCacheKey, $result); } return $result; }
php
protected function queryInternal($method, $fetchMode = null) { if ($method !== '') { $rawSql = $this->getRawSql(); $requestLocalCacheKey = implode('', [ __CLASS__, $method, $fetchMode, $this->db->dsn, $this->db->username, preg_replace('/\s+/', '', $rawSql) ]); mb_convert_encoding($requestLocalCacheKey, 'UTF-8', 'UTF-8'); if (($result = static::$requestLocalCache->get($requestLocalCacheKey)) !== false) { Yii::info('Query result served from request local cache' . PHP_EOL . 'Query: ' . VarDumper::dumpAsString($rawSql) . PHP_EOL . 'Result: ' . VarDumper::dumpAsString($result), __METHOD__); return $result; } static::$requestLocalCache->set('rawSql', $rawSql); } $result = parent::queryInternal($method, $fetchMode); if ($method !== '') { static::$requestLocalCache->set($requestLocalCacheKey, $result); } return $result; }
[ "protected", "function", "queryInternal", "(", "$", "method", ",", "$", "fetchMode", "=", "null", ")", "{", "if", "(", "$", "method", "!==", "''", ")", "{", "$", "rawSql", "=", "$", "this", "->", "getRawSql", "(", ")", ";", "$", "requestLocalCacheKey", "=", "implode", "(", "''", ",", "[", "__CLASS__", ",", "$", "method", ",", "$", "fetchMode", ",", "$", "this", "->", "db", "->", "dsn", ",", "$", "this", "->", "db", "->", "username", ",", "preg_replace", "(", "'/\\s+/'", ",", "''", ",", "$", "rawSql", ")", "]", ")", ";", "mb_convert_encoding", "(", "$", "requestLocalCacheKey", ",", "'UTF-8'", ",", "'UTF-8'", ")", ";", "if", "(", "(", "$", "result", "=", "static", "::", "$", "requestLocalCache", "->", "get", "(", "$", "requestLocalCacheKey", ")", ")", "!==", "false", ")", "{", "Yii", "::", "info", "(", "'Query result served from request local cache'", ".", "PHP_EOL", ".", "'Query: '", ".", "VarDumper", "::", "dumpAsString", "(", "$", "rawSql", ")", ".", "PHP_EOL", ".", "'Result: '", ".", "VarDumper", "::", "dumpAsString", "(", "$", "result", ")", ",", "__METHOD__", ")", ";", "return", "$", "result", ";", "}", "static", "::", "$", "requestLocalCache", "->", "set", "(", "'rawSql'", ",", "$", "rawSql", ")", ";", "}", "$", "result", "=", "parent", "::", "queryInternal", "(", "$", "method", ",", "$", "fetchMode", ")", ";", "if", "(", "$", "method", "!==", "''", ")", "{", "static", "::", "$", "requestLocalCache", "->", "set", "(", "$", "requestLocalCacheKey", ",", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Actual query with caching results in local for current request @inheritdoc
[ "Actual", "query", "with", "caching", "results", "in", "local", "for", "current", "request" ]
10f6bb6b0b9396c3d942e0f2ec06784fa9bbf72a
https://github.com/yii2-tools/yii2-base/blob/10f6bb6b0b9396c3d942e0f2ec06784fa9bbf72a/components/DbCommand.php#L72-L102
238,533
tarsana/filesystem
src/Adapters/Local.php
Local.isAbsolute
public function isAbsolute($path) { $firstChar = substr($path, 0, 1); if ('/' === $firstChar || '\\' === $firstChar) { return true; } $isLetter = ( ($firstChar >= 'A' && $firstChar <= 'Z') || ($firstChar >= 'a' && $firstChar <= 'z') ); $path = substr($path, 1, 2); return $isLetter && (':/' === $path || ':\\' === $path); }
php
public function isAbsolute($path) { $firstChar = substr($path, 0, 1); if ('/' === $firstChar || '\\' === $firstChar) { return true; } $isLetter = ( ($firstChar >= 'A' && $firstChar <= 'Z') || ($firstChar >= 'a' && $firstChar <= 'z') ); $path = substr($path, 1, 2); return $isLetter && (':/' === $path || ':\\' === $path); }
[ "public", "function", "isAbsolute", "(", "$", "path", ")", "{", "$", "firstChar", "=", "substr", "(", "$", "path", ",", "0", ",", "1", ")", ";", "if", "(", "'/'", "===", "$", "firstChar", "||", "'\\\\'", "===", "$", "firstChar", ")", "{", "return", "true", ";", "}", "$", "isLetter", "=", "(", "(", "$", "firstChar", ">=", "'A'", "&&", "$", "firstChar", "<=", "'Z'", ")", "||", "(", "$", "firstChar", ">=", "'a'", "&&", "$", "firstChar", "<=", "'z'", ")", ")", ";", "$", "path", "=", "substr", "(", "$", "path", ",", "1", ",", "2", ")", ";", "return", "$", "isLetter", "&&", "(", "':/'", "===", "$", "path", "||", "':\\\\'", "===", "$", "path", ")", ";", "}" ]
Tells if the given path is absolute. @param string $path @return boolean
[ "Tells", "if", "the", "given", "path", "is", "absolute", "." ]
db6c8f040af38dfb01066e382645aff6c72530fa
https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Local.php#L39-L51
238,534
samurai-fw/samurai
src/Samurai/Component/Core/Accessor.php
Accessor.hasProperty
public function hasProperty($name) { static $vars = null; if (! $vars) { $vars = get_object_vars($this); } return array_key_exists($name, $vars); }
php
public function hasProperty($name) { static $vars = null; if (! $vars) { $vars = get_object_vars($this); } return array_key_exists($name, $vars); }
[ "public", "function", "hasProperty", "(", "$", "name", ")", "{", "static", "$", "vars", "=", "null", ";", "if", "(", "!", "$", "vars", ")", "{", "$", "vars", "=", "get_object_vars", "(", "$", "this", ")", ";", "}", "return", "array_key_exists", "(", "$", "name", ",", "$", "vars", ")", ";", "}" ]
has property ? @access public @param string $name @return boolean
[ "has", "property", "?" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Core/Accessor.php#L143-L151
238,535
phn-io/compilation
src/Phn/Compilation/Debug.php
Debug.dumpTree
private static function dumpTree(NodeInterface $node, $verbose, $indent = 0) { list($attributes, $nodes) = self::extract($node); $dump = get_class($node); if ($attributes) { $dump .= ' ('; $dump .= implode(', ', array_map( function ($key, $value) use ($verbose) { return ($verbose ? sprintf('%s = ', $key) : '').self::stringify($value); }, array_keys($attributes), array_values($attributes) )); $dump .= ')'; } if ($nodes) { $dump .= ' {'.PHP_EOL; foreach ($nodes as $key => $node) { $dump .= str_repeat(' ', $indent + 1); if ($verbose && is_string($key)) { $dump .= sprintf('%s = ', $key); } if (is_array($node)) { $dump .= '['.PHP_EOL; foreach ($node as $item) { $dump .= str_repeat(' ', $indent + 2).self::dumpTree($item, $verbose, $indent + 2).PHP_EOL; } $dump .= str_repeat(' ', $indent + 1).']'.PHP_EOL; } else { $dump .= self::dumpTree($node, $verbose, $indent + 1).PHP_EOL; } } $dump .= str_repeat(' ', $indent).'}'; } return $dump; }
php
private static function dumpTree(NodeInterface $node, $verbose, $indent = 0) { list($attributes, $nodes) = self::extract($node); $dump = get_class($node); if ($attributes) { $dump .= ' ('; $dump .= implode(', ', array_map( function ($key, $value) use ($verbose) { return ($verbose ? sprintf('%s = ', $key) : '').self::stringify($value); }, array_keys($attributes), array_values($attributes) )); $dump .= ')'; } if ($nodes) { $dump .= ' {'.PHP_EOL; foreach ($nodes as $key => $node) { $dump .= str_repeat(' ', $indent + 1); if ($verbose && is_string($key)) { $dump .= sprintf('%s = ', $key); } if (is_array($node)) { $dump .= '['.PHP_EOL; foreach ($node as $item) { $dump .= str_repeat(' ', $indent + 2).self::dumpTree($item, $verbose, $indent + 2).PHP_EOL; } $dump .= str_repeat(' ', $indent + 1).']'.PHP_EOL; } else { $dump .= self::dumpTree($node, $verbose, $indent + 1).PHP_EOL; } } $dump .= str_repeat(' ', $indent).'}'; } return $dump; }
[ "private", "static", "function", "dumpTree", "(", "NodeInterface", "$", "node", ",", "$", "verbose", ",", "$", "indent", "=", "0", ")", "{", "list", "(", "$", "attributes", ",", "$", "nodes", ")", "=", "self", "::", "extract", "(", "$", "node", ")", ";", "$", "dump", "=", "get_class", "(", "$", "node", ")", ";", "if", "(", "$", "attributes", ")", "{", "$", "dump", ".=", "' ('", ";", "$", "dump", ".=", "implode", "(", "', '", ",", "array_map", "(", "function", "(", "$", "key", ",", "$", "value", ")", "use", "(", "$", "verbose", ")", "{", "return", "(", "$", "verbose", "?", "sprintf", "(", "'%s = '", ",", "$", "key", ")", ":", "''", ")", ".", "self", "::", "stringify", "(", "$", "value", ")", ";", "}", ",", "array_keys", "(", "$", "attributes", ")", ",", "array_values", "(", "$", "attributes", ")", ")", ")", ";", "$", "dump", ".=", "')'", ";", "}", "if", "(", "$", "nodes", ")", "{", "$", "dump", ".=", "' {'", ".", "PHP_EOL", ";", "foreach", "(", "$", "nodes", "as", "$", "key", "=>", "$", "node", ")", "{", "$", "dump", ".=", "str_repeat", "(", "' '", ",", "$", "indent", "+", "1", ")", ";", "if", "(", "$", "verbose", "&&", "is_string", "(", "$", "key", ")", ")", "{", "$", "dump", ".=", "sprintf", "(", "'%s = '", ",", "$", "key", ")", ";", "}", "if", "(", "is_array", "(", "$", "node", ")", ")", "{", "$", "dump", ".=", "'['", ".", "PHP_EOL", ";", "foreach", "(", "$", "node", "as", "$", "item", ")", "{", "$", "dump", ".=", "str_repeat", "(", "' '", ",", "$", "indent", "+", "2", ")", ".", "self", "::", "dumpTree", "(", "$", "item", ",", "$", "verbose", ",", "$", "indent", "+", "2", ")", ".", "PHP_EOL", ";", "}", "$", "dump", ".=", "str_repeat", "(", "' '", ",", "$", "indent", "+", "1", ")", ".", "']'", ".", "PHP_EOL", ";", "}", "else", "{", "$", "dump", ".=", "self", "::", "dumpTree", "(", "$", "node", ",", "$", "verbose", ",", "$", "indent", "+", "1", ")", ".", "PHP_EOL", ";", "}", "}", "$", "dump", ".=", "str_repeat", "(", "' '", ",", "$", "indent", ")", ".", "'}'", ";", "}", "return", "$", "dump", ";", "}" ]
Dumps the node and its children as a pretty printed string representation. @param NodeInterface $node The root node to dump. @param bool $verbose The dump will be more verbose if this flag is set to `true`. @param int $indent The indentation level to apply. @return string The dump of the node and its children.
[ "Dumps", "the", "node", "and", "its", "children", "as", "a", "pretty", "printed", "string", "representation", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Debug.php#L59-L106
238,536
phn-io/compilation
src/Phn/Compilation/Debug.php
Debug.extract
private static function extract(NodeInterface $node) { $attributes = []; $nodes = []; foreach (self::extractProperties($node) as $name => $value) { if (is_array($value)) { foreach ($value as $item) { if ($item instanceof NodeInterface) { $nodes[$name][] = $item; } else { $attributes[$name][] = $item; } } } else { if ($value instanceof NodeInterface) { $nodes[$name] = $value; } else { $attributes[$name] = $value; } } } return [$attributes, $nodes]; }
php
private static function extract(NodeInterface $node) { $attributes = []; $nodes = []; foreach (self::extractProperties($node) as $name => $value) { if (is_array($value)) { foreach ($value as $item) { if ($item instanceof NodeInterface) { $nodes[$name][] = $item; } else { $attributes[$name][] = $item; } } } else { if ($value instanceof NodeInterface) { $nodes[$name] = $value; } else { $attributes[$name] = $value; } } } return [$attributes, $nodes]; }
[ "private", "static", "function", "extract", "(", "NodeInterface", "$", "node", ")", "{", "$", "attributes", "=", "[", "]", ";", "$", "nodes", "=", "[", "]", ";", "foreach", "(", "self", "::", "extractProperties", "(", "$", "node", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "item", ")", "{", "if", "(", "$", "item", "instanceof", "NodeInterface", ")", "{", "$", "nodes", "[", "$", "name", "]", "[", "]", "=", "$", "item", ";", "}", "else", "{", "$", "attributes", "[", "$", "name", "]", "[", "]", "=", "$", "item", ";", "}", "}", "}", "else", "{", "if", "(", "$", "value", "instanceof", "NodeInterface", ")", "{", "$", "nodes", "[", "$", "name", "]", "=", "$", "value", ";", "}", "else", "{", "$", "attributes", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "}", "return", "[", "$", "attributes", ",", "$", "nodes", "]", ";", "}" ]
Extracts the properties of the given node. @param NodeInterface $node The node to use for the extraction. @return array An array with two indexes: the attributes and the children nodes.
[ "Extracts", "the", "properties", "of", "the", "given", "node", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Debug.php#L115-L139
238,537
phn-io/compilation
src/Phn/Compilation/Debug.php
Debug.extractProperties
private static function extractProperties(NodeInterface $node) { $class = new \ReflectionClass($node); foreach ($class->getProperties() as $property) { if (!$property->isPublic()) { $property->setAccessible(true); } $name = $property->getName(); $value = $property->getValue($node); yield $name => $value; if (!$property->isPublic()) { $property->setAccessible(false); } } }
php
private static function extractProperties(NodeInterface $node) { $class = new \ReflectionClass($node); foreach ($class->getProperties() as $property) { if (!$property->isPublic()) { $property->setAccessible(true); } $name = $property->getName(); $value = $property->getValue($node); yield $name => $value; if (!$property->isPublic()) { $property->setAccessible(false); } } }
[ "private", "static", "function", "extractProperties", "(", "NodeInterface", "$", "node", ")", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "node", ")", ";", "foreach", "(", "$", "class", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "if", "(", "!", "$", "property", "->", "isPublic", "(", ")", ")", "{", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "}", "$", "name", "=", "$", "property", "->", "getName", "(", ")", ";", "$", "value", "=", "$", "property", "->", "getValue", "(", "$", "node", ")", ";", "yield", "$", "name", "=>", "$", "value", ";", "if", "(", "!", "$", "property", "->", "isPublic", "(", ")", ")", "{", "$", "property", "->", "setAccessible", "(", "false", ")", ";", "}", "}", "}" ]
Provides a generator that share the properties of the given node. @param NodeInterface $node The node to use for the extraction. @return \Generator A key value tuple.
[ "Provides", "a", "generator", "that", "share", "the", "properties", "of", "the", "given", "node", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Debug.php#L148-L166
238,538
phn-io/compilation
src/Phn/Compilation/Debug.php
Debug.stringify
private static function stringify($value) { if (is_string($value)) { return sprintf('"%s"', preg_replace('/\n/', '\n', $value)); } if (is_bool($value)) { return $value ? 'true' : 'false'; } if (is_null($value)) { return 'null'; } if (is_array($value)) { return sprintf('[%s]', implode(', ', array_map( function ($value) { return self::stringify($value); }, $value ))); } return (string) $value; }
php
private static function stringify($value) { if (is_string($value)) { return sprintf('"%s"', preg_replace('/\n/', '\n', $value)); } if (is_bool($value)) { return $value ? 'true' : 'false'; } if (is_null($value)) { return 'null'; } if (is_array($value)) { return sprintf('[%s]', implode(', ', array_map( function ($value) { return self::stringify($value); }, $value ))); } return (string) $value; }
[ "private", "static", "function", "stringify", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "return", "sprintf", "(", "'\"%s\"'", ",", "preg_replace", "(", "'/\\n/'", ",", "'\\n'", ",", "$", "value", ")", ")", ";", "}", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "return", "$", "value", "?", "'true'", ":", "'false'", ";", "}", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "'null'", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "sprintf", "(", "'[%s]'", ",", "implode", "(", "', '", ",", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "self", "::", "stringify", "(", "$", "value", ")", ";", "}", ",", "$", "value", ")", ")", ")", ";", "}", "return", "(", "string", ")", "$", "value", ";", "}" ]
Stringify the given value. It can handles strings, booleans, null values and arrays. The other types would be casted into string. @param string $value The value to stringify. @return string The string representation of the given value.
[ "Stringify", "the", "given", "value", ".", "It", "can", "handles", "strings", "booleans", "null", "values", "and", "arrays", ".", "The", "other", "types", "would", "be", "casted", "into", "string", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Debug.php#L176-L200
238,539
jasand-pereza/addmany
src/AddMany.php
AddMany.removeAbandonedPosts
public static function removeAbandonedPosts() { $sub_posts = \SubPost::getWhere(array('post_parent' => 0)); foreach($sub_posts as $sp) { wp_delete_post($sp->ID, true); } }
php
public static function removeAbandonedPosts() { $sub_posts = \SubPost::getWhere(array('post_parent' => 0)); foreach($sub_posts as $sp) { wp_delete_post($sp->ID, true); } }
[ "public", "static", "function", "removeAbandonedPosts", "(", ")", "{", "$", "sub_posts", "=", "\\", "SubPost", "::", "getWhere", "(", "array", "(", "'post_parent'", "=>", "0", ")", ")", ";", "foreach", "(", "$", "sub_posts", "as", "$", "sp", ")", "{", "wp_delete_post", "(", "$", "sp", "->", "ID", ",", "true", ")", ";", "}", "}" ]
without hitting the publish or update button
[ "without", "hitting", "the", "publish", "or", "update", "button" ]
309fb1590e669983e6f13b94ab8fd2166e43f188
https://github.com/jasand-pereza/addmany/blob/309fb1590e669983e6f13b94ab8fd2166e43f188/src/AddMany.php#L190-L195
238,540
alfredoem/ragnarok
app/Ragnarok/Soul/AuthRagnarok.php
AuthRagnarok.retrieve
public function retrieve($name) { $this->userRagnarok = Session::get($this->getName()); if (property_exists($this->userRagnarok, $name)) { return $this->userRagnarok->$name; } return null; }
php
public function retrieve($name) { $this->userRagnarok = Session::get($this->getName()); if (property_exists($this->userRagnarok, $name)) { return $this->userRagnarok->$name; } return null; }
[ "public", "function", "retrieve", "(", "$", "name", ")", "{", "$", "this", "->", "userRagnarok", "=", "Session", "::", "get", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "if", "(", "property_exists", "(", "$", "this", "->", "userRagnarok", ",", "$", "name", ")", ")", "{", "return", "$", "this", "->", "userRagnarok", "->", "$", "name", ";", "}", "return", "null", ";", "}" ]
Get User Session Object attribute @param $name @return string|null
[ "Get", "User", "Session", "Object", "attribute" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/AuthRagnarok.php#L24-L33
238,541
alfredoem/ragnarok
app/Ragnarok/Soul/AuthRagnarok.php
AuthRagnarok.make
public function make($user) { $RagnarokUser = new SecUser(); $this->userRagnarok = $RagnarokUser->populate($user); Session::put($this->getName(), $this->userRagnarok); return $this->userRagnarok; }
php
public function make($user) { $RagnarokUser = new SecUser(); $this->userRagnarok = $RagnarokUser->populate($user); Session::put($this->getName(), $this->userRagnarok); return $this->userRagnarok; }
[ "public", "function", "make", "(", "$", "user", ")", "{", "$", "RagnarokUser", "=", "new", "SecUser", "(", ")", ";", "$", "this", "->", "userRagnarok", "=", "$", "RagnarokUser", "->", "populate", "(", "$", "user", ")", ";", "Session", "::", "put", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "this", "->", "userRagnarok", ")", ";", "return", "$", "this", "->", "userRagnarok", ";", "}" ]
Make User Session Object @return \Alfredoem\Ragnarok\SecUsers\SecUser
[ "Make", "User", "Session", "Object" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/AuthRagnarok.php#L48-L54
238,542
alfredoem/ragnarok
app/Ragnarok/Soul/AuthRagnarok.php
AuthRagnarok.instance
public function instance($data) { $RagnarokUser = new SecUser(); $this->userRagnarok = $RagnarokUser->populate($data); return $this->userRagnarok; }
php
public function instance($data) { $RagnarokUser = new SecUser(); $this->userRagnarok = $RagnarokUser->populate($data); return $this->userRagnarok; }
[ "public", "function", "instance", "(", "$", "data", ")", "{", "$", "RagnarokUser", "=", "new", "SecUser", "(", ")", ";", "$", "this", "->", "userRagnarok", "=", "$", "RagnarokUser", "->", "populate", "(", "$", "data", ")", ";", "return", "$", "this", "->", "userRagnarok", ";", "}" ]
Get a new instance of the User @param $data @return $this
[ "Get", "a", "new", "instance", "of", "the", "User" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/AuthRagnarok.php#L61-L66
238,543
Sowapps/orpheus-inputcontroller
src/InputController/InputRequest.php
InputRequest.process
public function process() { $route = $this->findFirstMatchingRoute(); if( !$route ) { // Not found, look for an alternative (with /) $route = $this->findFirstMatchingRoute(true); if( $route ) { // Alternative found, try to redirect to this one $r = $this->redirect($route); if( $r ) { // Redirect return $r; } // Unable to redirect, throw not found $route = null; } } return $this->processRoute($route); }
php
public function process() { $route = $this->findFirstMatchingRoute(); if( !$route ) { // Not found, look for an alternative (with /) $route = $this->findFirstMatchingRoute(true); if( $route ) { // Alternative found, try to redirect to this one $r = $this->redirect($route); if( $r ) { // Redirect return $r; } // Unable to redirect, throw not found $route = null; } } return $this->processRoute($route); }
[ "public", "function", "process", "(", ")", "{", "$", "route", "=", "$", "this", "->", "findFirstMatchingRoute", "(", ")", ";", "if", "(", "!", "$", "route", ")", "{", "// Not found, look for an alternative (with /)", "$", "route", "=", "$", "this", "->", "findFirstMatchingRoute", "(", "true", ")", ";", "if", "(", "$", "route", ")", "{", "// Alternative found, try to redirect to this one", "$", "r", "=", "$", "this", "->", "redirect", "(", "$", "route", ")", ";", "if", "(", "$", "r", ")", "{", "// Redirect", "return", "$", "r", ";", "}", "// Unable to redirect, throw not found", "$", "route", "=", "null", ";", "}", "}", "return", "$", "this", "->", "processRoute", "(", "$", "route", ")", ";", "}" ]
Process the request by finding a route and processing it @return \Orpheus\InputController\OutputResponse
[ "Process", "the", "request", "by", "finding", "a", "route", "and", "processing", "it" ]
91f848a42ac02ae4009ffb3e9a9b4e8c0731455e
https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/InputRequest.php#L93-L110
238,544
Sowapps/orpheus-inputcontroller
src/InputController/InputRequest.php
InputRequest.processRoute
public function processRoute($route) { if( !$route ) { throw new NotFoundException('No route matches the current request '.$this); } $this->setRoute($route); return $this->route->run($this); }
php
public function processRoute($route) { if( !$route ) { throw new NotFoundException('No route matches the current request '.$this); } $this->setRoute($route); return $this->route->run($this); }
[ "public", "function", "processRoute", "(", "$", "route", ")", "{", "if", "(", "!", "$", "route", ")", "{", "throw", "new", "NotFoundException", "(", "'No route matches the current request '", ".", "$", "this", ")", ";", "}", "$", "this", "->", "setRoute", "(", "$", "route", ")", ";", "return", "$", "this", "->", "route", "->", "run", "(", "$", "this", ")", ";", "}" ]
Process the given route @param ControllerRoute $route @throws NotFoundException @return \Orpheus\InputController\OutputResponse
[ "Process", "the", "given", "route" ]
91f848a42ac02ae4009ffb3e9a9b4e8c0731455e
https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/InputRequest.php#L119-L125
238,545
webriq/core
module/Image/src/Grid/Image/Model/Paragraph/Structure/Image.php
Image.setWidth
public function setWidth( $width ) { $this->width = empty( $width ) ? null : (int) $width; return $this; }
php
public function setWidth( $width ) { $this->width = empty( $width ) ? null : (int) $width; return $this; }
[ "public", "function", "setWidth", "(", "$", "width", ")", "{", "$", "this", "->", "width", "=", "empty", "(", "$", "width", ")", "?", "null", ":", "(", "int", ")", "$", "width", ";", "return", "$", "this", ";", "}" ]
Set width attribute @param int $width @return \Image\Model\Paragraph\Structure\Image
[ "Set", "width", "attribute" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Image/src/Grid/Image/Model/Paragraph/Structure/Image.php#L138-L142
238,546
webriq/core
module/Image/src/Grid/Image/Model/Paragraph/Structure/Image.php
Image.setHeight
public function setHeight( $height ) { $this->height = empty( $height ) ? null : (int) $height; return $this; }
php
public function setHeight( $height ) { $this->height = empty( $height ) ? null : (int) $height; return $this; }
[ "public", "function", "setHeight", "(", "$", "height", ")", "{", "$", "this", "->", "height", "=", "empty", "(", "$", "height", ")", "?", "null", ":", "(", "int", ")", "$", "height", ";", "return", "$", "this", ";", "}" ]
Set height attribute @param int $height @return \Image\Model\Paragraph\Structure\Image
[ "Set", "height", "attribute" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Image/src/Grid/Image/Model/Paragraph/Structure/Image.php#L160-L164
238,547
phossa2/libs
src/Phossa2/Cache/Extension/Encrypt.php
Encrypt.processValue
protected function processValue(callable $func, CacheItem $item) { $item->setStrVal($func($item->getStrVal())); return true; }
php
protected function processValue(callable $func, CacheItem $item) { $item->setStrVal($func($item->getStrVal())); return true; }
[ "protected", "function", "processValue", "(", "callable", "$", "func", ",", "CacheItem", "$", "item", ")", "{", "$", "item", "->", "setStrVal", "(", "$", "func", "(", "$", "item", "->", "getStrVal", "(", ")", ")", ")", ";", "return", "true", ";", "}" ]
Encrypt or decrypt @param callable $func @param CacheItem $item @return bool @access protected
[ "Encrypt", "or", "decrypt" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/Extension/Encrypt.php#L127-L131
238,548
belgattitude/soluble-spreadsheet
src/Soluble/Spreadsheet/Library/LibXL.php
LibXL.getExcelBook
public function getExcelBook($file_format = self::FILE_FORMAT_XLSX, $locale = 'UTF-8') { //@codeCoverageIgnoreStart if (!extension_loaded('excel')) { throw new Exception\RuntimeException(__METHOD__ . ' LibXL requires excel extension (https://github.com/iliaal/php_excel) and http://libxl.com/.'); } //@codeCoverageIgnoreEnd if (!$this->isSupportedFormat($file_format)) { throw new Exception\InvalidArgumentException(__METHOD__ . " Unsupported file format '$file_format'."); } $license = $this->getLicense(); $license_name = $license['name']; $license_key = $license['key']; $excel2007 = true; switch ($file_format) { case self::FILE_FORMAT_XLS: $excel2007 = false; break; } $book = new ExcelBook($license_name, $license_key, $excel2007); if ($locale !== null) { $book->setLocale($locale); } return $book; }
php
public function getExcelBook($file_format = self::FILE_FORMAT_XLSX, $locale = 'UTF-8') { //@codeCoverageIgnoreStart if (!extension_loaded('excel')) { throw new Exception\RuntimeException(__METHOD__ . ' LibXL requires excel extension (https://github.com/iliaal/php_excel) and http://libxl.com/.'); } //@codeCoverageIgnoreEnd if (!$this->isSupportedFormat($file_format)) { throw new Exception\InvalidArgumentException(__METHOD__ . " Unsupported file format '$file_format'."); } $license = $this->getLicense(); $license_name = $license['name']; $license_key = $license['key']; $excel2007 = true; switch ($file_format) { case self::FILE_FORMAT_XLS: $excel2007 = false; break; } $book = new ExcelBook($license_name, $license_key, $excel2007); if ($locale !== null) { $book->setLocale($locale); } return $book; }
[ "public", "function", "getExcelBook", "(", "$", "file_format", "=", "self", "::", "FILE_FORMAT_XLSX", ",", "$", "locale", "=", "'UTF-8'", ")", "{", "//@codeCoverageIgnoreStart", "if", "(", "!", "extension_loaded", "(", "'excel'", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "__METHOD__", ".", "' LibXL requires excel extension (https://github.com/iliaal/php_excel) and http://libxl.com/.'", ")", ";", "}", "//@codeCoverageIgnoreEnd", "if", "(", "!", "$", "this", "->", "isSupportedFormat", "(", "$", "file_format", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "\" Unsupported file format '$file_format'.\"", ")", ";", "}", "$", "license", "=", "$", "this", "->", "getLicense", "(", ")", ";", "$", "license_name", "=", "$", "license", "[", "'name'", "]", ";", "$", "license_key", "=", "$", "license", "[", "'key'", "]", ";", "$", "excel2007", "=", "true", ";", "switch", "(", "$", "file_format", ")", "{", "case", "self", "::", "FILE_FORMAT_XLS", ":", "$", "excel2007", "=", "false", ";", "break", ";", "}", "$", "book", "=", "new", "ExcelBook", "(", "$", "license_name", ",", "$", "license_key", ",", "$", "excel2007", ")", ";", "if", "(", "$", "locale", "!==", "null", ")", "{", "$", "book", "->", "setLocale", "(", "$", "locale", ")", ";", "}", "return", "$", "book", ";", "}" ]
Return an empty ExcelBook instance @throws Exception\RuntimeException if no excel extension is found @throws Exception\InvalidArgumentException if unsupported format @param string $file_format by default xlsx, see constants FILE_FORMAT_* @param string $locale by default utf-8 @return ExcelBook
[ "Return", "an", "empty", "ExcelBook", "instance" ]
08df46c7199404343433a59a664d4e2c2afa10fb
https://github.com/belgattitude/soluble-spreadsheet/blob/08df46c7199404343433a59a664d4e2c2afa10fb/src/Soluble/Spreadsheet/Library/LibXL.php#L55-L81
238,549
belgattitude/soluble-spreadsheet
src/Soluble/Spreadsheet/Library/LibXL.php
LibXL.isSupportedFormat
public static function isSupportedFormat($format) { if (!is_string($format)) { throw new Exception\InvalidArgumentException(__METHOD__ . " file_format must be a string"); } return in_array((string) $format, self::$supportedFormats); }
php
public static function isSupportedFormat($format) { if (!is_string($format)) { throw new Exception\InvalidArgumentException(__METHOD__ . " file_format must be a string"); } return in_array((string) $format, self::$supportedFormats); }
[ "public", "static", "function", "isSupportedFormat", "(", "$", "format", ")", "{", "if", "(", "!", "is_string", "(", "$", "format", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "\" file_format must be a string\"", ")", ";", "}", "return", "in_array", "(", "(", "string", ")", "$", "format", ",", "self", "::", "$", "supportedFormats", ")", ";", "}" ]
Check whether the format is supported @throws Exception\InvalidArgumentException @param string $format @return boolean
[ "Check", "whether", "the", "format", "is", "supported" ]
08df46c7199404343433a59a664d4e2c2afa10fb
https://github.com/belgattitude/soluble-spreadsheet/blob/08df46c7199404343433a59a664d4e2c2afa10fb/src/Soluble/Spreadsheet/Library/LibXL.php#L103-L109
238,550
belgattitude/soluble-spreadsheet
src/Soluble/Spreadsheet/Library/LibXL.php
LibXL.setDefaultLicense
public static function setDefaultLicense(array $license) { if (!array_key_exists('name', $license) || !array_key_exists('key', $license)) { throw new Exception\InvalidArgumentException(__METHOD__ . " In order to set a default libxl license you must provide an associative array with 'name' and 'key' set."); } self::$default_license = $license; }
php
public static function setDefaultLicense(array $license) { if (!array_key_exists('name', $license) || !array_key_exists('key', $license)) { throw new Exception\InvalidArgumentException(__METHOD__ . " In order to set a default libxl license you must provide an associative array with 'name' and 'key' set."); } self::$default_license = $license; }
[ "public", "static", "function", "setDefaultLicense", "(", "array", "$", "license", ")", "{", "if", "(", "!", "array_key_exists", "(", "'name'", ",", "$", "license", ")", "||", "!", "array_key_exists", "(", "'key'", ",", "$", "license", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "\" In order to set a default libxl license you must provide an associative array with 'name' and 'key' set.\"", ")", ";", "}", "self", "::", "$", "default_license", "=", "$", "license", ";", "}" ]
Set default license information @throws Exception\InvalidArgumentException @param array $license associative array with 'name' and 'key'
[ "Set", "default", "license", "information" ]
08df46c7199404343433a59a664d4e2c2afa10fb
https://github.com/belgattitude/soluble-spreadsheet/blob/08df46c7199404343433a59a664d4e2c2afa10fb/src/Soluble/Spreadsheet/Library/LibXL.php#L141-L148
238,551
jamiehannaford/php-opencloud-zf2
src/Helper/CloudFilesHelper.php
CloudFilesHelper.getContainer
protected function getContainer($name) { if (!isset($this->containers[$name])) { $this->createContainer($name); } return $this->containers[$name]; }
php
protected function getContainer($name) { if (!isset($this->containers[$name])) { $this->createContainer($name); } return $this->containers[$name]; }
[ "protected", "function", "getContainer", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "containers", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "createContainer", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "containers", "[", "$", "name", "]", ";", "}" ]
Return a container wrapper based on its name, saving to cache if necessary. @param $name Container name @return \Zend\Zf2\Helper\CloudFiles\Container @throws \Zend\View\Exception\InvalidArgumentException
[ "Return", "a", "container", "wrapper", "based", "on", "its", "name", "saving", "to", "cache", "if", "necessary", "." ]
74140adaffc0b46d7bbe1d7b3441c61f2cf6a656
https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Helper/CloudFilesHelper.php#L56-L63
238,552
jamiehannaford/php-opencloud-zf2
src/Helper/CloudFilesHelper.php
CloudFilesHelper.createContainer
protected function createContainer($name) { $this->containers[$name] = new Container($this->getView(), $this->service, $name); }
php
protected function createContainer($name) { $this->containers[$name] = new Container($this->getView(), $this->service, $name); }
[ "protected", "function", "createContainer", "(", "$", "name", ")", "{", "$", "this", "->", "containers", "[", "$", "name", "]", "=", "new", "Container", "(", "$", "this", "->", "getView", "(", ")", ",", "$", "this", "->", "service", ",", "$", "name", ")", ";", "}" ]
Create a new container wrapper and save it to cache @param $name Container name
[ "Create", "a", "new", "container", "wrapper", "and", "save", "it", "to", "cache" ]
74140adaffc0b46d7bbe1d7b3441c61f2cf6a656
https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Helper/CloudFilesHelper.php#L70-L73
238,553
samurai-fw/samurai
src/Onikiri/Transaction.php
Transaction.rollbackWithoutThrow
public function rollbackWithoutThrow() { if (! $this->isValid()) return; foreach ($this->getConnections() as $connection) { $connection->rollback(); } $this->_depth = 0; }
php
public function rollbackWithoutThrow() { if (! $this->isValid()) return; foreach ($this->getConnections() as $connection) { $connection->rollback(); } $this->_depth = 0; }
[ "public", "function", "rollbackWithoutThrow", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isValid", "(", ")", ")", "return", ";", "foreach", "(", "$", "this", "->", "getConnections", "(", ")", "as", "$", "connection", ")", "{", "$", "connection", "->", "rollback", "(", ")", ";", "}", "$", "this", "->", "_depth", "=", "0", ";", "}" ]
rollback transaction without throw
[ "rollback", "transaction", "without", "throw" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Transaction.php#L138-L147
238,554
RowlandOti/ooglee-core
src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php
EloquentPresenter.createdAtDatetime
public function createdAtDatetime() { return $this->entity->created_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format')); }
php
public function createdAtDatetime() { return $this->entity->created_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format')); }
[ "public", "function", "createdAtDatetime", "(", ")", "{", "return", "$", "this", "->", "entity", "->", "created_at", "->", "setTimezone", "(", "$", "this", "->", "config", "->", "get", "(", "'config.timezone'", ")", ")", "->", "format", "(", "$", "this", "->", "config", "->", "get", "(", "'config.date_format'", ")", ".", "' '", ".", "$", "this", "->", "config", "->", "get", "(", "'config.time_format'", ")", ")", ";", "}" ]
Return the datetime string for created at. @return string
[ "Return", "the", "datetime", "string", "for", "created", "at", "." ]
6cd8a8e58e37749e1c58e99063ea72c9d37a98bc
https://github.com/RowlandOti/ooglee-core/blob/6cd8a8e58e37749e1c58e99063ea72c9d37a98bc/src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php#L53-L57
238,555
RowlandOti/ooglee-core
src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php
EloquentPresenter.updatedAtDate
public function updatedAtDate() { return $this->entity->updated_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format')); }
php
public function updatedAtDate() { return $this->entity->updated_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format')); }
[ "public", "function", "updatedAtDate", "(", ")", "{", "return", "$", "this", "->", "entity", "->", "updated_at", "->", "setTimezone", "(", "$", "this", "->", "config", "->", "get", "(", "'config.timezone'", ")", ")", "->", "format", "(", "$", "this", "->", "config", "->", "get", "(", "'config.date_format'", ")", ")", ";", "}" ]
Return the date string for updated at. @return string
[ "Return", "the", "date", "string", "for", "updated", "at", "." ]
6cd8a8e58e37749e1c58e99063ea72c9d37a98bc
https://github.com/RowlandOti/ooglee-core/blob/6cd8a8e58e37749e1c58e99063ea72c9d37a98bc/src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php#L64-L68
238,556
RowlandOti/ooglee-core
src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php
EloquentPresenter.updatedAtDatetime
public function updatedAtDatetime() { return $this->entity->updated_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format')); }
php
public function updatedAtDatetime() { return $this->entity->updated_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format')); }
[ "public", "function", "updatedAtDatetime", "(", ")", "{", "return", "$", "this", "->", "entity", "->", "updated_at", "->", "setTimezone", "(", "$", "this", "->", "config", "->", "get", "(", "'config.timezone'", ")", ")", "->", "format", "(", "$", "this", "->", "config", "->", "get", "(", "'config.date_format'", ")", ".", "' '", ".", "$", "this", "->", "config", "->", "get", "(", "'config.time_format'", ")", ")", ";", "}" ]
Return the datetime string for updated at. @return string
[ "Return", "the", "datetime", "string", "for", "updated", "at", "." ]
6cd8a8e58e37749e1c58e99063ea72c9d37a98bc
https://github.com/RowlandOti/ooglee-core/blob/6cd8a8e58e37749e1c58e99063ea72c9d37a98bc/src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php#L75-L79
238,557
beheh/sulphur
src/Response.php
Response.where
public function where($field, $section = 'Reference') { // default to reference if($section === null) { $section = 'Reference'; } // array_values reindexes the array here, otherwise we have gaps from non-matching array keys return new FilterableList(array_values(array_filter($this->sections, function(Section $val) use ($section) { // only return matching root sections return $val->getHeading() == $section; })), $field); }
php
public function where($field, $section = 'Reference') { // default to reference if($section === null) { $section = 'Reference'; } // array_values reindexes the array here, otherwise we have gaps from non-matching array keys return new FilterableList(array_values(array_filter($this->sections, function(Section $val) use ($section) { // only return matching root sections return $val->getHeading() == $section; })), $field); }
[ "public", "function", "where", "(", "$", "field", ",", "$", "section", "=", "'Reference'", ")", "{", "// default to reference", "if", "(", "$", "section", "===", "null", ")", "{", "$", "section", "=", "'Reference'", ";", "}", "// array_values reindexes the array here, otherwise we have gaps from non-matching array keys", "return", "new", "FilterableList", "(", "array_values", "(", "array_filter", "(", "$", "this", "->", "sections", ",", "function", "(", "Section", "$", "val", ")", "use", "(", "$", "section", ")", "{", "// only return matching root sections", "return", "$", "val", "->", "getHeading", "(", ")", "==", "$", "section", ";", "}", ")", ")", ",", "$", "field", ")", ";", "}" ]
Sets the field for the first filter. @param string $field the field to filter @return FilterableList
[ "Sets", "the", "field", "for", "the", "first", "filter", "." ]
d608b40d6cf26f12476d992276ee9a0aa455bd55
https://github.com/beheh/sulphur/blob/d608b40d6cf26f12476d992276ee9a0aa455bd55/src/Response.php#L28-L38
238,558
railsphp/framework
src/Rails/Toolbox/ArrayTools.php
ArrayTools.flatten
public static function flatten(array $arr) { $flat = []; foreach ($arr as $v) { if (is_array($v)) { $flat = array_merge($flat, self::flatten($v)); } else { $flat[] = $v; } } return $flat; }
php
public static function flatten(array $arr) { $flat = []; foreach ($arr as $v) { if (is_array($v)) { $flat = array_merge($flat, self::flatten($v)); } else { $flat[] = $v; } } return $flat; }
[ "public", "static", "function", "flatten", "(", "array", "$", "arr", ")", "{", "$", "flat", "=", "[", "]", ";", "foreach", "(", "$", "arr", "as", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "$", "flat", "=", "array_merge", "(", "$", "flat", ",", "self", "::", "flatten", "(", "$", "v", ")", ")", ";", "}", "else", "{", "$", "flat", "[", "]", "=", "$", "v", ";", "}", "}", "return", "$", "flat", ";", "}" ]
Flattens an array.
[ "Flattens", "an", "array", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/Toolbox/ArrayTools.php#L9-L20
238,559
railsphp/framework
src/Rails/Toolbox/ArrayTools.php
ArrayTools.isIndexed
public static function isIndexed(array $array) { $i = 0; foreach (array_keys($array) as $k) { if ($k !== $i) { return false; } $i++; } return true; }
php
public static function isIndexed(array $array) { $i = 0; foreach (array_keys($array) as $k) { if ($k !== $i) { return false; } $i++; } return true; }
[ "public", "static", "function", "isIndexed", "(", "array", "$", "array", ")", "{", "$", "i", "=", "0", ";", "foreach", "(", "array_keys", "(", "$", "array", ")", "as", "$", "k", ")", "{", "if", "(", "$", "k", "!==", "$", "i", ")", "{", "return", "false", ";", "}", "$", "i", "++", ";", "}", "return", "true", ";", "}" ]
Checks if an array is indexed.
[ "Checks", "if", "an", "array", "is", "indexed", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/Toolbox/ArrayTools.php#L25-L35
238,560
ripaclub/aclman
library/Service/ServiceAbstract.php
ServiceAbstract.addRole
public function addRole($role, $parents = null) { $this->getAcl()->addRole($role, $parents); return $this; }
php
public function addRole($role, $parents = null) { $this->getAcl()->addRole($role, $parents); return $this; }
[ "public", "function", "addRole", "(", "$", "role", ",", "$", "parents", "=", "null", ")", "{", "$", "this", "->", "getAcl", "(", ")", "->", "addRole", "(", "$", "role", ",", "$", "parents", ")", ";", "return", "$", "this", ";", "}" ]
Add roles from storage @param string|RoleInterface $role @param string|array|RoleInterface $parents @return $this
[ "Add", "roles", "from", "storage" ]
ca7c65fdb3291654f293829c70ced9fb2e1566f8
https://github.com/ripaclub/aclman/blob/ca7c65fdb3291654f293829c70ced9fb2e1566f8/library/Service/ServiceAbstract.php#L51-L55
238,561
fsi-open/metadata
lib/FSi/Component/Metadata/MetadataFactory.php
MetadataFactory.getClassMetadata
public function getClassMetadata($class) { $class = ltrim($class, '\\'); $metadataIndex = $this->getCacheId($class); if (isset($this->loadedMetadata[$metadataIndex])) { return $this->loadedMetadata[$metadataIndex]; } if (isset($this->cache)) { if (false !== ($metadata = $this->cache->fetch($metadataIndex))) { return $metadata; } } $metadata = new $this->metadataClassName($class); $parentClasses = array_reverse(class_parents($class)); foreach ($parentClasses as $parentClass) { $metadata->setClassName($parentClass); $this->driver->loadClassMetadata($metadata); } $metadata->setClassName($class); $this->driver->loadClassMetadata($metadata); if (isset($this->cache)) { $this->cache->save($metadataIndex, $metadata); } $this->loadedMetadata[$metadataIndex] = $metadata; return $metadata; }
php
public function getClassMetadata($class) { $class = ltrim($class, '\\'); $metadataIndex = $this->getCacheId($class); if (isset($this->loadedMetadata[$metadataIndex])) { return $this->loadedMetadata[$metadataIndex]; } if (isset($this->cache)) { if (false !== ($metadata = $this->cache->fetch($metadataIndex))) { return $metadata; } } $metadata = new $this->metadataClassName($class); $parentClasses = array_reverse(class_parents($class)); foreach ($parentClasses as $parentClass) { $metadata->setClassName($parentClass); $this->driver->loadClassMetadata($metadata); } $metadata->setClassName($class); $this->driver->loadClassMetadata($metadata); if (isset($this->cache)) { $this->cache->save($metadataIndex, $metadata); } $this->loadedMetadata[$metadataIndex] = $metadata; return $metadata; }
[ "public", "function", "getClassMetadata", "(", "$", "class", ")", "{", "$", "class", "=", "ltrim", "(", "$", "class", ",", "'\\\\'", ")", ";", "$", "metadataIndex", "=", "$", "this", "->", "getCacheId", "(", "$", "class", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "loadedMetadata", "[", "$", "metadataIndex", "]", ")", ")", "{", "return", "$", "this", "->", "loadedMetadata", "[", "$", "metadataIndex", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "cache", ")", ")", "{", "if", "(", "false", "!==", "(", "$", "metadata", "=", "$", "this", "->", "cache", "->", "fetch", "(", "$", "metadataIndex", ")", ")", ")", "{", "return", "$", "metadata", ";", "}", "}", "$", "metadata", "=", "new", "$", "this", "->", "metadataClassName", "(", "$", "class", ")", ";", "$", "parentClasses", "=", "array_reverse", "(", "class_parents", "(", "$", "class", ")", ")", ";", "foreach", "(", "$", "parentClasses", "as", "$", "parentClass", ")", "{", "$", "metadata", "->", "setClassName", "(", "$", "parentClass", ")", ";", "$", "this", "->", "driver", "->", "loadClassMetadata", "(", "$", "metadata", ")", ";", "}", "$", "metadata", "->", "setClassName", "(", "$", "class", ")", ";", "$", "this", "->", "driver", "->", "loadClassMetadata", "(", "$", "metadata", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "cache", ")", ")", "{", "$", "this", "->", "cache", "->", "save", "(", "$", "metadataIndex", ",", "$", "metadata", ")", ";", "}", "$", "this", "->", "loadedMetadata", "[", "$", "metadataIndex", "]", "=", "$", "metadata", ";", "return", "$", "metadata", ";", "}" ]
Returns class metadata read by the driver. This method calls itself recursively for each ancestor class @param string $class @return \FSi\Component\Metadata\ClassMetadataInterface
[ "Returns", "class", "metadata", "read", "by", "the", "driver", ".", "This", "method", "calls", "itself", "recursively", "for", "each", "ancestor", "class" ]
65c36bdab257d19d58e264b2b36bcf97a144075f
https://github.com/fsi-open/metadata/blob/65c36bdab257d19d58e264b2b36bcf97a144075f/lib/FSi/Component/Metadata/MetadataFactory.php#L89-L121
238,562
squire-assistant/console
Helper/QuestionHelper.php
QuestionHelper.setInputStream
public function setInputStream($stream) { @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); if (!is_resource($stream)) { throw new InvalidArgumentException('Input stream must be a valid resource.'); } $this->inputStream = $stream; }
php
public function setInputStream($stream) { @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); if (!is_resource($stream)) { throw new InvalidArgumentException('Input stream must be a valid resource.'); } $this->inputStream = $stream; }
[ "public", "function", "setInputStream", "(", "$", "stream", ")", "{", "@", "trigger_error", "(", "sprintf", "(", "'The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::setStream() instead.'", ",", "__METHOD__", ",", "StreamableInputInterface", "::", "class", ")", ",", "E_USER_DEPRECATED", ")", ";", "if", "(", "!", "is_resource", "(", "$", "stream", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Input stream must be a valid resource.'", ")", ";", "}", "$", "this", "->", "inputStream", "=", "$", "stream", ";", "}" ]
Sets the input stream to read from when interacting with the user. This is mainly useful for testing purpose. @deprecated since version 3.2, to be removed in 4.0. Use StreamableInputInterface::setStream() instead. @param resource $stream The input stream @throws InvalidArgumentException In case the stream is not a resource
[ "Sets", "the", "input", "stream", "to", "read", "from", "when", "interacting", "with", "the", "user", "." ]
9e16b975a3b9403af52e2d1b465a625e8936076c
https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Helper/QuestionHelper.php#L83-L92
238,563
squire-assistant/console
Helper/QuestionHelper.php
QuestionHelper.getInputStream
public function getInputStream() { if (0 === func_num_args() || func_get_arg(0)) { @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); } return $this->inputStream; }
php
public function getInputStream() { if (0 === func_num_args() || func_get_arg(0)) { @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); } return $this->inputStream; }
[ "public", "function", "getInputStream", "(", ")", "{", "if", "(", "0", "===", "func_num_args", "(", ")", "||", "func_get_arg", "(", "0", ")", ")", "{", "@", "trigger_error", "(", "sprintf", "(", "'The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::getStream() instead.'", ",", "__METHOD__", ",", "StreamableInputInterface", "::", "class", ")", ",", "E_USER_DEPRECATED", ")", ";", "}", "return", "$", "this", "->", "inputStream", ";", "}" ]
Returns the helper's input stream. @deprecated since version 3.2, to be removed in 4.0. Use StreamableInputInterface::getStream() instead. @return resource
[ "Returns", "the", "helper", "s", "input", "stream", "." ]
9e16b975a3b9403af52e2d1b465a625e8936076c
https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Helper/QuestionHelper.php#L102-L109
238,564
squire-assistant/console
Helper/QuestionHelper.php
QuestionHelper.getShell
private function getShell() { if (null !== self::$shell) { return self::$shell; } self::$shell = false; if (file_exists('/usr/bin/env')) { // handle other OSs with bash/zsh/ksh/csh if available to hide the answer $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) { if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { self::$shell = $sh; break; } } } return self::$shell; }
php
private function getShell() { if (null !== self::$shell) { return self::$shell; } self::$shell = false; if (file_exists('/usr/bin/env')) { // handle other OSs with bash/zsh/ksh/csh if available to hide the answer $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) { if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { self::$shell = $sh; break; } } } return self::$shell; }
[ "private", "function", "getShell", "(", ")", "{", "if", "(", "null", "!==", "self", "::", "$", "shell", ")", "{", "return", "self", "::", "$", "shell", ";", "}", "self", "::", "$", "shell", "=", "false", ";", "if", "(", "file_exists", "(", "'/usr/bin/env'", ")", ")", "{", "// handle other OSs with bash/zsh/ksh/csh if available to hide the answer", "$", "test", "=", "\"/usr/bin/env %s -c 'echo OK' 2> /dev/null\"", ";", "foreach", "(", "array", "(", "'bash'", ",", "'zsh'", ",", "'ksh'", ",", "'csh'", ")", "as", "$", "sh", ")", "{", "if", "(", "'OK'", "===", "rtrim", "(", "shell_exec", "(", "sprintf", "(", "$", "test", ",", "$", "sh", ")", ")", ")", ")", "{", "self", "::", "$", "shell", "=", "$", "sh", ";", "break", ";", "}", "}", "}", "return", "self", "::", "$", "shell", ";", "}" ]
Returns a valid unix shell. @return string|bool The valid shell name, false in case no valid shell is found
[ "Returns", "a", "valid", "unix", "shell", "." ]
9e16b975a3b9403af52e2d1b465a625e8936076c
https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Helper/QuestionHelper.php#L437-L457
238,565
AmericanCouncils/TranscodingBundle
Console/OutputSubscriber.php
OutputSubscriber.onMessage
public function onMessage(MessageEvent $e) { $formatter = $this->getFormatter(); $adapterKey = $e->getAdapter()->getKey(); $level = $e->getLevel(); $message = $e->getMessage(); $match = '/\r\n?/'; //check if the message has weird formatting before trying to format it (currently a hack to avoid segmentation faults) if (!preg_match($match, $message)) { $msg = sprintf( "%s (%s): %s", $formatter->formatBlock($adapterKey, 'info'), $formatter->formatBlock($level, 'comment'), $message ); } else { $msg = sprintf( "%s (%s): %s", $adapterKey, $level, preg_replace('/\r\n?/', '', $message) ); } $this->getOutput()->writeln($msg); }
php
public function onMessage(MessageEvent $e) { $formatter = $this->getFormatter(); $adapterKey = $e->getAdapter()->getKey(); $level = $e->getLevel(); $message = $e->getMessage(); $match = '/\r\n?/'; //check if the message has weird formatting before trying to format it (currently a hack to avoid segmentation faults) if (!preg_match($match, $message)) { $msg = sprintf( "%s (%s): %s", $formatter->formatBlock($adapterKey, 'info'), $formatter->formatBlock($level, 'comment'), $message ); } else { $msg = sprintf( "%s (%s): %s", $adapterKey, $level, preg_replace('/\r\n?/', '', $message) ); } $this->getOutput()->writeln($msg); }
[ "public", "function", "onMessage", "(", "MessageEvent", "$", "e", ")", "{", "$", "formatter", "=", "$", "this", "->", "getFormatter", "(", ")", ";", "$", "adapterKey", "=", "$", "e", "->", "getAdapter", "(", ")", "->", "getKey", "(", ")", ";", "$", "level", "=", "$", "e", "->", "getLevel", "(", ")", ";", "$", "message", "=", "$", "e", "->", "getMessage", "(", ")", ";", "$", "match", "=", "'/\\r\\n?/'", ";", "//check if the message has weird formatting before trying to format it (currently a hack to avoid segmentation faults)", "if", "(", "!", "preg_match", "(", "$", "match", ",", "$", "message", ")", ")", "{", "$", "msg", "=", "sprintf", "(", "\"%s (%s): %s\"", ",", "$", "formatter", "->", "formatBlock", "(", "$", "adapterKey", ",", "'info'", ")", ",", "$", "formatter", "->", "formatBlock", "(", "$", "level", ",", "'comment'", ")", ",", "$", "message", ")", ";", "}", "else", "{", "$", "msg", "=", "sprintf", "(", "\"%s (%s): %s\"", ",", "$", "adapterKey", ",", "$", "level", ",", "preg_replace", "(", "'/\\r\\n?/'", ",", "''", ",", "$", "message", ")", ")", ";", "}", "$", "this", "->", "getOutput", "(", ")", "->", "writeln", "(", "$", "msg", ")", ";", "}" ]
Write any messages received by an adapter
[ "Write", "any", "messages", "received", "by", "an", "adapter" ]
7131989ffc014221a9a89c6854c8e618eb4fa2e3
https://github.com/AmericanCouncils/TranscodingBundle/blob/7131989ffc014221a9a89c6854c8e618eb4fa2e3/Console/OutputSubscriber.php#L37-L64
238,566
AmericanCouncils/TranscodingBundle
Console/OutputSubscriber.php
OutputSubscriber.onTranscodeStart
public function onTranscodeStart(TranscodeEvent $e) { $inpath = $e->getInputPath(); $presetKey = $e->getPreset(); $formatter = $this->getFormatter(); $msg = sprintf( "Starting transcode of file %s with preset %s ...", $formatter->formatBlock($inpath, 'info'), $formatter->formatBlock($presetKey, 'info') ); $this->getOutput()->writeln($msg); $this->startTime = microtime(true); }
php
public function onTranscodeStart(TranscodeEvent $e) { $inpath = $e->getInputPath(); $presetKey = $e->getPreset(); $formatter = $this->getFormatter(); $msg = sprintf( "Starting transcode of file %s with preset %s ...", $formatter->formatBlock($inpath, 'info'), $formatter->formatBlock($presetKey, 'info') ); $this->getOutput()->writeln($msg); $this->startTime = microtime(true); }
[ "public", "function", "onTranscodeStart", "(", "TranscodeEvent", "$", "e", ")", "{", "$", "inpath", "=", "$", "e", "->", "getInputPath", "(", ")", ";", "$", "presetKey", "=", "$", "e", "->", "getPreset", "(", ")", ";", "$", "formatter", "=", "$", "this", "->", "getFormatter", "(", ")", ";", "$", "msg", "=", "sprintf", "(", "\"Starting transcode of file %s with preset %s ...\"", ",", "$", "formatter", "->", "formatBlock", "(", "$", "inpath", ",", "'info'", ")", ",", "$", "formatter", "->", "formatBlock", "(", "$", "presetKey", ",", "'info'", ")", ")", ";", "$", "this", "->", "getOutput", "(", ")", "->", "writeln", "(", "$", "msg", ")", ";", "$", "this", "->", "startTime", "=", "microtime", "(", "true", ")", ";", "}" ]
Write to output that a process has started.
[ "Write", "to", "output", "that", "a", "process", "has", "started", "." ]
7131989ffc014221a9a89c6854c8e618eb4fa2e3
https://github.com/AmericanCouncils/TranscodingBundle/blob/7131989ffc014221a9a89c6854c8e618eb4fa2e3/Console/OutputSubscriber.php#L69-L83
238,567
AmericanCouncils/TranscodingBundle
Console/OutputSubscriber.php
OutputSubscriber.onTranscodeComplete
public function onTranscodeComplete(TranscodeEvent $e) { $outpath = $e->getOutputPath(); $totalTime = microtime(true) - $this->startTime; $formatter = $this->getFormatter(); $msg = sprintf( "Transcode completed in %s seconds.", $formatter->formatBlock(round($totalTime, 4), 'info') ); $this->getOutput()->writeln($msg); $msg = sprintf( "Created new file %s", $formatter->formatBlock($outpath, 'info') ); $this->getOutput()->writeln($msg); }
php
public function onTranscodeComplete(TranscodeEvent $e) { $outpath = $e->getOutputPath(); $totalTime = microtime(true) - $this->startTime; $formatter = $this->getFormatter(); $msg = sprintf( "Transcode completed in %s seconds.", $formatter->formatBlock(round($totalTime, 4), 'info') ); $this->getOutput()->writeln($msg); $msg = sprintf( "Created new file %s", $formatter->formatBlock($outpath, 'info') ); $this->getOutput()->writeln($msg); }
[ "public", "function", "onTranscodeComplete", "(", "TranscodeEvent", "$", "e", ")", "{", "$", "outpath", "=", "$", "e", "->", "getOutputPath", "(", ")", ";", "$", "totalTime", "=", "microtime", "(", "true", ")", "-", "$", "this", "->", "startTime", ";", "$", "formatter", "=", "$", "this", "->", "getFormatter", "(", ")", ";", "$", "msg", "=", "sprintf", "(", "\"Transcode completed in %s seconds.\"", ",", "$", "formatter", "->", "formatBlock", "(", "round", "(", "$", "totalTime", ",", "4", ")", ",", "'info'", ")", ")", ";", "$", "this", "->", "getOutput", "(", ")", "->", "writeln", "(", "$", "msg", ")", ";", "$", "msg", "=", "sprintf", "(", "\"Created new file %s\"", ",", "$", "formatter", "->", "formatBlock", "(", "$", "outpath", ",", "'info'", ")", ")", ";", "$", "this", "->", "getOutput", "(", ")", "->", "writeln", "(", "$", "msg", ")", ";", "}" ]
Write to output that a process has completed.
[ "Write", "to", "output", "that", "a", "process", "has", "completed", "." ]
7131989ffc014221a9a89c6854c8e618eb4fa2e3
https://github.com/AmericanCouncils/TranscodingBundle/blob/7131989ffc014221a9a89c6854c8e618eb4fa2e3/Console/OutputSubscriber.php#L88-L105
238,568
AmericanCouncils/TranscodingBundle
Console/OutputSubscriber.php
OutputSubscriber.onTranscodeFailure
public function onTranscodeFailure(TranscodeEvent $e) { $inpath = $e->getInputPath(); $errorMsg = $e->getException()->getMessage(); $formatter = $this->getFormatter(); $msg = sprintf( "Transcode of %s failed! Message: %s", $formatter->formatBlock($inpath, 'info'), $formatter->formatBlock($errorMsg, 'error') ); $this->getOutput()->writeln($msg); }
php
public function onTranscodeFailure(TranscodeEvent $e) { $inpath = $e->getInputPath(); $errorMsg = $e->getException()->getMessage(); $formatter = $this->getFormatter(); $msg = sprintf( "Transcode of %s failed! Message: %s", $formatter->formatBlock($inpath, 'info'), $formatter->formatBlock($errorMsg, 'error') ); $this->getOutput()->writeln($msg); }
[ "public", "function", "onTranscodeFailure", "(", "TranscodeEvent", "$", "e", ")", "{", "$", "inpath", "=", "$", "e", "->", "getInputPath", "(", ")", ";", "$", "errorMsg", "=", "$", "e", "->", "getException", "(", ")", "->", "getMessage", "(", ")", ";", "$", "formatter", "=", "$", "this", "->", "getFormatter", "(", ")", ";", "$", "msg", "=", "sprintf", "(", "\"Transcode of %s failed! Message: %s\"", ",", "$", "formatter", "->", "formatBlock", "(", "$", "inpath", ",", "'info'", ")", ",", "$", "formatter", "->", "formatBlock", "(", "$", "errorMsg", ",", "'error'", ")", ")", ";", "$", "this", "->", "getOutput", "(", ")", "->", "writeln", "(", "$", "msg", ")", ";", "}" ]
Write to output that a process has failed.
[ "Write", "to", "output", "that", "a", "process", "has", "failed", "." ]
7131989ffc014221a9a89c6854c8e618eb4fa2e3
https://github.com/AmericanCouncils/TranscodingBundle/blob/7131989ffc014221a9a89c6854c8e618eb4fa2e3/Console/OutputSubscriber.php#L110-L123
238,569
crater-framework/crater-php-framework
Migration.php
Migration.newMigration
public function newMigration($name) { $time = time(); $date = date("n/j/Y"); $fileName = "{$time}_migration.php"; if ($name) $fileName = "{$time}_{$name}.php"; $file = $this->storagePath . "/" . $fileName; $class = 'Migration_' . ((int)$time); $contents = array('<?php'); $contents[] = '/*'; $contents[] = " * {$name} migration file"; $contents[] = ' *'; $contents[] = ' * @author '; $contents[] = ' * @version 1.0'; $contents[] = " * @date $date"; $contents[] = ' */'; $contents[] = 'class ' . $class . ' extends \Core\Migration'; $contents[] = '{'; $contents[] = ''; $contents[] = " public function up()"; $contents[] = " {"; $contents[] = ""; $contents[] = " }"; $contents[] = ""; $contents[] = " public function down()"; $contents[] = " {"; $contents[] = ""; $contents[] = " }"; $contents[] = '}'; if (file_put_contents($file, implode("\n", $contents))) { echo 'Create ' . $file . "\n\r"; return $file; } return false; }
php
public function newMigration($name) { $time = time(); $date = date("n/j/Y"); $fileName = "{$time}_migration.php"; if ($name) $fileName = "{$time}_{$name}.php"; $file = $this->storagePath . "/" . $fileName; $class = 'Migration_' . ((int)$time); $contents = array('<?php'); $contents[] = '/*'; $contents[] = " * {$name} migration file"; $contents[] = ' *'; $contents[] = ' * @author '; $contents[] = ' * @version 1.0'; $contents[] = " * @date $date"; $contents[] = ' */'; $contents[] = 'class ' . $class . ' extends \Core\Migration'; $contents[] = '{'; $contents[] = ''; $contents[] = " public function up()"; $contents[] = " {"; $contents[] = ""; $contents[] = " }"; $contents[] = ""; $contents[] = " public function down()"; $contents[] = " {"; $contents[] = ""; $contents[] = " }"; $contents[] = '}'; if (file_put_contents($file, implode("\n", $contents))) { echo 'Create ' . $file . "\n\r"; return $file; } return false; }
[ "public", "function", "newMigration", "(", "$", "name", ")", "{", "$", "time", "=", "time", "(", ")", ";", "$", "date", "=", "date", "(", "\"n/j/Y\"", ")", ";", "$", "fileName", "=", "\"{$time}_migration.php\"", ";", "if", "(", "$", "name", ")", "$", "fileName", "=", "\"{$time}_{$name}.php\"", ";", "$", "file", "=", "$", "this", "->", "storagePath", ".", "\"/\"", ".", "$", "fileName", ";", "$", "class", "=", "'Migration_'", ".", "(", "(", "int", ")", "$", "time", ")", ";", "$", "contents", "=", "array", "(", "'<?php'", ")", ";", "$", "contents", "[", "]", "=", "'/*'", ";", "$", "contents", "[", "]", "=", "\" * {$name} migration file\"", ";", "$", "contents", "[", "]", "=", "' *'", ";", "$", "contents", "[", "]", "=", "' * @author '", ";", "$", "contents", "[", "]", "=", "' * @version 1.0'", ";", "$", "contents", "[", "]", "=", "\" * @date $date\"", ";", "$", "contents", "[", "]", "=", "' */'", ";", "$", "contents", "[", "]", "=", "'class '", ".", "$", "class", ".", "' extends \\Core\\Migration'", ";", "$", "contents", "[", "]", "=", "'{'", ";", "$", "contents", "[", "]", "=", "''", ";", "$", "contents", "[", "]", "=", "\" public function up()\"", ";", "$", "contents", "[", "]", "=", "\" {\"", ";", "$", "contents", "[", "]", "=", "\"\"", ";", "$", "contents", "[", "]", "=", "\" }\"", ";", "$", "contents", "[", "]", "=", "\"\"", ";", "$", "contents", "[", "]", "=", "\" public function down()\"", ";", "$", "contents", "[", "]", "=", "\" {\"", ";", "$", "contents", "[", "]", "=", "\"\"", ";", "$", "contents", "[", "]", "=", "\" }\"", ";", "$", "contents", "[", "]", "=", "'}'", ";", "if", "(", "file_put_contents", "(", "$", "file", ",", "implode", "(", "\"\\n\"", ",", "$", "contents", ")", ")", ")", "{", "echo", "'Create '", ".", "$", "file", ".", "\"\\n\\r\"", ";", "return", "$", "file", ";", "}", "return", "false", ";", "}" ]
Create new migration file @param string $name Name of migration file @return bool|string
[ "Create", "new", "migration", "file" ]
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Migration.php#L22-L59
238,570
crater-framework/crater-php-framework
Migration.php
Migration.createTable
public function createTable($name, $data) { $q = "CREATE TABLE {$name} ("; foreach ($data as $key => $v) { $q .= $key; if (isset($v['type'])) { $q .= " {$v['type']}"; if (isset($v['length'])) { $q .= "({$v['length']})"; } else { if ($v['type'] != 'int' && $v['type'] != 'datetime') { die ("Please set length for table: {$name} - column: {$key}"); } } if (isset($v['unsigned']) && $v['unsigned'] == true) { $q .= " UNSIGNED"; } if (!isset($v['null']) || $v['null'] == false) { $q .= " NOT NULL"; } if (isset($v['default'])) { if (is_string($v['default'])) { $v['default'] = "'{$v['default']}'"; } $q .= " DEFAULT {$v['default']}"; } if (isset($v['ai']) && $v['ai'] == true) { $q .= " AUTO_INCREMENT"; } if ((isset($v['unique']) && $v['unique'] == true) && (isset($v['primary']) && $v['primary'] == true)) { die ("Unique or Primary?"); } if (isset($v['unique']) && $v['unique'] == true) { $q .= " UNIQUE"; } if (isset($v['primary']) && $v['primary'] == true) { $q .= " PRIMARY KEY"; } if (isset($v['foreign']) && isset($v['foreign']['table']) && isset($v['foreign']['column'])) { $q .= " ,FOREIGN KEY ({$key}) REFERENCES {$v['foreign']['table']}({$v['foreign']['column']})"; if (isset($v['foreign']['delete']) && $v['foreign']['delete'] == true) { $q .= " ON DELETE CASCADE"; } if (isset($v['foreign']['update']) && $v['foreign']['update'] == true) { $q .= " ON UPDATE CASCADE"; } } $q .= ", "; } else { die ("Please set type of column "); } } $q = substr($q, 0, -2); $q .= ")"; return $this->executeQuery($q); }
php
public function createTable($name, $data) { $q = "CREATE TABLE {$name} ("; foreach ($data as $key => $v) { $q .= $key; if (isset($v['type'])) { $q .= " {$v['type']}"; if (isset($v['length'])) { $q .= "({$v['length']})"; } else { if ($v['type'] != 'int' && $v['type'] != 'datetime') { die ("Please set length for table: {$name} - column: {$key}"); } } if (isset($v['unsigned']) && $v['unsigned'] == true) { $q .= " UNSIGNED"; } if (!isset($v['null']) || $v['null'] == false) { $q .= " NOT NULL"; } if (isset($v['default'])) { if (is_string($v['default'])) { $v['default'] = "'{$v['default']}'"; } $q .= " DEFAULT {$v['default']}"; } if (isset($v['ai']) && $v['ai'] == true) { $q .= " AUTO_INCREMENT"; } if ((isset($v['unique']) && $v['unique'] == true) && (isset($v['primary']) && $v['primary'] == true)) { die ("Unique or Primary?"); } if (isset($v['unique']) && $v['unique'] == true) { $q .= " UNIQUE"; } if (isset($v['primary']) && $v['primary'] == true) { $q .= " PRIMARY KEY"; } if (isset($v['foreign']) && isset($v['foreign']['table']) && isset($v['foreign']['column'])) { $q .= " ,FOREIGN KEY ({$key}) REFERENCES {$v['foreign']['table']}({$v['foreign']['column']})"; if (isset($v['foreign']['delete']) && $v['foreign']['delete'] == true) { $q .= " ON DELETE CASCADE"; } if (isset($v['foreign']['update']) && $v['foreign']['update'] == true) { $q .= " ON UPDATE CASCADE"; } } $q .= ", "; } else { die ("Please set type of column "); } } $q = substr($q, 0, -2); $q .= ")"; return $this->executeQuery($q); }
[ "public", "function", "createTable", "(", "$", "name", ",", "$", "data", ")", "{", "$", "q", "=", "\"CREATE TABLE {$name} (\"", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "v", ")", "{", "$", "q", ".=", "$", "key", ";", "if", "(", "isset", "(", "$", "v", "[", "'type'", "]", ")", ")", "{", "$", "q", ".=", "\" {$v['type']}\"", ";", "if", "(", "isset", "(", "$", "v", "[", "'length'", "]", ")", ")", "{", "$", "q", ".=", "\"({$v['length']})\"", ";", "}", "else", "{", "if", "(", "$", "v", "[", "'type'", "]", "!=", "'int'", "&&", "$", "v", "[", "'type'", "]", "!=", "'datetime'", ")", "{", "die", "(", "\"Please set length for table: {$name} - column: {$key}\"", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "v", "[", "'unsigned'", "]", ")", "&&", "$", "v", "[", "'unsigned'", "]", "==", "true", ")", "{", "$", "q", ".=", "\" UNSIGNED\"", ";", "}", "if", "(", "!", "isset", "(", "$", "v", "[", "'null'", "]", ")", "||", "$", "v", "[", "'null'", "]", "==", "false", ")", "{", "$", "q", ".=", "\" NOT NULL\"", ";", "}", "if", "(", "isset", "(", "$", "v", "[", "'default'", "]", ")", ")", "{", "if", "(", "is_string", "(", "$", "v", "[", "'default'", "]", ")", ")", "{", "$", "v", "[", "'default'", "]", "=", "\"'{$v['default']}'\"", ";", "}", "$", "q", ".=", "\" DEFAULT {$v['default']}\"", ";", "}", "if", "(", "isset", "(", "$", "v", "[", "'ai'", "]", ")", "&&", "$", "v", "[", "'ai'", "]", "==", "true", ")", "{", "$", "q", ".=", "\" AUTO_INCREMENT\"", ";", "}", "if", "(", "(", "isset", "(", "$", "v", "[", "'unique'", "]", ")", "&&", "$", "v", "[", "'unique'", "]", "==", "true", ")", "&&", "(", "isset", "(", "$", "v", "[", "'primary'", "]", ")", "&&", "$", "v", "[", "'primary'", "]", "==", "true", ")", ")", "{", "die", "(", "\"Unique or Primary?\"", ")", ";", "}", "if", "(", "isset", "(", "$", "v", "[", "'unique'", "]", ")", "&&", "$", "v", "[", "'unique'", "]", "==", "true", ")", "{", "$", "q", ".=", "\" UNIQUE\"", ";", "}", "if", "(", "isset", "(", "$", "v", "[", "'primary'", "]", ")", "&&", "$", "v", "[", "'primary'", "]", "==", "true", ")", "{", "$", "q", ".=", "\" PRIMARY KEY\"", ";", "}", "if", "(", "isset", "(", "$", "v", "[", "'foreign'", "]", ")", "&&", "isset", "(", "$", "v", "[", "'foreign'", "]", "[", "'table'", "]", ")", "&&", "isset", "(", "$", "v", "[", "'foreign'", "]", "[", "'column'", "]", ")", ")", "{", "$", "q", ".=", "\" ,FOREIGN KEY ({$key}) REFERENCES {$v['foreign']['table']}({$v['foreign']['column']})\"", ";", "if", "(", "isset", "(", "$", "v", "[", "'foreign'", "]", "[", "'delete'", "]", ")", "&&", "$", "v", "[", "'foreign'", "]", "[", "'delete'", "]", "==", "true", ")", "{", "$", "q", ".=", "\" ON DELETE CASCADE\"", ";", "}", "if", "(", "isset", "(", "$", "v", "[", "'foreign'", "]", "[", "'update'", "]", ")", "&&", "$", "v", "[", "'foreign'", "]", "[", "'update'", "]", "==", "true", ")", "{", "$", "q", ".=", "\" ON UPDATE CASCADE\"", ";", "}", "}", "$", "q", ".=", "\", \"", ";", "}", "else", "{", "die", "(", "\"Please set type of column \"", ")", ";", "}", "}", "$", "q", "=", "substr", "(", "$", "q", ",", "0", ",", "-", "2", ")", ";", "$", "q", ".=", "\")\"", ";", "return", "$", "this", "->", "executeQuery", "(", "$", "q", ")", ";", "}" ]
Create new table @param string $name Name of table @param array $data Array with table definition @return bool
[ "Create", "new", "table" ]
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Migration.php#L68-L139
238,571
bariew/yii2-notice-cms-module
models/EmailConfig.php
EmailConfig.createEventConfig
public static function createEventConfig(Event $event) { if ($event->sender->handler_class != Item::className() || $event->sender->handler_method != Item::HANDLER_METHOD ) { return false; } $model = new self([ 'title' => 'new config', 'content' => 'new content', 'subject' => 'new subject', 'owner_name' => $event->sender->trigger_class, 'owner_event'=> $event->sender->trigger_event, 'address' => 'test@test.com' ]); $model->save(); }
php
public static function createEventConfig(Event $event) { if ($event->sender->handler_class != Item::className() || $event->sender->handler_method != Item::HANDLER_METHOD ) { return false; } $model = new self([ 'title' => 'new config', 'content' => 'new content', 'subject' => 'new subject', 'owner_name' => $event->sender->trigger_class, 'owner_event'=> $event->sender->trigger_event, 'address' => 'test@test.com' ]); $model->save(); }
[ "public", "static", "function", "createEventConfig", "(", "Event", "$", "event", ")", "{", "if", "(", "$", "event", "->", "sender", "->", "handler_class", "!=", "Item", "::", "className", "(", ")", "||", "$", "event", "->", "sender", "->", "handler_method", "!=", "Item", "::", "HANDLER_METHOD", ")", "{", "return", "false", ";", "}", "$", "model", "=", "new", "self", "(", "[", "'title'", "=>", "'new config'", ",", "'content'", "=>", "'new content'", ",", "'subject'", "=>", "'new subject'", ",", "'owner_name'", "=>", "$", "event", "->", "sender", "->", "trigger_class", ",", "'owner_event'", "=>", "$", "event", "->", "sender", "->", "trigger_event", ",", "'address'", "=>", "'test@test.com'", "]", ")", ";", "$", "model", "->", "save", "(", ")", ";", "}" ]
For autocreate config from new event module items. @param Event $event event model new item event. @return bool
[ "For", "autocreate", "config", "from", "new", "event", "module", "items", "." ]
1dc9798b3ed2c511937e9d3e44867412c9f5a7b6
https://github.com/bariew/yii2-notice-cms-module/blob/1dc9798b3ed2c511937e9d3e44867412c9f5a7b6/models/EmailConfig.php#L45-L61
238,572
ironedgesoftware/common-utils
src/Data/DataTrait.php
DataTrait.setData
public function setData(array $data, $replaceTemplateVariables = true) : self { $this->assertDataIsWritable(); if ($replaceTemplateVariables) { $data = $this->replaceTemplateVariables($data); } $this->_data = $data; return $this; }
php
public function setData(array $data, $replaceTemplateVariables = true) : self { $this->assertDataIsWritable(); if ($replaceTemplateVariables) { $data = $this->replaceTemplateVariables($data); } $this->_data = $data; return $this; }
[ "public", "function", "setData", "(", "array", "$", "data", ",", "$", "replaceTemplateVariables", "=", "true", ")", ":", "self", "{", "$", "this", "->", "assertDataIsWritable", "(", ")", ";", "if", "(", "$", "replaceTemplateVariables", ")", "{", "$", "data", "=", "$", "this", "->", "replaceTemplateVariables", "(", "$", "data", ")", ";", "}", "$", "this", "->", "_data", "=", "$", "data", ";", "return", "$", "this", ";", "}" ]
Setter method for field data. @param array $data - data. @param bool $replaceTemplateVariables - Replace template variables? @throws DataIsReadOnlyException - If data is on read-only status. @return $this
[ "Setter", "method", "for", "field", "data", "." ]
1cbe4c77a4abeb17a45250b9b86353457ce6c2b4
https://github.com/ironedgesoftware/common-utils/blob/1cbe4c77a4abeb17a45250b9b86353457ce6c2b4/src/Data/DataTrait.php#L77-L88
238,573
ironedgesoftware/common-utils
src/Data/DataTrait.php
DataTrait.replaceTemplateVariables
public function replaceTemplateVariables($data) { $this->assertDataIsWritable(); if ($templateVariables = $this->getOption('templateVariables', [])) { $templateVariableKeys = array_keys($templateVariables); if (is_string($data)) { $data = str_replace($templateVariableKeys, $templateVariables, $data); } else if (is_array($data)) { array_walk_recursive( $data, function(&$value, &$key, &$data) { $value = str_replace($data['keys'], $data['values'], $value); }, [ 'keys' => $templateVariableKeys, 'values' => $templateVariables ] ); } } return $data; }
php
public function replaceTemplateVariables($data) { $this->assertDataIsWritable(); if ($templateVariables = $this->getOption('templateVariables', [])) { $templateVariableKeys = array_keys($templateVariables); if (is_string($data)) { $data = str_replace($templateVariableKeys, $templateVariables, $data); } else if (is_array($data)) { array_walk_recursive( $data, function(&$value, &$key, &$data) { $value = str_replace($data['keys'], $data['values'], $value); }, [ 'keys' => $templateVariableKeys, 'values' => $templateVariables ] ); } } return $data; }
[ "public", "function", "replaceTemplateVariables", "(", "$", "data", ")", "{", "$", "this", "->", "assertDataIsWritable", "(", ")", ";", "if", "(", "$", "templateVariables", "=", "$", "this", "->", "getOption", "(", "'templateVariables'", ",", "[", "]", ")", ")", "{", "$", "templateVariableKeys", "=", "array_keys", "(", "$", "templateVariables", ")", ";", "if", "(", "is_string", "(", "$", "data", ")", ")", "{", "$", "data", "=", "str_replace", "(", "$", "templateVariableKeys", ",", "$", "templateVariables", ",", "$", "data", ")", ";", "}", "else", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "array_walk_recursive", "(", "$", "data", ",", "function", "(", "&", "$", "value", ",", "&", "$", "key", ",", "&", "$", "data", ")", "{", "$", "value", "=", "str_replace", "(", "$", "data", "[", "'keys'", "]", ",", "$", "data", "[", "'values'", "]", ",", "$", "value", ")", ";", "}", ",", "[", "'keys'", "=>", "$", "templateVariableKeys", ",", "'values'", "=>", "$", "templateVariables", "]", ")", ";", "}", "}", "return", "$", "data", ";", "}" ]
Replaces the data with the template variables configured on this instance. @param string|array $data - Data. @throws DataIsReadOnlyException - If data is on read-only status. @return string|array
[ "Replaces", "the", "data", "with", "the", "template", "variables", "configured", "on", "this", "instance", "." ]
1cbe4c77a4abeb17a45250b9b86353457ce6c2b4
https://github.com/ironedgesoftware/common-utils/blob/1cbe4c77a4abeb17a45250b9b86353457ce6c2b4/src/Data/DataTrait.php#L109-L133
238,574
ironedgesoftware/common-utils
src/Data/DataTrait.php
DataTrait.has
public function has(string $index, array $options = []) : bool { $separator = isset($options['separator']) ? $options['separator'] : $this->getOption('separator', '.'); $value = $this->getData(); $keys = explode($separator, $index); foreach ($keys as $key) { if (!is_array($value) || !array_key_exists($key, $value)) { return false; } $value = $value[$key]; } return true; }
php
public function has(string $index, array $options = []) : bool { $separator = isset($options['separator']) ? $options['separator'] : $this->getOption('separator', '.'); $value = $this->getData(); $keys = explode($separator, $index); foreach ($keys as $key) { if (!is_array($value) || !array_key_exists($key, $value)) { return false; } $value = $value[$key]; } return true; }
[ "public", "function", "has", "(", "string", "$", "index", ",", "array", "$", "options", "=", "[", "]", ")", ":", "bool", "{", "$", "separator", "=", "isset", "(", "$", "options", "[", "'separator'", "]", ")", "?", "$", "options", "[", "'separator'", "]", ":", "$", "this", "->", "getOption", "(", "'separator'", ",", "'.'", ")", ";", "$", "value", "=", "$", "this", "->", "getData", "(", ")", ";", "$", "keys", "=", "explode", "(", "$", "separator", ",", "$", "index", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", "||", "!", "array_key_exists", "(", "$", "key", ",", "$", "value", ")", ")", "{", "return", "false", ";", "}", "$", "value", "=", "$", "value", "[", "$", "key", "]", ";", "}", "return", "true", ";", "}" ]
Returns true if the parameter exists or false otherwise. @param string $index - Index to search for. @param array $options - Options. @return bool
[ "Returns", "true", "if", "the", "parameter", "exists", "or", "false", "otherwise", "." ]
1cbe4c77a4abeb17a45250b9b86353457ce6c2b4
https://github.com/ironedgesoftware/common-utils/blob/1cbe4c77a4abeb17a45250b9b86353457ce6c2b4/src/Data/DataTrait.php#L268-L285
238,575
atorscho/menus
src/LoadMenus.php
LoadMenus.load
public function load() { // Make the $menu variable available to all files $menu = app('menu'); // Include menu files $files = $this->getFiles(); /** @var \SplFileInfo $file */ foreach ($files as $file) { require_once $file->getPath() . '/' . $file->getFilename(); } }
php
public function load() { // Make the $menu variable available to all files $menu = app('menu'); // Include menu files $files = $this->getFiles(); /** @var \SplFileInfo $file */ foreach ($files as $file) { require_once $file->getPath() . '/' . $file->getFilename(); } }
[ "public", "function", "load", "(", ")", "{", "// Make the $menu variable available to all files", "$", "menu", "=", "app", "(", "'menu'", ")", ";", "// Include menu files", "$", "files", "=", "$", "this", "->", "getFiles", "(", ")", ";", "/** @var \\SplFileInfo $file */", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "require_once", "$", "file", "->", "getPath", "(", ")", ".", "'/'", ".", "$", "file", "->", "getFilename", "(", ")", ";", "}", "}" ]
Load menus. @throws DirectoryNotFound @throws MenuFilesNotFound
[ "Load", "menus", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/LoadMenus.php#L33-L45
238,576
atorscho/menus
src/LoadMenus.php
LoadMenus.getPath
protected function getPath(): string { $directory = config('menus.directory'); if (! $directory) { throw new DirectoryNotFound('Directory with menu files does not exist.'); } $path = $this->file->exists(base_path($directory)) ? base_path($directory) : __DIR__ . '/../resources/menus'; return $path; }
php
protected function getPath(): string { $directory = config('menus.directory'); if (! $directory) { throw new DirectoryNotFound('Directory with menu files does not exist.'); } $path = $this->file->exists(base_path($directory)) ? base_path($directory) : __DIR__ . '/../resources/menus'; return $path; }
[ "protected", "function", "getPath", "(", ")", ":", "string", "{", "$", "directory", "=", "config", "(", "'menus.directory'", ")", ";", "if", "(", "!", "$", "directory", ")", "{", "throw", "new", "DirectoryNotFound", "(", "'Directory with menu files does not exist.'", ")", ";", "}", "$", "path", "=", "$", "this", "->", "file", "->", "exists", "(", "base_path", "(", "$", "directory", ")", ")", "?", "base_path", "(", "$", "directory", ")", ":", "__DIR__", ".", "'/../resources/menus'", ";", "return", "$", "path", ";", "}" ]
Get path to the directory with menus files.
[ "Get", "path", "to", "the", "directory", "with", "menus", "files", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/LoadMenus.php#L50-L61
238,577
atorscho/menus
src/LoadMenus.php
LoadMenus.getFiles
protected function getFiles(): array { $path = $this->getPath(); $files = $this->file->allFiles($path); if (! $files) { throw new MenuFilesNotFound("Menu files have not been found in [{$path}]."); } return $files; }
php
protected function getFiles(): array { $path = $this->getPath(); $files = $this->file->allFiles($path); if (! $files) { throw new MenuFilesNotFound("Menu files have not been found in [{$path}]."); } return $files; }
[ "protected", "function", "getFiles", "(", ")", ":", "array", "{", "$", "path", "=", "$", "this", "->", "getPath", "(", ")", ";", "$", "files", "=", "$", "this", "->", "file", "->", "allFiles", "(", "$", "path", ")", ";", "if", "(", "!", "$", "files", ")", "{", "throw", "new", "MenuFilesNotFound", "(", "\"Menu files have not been found in [{$path}].\"", ")", ";", "}", "return", "$", "files", ";", "}" ]
Get menu files from the specified directory.
[ "Get", "menu", "files", "from", "the", "specified", "directory", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/LoadMenus.php#L66-L77
238,578
marando/phpSOFA
src/Marando/IAU/iauTf2d.php
iauTf2d.Tf2d
public static function Tf2d($s, $ihour, $imin, $sec, &$days) { /* Compute the interval. */ $days = ( $s == '-' ? -1.0 : 1.0 ) * ( 60.0 * ( 60.0 * ( (double)abs($ihour) ) + ( (double)abs($imin) ) ) + abs($sec) ) / DAYSEC; /* Validate arguments and return status. */ if ($ihour < 0 || $ihour > 23) return 1; if ($imin < 0 || $imin > 59) return 2; if ($sec < 0.0 || $sec >= 60.0) return 3; return 0; }
php
public static function Tf2d($s, $ihour, $imin, $sec, &$days) { /* Compute the interval. */ $days = ( $s == '-' ? -1.0 : 1.0 ) * ( 60.0 * ( 60.0 * ( (double)abs($ihour) ) + ( (double)abs($imin) ) ) + abs($sec) ) / DAYSEC; /* Validate arguments and return status. */ if ($ihour < 0 || $ihour > 23) return 1; if ($imin < 0 || $imin > 59) return 2; if ($sec < 0.0 || $sec >= 60.0) return 3; return 0; }
[ "public", "static", "function", "Tf2d", "(", "$", "s", ",", "$", "ihour", ",", "$", "imin", ",", "$", "sec", ",", "&", "$", "days", ")", "{", "/* Compute the interval. */", "$", "days", "=", "(", "$", "s", "==", "'-'", "?", "-", "1.0", ":", "1.0", ")", "*", "(", "60.0", "*", "(", "60.0", "*", "(", "(", "double", ")", "abs", "(", "$", "ihour", ")", ")", "+", "(", "(", "double", ")", "abs", "(", "$", "imin", ")", ")", ")", "+", "abs", "(", "$", "sec", ")", ")", "/", "DAYSEC", ";", "/* Validate arguments and return status. */", "if", "(", "$", "ihour", "<", "0", "||", "$", "ihour", ">", "23", ")", "return", "1", ";", "if", "(", "$", "imin", "<", "0", "||", "$", "imin", ">", "59", ")", "return", "2", ";", "if", "(", "$", "sec", "<", "0.0", "||", "$", "sec", ">=", "60.0", ")", "return", "3", ";", "return", "0", ";", "}" ]
- - - - - - - - i a u T f 2 d - - - - - - - - Convert hours, minutes, seconds to days. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: s char sign: '-' = negative, otherwise positive ihour int hours imin int minutes sec double seconds Returned: days double interval in days Returned (function value): int status: 0 = OK 1 = ihour outside range 0-23 2 = imin outside range 0-59 3 = sec outside range 0-59.999... Notes: 1) The result is computed even if any of the range checks fail. 2) Negative ihour, imin and/or sec produce a warning status, but the absolute value is used in the conversion. 3) If there are multiple errors, the status value reflects only the first, the smallest taking precedence. This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "T", "f", "2", "d", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauTf2d.php#L50-L65
238,579
TreasurerPHP/Gateway-Stripe
src/StripeGateway.php
StripeGateway.charge
public function charge(InvoicePayment $payment) { // Make a charge through Stripe try { $charge = Charge::create([ // Multiply by 100 as Stripe charges in pence. 'amount' => $payment->amount * 100, 'currency' => 'gbp', 'description' => 'Invoice payment', 'metadata' => [ 'invoice_id' => $payment->invoice->id ], 'source' => $payment->getPreCommitMetadataArray()['STRIPE_TOKEN'], ]); // Add Stripe payment ID to invoice payment $payment->payment_id = $charge->id; $responseMeta = new InvoicePaymentMetadata(); $responseMeta->key = 'GATEWAY_RESPONSE'; $responseMeta->value = $charge->status; $payment->metadata()->save($responseMeta); $payment->save(); return true; } catch(Card $cardError) { $payment->payment_id = $cardError->getJsonBody()['error']['charge']; $responseMeta = new InvoicePaymentMetadata(); $responseMeta->key = 'GATEWAY_RESPONSE'; $responseMeta->value = $cardError->getMessage(); $payment->metadata()->save($responseMeta); $payment->save(); return false; } }
php
public function charge(InvoicePayment $payment) { // Make a charge through Stripe try { $charge = Charge::create([ // Multiply by 100 as Stripe charges in pence. 'amount' => $payment->amount * 100, 'currency' => 'gbp', 'description' => 'Invoice payment', 'metadata' => [ 'invoice_id' => $payment->invoice->id ], 'source' => $payment->getPreCommitMetadataArray()['STRIPE_TOKEN'], ]); // Add Stripe payment ID to invoice payment $payment->payment_id = $charge->id; $responseMeta = new InvoicePaymentMetadata(); $responseMeta->key = 'GATEWAY_RESPONSE'; $responseMeta->value = $charge->status; $payment->metadata()->save($responseMeta); $payment->save(); return true; } catch(Card $cardError) { $payment->payment_id = $cardError->getJsonBody()['error']['charge']; $responseMeta = new InvoicePaymentMetadata(); $responseMeta->key = 'GATEWAY_RESPONSE'; $responseMeta->value = $cardError->getMessage(); $payment->metadata()->save($responseMeta); $payment->save(); return false; } }
[ "public", "function", "charge", "(", "InvoicePayment", "$", "payment", ")", "{", "// Make a charge through Stripe", "try", "{", "$", "charge", "=", "Charge", "::", "create", "(", "[", "// Multiply by 100 as Stripe charges in pence.", "'amount'", "=>", "$", "payment", "->", "amount", "*", "100", ",", "'currency'", "=>", "'gbp'", ",", "'description'", "=>", "'Invoice payment'", ",", "'metadata'", "=>", "[", "'invoice_id'", "=>", "$", "payment", "->", "invoice", "->", "id", "]", ",", "'source'", "=>", "$", "payment", "->", "getPreCommitMetadataArray", "(", ")", "[", "'STRIPE_TOKEN'", "]", ",", "]", ")", ";", "// Add Stripe payment ID to invoice payment", "$", "payment", "->", "payment_id", "=", "$", "charge", "->", "id", ";", "$", "responseMeta", "=", "new", "InvoicePaymentMetadata", "(", ")", ";", "$", "responseMeta", "->", "key", "=", "'GATEWAY_RESPONSE'", ";", "$", "responseMeta", "->", "value", "=", "$", "charge", "->", "status", ";", "$", "payment", "->", "metadata", "(", ")", "->", "save", "(", "$", "responseMeta", ")", ";", "$", "payment", "->", "save", "(", ")", ";", "return", "true", ";", "}", "catch", "(", "Card", "$", "cardError", ")", "{", "$", "payment", "->", "payment_id", "=", "$", "cardError", "->", "getJsonBody", "(", ")", "[", "'error'", "]", "[", "'charge'", "]", ";", "$", "responseMeta", "=", "new", "InvoicePaymentMetadata", "(", ")", ";", "$", "responseMeta", "->", "key", "=", "'GATEWAY_RESPONSE'", ";", "$", "responseMeta", "->", "value", "=", "$", "cardError", "->", "getMessage", "(", ")", ";", "$", "payment", "->", "metadata", "(", ")", "->", "save", "(", "$", "responseMeta", ")", ";", "$", "payment", "->", "save", "(", ")", ";", "return", "false", ";", "}", "}" ]
Make a charge using Stripe. @param InvoicePayment $payment @return bool Whether or not the charge succeeded
[ "Make", "a", "charge", "using", "Stripe", "." ]
0af657b68956ed3571407643586c1009e7cf4832
https://github.com/TreasurerPHP/Gateway-Stripe/blob/0af657b68956ed3571407643586c1009e7cf4832/src/StripeGateway.php#L34-L72
238,580
hschulz/php-network-stuff
src/IPv4.php
IPv4.parse
protected function parse(): void { switch ($this->notation) { case self::NOTATION_DOT_DECIMAL: $this->fromDotDecimal($this->value); break; case self::NOTATION_BINARY: $this->fromBinary($this->value); break; case self::NOTATION_CIDR_SHORT: $this->fromCidrShort($this->value); break; case self::NOTATION_CIDR_LONG: $this->fromCidrLong($this->value); break; case self::NOTATION_CIDR_BINARY: $this->fromCidrBinary($this->value); break; default: $this->notation = self::NOTATION_INVALID; } }
php
protected function parse(): void { switch ($this->notation) { case self::NOTATION_DOT_DECIMAL: $this->fromDotDecimal($this->value); break; case self::NOTATION_BINARY: $this->fromBinary($this->value); break; case self::NOTATION_CIDR_SHORT: $this->fromCidrShort($this->value); break; case self::NOTATION_CIDR_LONG: $this->fromCidrLong($this->value); break; case self::NOTATION_CIDR_BINARY: $this->fromCidrBinary($this->value); break; default: $this->notation = self::NOTATION_INVALID; } }
[ "protected", "function", "parse", "(", ")", ":", "void", "{", "switch", "(", "$", "this", "->", "notation", ")", "{", "case", "self", "::", "NOTATION_DOT_DECIMAL", ":", "$", "this", "->", "fromDotDecimal", "(", "$", "this", "->", "value", ")", ";", "break", ";", "case", "self", "::", "NOTATION_BINARY", ":", "$", "this", "->", "fromBinary", "(", "$", "this", "->", "value", ")", ";", "break", ";", "case", "self", "::", "NOTATION_CIDR_SHORT", ":", "$", "this", "->", "fromCidrShort", "(", "$", "this", "->", "value", ")", ";", "break", ";", "case", "self", "::", "NOTATION_CIDR_LONG", ":", "$", "this", "->", "fromCidrLong", "(", "$", "this", "->", "value", ")", ";", "break", ";", "case", "self", "::", "NOTATION_CIDR_BINARY", ":", "$", "this", "->", "fromCidrBinary", "(", "$", "this", "->", "value", ")", ";", "break", ";", "default", ":", "$", "this", "->", "notation", "=", "self", "::", "NOTATION_INVALID", ";", "}", "}" ]
Parses the given value into the desired format. @return void
[ "Parses", "the", "given", "value", "into", "the", "desired", "format", "." ]
8d9f60bb5061f7df6ef3afbd1df4966533263d77
https://github.com/hschulz/php-network-stuff/blob/8d9f60bb5061f7df6ef3afbd1df4966533263d77/src/IPv4.php#L119-L146
238,581
hschulz/php-network-stuff
src/IPv4.php
IPv4.isValid
public function isValid(): bool { $segments = explode('.', $this->value, self::NUM_SEGMENTS); if (count($segments) !== self::NUM_SEGMENTS) { return false; } for ($i = 0; $i < self::NUM_SEGMENTS; $i++) { $value = (int) $segments[$i]; if ($value < self::MIN_VALUE || $value > self::MAX_VALUE) { return false; } } return true; }
php
public function isValid(): bool { $segments = explode('.', $this->value, self::NUM_SEGMENTS); if (count($segments) !== self::NUM_SEGMENTS) { return false; } for ($i = 0; $i < self::NUM_SEGMENTS; $i++) { $value = (int) $segments[$i]; if ($value < self::MIN_VALUE || $value > self::MAX_VALUE) { return false; } } return true; }
[ "public", "function", "isValid", "(", ")", ":", "bool", "{", "$", "segments", "=", "explode", "(", "'.'", ",", "$", "this", "->", "value", ",", "self", "::", "NUM_SEGMENTS", ")", ";", "if", "(", "count", "(", "$", "segments", ")", "!==", "self", "::", "NUM_SEGMENTS", ")", "{", "return", "false", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "self", "::", "NUM_SEGMENTS", ";", "$", "i", "++", ")", "{", "$", "value", "=", "(", "int", ")", "$", "segments", "[", "$", "i", "]", ";", "if", "(", "$", "value", "<", "self", "::", "MIN_VALUE", "||", "$", "value", ">", "self", "::", "MAX_VALUE", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Test each segment of the addess to be within the MIN_VALUE and MAX_VALUE. @return bool Returns true if the ip address is valid
[ "Test", "each", "segment", "of", "the", "addess", "to", "be", "within", "the", "MIN_VALUE", "and", "MAX_VALUE", "." ]
8d9f60bb5061f7df6ef3afbd1df4966533263d77
https://github.com/hschulz/php-network-stuff/blob/8d9f60bb5061f7df6ef3afbd1df4966533263d77/src/IPv4.php#L153-L170
238,582
phlexible/phlexible
src/Phlexible/Bundle/ProblemBundle/Entity/Problem.php
Problem.toArray
public function toArray() { return [ 'severity' => $this->severity, 'msg' => $this->msg, 'hint' => $this->hint, 'link' => !empty($this->link) ? $this->link : null, 'iconCls' => $this->iconClass, ]; }
php
public function toArray() { return [ 'severity' => $this->severity, 'msg' => $this->msg, 'hint' => $this->hint, 'link' => !empty($this->link) ? $this->link : null, 'iconCls' => $this->iconClass, ]; }
[ "public", "function", "toArray", "(", ")", "{", "return", "[", "'severity'", "=>", "$", "this", "->", "severity", ",", "'msg'", "=>", "$", "this", "->", "msg", ",", "'hint'", "=>", "$", "this", "->", "hint", ",", "'link'", "=>", "!", "empty", "(", "$", "this", "->", "link", ")", "?", "$", "this", "->", "link", ":", "null", ",", "'iconCls'", "=>", "$", "this", "->", "iconClass", ",", "]", ";", "}" ]
Return array represantation of this problem. @return array
[ "Return", "array", "represantation", "of", "this", "problem", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ProblemBundle/Entity/Problem.php#L321-L330
238,583
phossa2/libs
src/Phossa2/Cache/Extension/ByPass.php
ByPass.byPassCache
public function byPassCache(EventInterface $event)/*# : bool */ { /* @var CachePool $pool */ $pool = $event->getTarget(); if ($this->trigger === '' || isset($_REQUEST[$this->trigger])) { return $pool->setError( Message::get(Message::CACHE_EXT_BYPASS), Message::CACHE_EXT_BYPASS ); } else { return true; } }
php
public function byPassCache(EventInterface $event)/*# : bool */ { /* @var CachePool $pool */ $pool = $event->getTarget(); if ($this->trigger === '' || isset($_REQUEST[$this->trigger])) { return $pool->setError( Message::get(Message::CACHE_EXT_BYPASS), Message::CACHE_EXT_BYPASS ); } else { return true; } }
[ "public", "function", "byPassCache", "(", "EventInterface", "$", "event", ")", "/*# : bool */", "{", "/* @var CachePool $pool */", "$", "pool", "=", "$", "event", "->", "getTarget", "(", ")", ";", "if", "(", "$", "this", "->", "trigger", "===", "''", "||", "isset", "(", "$", "_REQUEST", "[", "$", "this", "->", "trigger", "]", ")", ")", "{", "return", "$", "pool", "->", "setError", "(", "Message", "::", "get", "(", "Message", "::", "CACHE_EXT_BYPASS", ")", ",", "Message", "::", "CACHE_EXT_BYPASS", ")", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Skip the cache 1. $this->trigger = '', always bypass the cache 2. if sees $this->trigger in $_REQUEST, bypass the cache @param EventInterface $event @return bool @access public
[ "Skip", "the", "cache" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/Extension/ByPass.php#L80-L93
238,584
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php
FastPriorityQueue.insert
public function insert($value, $priority) { if (! is_int($priority)) { throw new Exception\InvalidArgumentException('The priority must be an integer'); } $this->values[$priority][] = $value; if (! isset($this->priorities[$priority])) { $this->priorities[$priority] = $priority; $this->maxPriority = max($priority, $this->maxPriority); } ++$this->count; }
php
public function insert($value, $priority) { if (! is_int($priority)) { throw new Exception\InvalidArgumentException('The priority must be an integer'); } $this->values[$priority][] = $value; if (! isset($this->priorities[$priority])) { $this->priorities[$priority] = $priority; $this->maxPriority = max($priority, $this->maxPriority); } ++$this->count; }
[ "public", "function", "insert", "(", "$", "value", ",", "$", "priority", ")", "{", "if", "(", "!", "is_int", "(", "$", "priority", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'The priority must be an integer'", ")", ";", "}", "$", "this", "->", "values", "[", "$", "priority", "]", "[", "]", "=", "$", "value", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "priorities", "[", "$", "priority", "]", ")", ")", "{", "$", "this", "->", "priorities", "[", "$", "priority", "]", "=", "$", "priority", ";", "$", "this", "->", "maxPriority", "=", "max", "(", "$", "priority", ",", "$", "this", "->", "maxPriority", ")", ";", "}", "++", "$", "this", "->", "count", ";", "}" ]
Insert an element in the queue with a specified priority @param mixed $value @param integer $priority a positive integer
[ "Insert", "an", "element", "in", "the", "queue", "with", "a", "specified", "priority" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L91-L102
238,585
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php
FastPriorityQueue.extract
public function extract() { if (! $this->valid()) { return false; } $value = $this->current(); $this->nextAndRemove(); return $value; }
php
public function extract() { if (! $this->valid()) { return false; } $value = $this->current(); $this->nextAndRemove(); return $value; }
[ "public", "function", "extract", "(", ")", "{", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "return", "false", ";", "}", "$", "value", "=", "$", "this", "->", "current", "(", ")", ";", "$", "this", "->", "nextAndRemove", "(", ")", ";", "return", "$", "value", ";", "}" ]
Extract an element in the queue according to the priority and the order of insertion @return mixed
[ "Extract", "an", "element", "in", "the", "queue", "according", "to", "the", "priority", "and", "the", "order", "of", "insertion" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L110-L118
238,586
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php
FastPriorityQueue.current
public function current() { switch ($this->extractFlag) { case self::EXTR_DATA: return current($this->values[$this->maxPriority]); case self::EXTR_PRIORITY: return $this->maxPriority; case self::EXTR_BOTH: return [ 'data' => current($this->values[$this->maxPriority]), 'priority' => $this->maxPriority ]; } }
php
public function current() { switch ($this->extractFlag) { case self::EXTR_DATA: return current($this->values[$this->maxPriority]); case self::EXTR_PRIORITY: return $this->maxPriority; case self::EXTR_BOTH: return [ 'data' => current($this->values[$this->maxPriority]), 'priority' => $this->maxPriority ]; } }
[ "public", "function", "current", "(", ")", "{", "switch", "(", "$", "this", "->", "extractFlag", ")", "{", "case", "self", "::", "EXTR_DATA", ":", "return", "current", "(", "$", "this", "->", "values", "[", "$", "this", "->", "maxPriority", "]", ")", ";", "case", "self", "::", "EXTR_PRIORITY", ":", "return", "$", "this", "->", "maxPriority", ";", "case", "self", "::", "EXTR_BOTH", ":", "return", "[", "'data'", "=>", "current", "(", "$", "this", "->", "values", "[", "$", "this", "->", "maxPriority", "]", ")", ",", "'priority'", "=>", "$", "this", "->", "maxPriority", "]", ";", "}", "}" ]
Get the current element in the queue @return mixed
[ "Get", "the", "current", "element", "in", "the", "queue" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L163-L176
238,587
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php
FastPriorityQueue.nextAndRemove
protected function nextAndRemove() { if (false === next($this->values[$this->maxPriority])) { unset($this->priorities[$this->maxPriority]); unset($this->values[$this->maxPriority]); $this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities); $this->subIndex = -1; } ++$this->index; ++$this->subIndex; --$this->count; }
php
protected function nextAndRemove() { if (false === next($this->values[$this->maxPriority])) { unset($this->priorities[$this->maxPriority]); unset($this->values[$this->maxPriority]); $this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities); $this->subIndex = -1; } ++$this->index; ++$this->subIndex; --$this->count; }
[ "protected", "function", "nextAndRemove", "(", ")", "{", "if", "(", "false", "===", "next", "(", "$", "this", "->", "values", "[", "$", "this", "->", "maxPriority", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "priorities", "[", "$", "this", "->", "maxPriority", "]", ")", ";", "unset", "(", "$", "this", "->", "values", "[", "$", "this", "->", "maxPriority", "]", ")", ";", "$", "this", "->", "maxPriority", "=", "empty", "(", "$", "this", "->", "priorities", ")", "?", "0", ":", "max", "(", "$", "this", "->", "priorities", ")", ";", "$", "this", "->", "subIndex", "=", "-", "1", ";", "}", "++", "$", "this", "->", "index", ";", "++", "$", "this", "->", "subIndex", ";", "--", "$", "this", "->", "count", ";", "}" ]
Set the iterator pointer to the next element in the queue removing the previous element
[ "Set", "the", "iterator", "pointer", "to", "the", "next", "element", "in", "the", "queue", "removing", "the", "previous", "element" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L192-L203
238,588
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php
FastPriorityQueue.next
public function next() { if (false === next($this->values[$this->maxPriority])) { unset($this->subPriorities[$this->maxPriority]); reset($this->values[$this->maxPriority]); $this->maxPriority = empty($this->subPriorities) ? 0 : max($this->subPriorities); $this->subIndex = -1; } ++$this->index; ++$this->subIndex; }
php
public function next() { if (false === next($this->values[$this->maxPriority])) { unset($this->subPriorities[$this->maxPriority]); reset($this->values[$this->maxPriority]); $this->maxPriority = empty($this->subPriorities) ? 0 : max($this->subPriorities); $this->subIndex = -1; } ++$this->index; ++$this->subIndex; }
[ "public", "function", "next", "(", ")", "{", "if", "(", "false", "===", "next", "(", "$", "this", "->", "values", "[", "$", "this", "->", "maxPriority", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "subPriorities", "[", "$", "this", "->", "maxPriority", "]", ")", ";", "reset", "(", "$", "this", "->", "values", "[", "$", "this", "->", "maxPriority", "]", ")", ";", "$", "this", "->", "maxPriority", "=", "empty", "(", "$", "this", "->", "subPriorities", ")", "?", "0", ":", "max", "(", "$", "this", "->", "subPriorities", ")", ";", "$", "this", "->", "subIndex", "=", "-", "1", ";", "}", "++", "$", "this", "->", "index", ";", "++", "$", "this", "->", "subIndex", ";", "}" ]
Set the iterator pointer to the next element in the queue without removing the previous element
[ "Set", "the", "iterator", "pointer", "to", "the", "next", "element", "in", "the", "queue", "without", "removing", "the", "previous", "element" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L209-L219
238,589
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php
FastPriorityQueue.rewind
public function rewind() { $this->subPriorities = $this->priorities; $this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities); $this->index = 0; $this->subIndex = 0; }
php
public function rewind() { $this->subPriorities = $this->priorities; $this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities); $this->index = 0; $this->subIndex = 0; }
[ "public", "function", "rewind", "(", ")", "{", "$", "this", "->", "subPriorities", "=", "$", "this", "->", "priorities", ";", "$", "this", "->", "maxPriority", "=", "empty", "(", "$", "this", "->", "priorities", ")", "?", "0", ":", "max", "(", "$", "this", "->", "priorities", ")", ";", "$", "this", "->", "index", "=", "0", ";", "$", "this", "->", "subIndex", "=", "0", ";", "}" ]
Rewind the current iterator
[ "Rewind", "the", "current", "iterator" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L234-L240
238,590
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php
FastPriorityQueue.setExtractFlags
public function setExtractFlags($flag) { switch ($flag) { case self::EXTR_DATA: case self::EXTR_PRIORITY: case self::EXTR_BOTH: $this->extractFlag = $flag; break; default: throw new Exception\InvalidArgumentException("The extract flag specified is not valid"); } }
php
public function setExtractFlags($flag) { switch ($flag) { case self::EXTR_DATA: case self::EXTR_PRIORITY: case self::EXTR_BOTH: $this->extractFlag = $flag; break; default: throw new Exception\InvalidArgumentException("The extract flag specified is not valid"); } }
[ "public", "function", "setExtractFlags", "(", "$", "flag", ")", "{", "switch", "(", "$", "flag", ")", "{", "case", "self", "::", "EXTR_DATA", ":", "case", "self", "::", "EXTR_PRIORITY", ":", "case", "self", "::", "EXTR_BOTH", ":", "$", "this", "->", "extractFlag", "=", "$", "flag", ";", "break", ";", "default", ":", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "\"The extract flag specified is not valid\"", ")", ";", "}", "}" ]
Set the extract flag @param integer $flag
[ "Set", "the", "extract", "flag" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L294-L305
238,591
phramework/util
src/Request.php
Request.getIPAddress
public static function getIPAddress() { if (isset($_SERVER['HTTP_CLIENT_IP'])) { return $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { ///to check ip is pass from proxy return $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { return $_SERVER['REMOTE_ADDR']; } return null; }
php
public static function getIPAddress() { if (isset($_SERVER['HTTP_CLIENT_IP'])) { return $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { ///to check ip is pass from proxy return $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { return $_SERVER['REMOTE_ADDR']; } return null; }
[ "public", "static", "function", "getIPAddress", "(", ")", "{", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_CLIENT_IP'", "]", ")", ")", "{", "return", "$", "_SERVER", "[", "'HTTP_CLIENT_IP'", "]", ";", "}", "elseif", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ")", ")", "{", "///to check ip is pass from proxy", "return", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ";", "}", "elseif", "(", "isset", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", ")", "{", "return", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "}", "return", "null", ";", "}" ]
Get the ip address of the client @return string|null Returns fails on failure
[ "Get", "the", "ip", "address", "of", "the", "client" ]
09202b9962a9a07e2a31b0c9eff90ece1d6bd3ca
https://github.com/phramework/util/blob/09202b9962a9a07e2a31b0c9eff90ece1d6bd3ca/src/Request.php#L58-L70
238,592
drdplusinfo/drdplus-armourer
DrdPlus/Armourer/Armourer.php
Armourer.getOffensivenessOfWeaponlike
public function getOffensivenessOfWeaponlike(WeaponlikeCode $weaponlikeCode): int { return $this->tables->getWeaponlikeTableByWeaponlikeCode($weaponlikeCode)->getOffensivenessOf($weaponlikeCode); }
php
public function getOffensivenessOfWeaponlike(WeaponlikeCode $weaponlikeCode): int { return $this->tables->getWeaponlikeTableByWeaponlikeCode($weaponlikeCode)->getOffensivenessOf($weaponlikeCode); }
[ "public", "function", "getOffensivenessOfWeaponlike", "(", "WeaponlikeCode", "$", "weaponlikeCode", ")", ":", "int", "{", "return", "$", "this", "->", "tables", "->", "getWeaponlikeTableByWeaponlikeCode", "(", "$", "weaponlikeCode", ")", "->", "getOffensivenessOf", "(", "$", "weaponlikeCode", ")", ";", "}" ]
Even shield can be used as weapon, just quite ineffective. @param WeaponlikeCode $weaponlikeCode @return int @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownWeaponlike
[ "Even", "shield", "can", "be", "used", "as", "weapon", "just", "quite", "ineffective", "." ]
c2b8e2349881d4edb433689c5edba0810a32c6d8
https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L142-L145
238,593
drdplusinfo/drdplus-armourer
DrdPlus/Armourer/Armourer.php
Armourer.canHoldItByTwoHands
public function canHoldItByTwoHands(WeaponlikeCode $weaponToHoldByTwoHands): bool { return // shooting weapons are two-handed (except mini-crossbow), projectiles are not $this->isTwoHandedOnly($weaponToHoldByTwoHands) // the weapon is explicitly two-handed // or it is melee weapon with length at least 1 (see PPH page 92 right column) || ($weaponToHoldByTwoHands->isMelee() && $this->getLengthOfWeaponOrShield($weaponToHoldByTwoHands) >= 1); }
php
public function canHoldItByTwoHands(WeaponlikeCode $weaponToHoldByTwoHands): bool { return // shooting weapons are two-handed (except mini-crossbow), projectiles are not $this->isTwoHandedOnly($weaponToHoldByTwoHands) // the weapon is explicitly two-handed // or it is melee weapon with length at least 1 (see PPH page 92 right column) || ($weaponToHoldByTwoHands->isMelee() && $this->getLengthOfWeaponOrShield($weaponToHoldByTwoHands) >= 1); }
[ "public", "function", "canHoldItByTwoHands", "(", "WeaponlikeCode", "$", "weaponToHoldByTwoHands", ")", ":", "bool", "{", "return", "// shooting weapons are two-handed (except mini-crossbow), projectiles are not", "$", "this", "->", "isTwoHandedOnly", "(", "$", "weaponToHoldByTwoHands", ")", "// the weapon is explicitly two-handed", "// or it is melee weapon with length at least 1 (see PPH page 92 right column)", "||", "(", "$", "weaponToHoldByTwoHands", "->", "isMelee", "(", ")", "&&", "$", "this", "->", "getLengthOfWeaponOrShield", "(", "$", "weaponToHoldByTwoHands", ")", ">=", "1", ")", ";", "}" ]
Not all weapons can be hold by two hands - some of them are simply so small so it is not possible or highly ineffective. @param WeaponlikeCode $weaponToHoldByTwoHands @return bool @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownWeaponlike
[ "Not", "all", "weapons", "can", "be", "hold", "by", "two", "hands", "-", "some", "of", "them", "are", "simply", "so", "small", "so", "it", "is", "not", "possible", "or", "highly", "ineffective", "." ]
c2b8e2349881d4edb433689c5edba0810a32c6d8
https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L201-L208
238,594
drdplusinfo/drdplus-armourer
DrdPlus/Armourer/Armourer.php
Armourer.getMissingStrengthForArmament
public function getMissingStrengthForArmament( ArmamentCode $armamentCode, Strength $currentStrength, Size $bodySize ): int { $requiredStrength = $this->tables->getArmamentsTableByArmamentCode($armamentCode)->getRequiredStrengthOf($armamentCode); if ($requiredStrength === false) { // no strength is required, like for a hand return 0; } $missingStrength = $requiredStrength - $currentStrength->getValue(); if ($armamentCode instanceof ArmorCode) { // only armor weight is related to body size $missingStrength += $bodySize->getValue(); } if ($missingStrength < 0) { // missing strength can not be negative, of course return 0; } return $missingStrength; }
php
public function getMissingStrengthForArmament( ArmamentCode $armamentCode, Strength $currentStrength, Size $bodySize ): int { $requiredStrength = $this->tables->getArmamentsTableByArmamentCode($armamentCode)->getRequiredStrengthOf($armamentCode); if ($requiredStrength === false) { // no strength is required, like for a hand return 0; } $missingStrength = $requiredStrength - $currentStrength->getValue(); if ($armamentCode instanceof ArmorCode) { // only armor weight is related to body size $missingStrength += $bodySize->getValue(); } if ($missingStrength < 0) { // missing strength can not be negative, of course return 0; } return $missingStrength; }
[ "public", "function", "getMissingStrengthForArmament", "(", "ArmamentCode", "$", "armamentCode", ",", "Strength", "$", "currentStrength", ",", "Size", "$", "bodySize", ")", ":", "int", "{", "$", "requiredStrength", "=", "$", "this", "->", "tables", "->", "getArmamentsTableByArmamentCode", "(", "$", "armamentCode", ")", "->", "getRequiredStrengthOf", "(", "$", "armamentCode", ")", ";", "if", "(", "$", "requiredStrength", "===", "false", ")", "{", "// no strength is required, like for a hand", "return", "0", ";", "}", "$", "missingStrength", "=", "$", "requiredStrength", "-", "$", "currentStrength", "->", "getValue", "(", ")", ";", "if", "(", "$", "armamentCode", "instanceof", "ArmorCode", ")", "{", "// only armor weight is related to body size", "$", "missingStrength", "+=", "$", "bodySize", "->", "getValue", "(", ")", ";", "}", "if", "(", "$", "missingStrength", "<", "0", ")", "{", "// missing strength can not be negative, of course", "return", "0", ";", "}", "return", "$", "missingStrength", ";", "}" ]
See PPH page 91, right column @param ArmamentCode $armamentCode @param Size $bodySize @param Strength $currentStrength @return int positive number @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownArmament
[ "See", "PPH", "page", "91", "right", "column" ]
c2b8e2349881d4edb433689c5edba0810a32c6d8
https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L378-L399
238,595
drdplusinfo/drdplus-armourer
DrdPlus/Armourer/Armourer.php
Armourer.getAttackNumberModifierByDistance
public function getAttackNumberModifierByDistance( Distance $targetDistance, EncounterRange $currentEncounterRange, MaximalRange $currentMaximalRange ): int { if ($targetDistance->getBonus()->getValue() > $currentMaximalRange->getValue()) { // comparing distance bonuses in fact throw new DistanceIsOutOfMaximalRange( "Given distance {$targetDistance->getBonus()} ({$targetDistance->getMeters()} meters)" . " is out of maximal range {$currentMaximalRange}" . ' (' . $currentMaximalRange->getInMeters($this->tables) . ' meters)' ); } if ($currentEncounterRange->getValue() > $currentMaximalRange->getValue()) { throw new EncounterRangeCanNotBeGreaterThanMaximalRange( "Got encounter range {$currentEncounterRange} greater than given maximal range {$currentMaximalRange}" ); } $attackNumberModifier = $this->tables->getAttackNumberByContinuousDistanceTable() ->getAttackNumberModifierByDistance($targetDistance); if ($targetDistance->getBonus()->getValue() > $currentEncounterRange->getValue()) { // comparing distance bonuses in fact $attackNumberModifier += $currentEncounterRange->getValue() - $targetDistance->getBonus()->getValue(); // always negative } return $attackNumberModifier; }
php
public function getAttackNumberModifierByDistance( Distance $targetDistance, EncounterRange $currentEncounterRange, MaximalRange $currentMaximalRange ): int { if ($targetDistance->getBonus()->getValue() > $currentMaximalRange->getValue()) { // comparing distance bonuses in fact throw new DistanceIsOutOfMaximalRange( "Given distance {$targetDistance->getBonus()} ({$targetDistance->getMeters()} meters)" . " is out of maximal range {$currentMaximalRange}" . ' (' . $currentMaximalRange->getInMeters($this->tables) . ' meters)' ); } if ($currentEncounterRange->getValue() > $currentMaximalRange->getValue()) { throw new EncounterRangeCanNotBeGreaterThanMaximalRange( "Got encounter range {$currentEncounterRange} greater than given maximal range {$currentMaximalRange}" ); } $attackNumberModifier = $this->tables->getAttackNumberByContinuousDistanceTable() ->getAttackNumberModifierByDistance($targetDistance); if ($targetDistance->getBonus()->getValue() > $currentEncounterRange->getValue()) { // comparing distance bonuses in fact $attackNumberModifier += $currentEncounterRange->getValue() - $targetDistance->getBonus()->getValue(); // always negative } return $attackNumberModifier; }
[ "public", "function", "getAttackNumberModifierByDistance", "(", "Distance", "$", "targetDistance", ",", "EncounterRange", "$", "currentEncounterRange", ",", "MaximalRange", "$", "currentMaximalRange", ")", ":", "int", "{", "if", "(", "$", "targetDistance", "->", "getBonus", "(", ")", "->", "getValue", "(", ")", ">", "$", "currentMaximalRange", "->", "getValue", "(", ")", ")", "{", "// comparing distance bonuses in fact", "throw", "new", "DistanceIsOutOfMaximalRange", "(", "\"Given distance {$targetDistance->getBonus()} ({$targetDistance->getMeters()} meters)\"", ".", "\" is out of maximal range {$currentMaximalRange}\"", ".", "' ('", ".", "$", "currentMaximalRange", "->", "getInMeters", "(", "$", "this", "->", "tables", ")", ".", "' meters)'", ")", ";", "}", "if", "(", "$", "currentEncounterRange", "->", "getValue", "(", ")", ">", "$", "currentMaximalRange", "->", "getValue", "(", ")", ")", "{", "throw", "new", "EncounterRangeCanNotBeGreaterThanMaximalRange", "(", "\"Got encounter range {$currentEncounterRange} greater than given maximal range {$currentMaximalRange}\"", ")", ";", "}", "$", "attackNumberModifier", "=", "$", "this", "->", "tables", "->", "getAttackNumberByContinuousDistanceTable", "(", ")", "->", "getAttackNumberModifierByDistance", "(", "$", "targetDistance", ")", ";", "if", "(", "$", "targetDistance", "->", "getBonus", "(", ")", "->", "getValue", "(", ")", ">", "$", "currentEncounterRange", "->", "getValue", "(", ")", ")", "{", "// comparing distance bonuses in fact", "$", "attackNumberModifier", "+=", "$", "currentEncounterRange", "->", "getValue", "(", ")", "-", "$", "targetDistance", "->", "getBonus", "(", ")", "->", "getValue", "(", ")", ";", "// always negative", "}", "return", "$", "attackNumberModifier", ";", "}" ]
Distance modifier can be solved very roughly by a simple table or more precisely with continual values by a calculation. This uses that calculation. See PPH page 104 left column. @param EncounterRange $currentEncounterRange @param Distance $targetDistance @param MaximalRange $currentMaximalRange @return int @throws \DrdPlus\Tables\Armaments\Exceptions\DistanceIsOutOfMaximalRange @throws \DrdPlus\Tables\Armaments\Exceptions\EncounterRangeCanNotBeGreaterThanMaximalRange @throws \DrdPlus\Tables\Combat\Attacks\Exceptions\DistanceOutOfKnownValues
[ "Distance", "modifier", "can", "be", "solved", "very", "roughly", "by", "a", "simple", "table", "or", "more", "precisely", "with", "continual", "values", "by", "a", "calculation", ".", "This", "uses", "that", "calculation", ".", "See", "PPH", "page", "104", "left", "column", "." ]
c2b8e2349881d4edb433689c5edba0810a32c6d8
https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L455-L480
238,596
drdplusinfo/drdplus-armourer
DrdPlus/Armourer/Armourer.php
Armourer.getLoadingInRoundsByStrengthWithRangedWeapon
public function getLoadingInRoundsByStrengthWithRangedWeapon( RangedWeaponCode $rangedWeaponCode, Strength $currentStrength ): int { return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRounds( $this->getMissingStrengthForArmament($rangedWeaponCode, $currentStrength, Size::getIt(0)) ); }
php
public function getLoadingInRoundsByStrengthWithRangedWeapon( RangedWeaponCode $rangedWeaponCode, Strength $currentStrength ): int { return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRounds( $this->getMissingStrengthForArmament($rangedWeaponCode, $currentStrength, Size::getIt(0)) ); }
[ "public", "function", "getLoadingInRoundsByStrengthWithRangedWeapon", "(", "RangedWeaponCode", "$", "rangedWeaponCode", ",", "Strength", "$", "currentStrength", ")", ":", "int", "{", "return", "$", "this", "->", "tables", "->", "getRangedWeaponStrengthSanctionsTable", "(", ")", "->", "getLoadingInRounds", "(", "$", "this", "->", "getMissingStrengthForArmament", "(", "$", "rangedWeaponCode", ",", "$", "currentStrength", ",", "Size", "::", "getIt", "(", "0", ")", ")", ")", ";", "}" ]
The final number of rounds needed to load a weapon. @param RangedWeaponCode $rangedWeaponCode @param Strength $currentStrength @return int @throws \DrdPlus\Tables\Armaments\Weapons\Exceptions\CanNotUseWeaponBecauseOfMissingStrength
[ "The", "final", "number", "of", "rounds", "needed", "to", "load", "a", "weapon", "." ]
c2b8e2349881d4edb433689c5edba0810a32c6d8
https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L551-L559
238,597
drdplusinfo/drdplus-armourer
DrdPlus/Armourer/Armourer.php
Armourer.getLoadingInRoundsMalusByStrengthWithRangedWeapon
public function getLoadingInRoundsMalusByStrengthWithRangedWeapon( RangedWeaponCode $rangedWeaponCode, Strength $currentStrength ): int { return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRoundsSanction( $this->getMissingStrengthForArmament($rangedWeaponCode, $currentStrength, Size::getIt(0)) ); }
php
public function getLoadingInRoundsMalusByStrengthWithRangedWeapon( RangedWeaponCode $rangedWeaponCode, Strength $currentStrength ): int { return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRoundsSanction( $this->getMissingStrengthForArmament($rangedWeaponCode, $currentStrength, Size::getIt(0)) ); }
[ "public", "function", "getLoadingInRoundsMalusByStrengthWithRangedWeapon", "(", "RangedWeaponCode", "$", "rangedWeaponCode", ",", "Strength", "$", "currentStrength", ")", ":", "int", "{", "return", "$", "this", "->", "tables", "->", "getRangedWeaponStrengthSanctionsTable", "(", ")", "->", "getLoadingInRoundsSanction", "(", "$", "this", "->", "getMissingStrengthForArmament", "(", "$", "rangedWeaponCode", ",", "$", "currentStrength", ",", "Size", "::", "getIt", "(", "0", ")", ")", ")", ";", "}" ]
The relative number of rounds as a malus to standard number of rounds needed to load a weapon. @param RangedWeaponCode $rangedWeaponCode @param Strength $currentStrength @return int @throws \DrdPlus\Tables\Armaments\Weapons\Exceptions\CanNotUseWeaponBecauseOfMissingStrength
[ "The", "relative", "number", "of", "rounds", "as", "a", "malus", "to", "standard", "number", "of", "rounds", "needed", "to", "load", "a", "weapon", "." ]
c2b8e2349881d4edb433689c5edba0810a32c6d8
https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L569-L577
238,598
drdplusinfo/drdplus-armourer
DrdPlus/Armourer/Armourer.php
Armourer.getEncounterRangeWithWeaponlike
public function getEncounterRangeWithWeaponlike( WeaponlikeCode $weaponlikeCode, Strength $currentStrength, Speed $currentSpeed ): EncounterRange { if (!($weaponlikeCode instanceof RangedWeaponCode)) { /** note: melee weapon length in meters is half of weapon length, see PPH page 85 right column */ return EncounterRange::getIt(0); } $encounterRange = $this->getRangeOfRangedWeapon($weaponlikeCode); $encounterRange += $this->getEncounterRangeMalusByStrength($weaponlikeCode, $currentStrength); $encounterRange += $this->getEncounterRangeBonusByStrength($weaponlikeCode, $currentStrength); $encounterRange += $this->getEncounterRangeBonusBySpeed($weaponlikeCode, $currentSpeed); return EncounterRange::getIt($encounterRange); }
php
public function getEncounterRangeWithWeaponlike( WeaponlikeCode $weaponlikeCode, Strength $currentStrength, Speed $currentSpeed ): EncounterRange { if (!($weaponlikeCode instanceof RangedWeaponCode)) { /** note: melee weapon length in meters is half of weapon length, see PPH page 85 right column */ return EncounterRange::getIt(0); } $encounterRange = $this->getRangeOfRangedWeapon($weaponlikeCode); $encounterRange += $this->getEncounterRangeMalusByStrength($weaponlikeCode, $currentStrength); $encounterRange += $this->getEncounterRangeBonusByStrength($weaponlikeCode, $currentStrength); $encounterRange += $this->getEncounterRangeBonusBySpeed($weaponlikeCode, $currentSpeed); return EncounterRange::getIt($encounterRange); }
[ "public", "function", "getEncounterRangeWithWeaponlike", "(", "WeaponlikeCode", "$", "weaponlikeCode", ",", "Strength", "$", "currentStrength", ",", "Speed", "$", "currentSpeed", ")", ":", "EncounterRange", "{", "if", "(", "!", "(", "$", "weaponlikeCode", "instanceof", "RangedWeaponCode", ")", ")", "{", "/** note: melee weapon length in meters is half of weapon length, see PPH page 85 right column */", "return", "EncounterRange", "::", "getIt", "(", "0", ")", ";", "}", "$", "encounterRange", "=", "$", "this", "->", "getRangeOfRangedWeapon", "(", "$", "weaponlikeCode", ")", ";", "$", "encounterRange", "+=", "$", "this", "->", "getEncounterRangeMalusByStrength", "(", "$", "weaponlikeCode", ",", "$", "currentStrength", ")", ";", "$", "encounterRange", "+=", "$", "this", "->", "getEncounterRangeBonusByStrength", "(", "$", "weaponlikeCode", ",", "$", "currentStrength", ")", ";", "$", "encounterRange", "+=", "$", "this", "->", "getEncounterRangeBonusBySpeed", "(", "$", "weaponlikeCode", ",", "$", "currentSpeed", ")", ";", "return", "EncounterRange", "::", "getIt", "(", "$", "encounterRange", ")", ";", "}" ]
Gives bonus to range of a weapon, which can be turned into meters. @param WeaponlikeCode $weaponlikeCode @param Strength $currentStrength @param Speed $currentSpeed @return EncounterRange @throws \DrdPlus\Tables\Armaments\Weapons\Exceptions\CanNotUseWeaponBecauseOfMissingStrength @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownArmament @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownRangedWeapon @throws \DrdPlus\Tables\Armaments\Weapons\Ranged\Exceptions\UnknownBow
[ "Gives", "bonus", "to", "range", "of", "a", "weapon", "which", "can", "be", "turned", "into", "meters", "." ]
c2b8e2349881d4edb433689c5edba0810a32c6d8
https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L591-L607
238,599
drdplusinfo/drdplus-armourer
DrdPlus/Armourer/Armourer.php
Armourer.getProtectiveArmamentRestrictionForSkillRank
public function getProtectiveArmamentRestrictionForSkillRank( ProtectiveArmamentCode $protectiveArmamentCode, PositiveInteger $protectiveArmamentSkillRank ): int { $restriction = $this->getRestrictionOfProtectiveArmament($protectiveArmamentCode) + $this->getProtectiveArmamentRestrictionBonusForSkillRank($protectiveArmamentCode, $protectiveArmamentSkillRank); if ($restriction > 0) { return 0; // can not turn into bonus } return $restriction; }
php
public function getProtectiveArmamentRestrictionForSkillRank( ProtectiveArmamentCode $protectiveArmamentCode, PositiveInteger $protectiveArmamentSkillRank ): int { $restriction = $this->getRestrictionOfProtectiveArmament($protectiveArmamentCode) + $this->getProtectiveArmamentRestrictionBonusForSkillRank($protectiveArmamentCode, $protectiveArmamentSkillRank); if ($restriction > 0) { return 0; // can not turn into bonus } return $restriction; }
[ "public", "function", "getProtectiveArmamentRestrictionForSkillRank", "(", "ProtectiveArmamentCode", "$", "protectiveArmamentCode", ",", "PositiveInteger", "$", "protectiveArmamentSkillRank", ")", ":", "int", "{", "$", "restriction", "=", "$", "this", "->", "getRestrictionOfProtectiveArmament", "(", "$", "protectiveArmamentCode", ")", "+", "$", "this", "->", "getProtectiveArmamentRestrictionBonusForSkillRank", "(", "$", "protectiveArmamentCode", ",", "$", "protectiveArmamentSkillRank", ")", ";", "if", "(", "$", "restriction", ">", "0", ")", "{", "return", "0", ";", "// can not turn into bonus", "}", "return", "$", "restriction", ";", "}" ]
Restriction is Fight number malus. @param ProtectiveArmamentCode $protectiveArmamentCode @param PositiveInteger $protectiveArmamentSkillRank @return int @throws \DrdPlus\Tables\Armaments\Partials\Exceptions\UnexpectedSkillRank @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownProtectiveArmament
[ "Restriction", "is", "Fight", "number", "malus", "." ]
c2b8e2349881d4edb433689c5edba0810a32c6d8
https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L843-L855