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
223,500
wirecard/checkout-client-library
library/WirecardCEE/Stdlib/Basket/Item.php
WirecardCEE_Stdlib_Basket_Item.getImageUrl
public function getImageUrl() { if(array_key_exists(self::ITEM_IMAGE_URL, $this->_itemData)) { return (string) $this->_itemData[self::ITEM_IMAGE_URL]; } return null; }
php
public function getImageUrl() { if(array_key_exists(self::ITEM_IMAGE_URL, $this->_itemData)) { return (string) $this->_itemData[self::ITEM_IMAGE_URL]; } return null; }
[ "public", "function", "getImageUrl", "(", ")", "{", "if", "(", "array_key_exists", "(", "self", "::", "ITEM_IMAGE_URL", ",", "$", "this", "->", "_itemData", ")", ")", "{", "return", "(", "string", ")", "$", "this", "->", "_itemData", "[", "self", "::", "ITEM_IMAGE_URL", "]", ";", "}", "return", "null", ";", "}" ]
Returns the item image url @return string
[ "Returns", "the", "item", "image", "url" ]
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/Basket/Item.php#L254-L260
223,501
wirecard/checkout-client-library
library/WirecardCEE/QMore/DataStorage/Response/Read.php
WirecardCEE_QMore_DataStorage_Response_Read.getPaymentInformation
public function getPaymentInformation($paymentType = null) { $paymentInformation = $this->_getField(self::$PAYMENT_INFORMATION); if (is_array($paymentInformation)) { if (!is_null($paymentType)) { $paymentType = strtoupper($paymentType); foreach ($paymentInformation as $singlePaymentInformation) { if ($singlePaymentInformation['paymentType'] == $paymentType) { return $singlePaymentInformation; } } return Array(); } else { return $paymentInformation; } } else { return Array(); } }
php
public function getPaymentInformation($paymentType = null) { $paymentInformation = $this->_getField(self::$PAYMENT_INFORMATION); if (is_array($paymentInformation)) { if (!is_null($paymentType)) { $paymentType = strtoupper($paymentType); foreach ($paymentInformation as $singlePaymentInformation) { if ($singlePaymentInformation['paymentType'] == $paymentType) { return $singlePaymentInformation; } } return Array(); } else { return $paymentInformation; } } else { return Array(); } }
[ "public", "function", "getPaymentInformation", "(", "$", "paymentType", "=", "null", ")", "{", "$", "paymentInformation", "=", "$", "this", "->", "_getField", "(", "self", "::", "$", "PAYMENT_INFORMATION", ")", ";", "if", "(", "is_array", "(", "$", "paymentInformation", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "paymentType", ")", ")", "{", "$", "paymentType", "=", "strtoupper", "(", "$", "paymentType", ")", ";", "foreach", "(", "$", "paymentInformation", "as", "$", "singlePaymentInformation", ")", "{", "if", "(", "$", "singlePaymentInformation", "[", "'paymentType'", "]", "==", "$", "paymentType", ")", "{", "return", "$", "singlePaymentInformation", ";", "}", "}", "return", "Array", "(", ")", ";", "}", "else", "{", "return", "$", "paymentInformation", ";", "}", "}", "else", "{", "return", "Array", "(", ")", ";", "}", "}" ]
getter for all stored anonymized paymentInformation @param string $paymentType - filter only one paymenttype @return mixed[]
[ "getter", "for", "all", "stored", "anonymized", "paymentInformation" ]
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/QMore/DataStorage/Response/Read.php#L170-L189
223,502
wirecard/checkout-client-library
library/WirecardCEE/Stdlib/ConsumerData.php
WirecardCEE_Stdlib_ConsumerData.setBirthDate
public function setBirthDate(DateTime $birthDate) { $this->_setField(self::$BIRTH_DATE, $birthDate->format(self::$BIRTH_DATE_FORMAT)); return $this; }
php
public function setBirthDate(DateTime $birthDate) { $this->_setField(self::$BIRTH_DATE, $birthDate->format(self::$BIRTH_DATE_FORMAT)); return $this; }
[ "public", "function", "setBirthDate", "(", "DateTime", "$", "birthDate", ")", "{", "$", "this", "->", "_setField", "(", "self", "::", "$", "BIRTH_DATE", ",", "$", "birthDate", "->", "format", "(", "self", "::", "$", "BIRTH_DATE_FORMAT", ")", ")", ";", "return", "$", "this", ";", "}" ]
setter for the birthdate of the consumer @param DateTime $birthDate @return WirecardCEE_Stdlib_ConsumerData
[ "setter", "for", "the", "birthdate", "of", "the", "consumer" ]
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/ConsumerData.php#L146-L151
223,503
wirecard/checkout-client-library
library/WirecardCEE/Stdlib/ConsumerData.php
WirecardCEE_Stdlib_ConsumerData._setField
protected function _setField($name, $value) { // e.g. consumerBillingFirstname $this->_consumerData[self::$PREFIX . $name] = (string) $value; }
php
protected function _setField($name, $value) { // e.g. consumerBillingFirstname $this->_consumerData[self::$PREFIX . $name] = (string) $value; }
[ "protected", "function", "_setField", "(", "$", "name", ",", "$", "value", ")", "{", "// e.g. consumerBillingFirstname", "$", "this", "->", "_consumerData", "[", "self", "::", "$", "PREFIX", ".", "$", "name", "]", "=", "(", "string", ")", "$", "value", ";", "}" ]
setter for consumerdata fields @param string $name @param string $value @access private
[ "setter", "for", "consumerdata", "fields" ]
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/ConsumerData.php#L327-L331
223,504
haridarshan/instagram-php
src/Instagram.php
Instagram.getLoginUrl
public function getLoginUrl(array $parameters) { if ($this->callbackUrl === null) { throw new InstagramException('Missing Callback Url', 400); } if (!isset($parameters['scope'])) { throw new InstagramException('Missing or Invalid Scope permission used', 400); } if (count(array_diff($parameters['scope'], $this->defaultScopes)) !== 0) { throw new InstagramException('Missing or Invalid Scope permission used', 400); } $this->scopes = $parameters['scope']; $loginUrl = new LoginUrl( $this->getApp(), $this->getCallbackUrl(), $this->getState(), $this->scopes ); return $loginUrl->loginUrl(); }
php
public function getLoginUrl(array $parameters) { if ($this->callbackUrl === null) { throw new InstagramException('Missing Callback Url', 400); } if (!isset($parameters['scope'])) { throw new InstagramException('Missing or Invalid Scope permission used', 400); } if (count(array_diff($parameters['scope'], $this->defaultScopes)) !== 0) { throw new InstagramException('Missing or Invalid Scope permission used', 400); } $this->scopes = $parameters['scope']; $loginUrl = new LoginUrl( $this->getApp(), $this->getCallbackUrl(), $this->getState(), $this->scopes ); return $loginUrl->loginUrl(); }
[ "public", "function", "getLoginUrl", "(", "array", "$", "parameters", ")", "{", "if", "(", "$", "this", "->", "callbackUrl", "===", "null", ")", "{", "throw", "new", "InstagramException", "(", "'Missing Callback Url'", ",", "400", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "parameters", "[", "'scope'", "]", ")", ")", "{", "throw", "new", "InstagramException", "(", "'Missing or Invalid Scope permission used'", ",", "400", ")", ";", "}", "if", "(", "count", "(", "array_diff", "(", "$", "parameters", "[", "'scope'", "]", ",", "$", "this", "->", "defaultScopes", ")", ")", "!==", "0", ")", "{", "throw", "new", "InstagramException", "(", "'Missing or Invalid Scope permission used'", ",", "400", ")", ";", "}", "$", "this", "->", "scopes", "=", "$", "parameters", "[", "'scope'", "]", ";", "$", "loginUrl", "=", "new", "LoginUrl", "(", "$", "this", "->", "getApp", "(", ")", ",", "$", "this", "->", "getCallbackUrl", "(", ")", ",", "$", "this", "->", "getState", "(", ")", ",", "$", "this", "->", "scopes", ")", ";", "return", "$", "loginUrl", "->", "loginUrl", "(", ")", ";", "}" ]
Make URLs for user browser navigation @param array $parameters @throws InstagramException @return string
[ "Make", "URLs", "for", "user", "browser", "navigation" ]
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/Instagram.php#L120-L143
223,505
haridarshan/instagram-php
src/Instagram.php
Instagram.oauth
public function oauth($code) { $options = [ 'grant_type' => 'authorization_code', 'client_id' => $this->app->getId(), 'client_secret' => $this->app->getSecret(), 'redirect_uri' => $this->getCallbackUrl(), 'code' => $code, 'state' => $this->state, ]; $response = HelperFactory::getInstance()->request($this->client, Constants::API_TOKEN, $options, 'POST'); $this->oauthResponse = new InstagramOAuth( json_decode($response->getBody()->getContents()) ); return $this->oauthResponse; }
php
public function oauth($code) { $options = [ 'grant_type' => 'authorization_code', 'client_id' => $this->app->getId(), 'client_secret' => $this->app->getSecret(), 'redirect_uri' => $this->getCallbackUrl(), 'code' => $code, 'state' => $this->state, ]; $response = HelperFactory::getInstance()->request($this->client, Constants::API_TOKEN, $options, 'POST'); $this->oauthResponse = new InstagramOAuth( json_decode($response->getBody()->getContents()) ); return $this->oauthResponse; }
[ "public", "function", "oauth", "(", "$", "code", ")", "{", "$", "options", "=", "[", "'grant_type'", "=>", "'authorization_code'", ",", "'client_id'", "=>", "$", "this", "->", "app", "->", "getId", "(", ")", ",", "'client_secret'", "=>", "$", "this", "->", "app", "->", "getSecret", "(", ")", ",", "'redirect_uri'", "=>", "$", "this", "->", "getCallbackUrl", "(", ")", ",", "'code'", "=>", "$", "code", ",", "'state'", "=>", "$", "this", "->", "state", ",", "]", ";", "$", "response", "=", "HelperFactory", "::", "getInstance", "(", ")", "->", "request", "(", "$", "this", "->", "client", ",", "Constants", "::", "API_TOKEN", ",", "$", "options", ",", "'POST'", ")", ";", "$", "this", "->", "oauthResponse", "=", "new", "InstagramOAuth", "(", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ")", ")", ";", "return", "$", "this", "->", "oauthResponse", ";", "}" ]
Get the Oauth Access Token of a user from callback code @param string $code - Oauth2 Code returned with callback url after successfull login @return InstagramOAuth
[ "Get", "the", "Oauth", "Access", "Token", "of", "a", "user", "from", "callback", "code" ]
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/Instagram.php#L152-L170
223,506
haridarshan/instagram-php
src/Instagram.php
Instagram.setAccessToken
public function setAccessToken($token) { if (!$this->oauthResponse instanceof InstagramOAuth) { $this->oauthResponse = new InstagramOAuth(json_decode(json_encode(['access_token' => $token]))); } }
php
public function setAccessToken($token) { if (!$this->oauthResponse instanceof InstagramOAuth) { $this->oauthResponse = new InstagramOAuth(json_decode(json_encode(['access_token' => $token]))); } }
[ "public", "function", "setAccessToken", "(", "$", "token", ")", "{", "if", "(", "!", "$", "this", "->", "oauthResponse", "instanceof", "InstagramOAuth", ")", "{", "$", "this", "->", "oauthResponse", "=", "new", "InstagramOAuth", "(", "json_decode", "(", "json_encode", "(", "[", "'access_token'", "=>", "$", "token", "]", ")", ")", ")", ";", "}", "}" ]
Set User Access Token @param string $token
[ "Set", "User", "Access", "Token" ]
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/Instagram.php#L226-L231
223,507
rymanalu/factory-generator
src/Console/MakeCommand.php
MakeCommand.replaceClassAndNamespace
protected function replaceClassAndNamespace($name, &$stub) { $stub = str_replace( ['DummyClassWithNamespace', 'DummyClass'], [$this->argument('name'), $name], $stub ); return $this; }
php
protected function replaceClassAndNamespace($name, &$stub) { $stub = str_replace( ['DummyClassWithNamespace', 'DummyClass'], [$this->argument('name'), $name], $stub ); return $this; }
[ "protected", "function", "replaceClassAndNamespace", "(", "$", "name", ",", "&", "$", "stub", ")", "{", "$", "stub", "=", "str_replace", "(", "[", "'DummyClassWithNamespace'", ",", "'DummyClass'", "]", ",", "[", "$", "this", "->", "argument", "(", "'name'", ")", ",", "$", "name", "]", ",", "$", "stub", ")", ";", "return", "$", "this", ";", "}" ]
Replace the classname and the namespace for the given stub. @param string $name @param string $stub @return \Rymanalu\FactoryGenerator\Console\MakeCommand
[ "Replace", "the", "classname", "and", "the", "namespace", "for", "the", "given", "stub", "." ]
35cc0d4b0d546087bfdefba22044ee6ad223f2dd
https://github.com/rymanalu/factory-generator/blob/35cc0d4b0d546087bfdefba22044ee6ad223f2dd/src/Console/MakeCommand.php#L82-L91
223,508
rymanalu/factory-generator
src/Console/MakeCommand.php
MakeCommand.replaceFields
protected function replaceFields($name, &$stub) { if (empty($fillable = $this->getFillable())) { return str_replace('fields', '//', $stub); } $fields = 'return ['; foreach ($fillable as $column) { $fields .= PHP_EOL." '{$column}' => \$faker->word,"; } return str_replace('fields', $fields.PHP_EOL.' ];', $stub); }
php
protected function replaceFields($name, &$stub) { if (empty($fillable = $this->getFillable())) { return str_replace('fields', '//', $stub); } $fields = 'return ['; foreach ($fillable as $column) { $fields .= PHP_EOL." '{$column}' => \$faker->word,"; } return str_replace('fields', $fields.PHP_EOL.' ];', $stub); }
[ "protected", "function", "replaceFields", "(", "$", "name", ",", "&", "$", "stub", ")", "{", "if", "(", "empty", "(", "$", "fillable", "=", "$", "this", "->", "getFillable", "(", ")", ")", ")", "{", "return", "str_replace", "(", "'fields'", ",", "'//'", ",", "$", "stub", ")", ";", "}", "$", "fields", "=", "'return ['", ";", "foreach", "(", "$", "fillable", "as", "$", "column", ")", "{", "$", "fields", ".=", "PHP_EOL", ".", "\" '{$column}' => \\$faker->word,\"", ";", "}", "return", "str_replace", "(", "'fields'", ",", "$", "fields", ".", "PHP_EOL", ".", "' ];'", ",", "$", "stub", ")", ";", "}" ]
Replace the fields of the model factory. @param string $name @param string $stub @return string
[ "Replace", "the", "fields", "of", "the", "model", "factory", "." ]
35cc0d4b0d546087bfdefba22044ee6ad223f2dd
https://github.com/rymanalu/factory-generator/blob/35cc0d4b0d546087bfdefba22044ee6ad223f2dd/src/Console/MakeCommand.php#L100-L113
223,509
the-tinderbox/ClickhouseClient
src/Cluster.php
Cluster.addServers
public function addServers(array $servers): self { foreach ($servers as $hostname => $server) { if (!$server instanceof Server && is_array($server)) { $host = $server['host']; $port = $server['port'] ?? null; $database = $server['database'] ?? null; $username = $server['username'] ?? null; $password = $server['password'] ?? null; $options = $server['options'] ?? null; $server = new Server($host, $port, $database, $username, $password, $options); } /* @var Server $server */ if (!is_string($hostname)) { $hostname = $server->getHost(); } $this->addServer($hostname, $server); } return $this; }
php
public function addServers(array $servers): self { foreach ($servers as $hostname => $server) { if (!$server instanceof Server && is_array($server)) { $host = $server['host']; $port = $server['port'] ?? null; $database = $server['database'] ?? null; $username = $server['username'] ?? null; $password = $server['password'] ?? null; $options = $server['options'] ?? null; $server = new Server($host, $port, $database, $username, $password, $options); } /* @var Server $server */ if (!is_string($hostname)) { $hostname = $server->getHost(); } $this->addServer($hostname, $server); } return $this; }
[ "public", "function", "addServers", "(", "array", "$", "servers", ")", ":", "self", "{", "foreach", "(", "$", "servers", "as", "$", "hostname", "=>", "$", "server", ")", "{", "if", "(", "!", "$", "server", "instanceof", "Server", "&&", "is_array", "(", "$", "server", ")", ")", "{", "$", "host", "=", "$", "server", "[", "'host'", "]", ";", "$", "port", "=", "$", "server", "[", "'port'", "]", "??", "null", ";", "$", "database", "=", "$", "server", "[", "'database'", "]", "??", "null", ";", "$", "username", "=", "$", "server", "[", "'username'", "]", "??", "null", ";", "$", "password", "=", "$", "server", "[", "'password'", "]", "??", "null", ";", "$", "options", "=", "$", "server", "[", "'options'", "]", "??", "null", ";", "$", "server", "=", "new", "Server", "(", "$", "host", ",", "$", "port", ",", "$", "database", ",", "$", "username", ",", "$", "password", ",", "$", "options", ")", ";", "}", "/* @var Server $server */", "if", "(", "!", "is_string", "(", "$", "hostname", ")", ")", "{", "$", "hostname", "=", "$", "server", "->", "getHost", "(", ")", ";", "}", "$", "this", "->", "addServer", "(", "$", "hostname", ",", "$", "server", ")", ";", "}", "return", "$", "this", ";", "}" ]
Pushes servers to cluster. @param array $servers Each server can be provided as array or Server instance @throws \Tinderbox\Clickhouse\Exceptions\ClusterException @return \Tinderbox\Clickhouse\Cluster
[ "Pushes", "servers", "to", "cluster", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Cluster.php#L49-L72
223,510
the-tinderbox/ClickhouseClient
src/Cluster.php
Cluster.addServer
public function addServer(string $hostname, Server $server) { if (isset($this->servers[$hostname])) { throw ClusterException::serverHostnameDuplicate($hostname); } $this->servers[$hostname] = $server; }
php
public function addServer(string $hostname, Server $server) { if (isset($this->servers[$hostname])) { throw ClusterException::serverHostnameDuplicate($hostname); } $this->servers[$hostname] = $server; }
[ "public", "function", "addServer", "(", "string", "$", "hostname", ",", "Server", "$", "server", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "servers", "[", "$", "hostname", "]", ")", ")", "{", "throw", "ClusterException", "::", "serverHostnameDuplicate", "(", "$", "hostname", ")", ";", "}", "$", "this", "->", "servers", "[", "$", "hostname", "]", "=", "$", "server", ";", "}" ]
Pushes one server to cluster. @param string $hostname @param \Tinderbox\Clickhouse\Server $server @throws \Tinderbox\Clickhouse\Exceptions\ClusterException
[ "Pushes", "one", "server", "to", "cluster", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Cluster.php#L82-L89
223,511
the-tinderbox/ClickhouseClient
src/Cluster.php
Cluster.getServerByHostname
public function getServerByHostname(string $hostname): Server { if (!isset($this->servers[$hostname])) { throw ClusterException::serverNotFound($hostname); } return $this->servers[$hostname]; }
php
public function getServerByHostname(string $hostname): Server { if (!isset($this->servers[$hostname])) { throw ClusterException::serverNotFound($hostname); } return $this->servers[$hostname]; }
[ "public", "function", "getServerByHostname", "(", "string", "$", "hostname", ")", ":", "Server", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "servers", "[", "$", "hostname", "]", ")", ")", "{", "throw", "ClusterException", "::", "serverNotFound", "(", "$", "hostname", ")", ";", "}", "return", "$", "this", "->", "servers", "[", "$", "hostname", "]", ";", "}" ]
Returns server by specified hostname. @param string $hostname @throws \Tinderbox\Clickhouse\Exceptions\ClusterException @return \Tinderbox\Clickhouse\Server
[ "Returns", "server", "by", "specified", "hostname", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Cluster.php#L110-L117
223,512
infobip/oneapi-php
oneapi/Conversions.php
Conversions.createFromJSON
public static function createFromJSON($className, $json, $isError=false) { if(!$className) { throw new Exception('Invalid className:'.$className); } $model = new $className(); self::fillFromJSON($model, $json, $isError); return $model; }
php
public static function createFromJSON($className, $json, $isError=false) { if(!$className) { throw new Exception('Invalid className:'.$className); } $model = new $className(); self::fillFromJSON($model, $json, $isError); return $model; }
[ "public", "static", "function", "createFromJSON", "(", "$", "className", ",", "$", "json", ",", "$", "isError", "=", "false", ")", "{", "if", "(", "!", "$", "className", ")", "{", "throw", "new", "Exception", "(", "'Invalid className:'", ".", "$", "className", ")", ";", "}", "$", "model", "=", "new", "$", "className", "(", ")", ";", "self", "::", "fillFromJSON", "(", "$", "model", ",", "$", "json", ",", "$", "isError", ")", ";", "return", "$", "model", ";", "}" ]
Create new model instance from JSON.
[ "Create", "new", "model", "instance", "from", "JSON", "." ]
e3eac385eac8bfc51d2b351091e4a9ceb7ee4ed6
https://github.com/infobip/oneapi-php/blob/e3eac385eac8bfc51d2b351091e4a9ceb7ee4ed6/oneapi/Conversions.php#L16-L23
223,513
infobip/oneapi-php
oneapi/Conversions.php
Conversions.fillFromJSON
public static function fillFromJSON($model, $json, $isError=false) { if(is_array($json)) { $array = $json; } else { if (get_magic_quotes_gpc()) { $json = stripslashes($json); } $array = json_decode($json, true); } if(!is_array($array)) $array = array(); if($isError) { $exception = self::createFromJSON('infobip\models\SmsException', $json, false); $model->exception = $exception; return $model; } $conversionRules = Models::getConversionRules(get_class($model)); $className = get_class($model); // Keep original JSON values (for simple string values): foreach($array as $key => $value) { if(property_exists($className, $key) && (is_string($value) || is_numeric($value) || is_bool($value))) { $model->$key = $value; } } // Convert the ones that have custom conversion rules: foreach($conversionRules as $conversionRule) { foreach($array as $key => $value) { if($conversionRule instanceof FieldConversionRule) { // field conversion rule: if(property_exists($className, $key) && $conversionRule->field == $key) { $model->$key = $conversionRule->convertFromJSON($value); } } } } foreach($conversionRules as $conversionRule) { if($conversionRule instanceof ObjectConversionRule) { $conversionRule->convertFromJson($model, $array); } } return $model; }
php
public static function fillFromJSON($model, $json, $isError=false) { if(is_array($json)) { $array = $json; } else { if (get_magic_quotes_gpc()) { $json = stripslashes($json); } $array = json_decode($json, true); } if(!is_array($array)) $array = array(); if($isError) { $exception = self::createFromJSON('infobip\models\SmsException', $json, false); $model->exception = $exception; return $model; } $conversionRules = Models::getConversionRules(get_class($model)); $className = get_class($model); // Keep original JSON values (for simple string values): foreach($array as $key => $value) { if(property_exists($className, $key) && (is_string($value) || is_numeric($value) || is_bool($value))) { $model->$key = $value; } } // Convert the ones that have custom conversion rules: foreach($conversionRules as $conversionRule) { foreach($array as $key => $value) { if($conversionRule instanceof FieldConversionRule) { // field conversion rule: if(property_exists($className, $key) && $conversionRule->field == $key) { $model->$key = $conversionRule->convertFromJSON($value); } } } } foreach($conversionRules as $conversionRule) { if($conversionRule instanceof ObjectConversionRule) { $conversionRule->convertFromJson($model, $array); } } return $model; }
[ "public", "static", "function", "fillFromJSON", "(", "$", "model", ",", "$", "json", ",", "$", "isError", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "json", ")", ")", "{", "$", "array", "=", "$", "json", ";", "}", "else", "{", "if", "(", "get_magic_quotes_gpc", "(", ")", ")", "{", "$", "json", "=", "stripslashes", "(", "$", "json", ")", ";", "}", "$", "array", "=", "json_decode", "(", "$", "json", ",", "true", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "$", "array", "=", "array", "(", ")", ";", "if", "(", "$", "isError", ")", "{", "$", "exception", "=", "self", "::", "createFromJSON", "(", "'infobip\\models\\SmsException'", ",", "$", "json", ",", "false", ")", ";", "$", "model", "->", "exception", "=", "$", "exception", ";", "return", "$", "model", ";", "}", "$", "conversionRules", "=", "Models", "::", "getConversionRules", "(", "get_class", "(", "$", "model", ")", ")", ";", "$", "className", "=", "get_class", "(", "$", "model", ")", ";", "// Keep original JSON values (for simple string values):", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "className", ",", "$", "key", ")", "&&", "(", "is_string", "(", "$", "value", ")", "||", "is_numeric", "(", "$", "value", ")", "||", "is_bool", "(", "$", "value", ")", ")", ")", "{", "$", "model", "->", "$", "key", "=", "$", "value", ";", "}", "}", "// Convert the ones that have custom conversion rules:", "foreach", "(", "$", "conversionRules", "as", "$", "conversionRule", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "conversionRule", "instanceof", "FieldConversionRule", ")", "{", "// field conversion rule:", "if", "(", "property_exists", "(", "$", "className", ",", "$", "key", ")", "&&", "$", "conversionRule", "->", "field", "==", "$", "key", ")", "{", "$", "model", "->", "$", "key", "=", "$", "conversionRule", "->", "convertFromJSON", "(", "$", "value", ")", ";", "}", "}", "}", "}", "foreach", "(", "$", "conversionRules", "as", "$", "conversionRule", ")", "{", "if", "(", "$", "conversionRule", "instanceof", "ObjectConversionRule", ")", "{", "$", "conversionRule", "->", "convertFromJson", "(", "$", "model", ",", "$", "array", ")", ";", "}", "}", "return", "$", "model", ";", "}" ]
Fill existing model instance from JSON.
[ "Fill", "existing", "model", "instance", "from", "JSON", "." ]
e3eac385eac8bfc51d2b351091e4a9ceb7ee4ed6
https://github.com/infobip/oneapi-php/blob/e3eac385eac8bfc51d2b351091e4a9ceb7ee4ed6/oneapi/Conversions.php#L26-L74
223,514
infobip/oneapi-php
oneapi/Conversions.php
Conversions.convertToJSON
public static function convertToJSON($model, $toString=false) { $conversionRules = Models::getConversionRules(get_class($model)); $result = array(); // Keep original simple values: $objectVars = get_object_vars($model); foreach($objectVars as $key => $value) { if(is_string($value) || is_numeric($value)) $result[$key] = $value; } foreach($conversionRules as $conversionRule) { if($conversionRule instanceof FieldConversionRule) { $fieldName = $conversionRule->field; // TODO what if field names in JSON and in model are not the same? $result[$fieldName] = $conversionRule->toJSON($model->$fieldName); } else if($conversionRule instanceof FieldConversionRule) { // TODO } } if($toString) return json_encode($result); return $result; }
php
public static function convertToJSON($model, $toString=false) { $conversionRules = Models::getConversionRules(get_class($model)); $result = array(); // Keep original simple values: $objectVars = get_object_vars($model); foreach($objectVars as $key => $value) { if(is_string($value) || is_numeric($value)) $result[$key] = $value; } foreach($conversionRules as $conversionRule) { if($conversionRule instanceof FieldConversionRule) { $fieldName = $conversionRule->field; // TODO what if field names in JSON and in model are not the same? $result[$fieldName] = $conversionRule->toJSON($model->$fieldName); } else if($conversionRule instanceof FieldConversionRule) { // TODO } } if($toString) return json_encode($result); return $result; }
[ "public", "static", "function", "convertToJSON", "(", "$", "model", ",", "$", "toString", "=", "false", ")", "{", "$", "conversionRules", "=", "Models", "::", "getConversionRules", "(", "get_class", "(", "$", "model", ")", ")", ";", "$", "result", "=", "array", "(", ")", ";", "// Keep original simple values:", "$", "objectVars", "=", "get_object_vars", "(", "$", "model", ")", ";", "foreach", "(", "$", "objectVars", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", "||", "is_numeric", "(", "$", "value", ")", ")", "$", "result", "[", "$", "key", "]", "=", "$", "value", ";", "}", "foreach", "(", "$", "conversionRules", "as", "$", "conversionRule", ")", "{", "if", "(", "$", "conversionRule", "instanceof", "FieldConversionRule", ")", "{", "$", "fieldName", "=", "$", "conversionRule", "->", "field", ";", "// TODO what if field names in JSON and in model are not the same?", "$", "result", "[", "$", "fieldName", "]", "=", "$", "conversionRule", "->", "toJSON", "(", "$", "model", "->", "$", "fieldName", ")", ";", "}", "else", "if", "(", "$", "conversionRule", "instanceof", "FieldConversionRule", ")", "{", "// TODO", "}", "}", "if", "(", "$", "toString", ")", "return", "json_encode", "(", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Convert model to JSON.
[ "Convert", "model", "to", "JSON", "." ]
e3eac385eac8bfc51d2b351091e4a9ceb7ee4ed6
https://github.com/infobip/oneapi-php/blob/e3eac385eac8bfc51d2b351091e4a9ceb7ee4ed6/oneapi/Conversions.php#L77-L101
223,515
updivision/matrix-php-sdk
src/Matrix.php
Matrix.request
public function request($method, $endpoint, array $data = null, array $query = null, $rawData = false) { $options = ['json' => $data]; if ($rawData) { $options = $data; } if (isset($query)) { $options['query'] = $query; } $url = $this->baseUrl . $endpoint; return $this->performRequest($method, $url, $options); }
php
public function request($method, $endpoint, array $data = null, array $query = null, $rawData = false) { $options = ['json' => $data]; if ($rawData) { $options = $data; } if (isset($query)) { $options['query'] = $query; } $url = $this->baseUrl . $endpoint; return $this->performRequest($method, $url, $options); }
[ "public", "function", "request", "(", "$", "method", ",", "$", "endpoint", ",", "array", "$", "data", "=", "null", ",", "array", "$", "query", "=", "null", ",", "$", "rawData", "=", "false", ")", "{", "$", "options", "=", "[", "'json'", "=>", "$", "data", "]", ";", "if", "(", "$", "rawData", ")", "{", "$", "options", "=", "$", "data", ";", "}", "if", "(", "isset", "(", "$", "query", ")", ")", "{", "$", "options", "[", "'query'", "]", "=", "$", "query", ";", "}", "$", "url", "=", "$", "this", "->", "baseUrl", ".", "$", "endpoint", ";", "return", "$", "this", "->", "performRequest", "(", "$", "method", ",", "$", "url", ",", "$", "options", ")", ";", "}" ]
Internal method for handling requests @internal @param $method @param $endpoint @param array|null $data @param array|null $query @return mixed|null @throws ApiException @throws ConflictingStateException @throws RateLimitExceededException @throws UnsupportedContentTypeException
[ "Internal", "method", "for", "handling", "requests" ]
6ce47ffee72e6300c54e473e9d20b174846beb26
https://github.com/updivision/matrix-php-sdk/blob/6ce47ffee72e6300c54e473e9d20b174846beb26/src/Matrix.php#L90-L105
223,516
romka-chev/yii2-swiper
Swiper.php
Swiper.addItem
public function addItem( $item = [ ] ) { $this->items[] = $this->normalizeItem( $item, count( $this->items ) ); return $this; }
php
public function addItem( $item = [ ] ) { $this->items[] = $this->normalizeItem( $item, count( $this->items ) ); return $this; }
[ "public", "function", "addItem", "(", "$", "item", "=", "[", "]", ")", "{", "$", "this", "->", "items", "[", "]", "=", "$", "this", "->", "normalizeItem", "(", "$", "item", ",", "count", "(", "$", "this", "->", "items", ")", ")", ";", "return", "$", "this", ";", "}" ]
If you wants to add an item to collection in runtime, you should use this instead of direct items pushing to collection, because it supports configuring slides from strings and arrays. Also it merges [[\romkaChev\yii2\swiper\Swiper::$itemOptions]] with concrete item options. @param string|mixed[]|Slide $item The content, or configuration, or [[\romkaChev\yii2\swiper\Slide]] itself. @see \romkaChev\yii2\swiper\Swiper::$items @see \romkaChev\yii2\swiper\Slide @return Swiper
[ "If", "you", "wants", "to", "add", "an", "item", "to", "collection", "in", "runtime", "you", "should", "use", "this", "instead", "of", "direct", "items", "pushing", "to", "collection", "because", "it", "supports", "configuring", "slides", "from", "strings", "and", "arrays", "." ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Swiper.php#L355-L360
223,517
romka-chev/yii2-swiper
Swiper.php
Swiper.checkBehaviours
protected function checkBehaviours() { foreach ($this->behaviours as $behaviour) { if ( ! in_array( $behaviour, $this->availableBehaviours )) { throw new \InvalidArgumentException( "Unknown behaviour {$behaviour}" ); } } }
php
protected function checkBehaviours() { foreach ($this->behaviours as $behaviour) { if ( ! in_array( $behaviour, $this->availableBehaviours )) { throw new \InvalidArgumentException( "Unknown behaviour {$behaviour}" ); } } }
[ "protected", "function", "checkBehaviours", "(", ")", "{", "foreach", "(", "$", "this", "->", "behaviours", "as", "$", "behaviour", ")", "{", "if", "(", "!", "in_array", "(", "$", "behaviour", ",", "$", "this", "->", "availableBehaviours", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Unknown behaviour {$behaviour}\"", ")", ";", "}", "}", "}" ]
Checks if there is invalid behaviour given. If given, then throws exception @throws \InvalidArgumentException
[ "Checks", "if", "there", "is", "invalid", "behaviour", "given", ".", "If", "given", "then", "throws", "exception" ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Swiper.php#L553-L560
223,518
romka-chev/yii2-swiper
Swiper.php
Swiper.renderBehaviourParallax
protected function renderBehaviourParallax() { if ( ! in_array( self::BEHAVIOUR_PARALLAX, $this->behaviours )) { return ''; } $parallaxOptions = $this->parallaxOptions; $parallaxTag = ArrayHelper::remove( $parallaxOptions, 'tag', 'div' ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_BACKGROUND ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_TRANSITION ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_TRANSITION_X ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_TRANSITION_Y ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_DURATION ); return Html::tag( $parallaxTag, '', $parallaxOptions ); }
php
protected function renderBehaviourParallax() { if ( ! in_array( self::BEHAVIOUR_PARALLAX, $this->behaviours )) { return ''; } $parallaxOptions = $this->parallaxOptions; $parallaxTag = ArrayHelper::remove( $parallaxOptions, 'tag', 'div' ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_BACKGROUND ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_TRANSITION ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_TRANSITION_X ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_TRANSITION_Y ); ArrayHelper::remove( $parallaxOptions, self::PARALLAX_DURATION ); return Html::tag( $parallaxTag, '', $parallaxOptions ); }
[ "protected", "function", "renderBehaviourParallax", "(", ")", "{", "if", "(", "!", "in_array", "(", "self", "::", "BEHAVIOUR_PARALLAX", ",", "$", "this", "->", "behaviours", ")", ")", "{", "return", "''", ";", "}", "$", "parallaxOptions", "=", "$", "this", "->", "parallaxOptions", ";", "$", "parallaxTag", "=", "ArrayHelper", "::", "remove", "(", "$", "parallaxOptions", ",", "'tag'", ",", "'div'", ")", ";", "ArrayHelper", "::", "remove", "(", "$", "parallaxOptions", ",", "self", "::", "PARALLAX_BACKGROUND", ")", ";", "ArrayHelper", "::", "remove", "(", "$", "parallaxOptions", ",", "self", "::", "PARALLAX_TRANSITION", ")", ";", "ArrayHelper", "::", "remove", "(", "$", "parallaxOptions", ",", "self", "::", "PARALLAX_TRANSITION_X", ")", ";", "ArrayHelper", "::", "remove", "(", "$", "parallaxOptions", ",", "self", "::", "PARALLAX_TRANSITION_Y", ")", ";", "ArrayHelper", "::", "remove", "(", "$", "parallaxOptions", ",", "self", "::", "PARALLAX_DURATION", ")", ";", "return", "Html", "::", "tag", "(", "$", "parallaxTag", ",", "''", ",", "$", "parallaxOptions", ")", ";", "}" ]
This function renders parallax part of widget More information about parallax you can find in official site of plugin - http://www.idangero.us/swiper/api/ Also you can find some examples in [[~/yii2-swiper/demos]] folder @link http://www.idangero.us/swiper/api/ - Parallax section at the bottom @see \romkaChev\yii2\swiper\Swiper::PARALLAX_BACKGROUND @see \romkaChev\yii2\swiper\Swiper::PARALLAX_TRANSITION @see \romkaChev\yii2\swiper\Swiper::PARALLAX_TRANSITION_X @see \romkaChev\yii2\swiper\Swiper::PARALLAX_TRANSITION_Y @see \romkaChev\yii2\swiper\Swiper::PARALLAX_DURATION @see \romkaChev\yii2\swiper\Swiper::$parallaxOptions @return string
[ "This", "function", "renders", "parallax", "part", "of", "widget" ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Swiper.php#L582-L598
223,519
romka-chev/yii2-swiper
Swiper.php
Swiper.renderBehaviourPagination
protected function renderBehaviourPagination() { if (in_array( self::BEHAVIOUR_PAGINATION, $this->behaviours )) { $paginationOptions = $this->paginationOptions; $paginationTag = ArrayHelper::remove( $paginationOptions, 'tag', 'div' ); if ( ! isset( $this->pluginOptions[self::OPTION_PAGINATION] )) { $this->pluginOptions[self::OPTION_PAGINATION] = "#" . $paginationOptions["id"]; } return Html::tag( $paginationTag, '', $paginationOptions ); } return ''; }
php
protected function renderBehaviourPagination() { if (in_array( self::BEHAVIOUR_PAGINATION, $this->behaviours )) { $paginationOptions = $this->paginationOptions; $paginationTag = ArrayHelper::remove( $paginationOptions, 'tag', 'div' ); if ( ! isset( $this->pluginOptions[self::OPTION_PAGINATION] )) { $this->pluginOptions[self::OPTION_PAGINATION] = "#" . $paginationOptions["id"]; } return Html::tag( $paginationTag, '', $paginationOptions ); } return ''; }
[ "protected", "function", "renderBehaviourPagination", "(", ")", "{", "if", "(", "in_array", "(", "self", "::", "BEHAVIOUR_PAGINATION", ",", "$", "this", "->", "behaviours", ")", ")", "{", "$", "paginationOptions", "=", "$", "this", "->", "paginationOptions", ";", "$", "paginationTag", "=", "ArrayHelper", "::", "remove", "(", "$", "paginationOptions", ",", "'tag'", ",", "'div'", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "pluginOptions", "[", "self", "::", "OPTION_PAGINATION", "]", ")", ")", "{", "$", "this", "->", "pluginOptions", "[", "self", "::", "OPTION_PAGINATION", "]", "=", "\"#\"", ".", "$", "paginationOptions", "[", "\"id\"", "]", ";", "}", "return", "Html", "::", "tag", "(", "$", "paginationTag", ",", "''", ",", "$", "paginationOptions", ")", ";", "}", "return", "''", ";", "}" ]
This function renders pagination part of widget More information about pagination you can find in official site of plugin - http://www.idangero.us/swiper/api/ Also you can find some examples in [[~/yii2-swiper/demos]] folder @see \romkaChev\yii2\swiper\Swiper::BEHAVIOUR_PAGINATION @see \romkaChev\yii2\swiper\Swiper::$paginationOptions @see \romkaChev\yii2\swiper\Swiper::renderBehaviourScrollbar @return string
[ "This", "function", "renders", "pagination", "part", "of", "widget" ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Swiper.php#L615-L629
223,520
romka-chev/yii2-swiper
Swiper.php
Swiper.renderBehaviourScrollbar
protected function renderBehaviourScrollbar() { if (in_array( self::BEHAVIOUR_SCROLLBAR, $this->behaviours )) { $scrollbarOptions = $this->scrollbarOptions; $scrollbarTag = ArrayHelper::remove( $scrollbarOptions, 'tag', 'div' ); if ( ! isset( $this->pluginOptions[self::OPTION_SCROLLBAR] )) { $this->pluginOptions[self::OPTION_SCROLLBAR] = "#" . $scrollbarOptions["id"]; } return Html::tag( $scrollbarTag, '', $scrollbarOptions ); } return ''; }
php
protected function renderBehaviourScrollbar() { if (in_array( self::BEHAVIOUR_SCROLLBAR, $this->behaviours )) { $scrollbarOptions = $this->scrollbarOptions; $scrollbarTag = ArrayHelper::remove( $scrollbarOptions, 'tag', 'div' ); if ( ! isset( $this->pluginOptions[self::OPTION_SCROLLBAR] )) { $this->pluginOptions[self::OPTION_SCROLLBAR] = "#" . $scrollbarOptions["id"]; } return Html::tag( $scrollbarTag, '', $scrollbarOptions ); } return ''; }
[ "protected", "function", "renderBehaviourScrollbar", "(", ")", "{", "if", "(", "in_array", "(", "self", "::", "BEHAVIOUR_SCROLLBAR", ",", "$", "this", "->", "behaviours", ")", ")", "{", "$", "scrollbarOptions", "=", "$", "this", "->", "scrollbarOptions", ";", "$", "scrollbarTag", "=", "ArrayHelper", "::", "remove", "(", "$", "scrollbarOptions", ",", "'tag'", ",", "'div'", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "pluginOptions", "[", "self", "::", "OPTION_SCROLLBAR", "]", ")", ")", "{", "$", "this", "->", "pluginOptions", "[", "self", "::", "OPTION_SCROLLBAR", "]", "=", "\"#\"", ".", "$", "scrollbarOptions", "[", "\"id\"", "]", ";", "}", "return", "Html", "::", "tag", "(", "$", "scrollbarTag", ",", "''", ",", "$", "scrollbarOptions", ")", ";", "}", "return", "''", ";", "}" ]
This function renders scrollbar part of widget More information about scrollbar you can find in official site of plugin - http://www.idangero.us/swiper/api/ Also you can find some examples in [[~/yii2-swiper/demos]] folder @see \romkaChev\yii2\swiper\Swiper::BEHAVIOUR_SCROLLBAR @see \romkaChev\yii2\swiper\Swiper::$scrollbarOptions @see \romkaChev\yii2\swiper\Swiper::renderBehaviourPagination @return string
[ "This", "function", "renders", "scrollbar", "part", "of", "widget" ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Swiper.php#L646-L661
223,521
romka-chev/yii2-swiper
Swiper.php
Swiper.renderBehaviourNextButton
protected function renderBehaviourNextButton() { if (in_array( self::BEHAVIOUR_NEXT_BUTTON, $this->behaviours )) { $nextButtonOptions = $this->nextButtonOptions; $nextButtonTag = ArrayHelper::remove( $nextButtonOptions, 'tag', 'div' ); if ( ! isset( $this->pluginOptions[self::OPTION_NEXT_BUTTON] )) { $this->pluginOptions[self::OPTION_NEXT_BUTTON] = "#" . $nextButtonOptions["id"]; } return Html::tag( $nextButtonTag, '', $nextButtonOptions ); } return ''; }
php
protected function renderBehaviourNextButton() { if (in_array( self::BEHAVIOUR_NEXT_BUTTON, $this->behaviours )) { $nextButtonOptions = $this->nextButtonOptions; $nextButtonTag = ArrayHelper::remove( $nextButtonOptions, 'tag', 'div' ); if ( ! isset( $this->pluginOptions[self::OPTION_NEXT_BUTTON] )) { $this->pluginOptions[self::OPTION_NEXT_BUTTON] = "#" . $nextButtonOptions["id"]; } return Html::tag( $nextButtonTag, '', $nextButtonOptions ); } return ''; }
[ "protected", "function", "renderBehaviourNextButton", "(", ")", "{", "if", "(", "in_array", "(", "self", "::", "BEHAVIOUR_NEXT_BUTTON", ",", "$", "this", "->", "behaviours", ")", ")", "{", "$", "nextButtonOptions", "=", "$", "this", "->", "nextButtonOptions", ";", "$", "nextButtonTag", "=", "ArrayHelper", "::", "remove", "(", "$", "nextButtonOptions", ",", "'tag'", ",", "'div'", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "pluginOptions", "[", "self", "::", "OPTION_NEXT_BUTTON", "]", ")", ")", "{", "$", "this", "->", "pluginOptions", "[", "self", "::", "OPTION_NEXT_BUTTON", "]", "=", "\"#\"", ".", "$", "nextButtonOptions", "[", "\"id\"", "]", ";", "}", "return", "Html", "::", "tag", "(", "$", "nextButtonTag", ",", "''", ",", "$", "nextButtonOptions", ")", ";", "}", "return", "''", ";", "}" ]
This function renders nextButton part of widget More information about nextButton you can find in official site of plugin - http://www.idangero.us/swiper/api/ Also you can find some examples in [[~/yii2-swiper/demos]] folder @see \romkaChev\yii2\swiper\Swiper::BEHAVIOUR_NEXT_BUTTON @see \romkaChev\yii2\swiper\Swiper::$nextButtonOptions @see \romkaChev\yii2\swiper\Swiper::renderBehaviourPrevButton @return string
[ "This", "function", "renders", "nextButton", "part", "of", "widget" ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Swiper.php#L678-L693
223,522
romka-chev/yii2-swiper
Swiper.php
Swiper.renderBehaviourPrevButton
protected function renderBehaviourPrevButton() { if (in_array( self::BEHAVIOUR_PREV_BUTTON, $this->behaviours )) { $prevButtonOptions = $this->prevButtonOptions; $prevButtonTag = ArrayHelper::remove( $prevButtonOptions, 'tag', 'div' ); if ( ! isset( $this->pluginOptions[self::OPTION_PREV_BUTTON] )) { $this->pluginOptions[self::OPTION_PREV_BUTTON] = "#" . $prevButtonOptions["id"]; } return Html::tag( $prevButtonTag, '', $prevButtonOptions ); } return ''; }
php
protected function renderBehaviourPrevButton() { if (in_array( self::BEHAVIOUR_PREV_BUTTON, $this->behaviours )) { $prevButtonOptions = $this->prevButtonOptions; $prevButtonTag = ArrayHelper::remove( $prevButtonOptions, 'tag', 'div' ); if ( ! isset( $this->pluginOptions[self::OPTION_PREV_BUTTON] )) { $this->pluginOptions[self::OPTION_PREV_BUTTON] = "#" . $prevButtonOptions["id"]; } return Html::tag( $prevButtonTag, '', $prevButtonOptions ); } return ''; }
[ "protected", "function", "renderBehaviourPrevButton", "(", ")", "{", "if", "(", "in_array", "(", "self", "::", "BEHAVIOUR_PREV_BUTTON", ",", "$", "this", "->", "behaviours", ")", ")", "{", "$", "prevButtonOptions", "=", "$", "this", "->", "prevButtonOptions", ";", "$", "prevButtonTag", "=", "ArrayHelper", "::", "remove", "(", "$", "prevButtonOptions", ",", "'tag'", ",", "'div'", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "pluginOptions", "[", "self", "::", "OPTION_PREV_BUTTON", "]", ")", ")", "{", "$", "this", "->", "pluginOptions", "[", "self", "::", "OPTION_PREV_BUTTON", "]", "=", "\"#\"", ".", "$", "prevButtonOptions", "[", "\"id\"", "]", ";", "}", "return", "Html", "::", "tag", "(", "$", "prevButtonTag", ",", "''", ",", "$", "prevButtonOptions", ")", ";", "}", "return", "''", ";", "}" ]
This function renders prevButton part of widget More information about prevButton you can find in official site of plugin - http://www.idangero.us/swiper/api/ Also you can find some examples in [[~/yii2-swiper/demos]] folder @see \romkaChev\yii2\swiper\Swiper::BEHAVIOUR_PREV_BUTTON @see \romkaChev\yii2\swiper\Swiper::$prevButtonOptions @see \romkaChev\yii2\swiper\Swiper::renderBehaviourNextButton @return string
[ "This", "function", "renders", "prevButton", "part", "of", "widget" ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Swiper.php#L710-L725
223,523
romka-chev/yii2-swiper
Swiper.php
Swiper.renderWrapper
protected function renderWrapper() { $renderedItems = $this->renderItems( $this->items ); $wrapperOptions = $this->wrapperOptions; $wrapperTag = ArrayHelper::remove( $wrapperOptions, 'tag', 'div' ); $renderedWrapper = Html::tag( $wrapperTag, PHP_EOL . $renderedItems . PHP_EOL, $wrapperOptions ); return PHP_EOL . $renderedWrapper . PHP_EOL; }
php
protected function renderWrapper() { $renderedItems = $this->renderItems( $this->items ); $wrapperOptions = $this->wrapperOptions; $wrapperTag = ArrayHelper::remove( $wrapperOptions, 'tag', 'div' ); $renderedWrapper = Html::tag( $wrapperTag, PHP_EOL . $renderedItems . PHP_EOL, $wrapperOptions ); return PHP_EOL . $renderedWrapper . PHP_EOL; }
[ "protected", "function", "renderWrapper", "(", ")", "{", "$", "renderedItems", "=", "$", "this", "->", "renderItems", "(", "$", "this", "->", "items", ")", ";", "$", "wrapperOptions", "=", "$", "this", "->", "wrapperOptions", ";", "$", "wrapperTag", "=", "ArrayHelper", "::", "remove", "(", "$", "wrapperOptions", ",", "'tag'", ",", "'div'", ")", ";", "$", "renderedWrapper", "=", "Html", "::", "tag", "(", "$", "wrapperTag", ",", "PHP_EOL", ".", "$", "renderedItems", ".", "PHP_EOL", ",", "$", "wrapperOptions", ")", ";", "return", "PHP_EOL", ".", "$", "renderedWrapper", ".", "PHP_EOL", ";", "}" ]
This function renders the wrapper tag of swiper, which contains slides @see \romkaChev\yii2\swiper\Swiper::$wrapperOptions @see \romkaChev\yii2\swiper\Swiper::renderItems @return string
[ "This", "function", "renders", "the", "wrapper", "tag", "of", "swiper", "which", "contains", "slides" ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Swiper.php#L757-L766
223,524
romka-chev/yii2-swiper
Swiper.php
Swiper.registerClientScript
protected function registerClientScript() { $view = $this->getView(); SwiperAsset::register( $view ); $id = $this->containerOptions['id']; $pluginOptions = Json::encode( $this->pluginOptions ); $variableName = 'swiper' . Inflector::id2camel( $this->containerOptions['id'] ); $view->registerJs( new JsExpression( <<<JS //noinspection JSUnnecessarySemicolon ;var {$variableName} = new Swiper('#{$id}', {$pluginOptions}); JS ) ); return $this; }
php
protected function registerClientScript() { $view = $this->getView(); SwiperAsset::register( $view ); $id = $this->containerOptions['id']; $pluginOptions = Json::encode( $this->pluginOptions ); $variableName = 'swiper' . Inflector::id2camel( $this->containerOptions['id'] ); $view->registerJs( new JsExpression( <<<JS //noinspection JSUnnecessarySemicolon ;var {$variableName} = new Swiper('#{$id}', {$pluginOptions}); JS ) ); return $this; }
[ "protected", "function", "registerClientScript", "(", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "SwiperAsset", "::", "register", "(", "$", "view", ")", ";", "$", "id", "=", "$", "this", "->", "containerOptions", "[", "'id'", "]", ";", "$", "pluginOptions", "=", "Json", "::", "encode", "(", "$", "this", "->", "pluginOptions", ")", ";", "$", "variableName", "=", "'swiper'", ".", "Inflector", "::", "id2camel", "(", "$", "this", "->", "containerOptions", "[", "'id'", "]", ")", ";", "$", "view", "->", "registerJs", "(", "new", "JsExpression", "(", " <<<JS\n //noinspection JSUnnecessarySemicolon\n ;var {$variableName} = new Swiper('#{$id}', {$pluginOptions});\nJS", ")", ")", ";", "return", "$", "this", ";", "}" ]
Registers the initializer of Swiper plugin @see \romkaChev\yii2\swiper\Swiper::$pluginOptions @return Swiper
[ "Registers", "the", "initializer", "of", "Swiper", "plugin" ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Swiper.php#L809-L826
223,525
NuclearCMS/Documents
src/Media/Media.php
Media.scopeFilteredByType
public function scopeFilteredByType(Builder $query, $type = null) { $type = is_null($type) ? request('f', 'all') : $type; if (in_array($type, ['audio', 'document', 'image', 'video', 'embedded'])) { $query->whereType($type); } return $query; }
php
public function scopeFilteredByType(Builder $query, $type = null) { $type = is_null($type) ? request('f', 'all') : $type; if (in_array($type, ['audio', 'document', 'image', 'video', 'embedded'])) { $query->whereType($type); } return $query; }
[ "public", "function", "scopeFilteredByType", "(", "Builder", "$", "query", ",", "$", "type", "=", "null", ")", "{", "$", "type", "=", "is_null", "(", "$", "type", ")", "?", "request", "(", "'f'", ",", "'all'", ")", ":", "$", "type", ";", "if", "(", "in_array", "(", "$", "type", ",", "[", "'audio'", ",", "'document'", ",", "'image'", ",", "'video'", ",", "'embedded'", "]", ")", ")", "{", "$", "query", "->", "whereType", "(", "$", "type", ")", ";", "}", "return", "$", "query", ";", "}" ]
Scope for request filter @param Builder $query @param string $type @return Builder
[ "Scope", "for", "request", "filter" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Media/Media.php#L141-L151
223,526
NuclearCMS/Documents
src/Media/Media.php
Media.setImageMetadata
protected function setImageMetadata() { $image = ImageFacade::make( $this->getFilePath() ); $this->setMetadata('width', $image->width()); $this->setMetadata('height', $image->height()); }
php
protected function setImageMetadata() { $image = ImageFacade::make( $this->getFilePath() ); $this->setMetadata('width', $image->width()); $this->setMetadata('height', $image->height()); }
[ "protected", "function", "setImageMetadata", "(", ")", "{", "$", "image", "=", "ImageFacade", "::", "make", "(", "$", "this", "->", "getFilePath", "(", ")", ")", ";", "$", "this", "->", "setMetadata", "(", "'width'", ",", "$", "image", "->", "width", "(", ")", ")", ";", "$", "this", "->", "setMetadata", "(", "'height'", ",", "$", "image", "->", "height", "(", ")", ")", ";", "}" ]
Sets the image metadata
[ "Sets", "the", "image", "metadata" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Media/Media.php#L220-L228
223,527
NuclearCMS/Documents
src/Media/Media.php
Media.summarize
public function summarize($json = false) { $attributes = [ 'id' => $this->getKey(), 'name' => $this->getAttribute('name'), 'type' => $this->getAttribute('type'), 'meta' => $this->present()->metaDescription, 'thumbnail' => $this->present()->thumbnail, 'preview' => ($this->type === 'image') ? $this->present()->filteredImageWith('rcompact') : '' ]; foreach ($this->translations as $translation) { $attributes[$translation->locale] = [ 'caption' => $translation->caption, 'description' => $translation->description, 'alttext' => $translation->alttext ]; } return $json ? json_encode($attributes) : $attributes; }
php
public function summarize($json = false) { $attributes = [ 'id' => $this->getKey(), 'name' => $this->getAttribute('name'), 'type' => $this->getAttribute('type'), 'meta' => $this->present()->metaDescription, 'thumbnail' => $this->present()->thumbnail, 'preview' => ($this->type === 'image') ? $this->present()->filteredImageWith('rcompact') : '' ]; foreach ($this->translations as $translation) { $attributes[$translation->locale] = [ 'caption' => $translation->caption, 'description' => $translation->description, 'alttext' => $translation->alttext ]; } return $json ? json_encode($attributes) : $attributes; }
[ "public", "function", "summarize", "(", "$", "json", "=", "false", ")", "{", "$", "attributes", "=", "[", "'id'", "=>", "$", "this", "->", "getKey", "(", ")", ",", "'name'", "=>", "$", "this", "->", "getAttribute", "(", "'name'", ")", ",", "'type'", "=>", "$", "this", "->", "getAttribute", "(", "'type'", ")", ",", "'meta'", "=>", "$", "this", "->", "present", "(", ")", "->", "metaDescription", ",", "'thumbnail'", "=>", "$", "this", "->", "present", "(", ")", "->", "thumbnail", ",", "'preview'", "=>", "(", "$", "this", "->", "type", "===", "'image'", ")", "?", "$", "this", "->", "present", "(", ")", "->", "filteredImageWith", "(", "'rcompact'", ")", ":", "''", "]", ";", "foreach", "(", "$", "this", "->", "translations", "as", "$", "translation", ")", "{", "$", "attributes", "[", "$", "translation", "->", "locale", "]", "=", "[", "'caption'", "=>", "$", "translation", "->", "caption", ",", "'description'", "=>", "$", "translation", "->", "description", ",", "'alttext'", "=>", "$", "translation", "->", "alttext", "]", ";", "}", "return", "$", "json", "?", "json_encode", "(", "$", "attributes", ")", ":", "$", "attributes", ";", "}" ]
Summarizes the model @param bool $json @return array
[ "Summarizes", "the", "model" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Media/Media.php#L236-L257
223,528
middlewares/cache
src/Expires.php
Expires.withExpires
private static function withExpires( ResponseInterface $response, CacheUtil $util, string $expires ): ResponseInterface { $expires = new DateTime($expires); $cacheControl = ResponseCacheControl::fromString($response->getHeaderLine('Cache-Control')) ->withMaxAge($expires->getTimestamp() - time()); $response = $util->withExpires($response, $expires); return $util->withCacheControl($response, $cacheControl); }
php
private static function withExpires( ResponseInterface $response, CacheUtil $util, string $expires ): ResponseInterface { $expires = new DateTime($expires); $cacheControl = ResponseCacheControl::fromString($response->getHeaderLine('Cache-Control')) ->withMaxAge($expires->getTimestamp() - time()); $response = $util->withExpires($response, $expires); return $util->withCacheControl($response, $cacheControl); }
[ "private", "static", "function", "withExpires", "(", "ResponseInterface", "$", "response", ",", "CacheUtil", "$", "util", ",", "string", "$", "expires", ")", ":", "ResponseInterface", "{", "$", "expires", "=", "new", "DateTime", "(", "$", "expires", ")", ";", "$", "cacheControl", "=", "ResponseCacheControl", "::", "fromString", "(", "$", "response", "->", "getHeaderLine", "(", "'Cache-Control'", ")", ")", "->", "withMaxAge", "(", "$", "expires", "->", "getTimestamp", "(", ")", "-", "time", "(", ")", ")", ";", "$", "response", "=", "$", "util", "->", "withExpires", "(", "$", "response", ",", "$", "expires", ")", ";", "return", "$", "util", "->", "withCacheControl", "(", "$", "response", ",", "$", "cacheControl", ")", ";", "}" ]
Add the Expires and Cache-Control headers.
[ "Add", "the", "Expires", "and", "Cache", "-", "Control", "headers", "." ]
465ed19d1702a8b7ab1c92d3bc1d4e5ad9dd2b09
https://github.com/middlewares/cache/blob/465ed19d1702a8b7ab1c92d3bc1d4e5ad9dd2b09/src/Expires.php#L90-L102
223,529
NuclearCMS/Documents
src/Media/EmbeddedMedia.php
EmbeddedMedia.populateDefaultMetadata
public function populateDefaultMetadata() { $oEmbed = Oembed::cache($this->path, ['lifetime' => 432000]); $this->type = $this->mediaType; $this->mimetype = mb_strtolower($oEmbed->providerName); $this->size = 0; $this->name = $oEmbed->title; $this->caption = $oEmbed->title; $this->description = $oEmbed->description; $this->setMetadata('media_type', $oEmbed->type); $this->setMetadata('provider_url', $oEmbed->providerUrl); $this->setMetadata('provider_icon', $oEmbed->providerIcon); if ( ! is_null($oEmbed->image)) { $this->createEmbeddedPath(); $destination = 'embedded/' . $this->mimetype . '_' . md5($oEmbed->image); copy($oEmbed->image, upload_path($destination)); $this->setMetadata('thumbnail_original', $oEmbed->image); $this->setMetadata('thumbnail_url', $destination); $this->setMetadata('thumbnail_width', $oEmbed->imageWidth); $this->setMetadata('thumbnail_height', $oEmbed->imageHeight); } if ( ! is_null($oEmbed->authorName)) { $this->setMetadata('author_name', $oEmbed->authorName); $this->setMetadata('author_url', $oEmbed->authorUrl); } }
php
public function populateDefaultMetadata() { $oEmbed = Oembed::cache($this->path, ['lifetime' => 432000]); $this->type = $this->mediaType; $this->mimetype = mb_strtolower($oEmbed->providerName); $this->size = 0; $this->name = $oEmbed->title; $this->caption = $oEmbed->title; $this->description = $oEmbed->description; $this->setMetadata('media_type', $oEmbed->type); $this->setMetadata('provider_url', $oEmbed->providerUrl); $this->setMetadata('provider_icon', $oEmbed->providerIcon); if ( ! is_null($oEmbed->image)) { $this->createEmbeddedPath(); $destination = 'embedded/' . $this->mimetype . '_' . md5($oEmbed->image); copy($oEmbed->image, upload_path($destination)); $this->setMetadata('thumbnail_original', $oEmbed->image); $this->setMetadata('thumbnail_url', $destination); $this->setMetadata('thumbnail_width', $oEmbed->imageWidth); $this->setMetadata('thumbnail_height', $oEmbed->imageHeight); } if ( ! is_null($oEmbed->authorName)) { $this->setMetadata('author_name', $oEmbed->authorName); $this->setMetadata('author_url', $oEmbed->authorUrl); } }
[ "public", "function", "populateDefaultMetadata", "(", ")", "{", "$", "oEmbed", "=", "Oembed", "::", "cache", "(", "$", "this", "->", "path", ",", "[", "'lifetime'", "=>", "432000", "]", ")", ";", "$", "this", "->", "type", "=", "$", "this", "->", "mediaType", ";", "$", "this", "->", "mimetype", "=", "mb_strtolower", "(", "$", "oEmbed", "->", "providerName", ")", ";", "$", "this", "->", "size", "=", "0", ";", "$", "this", "->", "name", "=", "$", "oEmbed", "->", "title", ";", "$", "this", "->", "caption", "=", "$", "oEmbed", "->", "title", ";", "$", "this", "->", "description", "=", "$", "oEmbed", "->", "description", ";", "$", "this", "->", "setMetadata", "(", "'media_type'", ",", "$", "oEmbed", "->", "type", ")", ";", "$", "this", "->", "setMetadata", "(", "'provider_url'", ",", "$", "oEmbed", "->", "providerUrl", ")", ";", "$", "this", "->", "setMetadata", "(", "'provider_icon'", ",", "$", "oEmbed", "->", "providerIcon", ")", ";", "if", "(", "!", "is_null", "(", "$", "oEmbed", "->", "image", ")", ")", "{", "$", "this", "->", "createEmbeddedPath", "(", ")", ";", "$", "destination", "=", "'embedded/'", ".", "$", "this", "->", "mimetype", ".", "'_'", ".", "md5", "(", "$", "oEmbed", "->", "image", ")", ";", "copy", "(", "$", "oEmbed", "->", "image", ",", "upload_path", "(", "$", "destination", ")", ")", ";", "$", "this", "->", "setMetadata", "(", "'thumbnail_original'", ",", "$", "oEmbed", "->", "image", ")", ";", "$", "this", "->", "setMetadata", "(", "'thumbnail_url'", ",", "$", "destination", ")", ";", "$", "this", "->", "setMetadata", "(", "'thumbnail_width'", ",", "$", "oEmbed", "->", "imageWidth", ")", ";", "$", "this", "->", "setMetadata", "(", "'thumbnail_height'", ",", "$", "oEmbed", "->", "imageHeight", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "oEmbed", "->", "authorName", ")", ")", "{", "$", "this", "->", "setMetadata", "(", "'author_name'", ",", "$", "oEmbed", "->", "authorName", ")", ";", "$", "this", "->", "setMetadata", "(", "'author_url'", ",", "$", "oEmbed", "->", "authorUrl", ")", ";", "}", "}" ]
Populates default data with oEmbed data
[ "Populates", "default", "data", "with", "oEmbed", "data" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Media/EmbeddedMedia.php#L29-L64
223,530
NuclearCMS/Documents
src/Media/EmbeddedMedia.php
EmbeddedMedia.createEmbeddedPath
protected function createEmbeddedPath() { $path = upload_path('embedded'); if ( ! file_exists($path)) { if ( ! mkdir($path, 0777, true)) { throw new RuntimeException('Directory (' . $path . ') could not be created.'); } } }
php
protected function createEmbeddedPath() { $path = upload_path('embedded'); if ( ! file_exists($path)) { if ( ! mkdir($path, 0777, true)) { throw new RuntimeException('Directory (' . $path . ') could not be created.'); } } }
[ "protected", "function", "createEmbeddedPath", "(", ")", "{", "$", "path", "=", "upload_path", "(", "'embedded'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "!", "mkdir", "(", "$", "path", ",", "0777", ",", "true", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Directory ('", ".", "$", "path", ".", "') could not be created.'", ")", ";", "}", "}", "}" ]
Creates the current embedded directory @throws RuntimeException
[ "Creates", "the", "current", "embedded", "directory" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Media/EmbeddedMedia.php#L71-L82
223,531
aharen/OMDbAPI
src/OMDbAPI.php
OMDbAPI.poster
public function poster($imdbid, $height = 300) { if (is_null($this->api_key)) { return $this->output('400', 'No API Key Found'); } if ($this->validateIMDBid($imdbid) == false) { return $this->output('400', 'Invalid IMDB ID provided'); } if (!is_numeric($height)) { return $this->output('400', 'Height should be numeric'); } if ($height < 1 && $height > 1000) { return $this->output('400', 'Height should be between 1-1000'); } $api_uri = '?i=' . $imdbid . '&h=' . $height . '&apikey=' . $this->api_key; $output = $this->get($api_uri); if ($output->code === 200) { header("Content-Type: image/jpeg"); return $output->data; } return $output; }
php
public function poster($imdbid, $height = 300) { if (is_null($this->api_key)) { return $this->output('400', 'No API Key Found'); } if ($this->validateIMDBid($imdbid) == false) { return $this->output('400', 'Invalid IMDB ID provided'); } if (!is_numeric($height)) { return $this->output('400', 'Height should be numeric'); } if ($height < 1 && $height > 1000) { return $this->output('400', 'Height should be between 1-1000'); } $api_uri = '?i=' . $imdbid . '&h=' . $height . '&apikey=' . $this->api_key; $output = $this->get($api_uri); if ($output->code === 200) { header("Content-Type: image/jpeg"); return $output->data; } return $output; }
[ "public", "function", "poster", "(", "$", "imdbid", ",", "$", "height", "=", "300", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "api_key", ")", ")", "{", "return", "$", "this", "->", "output", "(", "'400'", ",", "'No API Key Found'", ")", ";", "}", "if", "(", "$", "this", "->", "validateIMDBid", "(", "$", "imdbid", ")", "==", "false", ")", "{", "return", "$", "this", "->", "output", "(", "'400'", ",", "'Invalid IMDB ID provided'", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "height", ")", ")", "{", "return", "$", "this", "->", "output", "(", "'400'", ",", "'Height should be numeric'", ")", ";", "}", "if", "(", "$", "height", "<", "1", "&&", "$", "height", ">", "1000", ")", "{", "return", "$", "this", "->", "output", "(", "'400'", ",", "'Height should be between 1-1000'", ")", ";", "}", "$", "api_uri", "=", "'?i='", ".", "$", "imdbid", ".", "'&h='", ".", "$", "height", ".", "'&apikey='", ".", "$", "this", "->", "api_key", ";", "$", "output", "=", "$", "this", "->", "get", "(", "$", "api_uri", ")", ";", "if", "(", "$", "output", "->", "code", "===", "200", ")", "{", "header", "(", "\"Content-Type: image/jpeg\"", ")", ";", "return", "$", "output", "->", "data", ";", "}", "return", "$", "output", ";", "}" ]
Get poster from OMDb Poster API @param string $imdbid @param integer $height @return string
[ "Get", "poster", "from", "OMDb", "Poster", "API" ]
6a283ce379621b3dad00fa29dc8df24a3712b7d5
https://github.com/aharen/OMDbAPI/blob/6a283ce379621b3dad00fa29dc8df24a3712b7d5/src/OMDbAPI.php#L128-L155
223,532
aharen/OMDbAPI
src/OMDbAPI.php
OMDbAPI.get
protected function get($api_uri) { try { $response = $this->client->get($api_uri); $code = $response->getStatusCode(); $message = $response->getReasonPhrase(); $body = $response->getBody(); $data = json_decode($body->getContents(), $this->assoc); } catch (RequestException $e) { $code = 500; $message = 'RequestException'; $data = $e->getMessage(); } catch (ClientException $e) { $code = 500; $message = 'RequestException'; $data = $e->getMessage(); } return $this->output($code, $message, $data); }
php
protected function get($api_uri) { try { $response = $this->client->get($api_uri); $code = $response->getStatusCode(); $message = $response->getReasonPhrase(); $body = $response->getBody(); $data = json_decode($body->getContents(), $this->assoc); } catch (RequestException $e) { $code = 500; $message = 'RequestException'; $data = $e->getMessage(); } catch (ClientException $e) { $code = 500; $message = 'RequestException'; $data = $e->getMessage(); } return $this->output($code, $message, $data); }
[ "protected", "function", "get", "(", "$", "api_uri", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "api_uri", ")", ";", "$", "code", "=", "$", "response", "->", "getStatusCode", "(", ")", ";", "$", "message", "=", "$", "response", "->", "getReasonPhrase", "(", ")", ";", "$", "body", "=", "$", "response", "->", "getBody", "(", ")", ";", "$", "data", "=", "json_decode", "(", "$", "body", "->", "getContents", "(", ")", ",", "$", "this", "->", "assoc", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "$", "code", "=", "500", ";", "$", "message", "=", "'RequestException'", ";", "$", "data", "=", "$", "e", "->", "getMessage", "(", ")", ";", "}", "catch", "(", "ClientException", "$", "e", ")", "{", "$", "code", "=", "500", ";", "$", "message", "=", "'RequestException'", ";", "$", "data", "=", "$", "e", "->", "getMessage", "(", ")", ";", "}", "return", "$", "this", "->", "output", "(", "$", "code", ",", "$", "message", ",", "$", "data", ")", ";", "}" ]
Make the call using Guzzle Client @param string $api_uri @return array
[ "Make", "the", "call", "using", "Guzzle", "Client" ]
6a283ce379621b3dad00fa29dc8df24a3712b7d5
https://github.com/aharen/OMDbAPI/blob/6a283ce379621b3dad00fa29dc8df24a3712b7d5/src/OMDbAPI.php#L163-L186
223,533
aharen/OMDbAPI
src/OMDbAPI.php
OMDbAPI.output
protected function output($code, $message, $data = null) { $result = [ 'code' => $code, 'message' => $message, 'data' => $data, ]; if (!$this->assoc) { $result = (object) $result; } return $result; }
php
protected function output($code, $message, $data = null) { $result = [ 'code' => $code, 'message' => $message, 'data' => $data, ]; if (!$this->assoc) { $result = (object) $result; } return $result; }
[ "protected", "function", "output", "(", "$", "code", ",", "$", "message", ",", "$", "data", "=", "null", ")", "{", "$", "result", "=", "[", "'code'", "=>", "$", "code", ",", "'message'", "=>", "$", "message", ",", "'data'", "=>", "$", "data", ",", "]", ";", "if", "(", "!", "$", "this", "->", "assoc", ")", "{", "$", "result", "=", "(", "object", ")", "$", "result", ";", "}", "return", "$", "result", ";", "}" ]
Format the output data @param string $code @param string $message @param array $data @return array
[ "Format", "the", "output", "data" ]
6a283ce379621b3dad00fa29dc8df24a3712b7d5
https://github.com/aharen/OMDbAPI/blob/6a283ce379621b3dad00fa29dc8df24a3712b7d5/src/OMDbAPI.php#L196-L209
223,534
projek-xyz/slim-plates
src/PlatesProvider.php
PlatesProvider.register
public function register(Container $container) { if (!isset($container->get('settings')['view'])) { throw new InvalidArgumentException('Template configuration not found'); } $engine = new Plates( $container->get('settings')['view'], $container->get('response') ); $engine->loadExtension( new PlatesExtension( $container->get('router'), $container->get('request')->getUri() ) ); $container['view'] = $engine; }
php
public function register(Container $container) { if (!isset($container->get('settings')['view'])) { throw new InvalidArgumentException('Template configuration not found'); } $engine = new Plates( $container->get('settings')['view'], $container->get('response') ); $engine->loadExtension( new PlatesExtension( $container->get('router'), $container->get('request')->getUri() ) ); $container['view'] = $engine; }
[ "public", "function", "register", "(", "Container", "$", "container", ")", "{", "if", "(", "!", "isset", "(", "$", "container", "->", "get", "(", "'settings'", ")", "[", "'view'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Template configuration not found'", ")", ";", "}", "$", "engine", "=", "new", "Plates", "(", "$", "container", "->", "get", "(", "'settings'", ")", "[", "'view'", "]", ",", "$", "container", "->", "get", "(", "'response'", ")", ")", ";", "$", "engine", "->", "loadExtension", "(", "new", "PlatesExtension", "(", "$", "container", "->", "get", "(", "'router'", ")", ",", "$", "container", "->", "get", "(", "'request'", ")", "->", "getUri", "(", ")", ")", ")", ";", "$", "container", "[", "'view'", "]", "=", "$", "engine", ";", "}" ]
Register this plates view provider with a Pimple container. @param \Pimple\Container $container
[ "Register", "this", "plates", "view", "provider", "with", "a", "Pimple", "container", "." ]
55d407d32e671dd5943a7d84f24edd179b288112
https://github.com/projek-xyz/slim-plates/blob/55d407d32e671dd5943a7d84f24edd179b288112/src/PlatesProvider.php#L15-L34
223,535
NuclearCMS/Documents
src/Media/Image.php
Image.editImage
public function editImage($action) { $image = $this->loadImage(); $path = $this->processImage($action, $image); $this->changeImagePath($path); }
php
public function editImage($action) { $image = $this->loadImage(); $path = $this->processImage($action, $image); $this->changeImagePath($path); }
[ "public", "function", "editImage", "(", "$", "action", ")", "{", "$", "image", "=", "$", "this", "->", "loadImage", "(", ")", ";", "$", "path", "=", "$", "this", "->", "processImage", "(", "$", "action", ",", "$", "image", ")", ";", "$", "this", "->", "changeImagePath", "(", "$", "path", ")", ";", "}" ]
Edits image according to given action @param string $action
[ "Edits", "image", "according", "to", "given", "action" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Media/Image.php#L32-L39
223,536
NuclearCMS/Documents
src/Media/Image.php
Image.processImage
protected function processImage($action, InterventionImage $image) { $action = explode('_', $action); if (count($action) > 1) { list($method, $param) = $action; } else { $method = current($action); $param = []; } if ($method === 'crop') { $params = explode(',', $param); call_user_func_array([$image, 'crop'], $params); } else { call_user_func([$image, $method], $param); } return $this->saveImage($image); }
php
protected function processImage($action, InterventionImage $image) { $action = explode('_', $action); if (count($action) > 1) { list($method, $param) = $action; } else { $method = current($action); $param = []; } if ($method === 'crop') { $params = explode(',', $param); call_user_func_array([$image, 'crop'], $params); } else { call_user_func([$image, $method], $param); } return $this->saveImage($image); }
[ "protected", "function", "processImage", "(", "$", "action", ",", "InterventionImage", "$", "image", ")", "{", "$", "action", "=", "explode", "(", "'_'", ",", "$", "action", ")", ";", "if", "(", "count", "(", "$", "action", ")", ">", "1", ")", "{", "list", "(", "$", "method", ",", "$", "param", ")", "=", "$", "action", ";", "}", "else", "{", "$", "method", "=", "current", "(", "$", "action", ")", ";", "$", "param", "=", "[", "]", ";", "}", "if", "(", "$", "method", "===", "'crop'", ")", "{", "$", "params", "=", "explode", "(", "','", ",", "$", "param", ")", ";", "call_user_func_array", "(", "[", "$", "image", ",", "'crop'", "]", ",", "$", "params", ")", ";", "}", "else", "{", "call_user_func", "(", "[", "$", "image", ",", "$", "method", "]", ",", "$", "param", ")", ";", "}", "return", "$", "this", "->", "saveImage", "(", "$", "image", ")", ";", "}" ]
Processes the image with given action @param string $action @param InterventionImage $image @return string
[ "Processes", "the", "image", "with", "given", "action" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Media/Image.php#L60-L84
223,537
NuclearCMS/Documents
src/Media/Image.php
Image.saveImage
protected function saveImage(InterventionImage $image) { $filename = Uploader::getNewFileName($this->getFileExtension()); list($absolutePath, $relativePath) = Uploader::getUploadPath(); $image->save($absolutePath . '/' . $filename); $this->refreshImageMetadata($image); return $relativePath . '/' . $filename; }
php
protected function saveImage(InterventionImage $image) { $filename = Uploader::getNewFileName($this->getFileExtension()); list($absolutePath, $relativePath) = Uploader::getUploadPath(); $image->save($absolutePath . '/' . $filename); $this->refreshImageMetadata($image); return $relativePath . '/' . $filename; }
[ "protected", "function", "saveImage", "(", "InterventionImage", "$", "image", ")", "{", "$", "filename", "=", "Uploader", "::", "getNewFileName", "(", "$", "this", "->", "getFileExtension", "(", ")", ")", ";", "list", "(", "$", "absolutePath", ",", "$", "relativePath", ")", "=", "Uploader", "::", "getUploadPath", "(", ")", ";", "$", "image", "->", "save", "(", "$", "absolutePath", ".", "'/'", ".", "$", "filename", ")", ";", "$", "this", "->", "refreshImageMetadata", "(", "$", "image", ")", ";", "return", "$", "relativePath", ".", "'/'", ".", "$", "filename", ";", "}" ]
Saves the processed image @param InterventionImage $image @return string
[ "Saves", "the", "processed", "image" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Media/Image.php#L92-L103
223,538
NuclearCMS/Documents
src/Media/Image.php
Image.refreshImageMetadata
protected function refreshImageMetadata(InterventionImage $image) { $this->setMetadata('width', $image->width()); $this->setMetadata('height', $image->height()); }
php
protected function refreshImageMetadata(InterventionImage $image) { $this->setMetadata('width', $image->width()); $this->setMetadata('height', $image->height()); }
[ "protected", "function", "refreshImageMetadata", "(", "InterventionImage", "$", "image", ")", "{", "$", "this", "->", "setMetadata", "(", "'width'", ",", "$", "image", "->", "width", "(", ")", ")", ";", "$", "this", "->", "setMetadata", "(", "'height'", ",", "$", "image", "->", "height", "(", ")", ")", ";", "}" ]
Refreshes the image metadata @param InterventionImage $image
[ "Refreshes", "the", "image", "metadata" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Media/Image.php#L110-L114
223,539
the-tinderbox/ClickhouseClient
src/Transport/HttpTransport.php
HttpTransport.setClient
protected function setClient(Client $client = null) { if (is_null($client)) { $this->httpClient = $this->createHttpClient(); } else { $this->httpClient = $client; } }
php
protected function setClient(Client $client = null) { if (is_null($client)) { $this->httpClient = $this->createHttpClient(); } else { $this->httpClient = $client; } }
[ "protected", "function", "setClient", "(", "Client", "$", "client", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "client", ")", ")", "{", "$", "this", "->", "httpClient", "=", "$", "this", "->", "createHttpClient", "(", ")", ";", "}", "else", "{", "$", "this", "->", "httpClient", "=", "$", "client", ";", "}", "}" ]
Sets Guzzle client. @param Client|null $client
[ "Sets", "Guzzle", "client", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Transport/HttpTransport.php#L81-L88
223,540
the-tinderbox/ClickhouseClient
src/Transport/HttpTransport.php
HttpTransport.write
public function write(array $queries, int $concurrency = 5) : array { $result = []; $openedStreams = []; foreach ($queries as $query) { $requests = function(Query $query) use(&$openedStreams) { if (!empty($query->getFiles())) { foreach ($query->getFiles() as $file) { /* @var FileInterface $file */ $headers = $this->getHeaders(); $uri = $this->buildRequestUri($query->getServer(), [ 'query' => $query->getQuery() ], $query->getSettings()); $stream = $file->open(); $openedStreams[] = $stream; $request = new Request('POST', $uri, $headers, $stream); yield $request; } } else { $headers = $this->getHeaders(); $uri = $this->buildRequestUri($query->getServer(), [], $query->getSettings()); $request = new Request('POST', $uri, $headers, gzencode($query->getQuery())); yield $request; } }; $queryResult = []; $pool = new Pool( $this->httpClient, $requests($query), [ 'concurrency' => $concurrency, 'fulfilled' => function ($response, $index) use (&$queryResult, $query) { $queryResult[$index] = true; }, 'rejected' => $this->parseReason($query), 'options' => array_merge([ 'expect' => false ], $this->options['write'] ?? []), ] ); $promise = $pool->promise(); try { $promise->wait(); } catch (\Throwable $exception) { foreach ($openedStreams as $openedStream) { $openedStream->close(); } throw $exception; } ksort($result); foreach ($openedStreams as $openedStream) { $openedStream->close(); } $result[] = $queryResult; } return $result; }
php
public function write(array $queries, int $concurrency = 5) : array { $result = []; $openedStreams = []; foreach ($queries as $query) { $requests = function(Query $query) use(&$openedStreams) { if (!empty($query->getFiles())) { foreach ($query->getFiles() as $file) { /* @var FileInterface $file */ $headers = $this->getHeaders(); $uri = $this->buildRequestUri($query->getServer(), [ 'query' => $query->getQuery() ], $query->getSettings()); $stream = $file->open(); $openedStreams[] = $stream; $request = new Request('POST', $uri, $headers, $stream); yield $request; } } else { $headers = $this->getHeaders(); $uri = $this->buildRequestUri($query->getServer(), [], $query->getSettings()); $request = new Request('POST', $uri, $headers, gzencode($query->getQuery())); yield $request; } }; $queryResult = []; $pool = new Pool( $this->httpClient, $requests($query), [ 'concurrency' => $concurrency, 'fulfilled' => function ($response, $index) use (&$queryResult, $query) { $queryResult[$index] = true; }, 'rejected' => $this->parseReason($query), 'options' => array_merge([ 'expect' => false ], $this->options['write'] ?? []), ] ); $promise = $pool->promise(); try { $promise->wait(); } catch (\Throwable $exception) { foreach ($openedStreams as $openedStream) { $openedStream->close(); } throw $exception; } ksort($result); foreach ($openedStreams as $openedStream) { $openedStream->close(); } $result[] = $queryResult; } return $result; }
[ "public", "function", "write", "(", "array", "$", "queries", ",", "int", "$", "concurrency", "=", "5", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "$", "openedStreams", "=", "[", "]", ";", "foreach", "(", "$", "queries", "as", "$", "query", ")", "{", "$", "requests", "=", "function", "(", "Query", "$", "query", ")", "use", "(", "&", "$", "openedStreams", ")", "{", "if", "(", "!", "empty", "(", "$", "query", "->", "getFiles", "(", ")", ")", ")", "{", "foreach", "(", "$", "query", "->", "getFiles", "(", ")", "as", "$", "file", ")", "{", "/* @var FileInterface $file */", "$", "headers", "=", "$", "this", "->", "getHeaders", "(", ")", ";", "$", "uri", "=", "$", "this", "->", "buildRequestUri", "(", "$", "query", "->", "getServer", "(", ")", ",", "[", "'query'", "=>", "$", "query", "->", "getQuery", "(", ")", "]", ",", "$", "query", "->", "getSettings", "(", ")", ")", ";", "$", "stream", "=", "$", "file", "->", "open", "(", ")", ";", "$", "openedStreams", "[", "]", "=", "$", "stream", ";", "$", "request", "=", "new", "Request", "(", "'POST'", ",", "$", "uri", ",", "$", "headers", ",", "$", "stream", ")", ";", "yield", "$", "request", ";", "}", "}", "else", "{", "$", "headers", "=", "$", "this", "->", "getHeaders", "(", ")", ";", "$", "uri", "=", "$", "this", "->", "buildRequestUri", "(", "$", "query", "->", "getServer", "(", ")", ",", "[", "]", ",", "$", "query", "->", "getSettings", "(", ")", ")", ";", "$", "request", "=", "new", "Request", "(", "'POST'", ",", "$", "uri", ",", "$", "headers", ",", "gzencode", "(", "$", "query", "->", "getQuery", "(", ")", ")", ")", ";", "yield", "$", "request", ";", "}", "}", ";", "$", "queryResult", "=", "[", "]", ";", "$", "pool", "=", "new", "Pool", "(", "$", "this", "->", "httpClient", ",", "$", "requests", "(", "$", "query", ")", ",", "[", "'concurrency'", "=>", "$", "concurrency", ",", "'fulfilled'", "=>", "function", "(", "$", "response", ",", "$", "index", ")", "use", "(", "&", "$", "queryResult", ",", "$", "query", ")", "{", "$", "queryResult", "[", "$", "index", "]", "=", "true", ";", "}", ",", "'rejected'", "=>", "$", "this", "->", "parseReason", "(", "$", "query", ")", ",", "'options'", "=>", "array_merge", "(", "[", "'expect'", "=>", "false", "]", ",", "$", "this", "->", "options", "[", "'write'", "]", "??", "[", "]", ")", ",", "]", ")", ";", "$", "promise", "=", "$", "pool", "->", "promise", "(", ")", ";", "try", "{", "$", "promise", "->", "wait", "(", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "exception", ")", "{", "foreach", "(", "$", "openedStreams", "as", "$", "openedStream", ")", "{", "$", "openedStream", "->", "close", "(", ")", ";", "}", "throw", "$", "exception", ";", "}", "ksort", "(", "$", "result", ")", ";", "foreach", "(", "$", "openedStreams", "as", "$", "openedStream", ")", "{", "$", "openedStream", "->", "close", "(", ")", ";", "}", "$", "result", "[", "]", "=", "$", "queryResult", ";", "}", "return", "$", "result", ";", "}" ]
Executes write queries. @param array $queries @param int $concurrency @return array @throws \Throwable
[ "Executes", "write", "queries", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Transport/HttpTransport.php#L107-L178
223,541
the-tinderbox/ClickhouseClient
src/Transport/HttpTransport.php
HttpTransport.getTempTableQueryParams
protected function getTempTableQueryParams(TempTable $table) { list($structure, $withColumns) = $this->assembleTempTableStructure($table); return [ $table->getName() . '_' . ($withColumns ? 'structure' : 'types') => $structure, $table->getName() . '_format' => $table->getFormat(), ]; }
php
protected function getTempTableQueryParams(TempTable $table) { list($structure, $withColumns) = $this->assembleTempTableStructure($table); return [ $table->getName() . '_' . ($withColumns ? 'structure' : 'types') => $structure, $table->getName() . '_format' => $table->getFormat(), ]; }
[ "protected", "function", "getTempTableQueryParams", "(", "TempTable", "$", "table", ")", "{", "list", "(", "$", "structure", ",", "$", "withColumns", ")", "=", "$", "this", "->", "assembleTempTableStructure", "(", "$", "table", ")", ";", "return", "[", "$", "table", "->", "getName", "(", ")", ".", "'_'", ".", "(", "$", "withColumns", "?", "'structure'", ":", "'types'", ")", "=>", "$", "structure", ",", "$", "table", "->", "getName", "(", ")", ".", "'_format'", "=>", "$", "table", "->", "getFormat", "(", ")", ",", "]", ";", "}" ]
Parse temp table data to append it to request. @param \Tinderbox\Clickhouse\Common\TempTable $table @return array
[ "Parse", "temp", "table", "data", "to", "append", "it", "to", "request", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Transport/HttpTransport.php#L270-L278
223,542
the-tinderbox/ClickhouseClient
src/Transport/HttpTransport.php
HttpTransport.assembleTempTableStructure
protected function assembleTempTableStructure(TempTable $table) { $structure = $table->getStructure(); $withColumns = true; $preparedStructure = []; foreach ($structure as $column => $type) { if (is_int($column)) { $withColumns = false; $preparedStructure[] = $type; } else { $preparedStructure[] = $column . ' ' . $type; } } return [implode(', ', $preparedStructure), $withColumns]; }
php
protected function assembleTempTableStructure(TempTable $table) { $structure = $table->getStructure(); $withColumns = true; $preparedStructure = []; foreach ($structure as $column => $type) { if (is_int($column)) { $withColumns = false; $preparedStructure[] = $type; } else { $preparedStructure[] = $column . ' ' . $type; } } return [implode(', ', $preparedStructure), $withColumns]; }
[ "protected", "function", "assembleTempTableStructure", "(", "TempTable", "$", "table", ")", "{", "$", "structure", "=", "$", "table", "->", "getStructure", "(", ")", ";", "$", "withColumns", "=", "true", ";", "$", "preparedStructure", "=", "[", "]", ";", "foreach", "(", "$", "structure", "as", "$", "column", "=>", "$", "type", ")", "{", "if", "(", "is_int", "(", "$", "column", ")", ")", "{", "$", "withColumns", "=", "false", ";", "$", "preparedStructure", "[", "]", "=", "$", "type", ";", "}", "else", "{", "$", "preparedStructure", "[", "]", "=", "$", "column", ".", "' '", ".", "$", "type", ";", "}", "}", "return", "[", "implode", "(", "', '", ",", "$", "preparedStructure", ")", ",", "$", "withColumns", "]", ";", "}" ]
Assembles string from TempTable structure. @param \Tinderbox\Clickhouse\Common\TempTable $table @return string
[ "Assembles", "string", "from", "TempTable", "structure", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Transport/HttpTransport.php#L287-L304
223,543
the-tinderbox/ClickhouseClient
src/Transport/HttpTransport.php
HttpTransport.parseReason
protected function parseReason(Query $query) { return function ($reason) use ($query) { if ($reason instanceof RequestException) { $response = $reason->getResponse(); if (is_null($response)) { throw TransportException::connectionError($query->getServer(), $reason->getMessage()); } else { throw TransportException::serverReturnedError($reason, $query); } } throw $reason; }; }
php
protected function parseReason(Query $query) { return function ($reason) use ($query) { if ($reason instanceof RequestException) { $response = $reason->getResponse(); if (is_null($response)) { throw TransportException::connectionError($query->getServer(), $reason->getMessage()); } else { throw TransportException::serverReturnedError($reason, $query); } } throw $reason; }; }
[ "protected", "function", "parseReason", "(", "Query", "$", "query", ")", "{", "return", "function", "(", "$", "reason", ")", "use", "(", "$", "query", ")", "{", "if", "(", "$", "reason", "instanceof", "RequestException", ")", "{", "$", "response", "=", "$", "reason", "->", "getResponse", "(", ")", ";", "if", "(", "is_null", "(", "$", "response", ")", ")", "{", "throw", "TransportException", "::", "connectionError", "(", "$", "query", "->", "getServer", "(", ")", ",", "$", "reason", "->", "getMessage", "(", ")", ")", ";", "}", "else", "{", "throw", "TransportException", "::", "serverReturnedError", "(", "$", "reason", ",", "$", "query", ")", ";", "}", "}", "throw", "$", "reason", ";", "}", ";", "}" ]
Determines the reason why request was rejected. @param Query $query @return \Closure
[ "Determines", "the", "reason", "why", "request", "was", "rejected", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Transport/HttpTransport.php#L313-L328
223,544
the-tinderbox/ClickhouseClient
src/Transport/HttpTransport.php
HttpTransport.assembleResult
protected function assembleResult(Query $query, ResponseInterface $response): Result { $response = $response->getBody()->getContents(); try { $result = \GuzzleHttp\json_decode($response, true); $statistic = new QueryStatistic( $result['statistics']['rows_read'] ?? 0, $result['statistics']['bytes_read'] ?? 0, $result['statistics']['elapsed'] ?? 0, $result['rows_before_limit_at_least'] ?? null ); return new Result($query, $result['data'] ?? [], $statistic); } catch (\Exception $e) { throw TransportException::malformedResponseFromServer($response); } }
php
protected function assembleResult(Query $query, ResponseInterface $response): Result { $response = $response->getBody()->getContents(); try { $result = \GuzzleHttp\json_decode($response, true); $statistic = new QueryStatistic( $result['statistics']['rows_read'] ?? 0, $result['statistics']['bytes_read'] ?? 0, $result['statistics']['elapsed'] ?? 0, $result['rows_before_limit_at_least'] ?? null ); return new Result($query, $result['data'] ?? [], $statistic); } catch (\Exception $e) { throw TransportException::malformedResponseFromServer($response); } }
[ "protected", "function", "assembleResult", "(", "Query", "$", "query", ",", "ResponseInterface", "$", "response", ")", ":", "Result", "{", "$", "response", "=", "$", "response", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ";", "try", "{", "$", "result", "=", "\\", "GuzzleHttp", "\\", "json_decode", "(", "$", "response", ",", "true", ")", ";", "$", "statistic", "=", "new", "QueryStatistic", "(", "$", "result", "[", "'statistics'", "]", "[", "'rows_read'", "]", "??", "0", ",", "$", "result", "[", "'statistics'", "]", "[", "'bytes_read'", "]", "??", "0", ",", "$", "result", "[", "'statistics'", "]", "[", "'elapsed'", "]", "??", "0", ",", "$", "result", "[", "'rows_before_limit_at_least'", "]", "??", "null", ")", ";", "return", "new", "Result", "(", "$", "query", ",", "$", "result", "[", "'data'", "]", "??", "[", "]", ",", "$", "statistic", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "TransportException", "::", "malformedResponseFromServer", "(", "$", "response", ")", ";", "}", "}" ]
Assembles Result instance from server response. @param Query $query @param \Psr\Http\Message\ResponseInterface $response @return \Tinderbox\Clickhouse\Query\Result
[ "Assembles", "Result", "instance", "from", "server", "response", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Transport/HttpTransport.php#L338-L356
223,545
the-tinderbox/ClickhouseClient
src/Transport/HttpTransport.php
HttpTransport.buildRequestUri
protected function buildRequestUri(Server $server, array $query = [], array $settings = []): string { $uri = $server->getOptions()->getProtocol() . '://' . $server->getHost() . ':' . $server->getPort(); if (!is_null($server->getDatabase())) { $query['database'] = $server->getDatabase(); } if (!is_null($server->getUsername())) { $query['user'] = $server->getUsername(); } if (!is_null($server->getPassword())) { $query['password'] = $server->getPassword(); } $query = array_merge($query, $settings); return $uri . '?' . http_build_query($query); }
php
protected function buildRequestUri(Server $server, array $query = [], array $settings = []): string { $uri = $server->getOptions()->getProtocol() . '://' . $server->getHost() . ':' . $server->getPort(); if (!is_null($server->getDatabase())) { $query['database'] = $server->getDatabase(); } if (!is_null($server->getUsername())) { $query['user'] = $server->getUsername(); } if (!is_null($server->getPassword())) { $query['password'] = $server->getPassword(); } $query = array_merge($query, $settings); return $uri . '?' . http_build_query($query); }
[ "protected", "function", "buildRequestUri", "(", "Server", "$", "server", ",", "array", "$", "query", "=", "[", "]", ",", "array", "$", "settings", "=", "[", "]", ")", ":", "string", "{", "$", "uri", "=", "$", "server", "->", "getOptions", "(", ")", "->", "getProtocol", "(", ")", ".", "'://'", ".", "$", "server", "->", "getHost", "(", ")", ".", "':'", ".", "$", "server", "->", "getPort", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "server", "->", "getDatabase", "(", ")", ")", ")", "{", "$", "query", "[", "'database'", "]", "=", "$", "server", "->", "getDatabase", "(", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "server", "->", "getUsername", "(", ")", ")", ")", "{", "$", "query", "[", "'user'", "]", "=", "$", "server", "->", "getUsername", "(", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "server", "->", "getPassword", "(", ")", ")", ")", "{", "$", "query", "[", "'password'", "]", "=", "$", "server", "->", "getPassword", "(", ")", ";", "}", "$", "query", "=", "array_merge", "(", "$", "query", ",", "$", "settings", ")", ";", "return", "$", "uri", ".", "'?'", ".", "http_build_query", "(", "$", "query", ")", ";", "}" ]
Builds uri with necessary params. @param \Tinderbox\Clickhouse\Server $server @param array $query @param array $settings @return string
[ "Builds", "uri", "with", "necessary", "params", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Transport/HttpTransport.php#L367-L386
223,546
NuclearCMS/Documents
src/Repositories/DocumentsRepository.php
DocumentsRepository.getGallery
public function getGallery($ids) { if (empty($ids) || $ids === '{}' || $ids === '[]') return null; $ids = $this->parseGalleryIds($ids); $placeholders = implode(',', array_fill(0, count($ids), '?')); $imageModel = $this->getImageModelName(); $gallery = call_user_func_array([$imageModel, 'whereIn'], ['id', $ids]); $gallery = $gallery ->orderByRaw('field(id,' . $placeholders . ')', $ids) ->get(); return (count($gallery) > 0) ? $gallery : null; }
php
public function getGallery($ids) { if (empty($ids) || $ids === '{}' || $ids === '[]') return null; $ids = $this->parseGalleryIds($ids); $placeholders = implode(',', array_fill(0, count($ids), '?')); $imageModel = $this->getImageModelName(); $gallery = call_user_func_array([$imageModel, 'whereIn'], ['id', $ids]); $gallery = $gallery ->orderByRaw('field(id,' . $placeholders . ')', $ids) ->get(); return (count($gallery) > 0) ? $gallery : null; }
[ "public", "function", "getGallery", "(", "$", "ids", ")", "{", "if", "(", "empty", "(", "$", "ids", ")", "||", "$", "ids", "===", "'{}'", "||", "$", "ids", "===", "'[]'", ")", "return", "null", ";", "$", "ids", "=", "$", "this", "->", "parseGalleryIds", "(", "$", "ids", ")", ";", "$", "placeholders", "=", "implode", "(", "','", ",", "array_fill", "(", "0", ",", "count", "(", "$", "ids", ")", ",", "'?'", ")", ")", ";", "$", "imageModel", "=", "$", "this", "->", "getImageModelName", "(", ")", ";", "$", "gallery", "=", "call_user_func_array", "(", "[", "$", "imageModel", ",", "'whereIn'", "]", ",", "[", "'id'", ",", "$", "ids", "]", ")", ";", "$", "gallery", "=", "$", "gallery", "->", "orderByRaw", "(", "'field(id,'", ".", "$", "placeholders", ".", "')'", ",", "$", "ids", ")", "->", "get", "(", ")", ";", "return", "(", "count", "(", "$", "gallery", ")", ">", "0", ")", "?", "$", "gallery", ":", "null", ";", "}" ]
Returns the gallery by given ids @param int|string|array $ids @return Collection
[ "Returns", "the", "gallery", "by", "given", "ids" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Repositories/DocumentsRepository.php#L30-L46
223,547
NuclearCMS/Documents
src/Repositories/DocumentsRepository.php
DocumentsRepository.getCover
public function getCover($ids) { if (empty($ids) || $ids === '{}' || $ids === '[]') return null; $ids = $this->parseGalleryIds($ids); $id = current($ids); $imageModel = $this->getImageModelName(); return call_user_func_array([$imageModel, 'find'], [$id]); }
php
public function getCover($ids) { if (empty($ids) || $ids === '{}' || $ids === '[]') return null; $ids = $this->parseGalleryIds($ids); $id = current($ids); $imageModel = $this->getImageModelName(); return call_user_func_array([$imageModel, 'find'], [$id]); }
[ "public", "function", "getCover", "(", "$", "ids", ")", "{", "if", "(", "empty", "(", "$", "ids", ")", "||", "$", "ids", "===", "'{}'", "||", "$", "ids", "===", "'[]'", ")", "return", "null", ";", "$", "ids", "=", "$", "this", "->", "parseGalleryIds", "(", "$", "ids", ")", ";", "$", "id", "=", "current", "(", "$", "ids", ")", ";", "$", "imageModel", "=", "$", "this", "->", "getImageModelName", "(", ")", ";", "return", "call_user_func_array", "(", "[", "$", "imageModel", ",", "'find'", "]", ",", "[", "$", "id", "]", ")", ";", "}" ]
Returns the cover for given ids @param int|string|array $ids @return Media
[ "Returns", "the", "cover", "for", "given", "ids" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Repositories/DocumentsRepository.php#L54-L65
223,548
NuclearCMS/Documents
src/Repositories/DocumentsRepository.php
DocumentsRepository.parseGalleryIds
protected function parseGalleryIds($ids) { if (is_array($ids)) { return $ids; } if (0 !== (int)$ids) { return (array)$ids; } return json_decode($ids, true); }
php
protected function parseGalleryIds($ids) { if (is_array($ids)) { return $ids; } if (0 !== (int)$ids) { return (array)$ids; } return json_decode($ids, true); }
[ "protected", "function", "parseGalleryIds", "(", "$", "ids", ")", "{", "if", "(", "is_array", "(", "$", "ids", ")", ")", "{", "return", "$", "ids", ";", "}", "if", "(", "0", "!==", "(", "int", ")", "$", "ids", ")", "{", "return", "(", "array", ")", "$", "ids", ";", "}", "return", "json_decode", "(", "$", "ids", ",", "true", ")", ";", "}" ]
Parses a gallery array @param int|string|array $ids @return array
[ "Parses", "a", "gallery", "array" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Repositories/DocumentsRepository.php#L73-L86
223,549
the-tinderbox/ClickhouseClient
src/Client.php
Client.setTransport
protected function setTransport(TransportInterface $transport = null) { if (is_null($transport)) { $this->transport = $this->createTransport(); } else { $this->transport = $transport; } }
php
protected function setTransport(TransportInterface $transport = null) { if (is_null($transport)) { $this->transport = $this->createTransport(); } else { $this->transport = $transport; } }
[ "protected", "function", "setTransport", "(", "TransportInterface", "$", "transport", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "transport", ")", ")", "{", "$", "this", "->", "transport", "=", "$", "this", "->", "createTransport", "(", ")", ";", "}", "else", "{", "$", "this", "->", "transport", "=", "$", "transport", ";", "}", "}" ]
Sets transport. @param \Tinderbox\Clickhouse\Interfaces\TransportInterface|null $transport
[ "Sets", "transport", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L97-L104
223,550
the-tinderbox/ClickhouseClient
src/Client.php
Client.setMapper
protected function setMapper(QueryMapperInterface $mapper = null): self { if (is_null($mapper)) { return $this->setDefaultMapper(); } $this->mapper = $mapper; return $this; }
php
protected function setMapper(QueryMapperInterface $mapper = null): self { if (is_null($mapper)) { return $this->setDefaultMapper(); } $this->mapper = $mapper; return $this; }
[ "protected", "function", "setMapper", "(", "QueryMapperInterface", "$", "mapper", "=", "null", ")", ":", "self", "{", "if", "(", "is_null", "(", "$", "mapper", ")", ")", "{", "return", "$", "this", "->", "setDefaultMapper", "(", ")", ";", "}", "$", "this", "->", "mapper", "=", "$", "mapper", ";", "return", "$", "this", ";", "}" ]
Sets Mapper. @param \Tinderbox\Clickhouse\Interfaces\QueryMapperInterface $mapper @return \Tinderbox\Clickhouse\Client
[ "Sets", "Mapper", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L113-L122
223,551
the-tinderbox/ClickhouseClient
src/Client.php
Client.onCluster
public function onCluster(?string $cluster) { $this->clusterName = $cluster; $this->serverHostname = null; return $this; }
php
public function onCluster(?string $cluster) { $this->clusterName = $cluster; $this->serverHostname = null; return $this; }
[ "public", "function", "onCluster", "(", "?", "string", "$", "cluster", ")", "{", "$", "this", "->", "clusterName", "=", "$", "cluster", ";", "$", "this", "->", "serverHostname", "=", "null", ";", "return", "$", "this", ";", "}" ]
Client will use servers from specified cluster @param string|null $cluster @return $this
[ "Client", "will", "use", "servers", "from", "specified", "cluster" ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L153-L159
223,552
the-tinderbox/ClickhouseClient
src/Client.php
Client.usingRandomServer
public function usingRandomServer() { $this->serverHostname = function () { if ($this->isOnCluster()) { return $this->serverProvider->getRandomServerFromCluster($this->getClusterName()); } else { return $this->serverProvider->getRandomServer(); } }; return $this; }
php
public function usingRandomServer() { $this->serverHostname = function () { if ($this->isOnCluster()) { return $this->serverProvider->getRandomServerFromCluster($this->getClusterName()); } else { return $this->serverProvider->getRandomServer(); } }; return $this; }
[ "public", "function", "usingRandomServer", "(", ")", "{", "$", "this", "->", "serverHostname", "=", "function", "(", ")", "{", "if", "(", "$", "this", "->", "isOnCluster", "(", ")", ")", "{", "return", "$", "this", "->", "serverProvider", "->", "getRandomServerFromCluster", "(", "$", "this", "->", "getClusterName", "(", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "serverProvider", "->", "getRandomServer", "(", ")", ";", "}", "}", ";", "return", "$", "this", ";", "}" ]
Client will return random server on each query @return $this
[ "Client", "will", "return", "random", "server", "on", "each", "query" ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L190-L201
223,553
the-tinderbox/ClickhouseClient
src/Client.php
Client.getServer
public function getServer(): Server { if ($this->serverHostname instanceof \Closure) { $server = call_user_func($this->serverHostname); } else { if ($this->isOnCluster()) { /* * If no server provided, will take random server from cluster */ if (is_null($this->serverHostname)) { $server = $this->serverProvider->getRandomServerFromCluster($this->getClusterName()); $this->serverHostname = $server->getHost(); } else { $server = $this->serverProvider->getServerFromCluster( $this->getClusterName(), $this->serverHostname ); } } else { /* * If no server provided, will take random server from cluster */ if (is_null($this->serverHostname)) { $server = $this->serverProvider->getRandomServer(); $this->serverHostname = $server->getHost(); } else { $server = $this->serverProvider->getServer($this->serverHostname); } } } return $server; }
php
public function getServer(): Server { if ($this->serverHostname instanceof \Closure) { $server = call_user_func($this->serverHostname); } else { if ($this->isOnCluster()) { /* * If no server provided, will take random server from cluster */ if (is_null($this->serverHostname)) { $server = $this->serverProvider->getRandomServerFromCluster($this->getClusterName()); $this->serverHostname = $server->getHost(); } else { $server = $this->serverProvider->getServerFromCluster( $this->getClusterName(), $this->serverHostname ); } } else { /* * If no server provided, will take random server from cluster */ if (is_null($this->serverHostname)) { $server = $this->serverProvider->getRandomServer(); $this->serverHostname = $server->getHost(); } else { $server = $this->serverProvider->getServer($this->serverHostname); } } } return $server; }
[ "public", "function", "getServer", "(", ")", ":", "Server", "{", "if", "(", "$", "this", "->", "serverHostname", "instanceof", "\\", "Closure", ")", "{", "$", "server", "=", "call_user_func", "(", "$", "this", "->", "serverHostname", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "isOnCluster", "(", ")", ")", "{", "/*\n * If no server provided, will take random server from cluster\n */", "if", "(", "is_null", "(", "$", "this", "->", "serverHostname", ")", ")", "{", "$", "server", "=", "$", "this", "->", "serverProvider", "->", "getRandomServerFromCluster", "(", "$", "this", "->", "getClusterName", "(", ")", ")", ";", "$", "this", "->", "serverHostname", "=", "$", "server", "->", "getHost", "(", ")", ";", "}", "else", "{", "$", "server", "=", "$", "this", "->", "serverProvider", "->", "getServerFromCluster", "(", "$", "this", "->", "getClusterName", "(", ")", ",", "$", "this", "->", "serverHostname", ")", ";", "}", "}", "else", "{", "/*\n * If no server provided, will take random server from cluster\n */", "if", "(", "is_null", "(", "$", "this", "->", "serverHostname", ")", ")", "{", "$", "server", "=", "$", "this", "->", "serverProvider", "->", "getRandomServer", "(", ")", ";", "$", "this", "->", "serverHostname", "=", "$", "server", "->", "getHost", "(", ")", ";", "}", "else", "{", "$", "server", "=", "$", "this", "->", "serverProvider", "->", "getServer", "(", "$", "this", "->", "serverHostname", ")", ";", "}", "}", "}", "return", "$", "server", ";", "}" ]
Returns server to perform request @return Server
[ "Returns", "server", "to", "perform", "request" ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L218-L250
223,554
the-tinderbox/ClickhouseClient
src/Client.php
Client.readOne
public function readOne(string $query, array $bindings = [], array $files = [], array $settings = []): Result { $query = $this->createQuery($this->getServer(), $query, $bindings, $files, $settings); $result = $this->getTransport()->read([$query], 1); return $result[0]; }
php
public function readOne(string $query, array $bindings = [], array $files = [], array $settings = []): Result { $query = $this->createQuery($this->getServer(), $query, $bindings, $files, $settings); $result = $this->getTransport()->read([$query], 1); return $result[0]; }
[ "public", "function", "readOne", "(", "string", "$", "query", ",", "array", "$", "bindings", "=", "[", "]", ",", "array", "$", "files", "=", "[", "]", ",", "array", "$", "settings", "=", "[", "]", ")", ":", "Result", "{", "$", "query", "=", "$", "this", "->", "createQuery", "(", "$", "this", "->", "getServer", "(", ")", ",", "$", "query", ",", "$", "bindings", ",", "$", "files", ",", "$", "settings", ")", ";", "$", "result", "=", "$", "this", "->", "getTransport", "(", ")", "->", "read", "(", "[", "$", "query", "]", ",", "1", ")", ";", "return", "$", "result", "[", "0", "]", ";", "}" ]
Performs select query and returns one result Example: $client->select('select * from table where column = ?', [1]); @param string $query @param array $bindings @param FileInterface[] $files @param array $settings @return \Tinderbox\Clickhouse\Query\Result
[ "Performs", "select", "query", "and", "returns", "one", "result" ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L266-L273
223,555
the-tinderbox/ClickhouseClient
src/Client.php
Client.read
public function read(array $queries, int $concurrency = 5): array { foreach ($queries as $i => $query) { if (!$query instanceof Query) { $queries[$i] = $this->guessQuery($query); } } return $this->getTransport()->read($queries, $concurrency); }
php
public function read(array $queries, int $concurrency = 5): array { foreach ($queries as $i => $query) { if (!$query instanceof Query) { $queries[$i] = $this->guessQuery($query); } } return $this->getTransport()->read($queries, $concurrency); }
[ "public", "function", "read", "(", "array", "$", "queries", ",", "int", "$", "concurrency", "=", "5", ")", ":", "array", "{", "foreach", "(", "$", "queries", "as", "$", "i", "=>", "$", "query", ")", "{", "if", "(", "!", "$", "query", "instanceof", "Query", ")", "{", "$", "queries", "[", "$", "i", "]", "=", "$", "this", "->", "guessQuery", "(", "$", "query", ")", ";", "}", "}", "return", "$", "this", "->", "getTransport", "(", ")", "->", "read", "(", "$", "queries", ",", "$", "concurrency", ")", ";", "}" ]
Performs batch of select queries. @param array $queries @param int $concurrency Max concurrency requests @return array
[ "Performs", "batch", "of", "select", "queries", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L283-L292
223,556
the-tinderbox/ClickhouseClient
src/Client.php
Client.writeOne
public function writeOne(string $query, array $bindings = [], array $files = [], array $settings = []): bool { if (!$query instanceof Query) { $query = $this->createQuery($this->getServer(), $query, $bindings, $files, $settings); } $result = $this->getTransport()->write([$query], 1); return $result[0][0]; }
php
public function writeOne(string $query, array $bindings = [], array $files = [], array $settings = []): bool { if (!$query instanceof Query) { $query = $this->createQuery($this->getServer(), $query, $bindings, $files, $settings); } $result = $this->getTransport()->write([$query], 1); return $result[0][0]; }
[ "public", "function", "writeOne", "(", "string", "$", "query", ",", "array", "$", "bindings", "=", "[", "]", ",", "array", "$", "files", "=", "[", "]", ",", "array", "$", "settings", "=", "[", "]", ")", ":", "bool", "{", "if", "(", "!", "$", "query", "instanceof", "Query", ")", "{", "$", "query", "=", "$", "this", "->", "createQuery", "(", "$", "this", "->", "getServer", "(", ")", ",", "$", "query", ",", "$", "bindings", ",", "$", "files", ",", "$", "settings", ")", ";", "}", "$", "result", "=", "$", "this", "->", "getTransport", "(", ")", "->", "write", "(", "[", "$", "query", "]", ",", "1", ")", ";", "return", "$", "result", "[", "0", "]", "[", "0", "]", ";", "}" ]
Performs insert or simple statement query. @param string $query @param array $bindings @param array $files @param array $settings @return bool
[ "Performs", "insert", "or", "simple", "statement", "query", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L304-L313
223,557
the-tinderbox/ClickhouseClient
src/Client.php
Client.writeFiles
public function writeFiles( string $table, array $columns, array $files, string $format = Format::TSV, array $settings = [], int $concurrency = 5 ) { $sql = 'INSERT INTO '.$table.' ('.implode(', ', $columns).') FORMAT '.strtoupper($format); foreach ($files as $i => $file) { if (!$file instanceof FileInterface) { $files[$i] = new File($file); } } $query = $this->createQuery($this->getServer(), $sql, [], $files, $settings); return $this->getTransport()->write([$query], $concurrency); }
php
public function writeFiles( string $table, array $columns, array $files, string $format = Format::TSV, array $settings = [], int $concurrency = 5 ) { $sql = 'INSERT INTO '.$table.' ('.implode(', ', $columns).') FORMAT '.strtoupper($format); foreach ($files as $i => $file) { if (!$file instanceof FileInterface) { $files[$i] = new File($file); } } $query = $this->createQuery($this->getServer(), $sql, [], $files, $settings); return $this->getTransport()->write([$query], $concurrency); }
[ "public", "function", "writeFiles", "(", "string", "$", "table", ",", "array", "$", "columns", ",", "array", "$", "files", ",", "string", "$", "format", "=", "Format", "::", "TSV", ",", "array", "$", "settings", "=", "[", "]", ",", "int", "$", "concurrency", "=", "5", ")", "{", "$", "sql", "=", "'INSERT INTO '", ".", "$", "table", ".", "' ('", ".", "implode", "(", "', '", ",", "$", "columns", ")", ".", "') FORMAT '", ".", "strtoupper", "(", "$", "format", ")", ";", "foreach", "(", "$", "files", "as", "$", "i", "=>", "$", "file", ")", "{", "if", "(", "!", "$", "file", "instanceof", "FileInterface", ")", "{", "$", "files", "[", "$", "i", "]", "=", "new", "File", "(", "$", "file", ")", ";", "}", "}", "$", "query", "=", "$", "this", "->", "createQuery", "(", "$", "this", "->", "getServer", "(", ")", ",", "$", "sql", ",", "[", "]", ",", "$", "files", ",", "$", "settings", ")", ";", "return", "$", "this", "->", "getTransport", "(", ")", "->", "write", "(", "[", "$", "query", "]", ",", "$", "concurrency", ")", ";", "}" ]
Performs async insert queries using local csv or tsv files. @param string $table @param array $columns @param array $files @param string|null $format @param array $settings @param int $concurrency Max concurrency requests @return array
[ "Performs", "async", "insert", "queries", "using", "local", "csv", "or", "tsv", "files", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L346-L365
223,558
the-tinderbox/ClickhouseClient
src/Client.php
Client.createQuery
protected function createQuery( Server $server, string $sql, array $bindings = [], array $files = [], array $settings = [] ): Query { $preparedSql = $this->prepareSql($sql, $bindings); return new Query($server, $preparedSql, $files, $settings); }
php
protected function createQuery( Server $server, string $sql, array $bindings = [], array $files = [], array $settings = [] ): Query { $preparedSql = $this->prepareSql($sql, $bindings); return new Query($server, $preparedSql, $files, $settings); }
[ "protected", "function", "createQuery", "(", "Server", "$", "server", ",", "string", "$", "sql", ",", "array", "$", "bindings", "=", "[", "]", ",", "array", "$", "files", "=", "[", "]", ",", "array", "$", "settings", "=", "[", "]", ")", ":", "Query", "{", "$", "preparedSql", "=", "$", "this", "->", "prepareSql", "(", "$", "sql", ",", "$", "bindings", ")", ";", "return", "new", "Query", "(", "$", "server", ",", "$", "preparedSql", ",", "$", "files", ",", "$", "settings", ")", ";", "}" ]
Creates query instance from specified arguments. @param \Tinderbox\Clickhouse\Server $server @param string $sql @param array $bindings @param array $files @param array $settings @return \Tinderbox\Clickhouse\Query
[ "Creates", "query", "instance", "from", "specified", "arguments", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L378-L388
223,559
the-tinderbox/ClickhouseClient
src/Client.php
Client.guessQuery
protected function guessQuery(array $query): Query { $server = $query['server'] ?? $this->getServer(); $sql = $query['query']; $bindings = $query['bindings'] ?? []; $tables = $query['files'] ?? []; $settings = $query['settings'] ?? []; return $this->createQuery($server, $sql, $bindings, $tables, $settings); }
php
protected function guessQuery(array $query): Query { $server = $query['server'] ?? $this->getServer(); $sql = $query['query']; $bindings = $query['bindings'] ?? []; $tables = $query['files'] ?? []; $settings = $query['settings'] ?? []; return $this->createQuery($server, $sql, $bindings, $tables, $settings); }
[ "protected", "function", "guessQuery", "(", "array", "$", "query", ")", ":", "Query", "{", "$", "server", "=", "$", "query", "[", "'server'", "]", "??", "$", "this", "->", "getServer", "(", ")", ";", "$", "sql", "=", "$", "query", "[", "'query'", "]", ";", "$", "bindings", "=", "$", "query", "[", "'bindings'", "]", "??", "[", "]", ";", "$", "tables", "=", "$", "query", "[", "'files'", "]", "??", "[", "]", ";", "$", "settings", "=", "$", "query", "[", "'settings'", "]", "??", "[", "]", ";", "return", "$", "this", "->", "createQuery", "(", "$", "server", ",", "$", "sql", ",", "$", "bindings", ",", "$", "tables", ",", "$", "settings", ")", ";", "}" ]
Parses query array and returns query instance. @param array $query @return \Tinderbox\Clickhouse\Query
[ "Parses", "query", "array", "and", "returns", "query", "instance", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Client.php#L397-L406
223,560
infobip/oneapi-php
oneapi/SocialInviteClient.php
SocialInviteClient.sendInvite
public function sendInvite($socialInviteRequest, $socialInviteAppSecret) { $restUrl = $this->getRestUrl('/1/social-invite/invitation'); $sender = $this->getOrCreateSenderId($socialInviteRequest->senderAddress); if(is_string($socialInviteRequest->recipients)) { $temp = explode(',', $socialInviteRequest->recipients); unset($socialInviteRequest->recipients); for ($i = 0; $i < count($temp); $i++) { $socialInviteRequest->recipients->destinations[$i] = new stdClass(); $socialInviteRequest->recipients->destinations[$i]->address = $temp[$i]; } } $params = array( 'messageKey' => $socialInviteRequest->messageKey, 'sender' => $sender, 'recipients' => $socialInviteRequest->recipients ); list($isSuccess, $content) = $this->executePOST( $restUrl, $params, 'application/json', $socialInviteAppSecret ); return $this->createFromJSON('infobip\models\SocialInviteResponse', $content, !$isSuccess); }
php
public function sendInvite($socialInviteRequest, $socialInviteAppSecret) { $restUrl = $this->getRestUrl('/1/social-invite/invitation'); $sender = $this->getOrCreateSenderId($socialInviteRequest->senderAddress); if(is_string($socialInviteRequest->recipients)) { $temp = explode(',', $socialInviteRequest->recipients); unset($socialInviteRequest->recipients); for ($i = 0; $i < count($temp); $i++) { $socialInviteRequest->recipients->destinations[$i] = new stdClass(); $socialInviteRequest->recipients->destinations[$i]->address = $temp[$i]; } } $params = array( 'messageKey' => $socialInviteRequest->messageKey, 'sender' => $sender, 'recipients' => $socialInviteRequest->recipients ); list($isSuccess, $content) = $this->executePOST( $restUrl, $params, 'application/json', $socialInviteAppSecret ); return $this->createFromJSON('infobip\models\SocialInviteResponse', $content, !$isSuccess); }
[ "public", "function", "sendInvite", "(", "$", "socialInviteRequest", ",", "$", "socialInviteAppSecret", ")", "{", "$", "restUrl", "=", "$", "this", "->", "getRestUrl", "(", "'/1/social-invite/invitation'", ")", ";", "$", "sender", "=", "$", "this", "->", "getOrCreateSenderId", "(", "$", "socialInviteRequest", "->", "senderAddress", ")", ";", "if", "(", "is_string", "(", "$", "socialInviteRequest", "->", "recipients", ")", ")", "{", "$", "temp", "=", "explode", "(", "','", ",", "$", "socialInviteRequest", "->", "recipients", ")", ";", "unset", "(", "$", "socialInviteRequest", "->", "recipients", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "temp", ")", ";", "$", "i", "++", ")", "{", "$", "socialInviteRequest", "->", "recipients", "->", "destinations", "[", "$", "i", "]", "=", "new", "stdClass", "(", ")", ";", "$", "socialInviteRequest", "->", "recipients", "->", "destinations", "[", "$", "i", "]", "->", "address", "=", "$", "temp", "[", "$", "i", "]", ";", "}", "}", "$", "params", "=", "array", "(", "'messageKey'", "=>", "$", "socialInviteRequest", "->", "messageKey", ",", "'sender'", "=>", "$", "sender", ",", "'recipients'", "=>", "$", "socialInviteRequest", "->", "recipients", ")", ";", "list", "(", "$", "isSuccess", ",", "$", "content", ")", "=", "$", "this", "->", "executePOST", "(", "$", "restUrl", ",", "$", "params", ",", "'application/json'", ",", "$", "socialInviteAppSecret", ")", ";", "return", "$", "this", "->", "createFromJSON", "(", "'infobip\\models\\SocialInviteResponse'", ",", "$", "content", ",", "!", "$", "isSuccess", ")", ";", "}" ]
Send social invitation
[ "Send", "social", "invitation" ]
e3eac385eac8bfc51d2b351091e4a9ceb7ee4ed6
https://github.com/infobip/oneapi-php/blob/e3eac385eac8bfc51d2b351091e4a9ceb7ee4ed6/oneapi/SocialInviteClient.php#L29-L54
223,561
odan/twig-translation
src/Twig/TwigCompiler.php
TwigCompiler.compile
public function compile(): bool { // Delete old twig cache files if (file_exists($this->cachePath)) { $this->removeDirectory($this->cachePath); } if (!file_exists($this->cachePath)) { mkdir($this->cachePath); } // Iterate over all your templates and force compilation $this->twig->disableDebug(); $this->twig->enableAutoReload(); if (!$this->twig->getCache()) { throw new RuntimeException('The Twig cache must be enabled!'); } $loader = $this->twig->getLoader(); if ($loader instanceof FilesystemLoader) { $paths = $loader->getPaths(); foreach ($paths as $path) { $this->compileFiles($path); } } return true; }
php
public function compile(): bool { // Delete old twig cache files if (file_exists($this->cachePath)) { $this->removeDirectory($this->cachePath); } if (!file_exists($this->cachePath)) { mkdir($this->cachePath); } // Iterate over all your templates and force compilation $this->twig->disableDebug(); $this->twig->enableAutoReload(); if (!$this->twig->getCache()) { throw new RuntimeException('The Twig cache must be enabled!'); } $loader = $this->twig->getLoader(); if ($loader instanceof FilesystemLoader) { $paths = $loader->getPaths(); foreach ($paths as $path) { $this->compileFiles($path); } } return true; }
[ "public", "function", "compile", "(", ")", ":", "bool", "{", "// Delete old twig cache files", "if", "(", "file_exists", "(", "$", "this", "->", "cachePath", ")", ")", "{", "$", "this", "->", "removeDirectory", "(", "$", "this", "->", "cachePath", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "this", "->", "cachePath", ")", ")", "{", "mkdir", "(", "$", "this", "->", "cachePath", ")", ";", "}", "// Iterate over all your templates and force compilation", "$", "this", "->", "twig", "->", "disableDebug", "(", ")", ";", "$", "this", "->", "twig", "->", "enableAutoReload", "(", ")", ";", "if", "(", "!", "$", "this", "->", "twig", "->", "getCache", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'The Twig cache must be enabled!'", ")", ";", "}", "$", "loader", "=", "$", "this", "->", "twig", "->", "getLoader", "(", ")", ";", "if", "(", "$", "loader", "instanceof", "FilesystemLoader", ")", "{", "$", "paths", "=", "$", "loader", "->", "getPaths", "(", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "$", "this", "->", "compileFiles", "(", "$", "path", ")", ";", "}", "}", "return", "true", ";", "}" ]
Compile all twig templates. @throws Exception Exception @return bool Success
[ "Compile", "all", "twig", "templates", "." ]
d5d3ec65a96587ba8267dbaaf98d7e8c93f07899
https://github.com/odan/twig-translation/blob/d5d3ec65a96587ba8267dbaaf98d7e8c93f07899/src/Twig/TwigCompiler.php#L55-L85
223,562
odan/twig-translation
src/Twig/TwigCompiler.php
TwigCompiler.compileFiles
private function compileFiles(string $viewPath) { $directory = new RecursiveDirectoryIterator($viewPath, FilesystemIterator::SKIP_DOTS); foreach (new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST) as $file) { /** @var SplFileInfo $file */ if ($file->isFile() && $file->getExtension() === 'twig') { $templateName = substr($file->getPathname(), strlen($viewPath) + 1); $templateName = str_replace('\\', '/', $templateName); //echo sprintf("Parsing: %s\n", $templateName); $this->twig->loadTemplate($templateName); } } }
php
private function compileFiles(string $viewPath) { $directory = new RecursiveDirectoryIterator($viewPath, FilesystemIterator::SKIP_DOTS); foreach (new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST) as $file) { /** @var SplFileInfo $file */ if ($file->isFile() && $file->getExtension() === 'twig') { $templateName = substr($file->getPathname(), strlen($viewPath) + 1); $templateName = str_replace('\\', '/', $templateName); //echo sprintf("Parsing: %s\n", $templateName); $this->twig->loadTemplate($templateName); } } }
[ "private", "function", "compileFiles", "(", "string", "$", "viewPath", ")", "{", "$", "directory", "=", "new", "RecursiveDirectoryIterator", "(", "$", "viewPath", ",", "FilesystemIterator", "::", "SKIP_DOTS", ")", ";", "foreach", "(", "new", "RecursiveIteratorIterator", "(", "$", "directory", ",", "RecursiveIteratorIterator", "::", "SELF_FIRST", ")", "as", "$", "file", ")", "{", "/** @var SplFileInfo $file */", "if", "(", "$", "file", "->", "isFile", "(", ")", "&&", "$", "file", "->", "getExtension", "(", ")", "===", "'twig'", ")", "{", "$", "templateName", "=", "substr", "(", "$", "file", "->", "getPathname", "(", ")", ",", "strlen", "(", "$", "viewPath", ")", "+", "1", ")", ";", "$", "templateName", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "templateName", ")", ";", "//echo sprintf(\"Parsing: %s\\n\", $templateName);", "$", "this", "->", "twig", "->", "loadTemplate", "(", "$", "templateName", ")", ";", "}", "}", "}" ]
Compile Twig files. @param string $viewPath @return void
[ "Compile", "Twig", "files", "." ]
d5d3ec65a96587ba8267dbaaf98d7e8c93f07899
https://github.com/odan/twig-translation/blob/d5d3ec65a96587ba8267dbaaf98d7e8c93f07899/src/Twig/TwigCompiler.php#L94-L107
223,563
romka-chev/yii2-swiper
Slide.php
Slide.normalizeOptions
protected function normalizeOptions() { $this->options['data'] = ArrayHelper::getValue( $this->options, 'data', [ ] ); $this->options['style'] = ArrayHelper::getValue( $this->options, 'style', '' ); $this->options['data']['hash'] = $this->hash ?: ArrayHelper::getValue( $this->options['data'], 'hash', null ); $this->hash = $this->hash ?: ArrayHelper::getValue( $this->options['data'], 'hash', null ); if ($this->background) { $this->options['style'] = SwiperCssHelper::mergeStyleAndBackground( $this->background, ArrayHelper::getValue( $this->options, 'style', '' ) ); } elseif (ArrayHelper::getValue( $this->options, 'style' )) { $this->background = SwiperCssHelper::getBackgroundUrl( $this->options['style'] ); } $this->options = array_filter( $this->options ); $this->options['data'] = array_filter( $this->options['data'] ); }
php
protected function normalizeOptions() { $this->options['data'] = ArrayHelper::getValue( $this->options, 'data', [ ] ); $this->options['style'] = ArrayHelper::getValue( $this->options, 'style', '' ); $this->options['data']['hash'] = $this->hash ?: ArrayHelper::getValue( $this->options['data'], 'hash', null ); $this->hash = $this->hash ?: ArrayHelper::getValue( $this->options['data'], 'hash', null ); if ($this->background) { $this->options['style'] = SwiperCssHelper::mergeStyleAndBackground( $this->background, ArrayHelper::getValue( $this->options, 'style', '' ) ); } elseif (ArrayHelper::getValue( $this->options, 'style' )) { $this->background = SwiperCssHelper::getBackgroundUrl( $this->options['style'] ); } $this->options = array_filter( $this->options ); $this->options['data'] = array_filter( $this->options['data'] ); }
[ "protected", "function", "normalizeOptions", "(", ")", "{", "$", "this", "->", "options", "[", "'data'", "]", "=", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "options", ",", "'data'", ",", "[", "]", ")", ";", "$", "this", "->", "options", "[", "'style'", "]", "=", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "options", ",", "'style'", ",", "''", ")", ";", "$", "this", "->", "options", "[", "'data'", "]", "[", "'hash'", "]", "=", "$", "this", "->", "hash", "?", ":", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "options", "[", "'data'", "]", ",", "'hash'", ",", "null", ")", ";", "$", "this", "->", "hash", "=", "$", "this", "->", "hash", "?", ":", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "options", "[", "'data'", "]", ",", "'hash'", ",", "null", ")", ";", "if", "(", "$", "this", "->", "background", ")", "{", "$", "this", "->", "options", "[", "'style'", "]", "=", "SwiperCssHelper", "::", "mergeStyleAndBackground", "(", "$", "this", "->", "background", ",", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "options", ",", "'style'", ",", "''", ")", ")", ";", "}", "elseif", "(", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "options", ",", "'style'", ")", ")", "{", "$", "this", "->", "background", "=", "SwiperCssHelper", "::", "getBackgroundUrl", "(", "$", "this", "->", "options", "[", "'style'", "]", ")", ";", "}", "$", "this", "->", "options", "=", "array_filter", "(", "$", "this", "->", "options", ")", ";", "$", "this", "->", "options", "[", "'data'", "]", "=", "array_filter", "(", "$", "this", "->", "options", "[", "'data'", "]", ")", ";", "}" ]
This function sets default values to options for further usage
[ "This", "function", "sets", "default", "values", "to", "options", "for", "further", "usage" ]
3b695401f2bf360abf1f5989023cde3654f7fb5f
https://github.com/romka-chev/yii2-swiper/blob/3b695401f2bf360abf1f5989023cde3654f7fb5f/Slide.php#L113-L138
223,564
NuclearCMS/Documents
src/Presenters/PresentsFilteredImage.php
PresentsFilteredImage.previewWith
public function previewWith($filter, $compact = false) { return $this->wrapPreview( $this->imageWith($filter), $compact ); }
php
public function previewWith($filter, $compact = false) { return $this->wrapPreview( $this->imageWith($filter), $compact ); }
[ "public", "function", "previewWith", "(", "$", "filter", ",", "$", "compact", "=", "false", ")", "{", "return", "$", "this", "->", "wrapPreview", "(", "$", "this", "->", "imageWith", "(", "$", "filter", ")", ",", "$", "compact", ")", ";", "}" ]
Previews the image with given filter @param string $filter @param bool $compact @return string
[ "Previews", "the", "image", "with", "given", "filter" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Presenters/PresentsFilteredImage.php#L16-L22
223,565
dfridrich/Library
src/Lib.php
Lib.slugify
public static function slugify($text) { // replace non letter or digits by - $text = preg_replace('#[^\\pL\d]+#u', '-', $text); // trim $text = trim($text, '-'); // transliterate if (function_exists('iconv')) { $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); } // lowercase $text = mb_strtolower($text); // remove unwanted characters $text = preg_replace('#[^-\w]+#', '', $text); if (empty($text)) { return 'n-a'; } return $text; }
php
public static function slugify($text) { // replace non letter or digits by - $text = preg_replace('#[^\\pL\d]+#u', '-', $text); // trim $text = trim($text, '-'); // transliterate if (function_exists('iconv')) { $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); } // lowercase $text = mb_strtolower($text); // remove unwanted characters $text = preg_replace('#[^-\w]+#', '', $text); if (empty($text)) { return 'n-a'; } return $text; }
[ "public", "static", "function", "slugify", "(", "$", "text", ")", "{", "// replace non letter or digits by -", "$", "text", "=", "preg_replace", "(", "'#[^\\\\pL\\d]+#u'", ",", "'-'", ",", "$", "text", ")", ";", "// trim", "$", "text", "=", "trim", "(", "$", "text", ",", "'-'", ")", ";", "// transliterate", "if", "(", "function_exists", "(", "'iconv'", ")", ")", "{", "$", "text", "=", "iconv", "(", "'utf-8'", ",", "'us-ascii//TRANSLIT'", ",", "$", "text", ")", ";", "}", "// lowercase", "$", "text", "=", "mb_strtolower", "(", "$", "text", ")", ";", "// remove unwanted characters", "$", "text", "=", "preg_replace", "(", "'#[^-\\w]+#'", ",", "''", ",", "$", "text", ")", ";", "if", "(", "empty", "(", "$", "text", ")", ")", "{", "return", "'n-a'", ";", "}", "return", "$", "text", ";", "}" ]
Vrati seo friendly slug. @param $text @return mixed|string
[ "Vrati", "seo", "friendly", "slug", "." ]
2a9eb98df23799a018ce072e9cfc57e903e4613a
https://github.com/dfridrich/Library/blob/2a9eb98df23799a018ce072e9cfc57e903e4613a/src/Lib.php#L321-L345
223,566
dfridrich/Library
src/Lib.php
Lib.cliMessage
public static function cliMessage($string) { $preString = ' | '; if (is_array($string)) { echo $preString.implode("\n==> ", $string)."\n"; } else { echo $preString.$string."\n"; } }
php
public static function cliMessage($string) { $preString = ' | '; if (is_array($string)) { echo $preString.implode("\n==> ", $string)."\n"; } else { echo $preString.$string."\n"; } }
[ "public", "static", "function", "cliMessage", "(", "$", "string", ")", "{", "$", "preString", "=", "' | '", ";", "if", "(", "is_array", "(", "$", "string", ")", ")", "{", "echo", "$", "preString", ".", "implode", "(", "\"\\n==> \"", ",", "$", "string", ")", ".", "\"\\n\"", ";", "}", "else", "{", "echo", "$", "preString", ".", "$", "string", ".", "\"\\n\"", ";", "}", "}" ]
Vrati zpravu do prikazove radky. @param $string mixed
[ "Vrati", "zpravu", "do", "prikazove", "radky", "." ]
2a9eb98df23799a018ce072e9cfc57e903e4613a
https://github.com/dfridrich/Library/blob/2a9eb98df23799a018ce072e9cfc57e903e4613a/src/Lib.php#L352-L360
223,567
dfridrich/Library
src/Lib.php
Lib.idize
public static function idize($string, $capitalize = false) { $string = mb_strtolower(static::stripDiacritics($string)); $string = preg_replace('/[^0-9a-zA-Z-]/i', '-', $string); $string = preg_replace('/(-+)/i', '-', $string); $string = trim($string, '-'); return $capitalize ? mb_strtoupper($string) : $string; }
php
public static function idize($string, $capitalize = false) { $string = mb_strtolower(static::stripDiacritics($string)); $string = preg_replace('/[^0-9a-zA-Z-]/i', '-', $string); $string = preg_replace('/(-+)/i', '-', $string); $string = trim($string, '-'); return $capitalize ? mb_strtoupper($string) : $string; }
[ "public", "static", "function", "idize", "(", "$", "string", ",", "$", "capitalize", "=", "false", ")", "{", "$", "string", "=", "mb_strtolower", "(", "static", "::", "stripDiacritics", "(", "$", "string", ")", ")", ";", "$", "string", "=", "preg_replace", "(", "'/[^0-9a-zA-Z-]/i'", ",", "'-'", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'/(-+)/i'", ",", "'-'", ",", "$", "string", ")", ";", "$", "string", "=", "trim", "(", "$", "string", ",", "'-'", ")", ";", "return", "$", "capitalize", "?", "mb_strtoupper", "(", "$", "string", ")", ":", "$", "string", ";", "}" ]
Upravi zadany retezec do podoby, ktera muze byt bezpecne pouzita jako id nebo predevsim v url jako rewrite string. Muze obsahovat znaky: 0-9, a-z, A-Z, - @param string $string @param bool $capitalize @return string
[ "Upravi", "zadany", "retezec", "do", "podoby", "ktera", "muze", "byt", "bezpecne", "pouzita", "jako", "id", "nebo", "predevsim", "v", "url", "jako", "rewrite", "string", "." ]
2a9eb98df23799a018ce072e9cfc57e903e4613a
https://github.com/dfridrich/Library/blob/2a9eb98df23799a018ce072e9cfc57e903e4613a/src/Lib.php#L525-L534
223,568
dfridrich/Library
src/Lib.php
Lib.parseName
public static function parseName($name) { $name = urldecode($name); $names = explode(' ', str_replace(',', '', $name)); $pretitle = $first_name = $last_name = $posttitle = ''; foreach ($names as $name) { if (('.' === mb_substr($name, -1) || 'et' === $name) && empty($first_name)) { $pretitle .= $name.' '; continue; } if (empty($first_name)) { $first_name = $name; continue; } if ('.' === mb_substr($name, -1) && !empty($last_name)) { $posttitle .= $name.' '; continue; } if (!empty($first_name)) { $last_name .= $name.' '; continue; } } return [ trim($pretitle), mb_convert_case(trim(mb_strtolower($first_name)), MB_CASE_TITLE, 'UTF-8'), mb_convert_case(trim(mb_strtolower($last_name)), MB_CASE_TITLE, 'UTF-8'), trim($posttitle), ]; }
php
public static function parseName($name) { $name = urldecode($name); $names = explode(' ', str_replace(',', '', $name)); $pretitle = $first_name = $last_name = $posttitle = ''; foreach ($names as $name) { if (('.' === mb_substr($name, -1) || 'et' === $name) && empty($first_name)) { $pretitle .= $name.' '; continue; } if (empty($first_name)) { $first_name = $name; continue; } if ('.' === mb_substr($name, -1) && !empty($last_name)) { $posttitle .= $name.' '; continue; } if (!empty($first_name)) { $last_name .= $name.' '; continue; } } return [ trim($pretitle), mb_convert_case(trim(mb_strtolower($first_name)), MB_CASE_TITLE, 'UTF-8'), mb_convert_case(trim(mb_strtolower($last_name)), MB_CASE_TITLE, 'UTF-8'), trim($posttitle), ]; }
[ "public", "static", "function", "parseName", "(", "$", "name", ")", "{", "$", "name", "=", "urldecode", "(", "$", "name", ")", ";", "$", "names", "=", "explode", "(", "' '", ",", "str_replace", "(", "','", ",", "''", ",", "$", "name", ")", ")", ";", "$", "pretitle", "=", "$", "first_name", "=", "$", "last_name", "=", "$", "posttitle", "=", "''", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "if", "(", "(", "'.'", "===", "mb_substr", "(", "$", "name", ",", "-", "1", ")", "||", "'et'", "===", "$", "name", ")", "&&", "empty", "(", "$", "first_name", ")", ")", "{", "$", "pretitle", ".=", "$", "name", ".", "' '", ";", "continue", ";", "}", "if", "(", "empty", "(", "$", "first_name", ")", ")", "{", "$", "first_name", "=", "$", "name", ";", "continue", ";", "}", "if", "(", "'.'", "===", "mb_substr", "(", "$", "name", ",", "-", "1", ")", "&&", "!", "empty", "(", "$", "last_name", ")", ")", "{", "$", "posttitle", ".=", "$", "name", ".", "' '", ";", "continue", ";", "}", "if", "(", "!", "empty", "(", "$", "first_name", ")", ")", "{", "$", "last_name", ".=", "$", "name", ".", "' '", ";", "continue", ";", "}", "}", "return", "[", "trim", "(", "$", "pretitle", ")", ",", "mb_convert_case", "(", "trim", "(", "mb_strtolower", "(", "$", "first_name", ")", ")", ",", "MB_CASE_TITLE", ",", "'UTF-8'", ")", ",", "mb_convert_case", "(", "trim", "(", "mb_strtolower", "(", "$", "last_name", ")", ")", ",", "MB_CASE_TITLE", ",", "'UTF-8'", ")", ",", "trim", "(", "$", "posttitle", ")", ",", "]", ";", "}" ]
Rozparsuje jmeno vcetne titulu pred a za jmenem. @param $name @return array
[ "Rozparsuje", "jmeno", "vcetne", "titulu", "pred", "a", "za", "jmenem", "." ]
2a9eb98df23799a018ce072e9cfc57e903e4613a
https://github.com/dfridrich/Library/blob/2a9eb98df23799a018ce072e9cfc57e903e4613a/src/Lib.php#L543-L575
223,569
dfridrich/Library
src/Lib.php
Lib.getImageDpi
public static function getImageDpi($filename) { $a = fopen($filename, 'r'); $string = fread($a, 20); fclose($a); $data = bin2hex(mb_substr($string, 14, 4)); $x = mb_substr($data, 0, 4); $y = mb_substr($data, 0, 4); return [hexdec($x), hexdec($y)]; }
php
public static function getImageDpi($filename) { $a = fopen($filename, 'r'); $string = fread($a, 20); fclose($a); $data = bin2hex(mb_substr($string, 14, 4)); $x = mb_substr($data, 0, 4); $y = mb_substr($data, 0, 4); return [hexdec($x), hexdec($y)]; }
[ "public", "static", "function", "getImageDpi", "(", "$", "filename", ")", "{", "$", "a", "=", "fopen", "(", "$", "filename", ",", "'r'", ")", ";", "$", "string", "=", "fread", "(", "$", "a", ",", "20", ")", ";", "fclose", "(", "$", "a", ")", ";", "$", "data", "=", "bin2hex", "(", "mb_substr", "(", "$", "string", ",", "14", ",", "4", ")", ")", ";", "$", "x", "=", "mb_substr", "(", "$", "data", ",", "0", ",", "4", ")", ";", "$", "y", "=", "mb_substr", "(", "$", "data", ",", "0", ",", "4", ")", ";", "return", "[", "hexdec", "(", "$", "x", ")", ",", "hexdec", "(", "$", "y", ")", "]", ";", "}" ]
Counts image DPI. @param $filename @return array
[ "Counts", "image", "DPI", "." ]
2a9eb98df23799a018ce072e9cfc57e903e4613a
https://github.com/dfridrich/Library/blob/2a9eb98df23799a018ce072e9cfc57e903e4613a/src/Lib.php#L598-L608
223,570
dfridrich/Library
src/Lib.php
Lib.identifyImage
public static function identifyImage($filename) { $dpi = static::getImageDpi($filename); $data = []; $data['dpi_x'] = $dpi[0]; $data['dpi_y'] = $dpi[1]; // Sometimes it returns 10752, which is (WHY?!) 72 dpi if (10752 === $data['dpi_x']) { $data['dpi_x'] = 72; } if (10752 === $data['dpi_y']) { $data['dpi_y'] = 72; } $info = getimagesize($filename); $data['image_w'] = $info[0]; $data['image_h'] = $info[1]; $data['bits'] = $info['bits']; $data['channels'] = ''; if (3 === $info['channels']) { $data['channels'] = 'RGB'; } if (4 === $info['channels']) { $data['channels'] = 'CMYK'; } return $data; }
php
public static function identifyImage($filename) { $dpi = static::getImageDpi($filename); $data = []; $data['dpi_x'] = $dpi[0]; $data['dpi_y'] = $dpi[1]; // Sometimes it returns 10752, which is (WHY?!) 72 dpi if (10752 === $data['dpi_x']) { $data['dpi_x'] = 72; } if (10752 === $data['dpi_y']) { $data['dpi_y'] = 72; } $info = getimagesize($filename); $data['image_w'] = $info[0]; $data['image_h'] = $info[1]; $data['bits'] = $info['bits']; $data['channels'] = ''; if (3 === $info['channels']) { $data['channels'] = 'RGB'; } if (4 === $info['channels']) { $data['channels'] = 'CMYK'; } return $data; }
[ "public", "static", "function", "identifyImage", "(", "$", "filename", ")", "{", "$", "dpi", "=", "static", "::", "getImageDpi", "(", "$", "filename", ")", ";", "$", "data", "=", "[", "]", ";", "$", "data", "[", "'dpi_x'", "]", "=", "$", "dpi", "[", "0", "]", ";", "$", "data", "[", "'dpi_y'", "]", "=", "$", "dpi", "[", "1", "]", ";", "// Sometimes it returns 10752, which is (WHY?!) 72 dpi", "if", "(", "10752", "===", "$", "data", "[", "'dpi_x'", "]", ")", "{", "$", "data", "[", "'dpi_x'", "]", "=", "72", ";", "}", "if", "(", "10752", "===", "$", "data", "[", "'dpi_y'", "]", ")", "{", "$", "data", "[", "'dpi_y'", "]", "=", "72", ";", "}", "$", "info", "=", "getimagesize", "(", "$", "filename", ")", ";", "$", "data", "[", "'image_w'", "]", "=", "$", "info", "[", "0", "]", ";", "$", "data", "[", "'image_h'", "]", "=", "$", "info", "[", "1", "]", ";", "$", "data", "[", "'bits'", "]", "=", "$", "info", "[", "'bits'", "]", ";", "$", "data", "[", "'channels'", "]", "=", "''", ";", "if", "(", "3", "===", "$", "info", "[", "'channels'", "]", ")", "{", "$", "data", "[", "'channels'", "]", "=", "'RGB'", ";", "}", "if", "(", "4", "===", "$", "info", "[", "'channels'", "]", ")", "{", "$", "data", "[", "'channels'", "]", "=", "'CMYK'", ";", "}", "return", "$", "data", ";", "}" ]
Identify image without Imagick. @param $filename @return array
[ "Identify", "image", "without", "Imagick", "." ]
2a9eb98df23799a018ce072e9cfc57e903e4613a
https://github.com/dfridrich/Library/blob/2a9eb98df23799a018ce072e9cfc57e903e4613a/src/Lib.php#L617-L645
223,571
dfridrich/Library
src/Lib.php
Lib.dirSize
public static function dirSize($directory) { $size = 0; foreach (new \RecursiveIteratorIterator( new RecursiveDirectoryIterator($directory, \FilesystemIterator::KEY_AS_PATHNAME) ) as $file) { $size += $file->getSize(); } return $size; }
php
public static function dirSize($directory) { $size = 0; foreach (new \RecursiveIteratorIterator( new RecursiveDirectoryIterator($directory, \FilesystemIterator::KEY_AS_PATHNAME) ) as $file) { $size += $file->getSize(); } return $size; }
[ "public", "static", "function", "dirSize", "(", "$", "directory", ")", "{", "$", "size", "=", "0", ";", "foreach", "(", "new", "\\", "RecursiveIteratorIterator", "(", "new", "RecursiveDirectoryIterator", "(", "$", "directory", ",", "\\", "FilesystemIterator", "::", "KEY_AS_PATHNAME", ")", ")", "as", "$", "file", ")", "{", "$", "size", "+=", "$", "file", "->", "getSize", "(", ")", ";", "}", "return", "$", "size", ";", "}" ]
Get the directory size. @param $directory @return int
[ "Get", "the", "directory", "size", "." ]
2a9eb98df23799a018ce072e9cfc57e903e4613a
https://github.com/dfridrich/Library/blob/2a9eb98df23799a018ce072e9cfc57e903e4613a/src/Lib.php#L926-L936
223,572
updivision/matrix-php-sdk
src/Resources/UserSession.php
UserSession.login
public function login($username, $password) { $data = $this->matrix()->request('POST', $this->endpoint('login'), [ 'type' => 'm.login.password', 'user' => $username, 'password' => $password ]); $this->setData($data); return $this->data; }
php
public function login($username, $password) { $data = $this->matrix()->request('POST', $this->endpoint('login'), [ 'type' => 'm.login.password', 'user' => $username, 'password' => $password ]); $this->setData($data); return $this->data; }
[ "public", "function", "login", "(", "$", "username", ",", "$", "password", ")", "{", "$", "data", "=", "$", "this", "->", "matrix", "(", ")", "->", "request", "(", "'POST'", ",", "$", "this", "->", "endpoint", "(", "'login'", ")", ",", "[", "'type'", "=>", "'m.login.password'", ",", "'user'", "=>", "$", "username", ",", "'password'", "=>", "$", "password", "]", ")", ";", "$", "this", "->", "setData", "(", "$", "data", ")", ";", "return", "$", "this", "->", "data", ";", "}" ]
Authenticates the user, and issues an access token they can use to authorize themself in subsequent requests. @param string $username The username @param string $password The password @return JSON Authenticated user
[ "Authenticates", "the", "user", "and", "issues", "an", "access", "token", "they", "can", "use", "to", "authorize", "themself", "in", "subsequent", "requests", "." ]
6ce47ffee72e6300c54e473e9d20b174846beb26
https://github.com/updivision/matrix-php-sdk/blob/6ce47ffee72e6300c54e473e9d20b174846beb26/src/Resources/UserSession.php#L31-L40
223,573
updivision/matrix-php-sdk
src/Resources/UserSession.php
UserSession.logout
public function logout() { if ($this->check()) { $this->matrix()->request('POST', $this->endpoint('logout'), [], [ 'access_token' => $this->data['access_token'] ]); $this->setData(null); return true; } throw new \Exception('Not authenticated'); }
php
public function logout() { if ($this->check()) { $this->matrix()->request('POST', $this->endpoint('logout'), [], [ 'access_token' => $this->data['access_token'] ]); $this->setData(null); return true; } throw new \Exception('Not authenticated'); }
[ "public", "function", "logout", "(", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "$", "this", "->", "matrix", "(", ")", "->", "request", "(", "'POST'", ",", "$", "this", "->", "endpoint", "(", "'logout'", ")", ",", "[", "]", ",", "[", "'access_token'", "=>", "$", "this", "->", "data", "[", "'access_token'", "]", "]", ")", ";", "$", "this", "->", "setData", "(", "null", ")", ";", "return", "true", ";", "}", "throw", "new", "\\", "Exception", "(", "'Not authenticated'", ")", ";", "}" ]
Invalidates an existing access token, so that it can no longer be used for authorization. @param string $token The access token @return JSON Empty json
[ "Invalidates", "an", "existing", "access", "token", "so", "that", "it", "can", "no", "longer", "be", "used", "for", "authorization", "." ]
6ce47ffee72e6300c54e473e9d20b174846beb26
https://github.com/updivision/matrix-php-sdk/blob/6ce47ffee72e6300c54e473e9d20b174846beb26/src/Resources/UserSession.php#L48-L58
223,574
the-tinderbox/ClickhouseClient
src/Query/Mapper/AbstractMapper.php
AbstractMapper.countBindingsFromQuery
protected function countBindingsFromQuery(string $query) { preg_match_all($this->getBindingPattern(), $query, $matches); return count($matches[0] ?? []); }
php
protected function countBindingsFromQuery(string $query) { preg_match_all($this->getBindingPattern(), $query, $matches); return count($matches[0] ?? []); }
[ "protected", "function", "countBindingsFromQuery", "(", "string", "$", "query", ")", "{", "preg_match_all", "(", "$", "this", "->", "getBindingPattern", "(", ")", ",", "$", "query", ",", "$", "matches", ")", ";", "return", "count", "(", "$", "matches", "[", "0", "]", "??", "[", "]", ")", ";", "}" ]
Counts bindings in query by given pattern. @param string $query @return int
[ "Counts", "bindings", "in", "query", "by", "given", "pattern", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Query/Mapper/AbstractMapper.php#L41-L46
223,575
the-tinderbox/ClickhouseClient
src/Query/Mapper/AbstractMapper.php
AbstractMapper.escapeBindings
protected function escapeBindings(array $bindings): array { foreach ($bindings as $key => $value) { $bindings[$key] = Sanitizer::escape($value); } return $bindings; }
php
protected function escapeBindings(array $bindings): array { foreach ($bindings as $key => $value) { $bindings[$key] = Sanitizer::escape($value); } return $bindings; }
[ "protected", "function", "escapeBindings", "(", "array", "$", "bindings", ")", ":", "array", "{", "foreach", "(", "$", "bindings", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "bindings", "[", "$", "key", "]", "=", "Sanitizer", "::", "escape", "(", "$", "value", ")", ";", "}", "return", "$", "bindings", ";", "}" ]
Escapes values. @param array $bindings @return array
[ "Escapes", "values", "." ]
1c72116a84bd303e0b57d9ad40e3c2465af2bf66
https://github.com/the-tinderbox/ClickhouseClient/blob/1c72116a84bd303e0b57d9ad40e3c2465af2bf66/src/Query/Mapper/AbstractMapper.php#L55-L62
223,576
updivision/matrix-php-sdk
src/Resources/UserData.php
UserData.get3pid
public function get3pid() { if ($this->check()) { return $this->matrix()->request('GET', $this->endpoint('account/3pid'), [], [ 'access_token' => $this->data['access_token'] ]); } throw new \Exception('Not authenticated'); }
php
public function get3pid() { if ($this->check()) { return $this->matrix()->request('GET', $this->endpoint('account/3pid'), [], [ 'access_token' => $this->data['access_token'] ]); } throw new \Exception('Not authenticated'); }
[ "public", "function", "get3pid", "(", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "return", "$", "this", "->", "matrix", "(", ")", "->", "request", "(", "'GET'", ",", "$", "this", "->", "endpoint", "(", "'account/3pid'", ")", ",", "[", "]", ",", "[", "'access_token'", "=>", "$", "this", "->", "data", "[", "'access_token'", "]", "]", ")", ";", "}", "throw", "new", "\\", "Exception", "(", "'Not authenticated'", ")", ";", "}" ]
Gets a list of the third party identifiers that the homeserver has associated with the user's account. @return mixed|null 3pid list @throws Exception
[ "Gets", "a", "list", "of", "the", "third", "party", "identifiers", "that", "the", "homeserver", "has", "associated", "with", "the", "user", "s", "account", "." ]
6ce47ffee72e6300c54e473e9d20b174846beb26
https://github.com/updivision/matrix-php-sdk/blob/6ce47ffee72e6300c54e473e9d20b174846beb26/src/Resources/UserData.php#L30-L38
223,577
updivision/matrix-php-sdk
src/Resources/UserData.php
UserData.set3pid
public function set3pid($data) { if ($this->check()) { return $this->matrix()->request('POST', $this->endpoint('account/3pid'), $data, [ 'access_token' => $this->data['access_token'] ]); } throw new \Exception('Not authenticated'); }
php
public function set3pid($data) { if ($this->check()) { return $this->matrix()->request('POST', $this->endpoint('account/3pid'), $data, [ 'access_token' => $this->data['access_token'] ]); } throw new \Exception('Not authenticated'); }
[ "public", "function", "set3pid", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "return", "$", "this", "->", "matrix", "(", ")", "->", "request", "(", "'POST'", ",", "$", "this", "->", "endpoint", "(", "'account/3pid'", ")", ",", "$", "data", ",", "[", "'access_token'", "=>", "$", "this", "->", "data", "[", "'access_token'", "]", "]", ")", ";", "}", "throw", "new", "\\", "Exception", "(", "'Not authenticated'", ")", ";", "}" ]
Adds contact information to the user's account. @param Array $data Contact info @return mixed|null The addition was successful. @throws Exception
[ "Adds", "contact", "information", "to", "the", "user", "s", "account", "." ]
6ce47ffee72e6300c54e473e9d20b174846beb26
https://github.com/updivision/matrix-php-sdk/blob/6ce47ffee72e6300c54e473e9d20b174846beb26/src/Resources/UserData.php#L47-L55
223,578
updivision/matrix-php-sdk
src/Resources/UserData.php
UserData.deactivate
public function deactivate() { if ($this->check()) { return $this->matrix()->request('POST', $this->endpoint('account/deactivate'), [ 'auth' => [ 'type' => 'm.login.password' ] ], [ 'access_token' => $this->data['access_token'] ]); } throw new \Exception('Not authenticated'); }
php
public function deactivate() { if ($this->check()) { return $this->matrix()->request('POST', $this->endpoint('account/deactivate'), [ 'auth' => [ 'type' => 'm.login.password' ] ], [ 'access_token' => $this->data['access_token'] ]); } throw new \Exception('Not authenticated'); }
[ "public", "function", "deactivate", "(", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "return", "$", "this", "->", "matrix", "(", ")", "->", "request", "(", "'POST'", ",", "$", "this", "->", "endpoint", "(", "'account/deactivate'", ")", ",", "[", "'auth'", "=>", "[", "'type'", "=>", "'m.login.password'", "]", "]", ",", "[", "'access_token'", "=>", "$", "this", "->", "data", "[", "'access_token'", "]", "]", ")", ";", "}", "throw", "new", "\\", "Exception", "(", "'Not authenticated'", ")", ";", "}" ]
Deactivate the user's account, removing all ability for the user to login again. @param Array $data User Data @return mixed|null Empty json @throws Exception
[ "Deactivate", "the", "user", "s", "account", "removing", "all", "ability", "for", "the", "user", "to", "login", "again", "." ]
6ce47ffee72e6300c54e473e9d20b174846beb26
https://github.com/updivision/matrix-php-sdk/blob/6ce47ffee72e6300c54e473e9d20b174846beb26/src/Resources/UserData.php#L64-L76
223,579
updivision/matrix-php-sdk
src/Resources/UserData.php
UserData.password
public function password($oldPassword, $newPassword) { if ($this->check()) { return $this->matrix()->request('POST', $this->endpoint('account/password'), [ 'auth' => [ 'type' => 'm.login.password', 'user' => $this->data['user_id'], 'password' => $oldPassword ], 'new_password' => $newPassword ], [ 'access_token' => $this->data['access_token'] ]); } throw new \Exception('Not authenticated'); }
php
public function password($oldPassword, $newPassword) { if ($this->check()) { return $this->matrix()->request('POST', $this->endpoint('account/password'), [ 'auth' => [ 'type' => 'm.login.password', 'user' => $this->data['user_id'], 'password' => $oldPassword ], 'new_password' => $newPassword ], [ 'access_token' => $this->data['access_token'] ]); } throw new \Exception('Not authenticated'); }
[ "public", "function", "password", "(", "$", "oldPassword", ",", "$", "newPassword", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "return", "$", "this", "->", "matrix", "(", ")", "->", "request", "(", "'POST'", ",", "$", "this", "->", "endpoint", "(", "'account/password'", ")", ",", "[", "'auth'", "=>", "[", "'type'", "=>", "'m.login.password'", ",", "'user'", "=>", "$", "this", "->", "data", "[", "'user_id'", "]", ",", "'password'", "=>", "$", "oldPassword", "]", ",", "'new_password'", "=>", "$", "newPassword", "]", ",", "[", "'access_token'", "=>", "$", "this", "->", "data", "[", "'access_token'", "]", "]", ")", ";", "}", "throw", "new", "\\", "Exception", "(", "'Not authenticated'", ")", ";", "}" ]
Changes the password for an account on this homeserver. @param String $password The new password @return mixed|null Empty json @throws Exception
[ "Changes", "the", "password", "for", "an", "account", "on", "this", "homeserver", "." ]
6ce47ffee72e6300c54e473e9d20b174846beb26
https://github.com/updivision/matrix-php-sdk/blob/6ce47ffee72e6300c54e473e9d20b174846beb26/src/Resources/UserData.php#L85-L100
223,580
updivision/matrix-php-sdk
src/Resources/UserData.php
UserData.getProfile
public function getProfile($userId = null) { if (!$userId) { if (!$this->check()) { throw new \Exception('Not authenticated'); } $userId = $this->data['user_id']; } return $this->matrix()->request('GET', $this->endpoint('profile/'.urlencode($userId))); }
php
public function getProfile($userId = null) { if (!$userId) { if (!$this->check()) { throw new \Exception('Not authenticated'); } $userId = $this->data['user_id']; } return $this->matrix()->request('GET', $this->endpoint('profile/'.urlencode($userId))); }
[ "public", "function", "getProfile", "(", "$", "userId", "=", "null", ")", "{", "if", "(", "!", "$", "userId", ")", "{", "if", "(", "!", "$", "this", "->", "check", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Not authenticated'", ")", ";", "}", "$", "userId", "=", "$", "this", "->", "data", "[", "'user_id'", "]", ";", "}", "return", "$", "this", "->", "matrix", "(", ")", "->", "request", "(", "'GET'", ",", "$", "this", "->", "endpoint", "(", "'profile/'", ".", "urlencode", "(", "$", "userId", ")", ")", ")", ";", "}" ]
Get the combined profile information for this user. This API may be used to fetch the user's own profile information or other users; either locally or on remote homeservers. @param String $userId User id in Matrix format @return mixed|null User data @throws Exception
[ "Get", "the", "combined", "profile", "information", "for", "this", "user", ".", "This", "API", "may", "be", "used", "to", "fetch", "the", "user", "s", "own", "profile", "information", "or", "other", "users", ";", "either", "locally", "or", "on", "remote", "homeservers", "." ]
6ce47ffee72e6300c54e473e9d20b174846beb26
https://github.com/updivision/matrix-php-sdk/blob/6ce47ffee72e6300c54e473e9d20b174846beb26/src/Resources/UserData.php#L110-L119
223,581
NuclearCMS/Documents
src/Presenters/PresentsHtmlMedia.php
PresentsHtmlMedia.presentHtmlMedia
public function presentHtmlMedia($mediaType) { $html = '<source src="' . $this->entity->getPublicURL() . '" type="' . $this->mimetype . '">'; foreach($this->entity->substitutes as $substitute) { $html .= '<source src="' . uploaded_asset($substitute->path) . '" type="' . $substitute->mimetype . '">'; } return '<' . $mediaType . ' controls>' . $html . '</' . $mediaType . '>'; }
php
public function presentHtmlMedia($mediaType) { $html = '<source src="' . $this->entity->getPublicURL() . '" type="' . $this->mimetype . '">'; foreach($this->entity->substitutes as $substitute) { $html .= '<source src="' . uploaded_asset($substitute->path) . '" type="' . $substitute->mimetype . '">'; } return '<' . $mediaType . ' controls>' . $html . '</' . $mediaType . '>'; }
[ "public", "function", "presentHtmlMedia", "(", "$", "mediaType", ")", "{", "$", "html", "=", "'<source src=\"'", ".", "$", "this", "->", "entity", "->", "getPublicURL", "(", ")", ".", "'\" type=\"'", ".", "$", "this", "->", "mimetype", ".", "'\">'", ";", "foreach", "(", "$", "this", "->", "entity", "->", "substitutes", "as", "$", "substitute", ")", "{", "$", "html", ".=", "'<source src=\"'", ".", "uploaded_asset", "(", "$", "substitute", "->", "path", ")", ".", "'\" type=\"'", ".", "$", "substitute", "->", "mimetype", ".", "'\">'", ";", "}", "return", "'<'", ".", "$", "mediaType", ".", "' controls>'", ".", "$", "html", ".", "'</'", ".", "$", "mediaType", ".", "'>'", ";", "}" ]
Presents audio html @param string $mediaType @return string
[ "Presents", "audio", "html" ]
0130e5920e45ade85a762f167b09ab8003e8104c
https://github.com/NuclearCMS/Documents/blob/0130e5920e45ade85a762f167b09ab8003e8104c/src/Presenters/PresentsHtmlMedia.php#L15-L25
223,582
sourcebroker/deployer-extended-database
src/Utility/ConsoleUtility.php
ConsoleUtility.getVerbosityAsParameter
public function getVerbosityAsParameter(OutputInterface $output) { switch ($output->getVerbosity()) { case OutputInterface::VERBOSITY_DEBUG: $verbosity = ' -vvv'; break; case OutputInterface::VERBOSITY_VERY_VERBOSE: $verbosity = ' -vv'; break; case OutputInterface::VERBOSITY_VERBOSE: $verbosity = ' -v'; break; case OutputInterface::VERBOSITY_QUIET: $verbosity = ' -q'; break; case OutputInterface::VERBOSITY_NORMAL: default: $verbosity = ''; } return $verbosity; }
php
public function getVerbosityAsParameter(OutputInterface $output) { switch ($output->getVerbosity()) { case OutputInterface::VERBOSITY_DEBUG: $verbosity = ' -vvv'; break; case OutputInterface::VERBOSITY_VERY_VERBOSE: $verbosity = ' -vv'; break; case OutputInterface::VERBOSITY_VERBOSE: $verbosity = ' -v'; break; case OutputInterface::VERBOSITY_QUIET: $verbosity = ' -q'; break; case OutputInterface::VERBOSITY_NORMAL: default: $verbosity = ''; } return $verbosity; }
[ "public", "function", "getVerbosityAsParameter", "(", "OutputInterface", "$", "output", ")", "{", "switch", "(", "$", "output", "->", "getVerbosity", "(", ")", ")", "{", "case", "OutputInterface", "::", "VERBOSITY_DEBUG", ":", "$", "verbosity", "=", "' -vvv'", ";", "break", ";", "case", "OutputInterface", "::", "VERBOSITY_VERY_VERBOSE", ":", "$", "verbosity", "=", "' -vv'", ";", "break", ";", "case", "OutputInterface", "::", "VERBOSITY_VERBOSE", ":", "$", "verbosity", "=", "' -v'", ";", "break", ";", "case", "OutputInterface", "::", "VERBOSITY_QUIET", ":", "$", "verbosity", "=", "' -q'", ";", "break", ";", "case", "OutputInterface", "::", "VERBOSITY_NORMAL", ":", "default", ":", "$", "verbosity", "=", "''", ";", "}", "return", "$", "verbosity", ";", "}" ]
Returns OutputInterface verbosity as parameter that can be used in cli command @param OutputInterface $output @return string
[ "Returns", "OutputInterface", "verbosity", "as", "parameter", "that", "can", "be", "used", "in", "cli", "command" ]
e07088e3fc913389530279c3a0a2136c691115fe
https://github.com/sourcebroker/deployer-extended-database/blob/e07088e3fc913389530279c3a0a2136c691115fe/src/Utility/ConsoleUtility.php#L21-L41
223,583
ongr-io/FilterManagerBundle
Filter/Widget/Sort/Sort.php
Sort.addFieldToSort
private function addFieldToSort(Search $search, $sortField) { $search->addSort( new FieldSort( $sortField['field'], $sortField['order'], isset($sortField['mode']) ? ['mode' => $sortField['mode']] : [] ) ); }
php
private function addFieldToSort(Search $search, $sortField) { $search->addSort( new FieldSort( $sortField['field'], $sortField['order'], isset($sortField['mode']) ? ['mode' => $sortField['mode']] : [] ) ); }
[ "private", "function", "addFieldToSort", "(", "Search", "$", "search", ",", "$", "sortField", ")", "{", "$", "search", "->", "addSort", "(", "new", "FieldSort", "(", "$", "sortField", "[", "'field'", "]", ",", "$", "sortField", "[", "'order'", "]", ",", "isset", "(", "$", "sortField", "[", "'mode'", "]", ")", "?", "[", "'mode'", "=>", "$", "sortField", "[", "'mode'", "]", "]", ":", "[", "]", ")", ")", ";", "}" ]
Adds sort field parameters into given search object. @param Search $search @param array $sortField
[ "Adds", "sort", "field", "parameters", "into", "given", "search", "object", "." ]
26c1125457f0440019b9bf20090bf23ba4bb1905
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Filter/Widget/Sort/Sort.php#L139-L148
223,584
puli/manager
src/Conflict/ModuleConflict.php
ModuleConflict.getOpponents
public function getOpponents($moduleName) { if (!isset($this->moduleNames[$moduleName])) { return array(); } $opponents = $this->moduleNames; unset($opponents[$moduleName]); return array_keys($opponents); }
php
public function getOpponents($moduleName) { if (!isset($this->moduleNames[$moduleName])) { return array(); } $opponents = $this->moduleNames; unset($opponents[$moduleName]); return array_keys($opponents); }
[ "public", "function", "getOpponents", "(", "$", "moduleName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "moduleNames", "[", "$", "moduleName", "]", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "opponents", "=", "$", "this", "->", "moduleNames", ";", "unset", "(", "$", "opponents", "[", "$", "moduleName", "]", ")", ";", "return", "array_keys", "(", "$", "opponents", ")", ";", "}" ]
Returns the opposing module names in the conflict. @param string $moduleName The name of a module. @return string[] Returns the names of the opposing modules or an empty array if the module is not involved in the conflict.
[ "Returns", "the", "opposing", "module", "names", "in", "the", "conflict", "." ]
b3e726e35c2e6da809fd13f73d590290fb3fca43
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/ModuleConflict.php#L94-L105
223,585
apoutchika/MediaBundle
Services/Image/Resize.php
Resize.resizeByWidth
private function resizeByWidth($originalWidth, $originalHeight, $targetWidth) { $targetHeight = ($targetWidth * $originalHeight) / $originalWidth; return $this->verifySize($originalWidth, $originalHeight, $targetWidth, $targetHeight); }
php
private function resizeByWidth($originalWidth, $originalHeight, $targetWidth) { $targetHeight = ($targetWidth * $originalHeight) / $originalWidth; return $this->verifySize($originalWidth, $originalHeight, $targetWidth, $targetHeight); }
[ "private", "function", "resizeByWidth", "(", "$", "originalWidth", ",", "$", "originalHeight", ",", "$", "targetWidth", ")", "{", "$", "targetHeight", "=", "(", "$", "targetWidth", "*", "$", "originalHeight", ")", "/", "$", "originalWidth", ";", "return", "$", "this", "->", "verifySize", "(", "$", "originalWidth", ",", "$", "originalHeight", ",", "$", "targetWidth", ",", "$", "targetHeight", ")", ";", "}" ]
Get Resize size when width > height. @param int $originalWidth @param int $originalHeight @param int $targetWidth @return array Width and Height
[ "Get", "Resize", "size", "when", "width", ">", "height", "." ]
dd52efed4a4463041da73af2cb25bdbe00365fcc
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/Image/Resize.php#L134-L139
223,586
apoutchika/MediaBundle
Services/Image/Resize.php
Resize.resizeByHeight
private function resizeByHeight($originalWidth, $originalHeight, $targetHeight) { $targetWidth = ($targetHeight * $originalWidth) / $originalHeight; return $this->verifySize($originalWidth, $originalHeight, $targetWidth, $targetHeight); }
php
private function resizeByHeight($originalWidth, $originalHeight, $targetHeight) { $targetWidth = ($targetHeight * $originalWidth) / $originalHeight; return $this->verifySize($originalWidth, $originalHeight, $targetWidth, $targetHeight); }
[ "private", "function", "resizeByHeight", "(", "$", "originalWidth", ",", "$", "originalHeight", ",", "$", "targetHeight", ")", "{", "$", "targetWidth", "=", "(", "$", "targetHeight", "*", "$", "originalWidth", ")", "/", "$", "originalHeight", ";", "return", "$", "this", "->", "verifySize", "(", "$", "originalWidth", ",", "$", "originalHeight", ",", "$", "targetWidth", ",", "$", "targetHeight", ")", ";", "}" ]
get resize size when height > width. @param int $originalWidth @param int $originalHeight @param int $targetHeight @return array Width and Height
[ "get", "resize", "size", "when", "height", ">", "width", "." ]
dd52efed4a4463041da73af2cb25bdbe00365fcc
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/Image/Resize.php#L150-L155
223,587
apoutchika/MediaBundle
Services/Image/Resize.php
Resize.verifySize
private function verifySize($originalWidth, $originalHeight, $targetWidth, $targetHeight) { if ($originalWidth < $targetWidth && $originalHeight < $targetHeight) { return array( 'width' => $originalWidth, 'height' => $originalHeight, ); } return array( 'width' => $targetWidth, 'height' => $targetHeight, ); }
php
private function verifySize($originalWidth, $originalHeight, $targetWidth, $targetHeight) { if ($originalWidth < $targetWidth && $originalHeight < $targetHeight) { return array( 'width' => $originalWidth, 'height' => $originalHeight, ); } return array( 'width' => $targetWidth, 'height' => $targetHeight, ); }
[ "private", "function", "verifySize", "(", "$", "originalWidth", ",", "$", "originalHeight", ",", "$", "targetWidth", ",", "$", "targetHeight", ")", "{", "if", "(", "$", "originalWidth", "<", "$", "targetWidth", "&&", "$", "originalHeight", "<", "$", "targetHeight", ")", "{", "return", "array", "(", "'width'", "=>", "$", "originalWidth", ",", "'height'", "=>", "$", "originalHeight", ",", ")", ";", "}", "return", "array", "(", "'width'", "=>", "$", "targetWidth", ",", "'height'", "=>", "$", "targetHeight", ",", ")", ";", "}" ]
Verify if the target size > originial size, if true return original size. @param int $originalWidth @param int $originalHeight @param int $targetWidth @param int $targetHeight @return array Width and Height
[ "Verify", "if", "the", "target", "size", ">", "originial", "size", "if", "true", "return", "original", "size", "." ]
dd52efed4a4463041da73af2cb25bdbe00365fcc
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/Image/Resize.php#L167-L180
223,588
nilportugues/php-sitemap
src/Sitemap.php
Sitemap.add
public function add($item, $url = '') { $this->validateItemClassType($item); $this->createSitemapFile(); $xmlData = $item->build(); if (false === $this->isNewFileIsRequired() && false === $this->isSurpassingFileSizeLimit($xmlData)) { $this->appendToFile($xmlData); ++$this->totalItems; return $this; } $this->createAdditionalSitemapFile($item); return $this; }
php
public function add($item, $url = '') { $this->validateItemClassType($item); $this->createSitemapFile(); $xmlData = $item->build(); if (false === $this->isNewFileIsRequired() && false === $this->isSurpassingFileSizeLimit($xmlData)) { $this->appendToFile($xmlData); ++$this->totalItems; return $this; } $this->createAdditionalSitemapFile($item); return $this; }
[ "public", "function", "add", "(", "$", "item", ",", "$", "url", "=", "''", ")", "{", "$", "this", "->", "validateItemClassType", "(", "$", "item", ")", ";", "$", "this", "->", "createSitemapFile", "(", ")", ";", "$", "xmlData", "=", "$", "item", "->", "build", "(", ")", ";", "if", "(", "false", "===", "$", "this", "->", "isNewFileIsRequired", "(", ")", "&&", "false", "===", "$", "this", "->", "isSurpassingFileSizeLimit", "(", "$", "xmlData", ")", ")", "{", "$", "this", "->", "appendToFile", "(", "$", "xmlData", ")", ";", "++", "$", "this", "->", "totalItems", ";", "return", "$", "this", ";", "}", "$", "this", "->", "createAdditionalSitemapFile", "(", "$", "item", ")", ";", "return", "$", "this", ";", "}" ]
Adds a new sitemap item. @param $item @param string $url @return $this
[ "Adds", "a", "new", "sitemap", "item", "." ]
b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd
https://github.com/nilportugues/php-sitemap/blob/b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd/src/Sitemap.php#L28-L44
223,589
szmnmichalowski/ZF2-NoCaptcha
src/NoCaptcha/Captcha/ReCaptcha.php
ReCaptcha.isValid
public function isValid($value) { if (!$value) { $this->error(self::MISSING_VALUE); return false; } $response = $this->getService()->verify($value); if ($response->getStatus() === true) { return true; } $this->error(self::ERR_CAPTCHA); return false; }
php
public function isValid($value) { if (!$value) { $this->error(self::MISSING_VALUE); return false; } $response = $this->getService()->verify($value); if ($response->getStatus() === true) { return true; } $this->error(self::ERR_CAPTCHA); return false; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "if", "(", "!", "$", "value", ")", "{", "$", "this", "->", "error", "(", "self", "::", "MISSING_VALUE", ")", ";", "return", "false", ";", "}", "$", "response", "=", "$", "this", "->", "getService", "(", ")", "->", "verify", "(", "$", "value", ")", ";", "if", "(", "$", "response", "->", "getStatus", "(", ")", "===", "true", ")", "{", "return", "true", ";", "}", "$", "this", "->", "error", "(", "self", "::", "ERR_CAPTCHA", ")", ";", "return", "false", ";", "}" ]
Check if captcha is valid @param mixed $value @return bool @throws \Exception
[ "Check", "if", "captcha", "is", "valid" ]
f839e9a6b2e9f400b1c6777be0ece995f691cbdb
https://github.com/szmnmichalowski/ZF2-NoCaptcha/blob/f839e9a6b2e9f400b1c6777be0ece995f691cbdb/src/NoCaptcha/Captcha/ReCaptcha.php#L242-L257
223,590
QoboLtd/cakephp-calendar
src/Object/Objects/Event.php
Event.setStartDate
public function setStartDate($startDate): void { if (is_string($startDate)) { $startDate = new Time($startDate); } $this->startDate = $startDate; }
php
public function setStartDate($startDate): void { if (is_string($startDate)) { $startDate = new Time($startDate); } $this->startDate = $startDate; }
[ "public", "function", "setStartDate", "(", "$", "startDate", ")", ":", "void", "{", "if", "(", "is_string", "(", "$", "startDate", ")", ")", "{", "$", "startDate", "=", "new", "Time", "(", "$", "startDate", ")", ";", "}", "$", "this", "->", "startDate", "=", "$", "startDate", ";", "}" ]
Set Start Date of event @param \Cake\I18n\Time|string $startDate of event @return void
[ "Set", "Start", "Date", "of", "event" ]
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Object/Objects/Event.php#L97-L104
223,591
QoboLtd/cakephp-calendar
src/Object/Objects/Event.php
Event.setEndDate
public function setEndDate($endDate): void { if (is_string($endDate)) { $endDate = new Time($endDate); } $this->endDate = $endDate; }
php
public function setEndDate($endDate): void { if (is_string($endDate)) { $endDate = new Time($endDate); } $this->endDate = $endDate; }
[ "public", "function", "setEndDate", "(", "$", "endDate", ")", ":", "void", "{", "if", "(", "is_string", "(", "$", "endDate", ")", ")", "{", "$", "endDate", "=", "new", "Time", "(", "$", "endDate", ")", ";", "}", "$", "this", "->", "endDate", "=", "$", "endDate", ";", "}" ]
Set End Date of event @param \Cake\I18n\Time|string $endDate for event @return void
[ "Set", "End", "Date", "of", "event" ]
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Object/Objects/Event.php#L120-L127
223,592
apoutchika/MediaBundle
Services/ContextsManipulator.php
ContextsManipulator.insertContextInAllowedExtensions
private function insertContextInAllowedExtensions($name) { if (!array_key_exists($name, $this->contexts)) { throw new \Exception('The context '.$name.' is not defined.'); } $this->allowedExtensions = array_merge($this->contexts[$name], $this->allowedExtensions); }
php
private function insertContextInAllowedExtensions($name) { if (!array_key_exists($name, $this->contexts)) { throw new \Exception('The context '.$name.' is not defined.'); } $this->allowedExtensions = array_merge($this->contexts[$name], $this->allowedExtensions); }
[ "private", "function", "insertContextInAllowedExtensions", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "contexts", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'The context '", ".", "$", "name", ".", "' is not defined.'", ")", ";", "}", "$", "this", "->", "allowedExtensions", "=", "array_merge", "(", "$", "this", "->", "contexts", "[", "$", "name", "]", ",", "$", "this", "->", "allowedExtensions", ")", ";", "}" ]
Insert contexts extensions in allowed extensions. @param string $name context name
[ "Insert", "contexts", "extensions", "in", "allowed", "extensions", "." ]
dd52efed4a4463041da73af2cb25bdbe00365fcc
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/ContextsManipulator.php#L44-L51
223,593
apoutchika/MediaBundle
Services/ContextsManipulator.php
ContextsManipulator.addContexts
public function addContexts($contexts) { if (is_array($contexts)) { foreach ($contexts as $context) { $this->insertContextInAllowedExtensions($context); } } elseif ($contexts !== false) { $this->insertContextInAllowedExtensions($contexts); } return $this; }
php
public function addContexts($contexts) { if (is_array($contexts)) { foreach ($contexts as $context) { $this->insertContextInAllowedExtensions($context); } } elseif ($contexts !== false) { $this->insertContextInAllowedExtensions($contexts); } return $this; }
[ "public", "function", "addContexts", "(", "$", "contexts", ")", "{", "if", "(", "is_array", "(", "$", "contexts", ")", ")", "{", "foreach", "(", "$", "contexts", "as", "$", "context", ")", "{", "$", "this", "->", "insertContextInAllowedExtensions", "(", "$", "context", ")", ";", "}", "}", "elseif", "(", "$", "contexts", "!==", "false", ")", "{", "$", "this", "->", "insertContextInAllowedExtensions", "(", "$", "contexts", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add other context. @param array|string $contexts @return ContextsManipulator
[ "Add", "other", "context", "." ]
dd52efed4a4463041da73af2cb25bdbe00365fcc
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/ContextsManipulator.php#L60-L71
223,594
QoboLtd/cakephp-calendar
src/Event/Plugin/GetCalendarsListener.php
GetCalendarsListener.addEvent
public function addEvent(Event $event, EntityInterface $entity, ArrayObject $options = null): void { $entities = $result = []; if (empty($options)) { $options = new ArrayObject(); } /** @var \Cake\ORM\Table $table */ $table = $event->getSubject(); /** @var \Qobo\Calendar\Model\Table\CalendarsTable $calendarsTable */ $calendarsTable = TableRegistry::get('Qobo/Calendar.Calendars'); /** @var \Qobo\Calendar\Model\Table\CalendarEventsTable $eventsTable */ $eventsTable = TableRegistry::get('Qobo/Calendar.CalendarEvents'); $calendars = $calendarsTable->getByAllowedEventTypes($table->alias()); $options['entity'] = $entity; $options['viewEntity'] = new View(); $entities = $eventsTable->getEventsFromEntities($table, $calendars, $options); if (!empty($entities)) { foreach ($entities as $item) { $saved = $eventsTable->saveEvent($item); $result[] = $saved; } } $event->result = $result; }
php
public function addEvent(Event $event, EntityInterface $entity, ArrayObject $options = null): void { $entities = $result = []; if (empty($options)) { $options = new ArrayObject(); } /** @var \Cake\ORM\Table $table */ $table = $event->getSubject(); /** @var \Qobo\Calendar\Model\Table\CalendarsTable $calendarsTable */ $calendarsTable = TableRegistry::get('Qobo/Calendar.Calendars'); /** @var \Qobo\Calendar\Model\Table\CalendarEventsTable $eventsTable */ $eventsTable = TableRegistry::get('Qobo/Calendar.CalendarEvents'); $calendars = $calendarsTable->getByAllowedEventTypes($table->alias()); $options['entity'] = $entity; $options['viewEntity'] = new View(); $entities = $eventsTable->getEventsFromEntities($table, $calendars, $options); if (!empty($entities)) { foreach ($entities as $item) { $saved = $eventsTable->saveEvent($item); $result[] = $saved; } } $event->result = $result; }
[ "public", "function", "addEvent", "(", "Event", "$", "event", ",", "EntityInterface", "$", "entity", ",", "ArrayObject", "$", "options", "=", "null", ")", ":", "void", "{", "$", "entities", "=", "$", "result", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "options", ")", ")", "{", "$", "options", "=", "new", "ArrayObject", "(", ")", ";", "}", "/** @var \\Cake\\ORM\\Table $table */", "$", "table", "=", "$", "event", "->", "getSubject", "(", ")", ";", "/** @var \\Qobo\\Calendar\\Model\\Table\\CalendarsTable $calendarsTable */", "$", "calendarsTable", "=", "TableRegistry", "::", "get", "(", "'Qobo/Calendar.Calendars'", ")", ";", "/** @var \\Qobo\\Calendar\\Model\\Table\\CalendarEventsTable $eventsTable */", "$", "eventsTable", "=", "TableRegistry", "::", "get", "(", "'Qobo/Calendar.CalendarEvents'", ")", ";", "$", "calendars", "=", "$", "calendarsTable", "->", "getByAllowedEventTypes", "(", "$", "table", "->", "alias", "(", ")", ")", ";", "$", "options", "[", "'entity'", "]", "=", "$", "entity", ";", "$", "options", "[", "'viewEntity'", "]", "=", "new", "View", "(", ")", ";", "$", "entities", "=", "$", "eventsTable", "->", "getEventsFromEntities", "(", "$", "table", ",", "$", "calendars", ",", "$", "options", ")", ";", "if", "(", "!", "empty", "(", "$", "entities", ")", ")", "{", "foreach", "(", "$", "entities", "as", "$", "item", ")", "{", "$", "saved", "=", "$", "eventsTable", "->", "saveEvent", "(", "$", "item", ")", ";", "$", "result", "[", "]", "=", "$", "saved", ";", "}", "}", "$", "event", "->", "result", "=", "$", "result", ";", "}" ]
Add CalendarEvent from App Adding Calendar event based on the entity table. @param \Cake\Event\Event $event received from the app @param \Cake\Datasource\EntityInterface $entity being recently saved. @param \ArrayObject $options with extra configs for adding reminder @return void
[ "Add", "CalendarEvent", "from", "App" ]
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Event/Plugin/GetCalendarsListener.php#L57-L87
223,595
QoboLtd/cakephp-calendar
src/Event/Plugin/GetCalendarsListener.php
GetCalendarsListener.getPluginCalendars
public function getPluginCalendars(Event $event, array $options = []): void { $content = $result = []; /** @var \Qobo\Calendar\Model\Table\CalendarsTable $table */ $table = TableRegistry::get('Qobo/Calendar.Calendars'); if (!empty($event->result)) { $result = $event->result; } // locally created calendars don't have source_id (external link). $options = array_merge($options, [ 'conditions' => [ 'source LIKE' => 'Plugin__%', ] ]); $calendars = $table->getCalendars($options); if (empty($calendars)) { return; } foreach ($calendars as $k => $calendar) { unset($calendar->calendar_events); $encoded = (string)json_encode($calendar); if (json_last_error() !== JSON_ERROR_NONE) { throw new \RuntimeException(json_last_error_msg()); } $content[$k]['calendar'] = json_decode($encoded, true); } if (!empty($content)) { $result = array_merge($result, $content); } $event->result = $result; }
php
public function getPluginCalendars(Event $event, array $options = []): void { $content = $result = []; /** @var \Qobo\Calendar\Model\Table\CalendarsTable $table */ $table = TableRegistry::get('Qobo/Calendar.Calendars'); if (!empty($event->result)) { $result = $event->result; } // locally created calendars don't have source_id (external link). $options = array_merge($options, [ 'conditions' => [ 'source LIKE' => 'Plugin__%', ] ]); $calendars = $table->getCalendars($options); if (empty($calendars)) { return; } foreach ($calendars as $k => $calendar) { unset($calendar->calendar_events); $encoded = (string)json_encode($calendar); if (json_last_error() !== JSON_ERROR_NONE) { throw new \RuntimeException(json_last_error_msg()); } $content[$k]['calendar'] = json_decode($encoded, true); } if (!empty($content)) { $result = array_merge($result, $content); } $event->result = $result; }
[ "public", "function", "getPluginCalendars", "(", "Event", "$", "event", ",", "array", "$", "options", "=", "[", "]", ")", ":", "void", "{", "$", "content", "=", "$", "result", "=", "[", "]", ";", "/** @var \\Qobo\\Calendar\\Model\\Table\\CalendarsTable $table */", "$", "table", "=", "TableRegistry", "::", "get", "(", "'Qobo/Calendar.Calendars'", ")", ";", "if", "(", "!", "empty", "(", "$", "event", "->", "result", ")", ")", "{", "$", "result", "=", "$", "event", "->", "result", ";", "}", "// locally created calendars don't have source_id (external link).", "$", "options", "=", "array_merge", "(", "$", "options", ",", "[", "'conditions'", "=>", "[", "'source LIKE'", "=>", "'Plugin__%'", ",", "]", "]", ")", ";", "$", "calendars", "=", "$", "table", "->", "getCalendars", "(", "$", "options", ")", ";", "if", "(", "empty", "(", "$", "calendars", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "calendars", "as", "$", "k", "=>", "$", "calendar", ")", "{", "unset", "(", "$", "calendar", "->", "calendar_events", ")", ";", "$", "encoded", "=", "(", "string", ")", "json_encode", "(", "$", "calendar", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "json_last_error_msg", "(", ")", ")", ";", "}", "$", "content", "[", "$", "k", "]", "[", "'calendar'", "]", "=", "json_decode", "(", "$", "encoded", ",", "true", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "$", "result", "=", "array_merge", "(", "$", "result", ",", "$", "content", ")", ";", "}", "$", "event", "->", "result", "=", "$", "result", ";", "}" ]
Get calendars from the plugin only. @param \Cake\Event\Event $event passed through @param mixed[] $options for calendars @return void
[ "Get", "calendars", "from", "the", "plugin", "only", "." ]
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Event/Plugin/GetCalendarsListener.php#L147-L187
223,596
QoboLtd/cakephp-calendar
src/Event/Plugin/GetCalendarsListener.php
GetCalendarsListener.getPluginCalendarEvents
public function getPluginCalendarEvents(Event $event, EntityInterface $calendar, array $options = []): void { /** @var \Qobo\Calendar\Model\Table\CalendarEventsTable $table */ $table = TableRegistry::get('Qobo/Calendar.CalendarEvents'); $events = $table->getEvents($calendar, $options); $event->result = $events; }
php
public function getPluginCalendarEvents(Event $event, EntityInterface $calendar, array $options = []): void { /** @var \Qobo\Calendar\Model\Table\CalendarEventsTable $table */ $table = TableRegistry::get('Qobo/Calendar.CalendarEvents'); $events = $table->getEvents($calendar, $options); $event->result = $events; }
[ "public", "function", "getPluginCalendarEvents", "(", "Event", "$", "event", ",", "EntityInterface", "$", "calendar", ",", "array", "$", "options", "=", "[", "]", ")", ":", "void", "{", "/** @var \\Qobo\\Calendar\\Model\\Table\\CalendarEventsTable $table */", "$", "table", "=", "TableRegistry", "::", "get", "(", "'Qobo/Calendar.CalendarEvents'", ")", ";", "$", "events", "=", "$", "table", "->", "getEvents", "(", "$", "calendar", ",", "$", "options", ")", ";", "$", "event", "->", "result", "=", "$", "events", ";", "}" ]
Get calendar events from the plugin only. @param \Cake\Event\Event $event passed through @param \Cake\Datasource\EntityInterface $calendar instance @param mixed[] $options for calendars @return void
[ "Get", "calendar", "events", "from", "the", "plugin", "only", "." ]
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Event/Plugin/GetCalendarsListener.php#L198-L206
223,597
apoutchika/MediaBundle
Model/Media.php
Media.setFocusLeft
public function setFocusLeft($focusLeft) { if ($focusLeft !== $this->focusLeft) { $this->focusIsEdited = true; $this->focusLeft = $focusLeft; } return $this; }
php
public function setFocusLeft($focusLeft) { if ($focusLeft !== $this->focusLeft) { $this->focusIsEdited = true; $this->focusLeft = $focusLeft; } return $this; }
[ "public", "function", "setFocusLeft", "(", "$", "focusLeft", ")", "{", "if", "(", "$", "focusLeft", "!==", "$", "this", "->", "focusLeft", ")", "{", "$", "this", "->", "focusIsEdited", "=", "true", ";", "$", "this", "->", "focusLeft", "=", "$", "focusLeft", ";", "}", "return", "$", "this", ";", "}" ]
Set focusLeft. @param float $focusLeft @return Media
[ "Set", "focusLeft", "." ]
dd52efed4a4463041da73af2cb25bdbe00365fcc
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Model/Media.php#L529-L537
223,598
apoutchika/MediaBundle
Model/Media.php
Media.setFocusTop
public function setFocusTop($focusTop) { if ($focusTop !== $this->focusTop) { $this->focusIsEdited = true; $this->focusTop = $focusTop; } return $this; }
php
public function setFocusTop($focusTop) { if ($focusTop !== $this->focusTop) { $this->focusIsEdited = true; $this->focusTop = $focusTop; } return $this; }
[ "public", "function", "setFocusTop", "(", "$", "focusTop", ")", "{", "if", "(", "$", "focusTop", "!==", "$", "this", "->", "focusTop", ")", "{", "$", "this", "->", "focusIsEdited", "=", "true", ";", "$", "this", "->", "focusTop", "=", "$", "focusTop", ";", "}", "return", "$", "this", ";", "}" ]
Set focusTop. @param float $focusTop @return Media
[ "Set", "focusTop", "." ]
dd52efed4a4463041da73af2cb25bdbe00365fcc
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Model/Media.php#L556-L564
223,599
nilportugues/php-sitemap
src/SubmitSitemap.php
SubmitSitemap.send
public static function send($url) { if (false === \filter_var($url, FILTER_VALIDATE_URL, ['options' => ['flags' => FILTER_FLAG_PATH_REQUIRED]])) { throw new SitemapException('The value for $url is not a valid URL resource.'); } return self::submitSitemap($url); }
php
public static function send($url) { if (false === \filter_var($url, FILTER_VALIDATE_URL, ['options' => ['flags' => FILTER_FLAG_PATH_REQUIRED]])) { throw new SitemapException('The value for $url is not a valid URL resource.'); } return self::submitSitemap($url); }
[ "public", "static", "function", "send", "(", "$", "url", ")", "{", "if", "(", "false", "===", "\\", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_URL", ",", "[", "'options'", "=>", "[", "'flags'", "=>", "FILTER_FLAG_PATH_REQUIRED", "]", "]", ")", ")", "{", "throw", "new", "SitemapException", "(", "'The value for $url is not a valid URL resource.'", ")", ";", "}", "return", "self", "::", "submitSitemap", "(", "$", "url", ")", ";", "}" ]
Submits a Sitemap to the available search engines. If provided it will first to send the GZipped version. @param string $url @return array @throws SitemapException
[ "Submits", "a", "Sitemap", "to", "the", "available", "search", "engines", ".", "If", "provided", "it", "will", "first", "to", "send", "the", "GZipped", "version", "." ]
b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd
https://github.com/nilportugues/php-sitemap/blob/b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd/src/SubmitSitemap.php#L35-L42