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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
webeweb/core-library | src/FileSystem/FileHelper.php | FileHelper.formatSize | public static function formatSize($size, $unit = null, $decimals = 2) {
// Initialize the units.
$units = static::getUnits();
// Find the unit.
$index = array_search($unit, $units);
if (null !== $unit && false === $index) {
throw new IllegalArgumentException("The unit \"" . $unit . "\" does not exists");
}
// Initialize the output.
$output = $size;
$iteration = 0;
while (self::FILE_SIZE_DIVIDER <= $output || $iteration < $index) {
$output /= self::FILE_SIZE_DIVIDER;
++$iteration;
}
// Return the output.
return implode(" ", [sprintf("%." . $decimals . "f", $output), $units[$iteration]]);
} | php | public static function formatSize($size, $unit = null, $decimals = 2) {
// Initialize the units.
$units = static::getUnits();
// Find the unit.
$index = array_search($unit, $units);
if (null !== $unit && false === $index) {
throw new IllegalArgumentException("The unit \"" . $unit . "\" does not exists");
}
// Initialize the output.
$output = $size;
$iteration = 0;
while (self::FILE_SIZE_DIVIDER <= $output || $iteration < $index) {
$output /= self::FILE_SIZE_DIVIDER;
++$iteration;
}
// Return the output.
return implode(" ", [sprintf("%." . $decimals . "f", $output), $units[$iteration]]);
} | [
"public",
"static",
"function",
"formatSize",
"(",
"$",
"size",
",",
"$",
"unit",
"=",
"null",
",",
"$",
"decimals",
"=",
"2",
")",
"{",
"// Initialize the units.",
"$",
"units",
"=",
"static",
"::",
"getUnits",
"(",
")",
";",
"// Find the unit.",
"$",
"... | Format a size.
@param $size The size.
@param string $unit The unit.
@return string Returns the formated size. | [
"Format",
"a",
"size",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/FileSystem/FileHelper.php#L92-L115 | train |
webeweb/core-library | src/FileSystem/FileHelper.php | FileHelper.getFilenames | public static function getFilenames($pathname, $extension = null) {
// Check if the directory exists.
if (false === file_exists($pathname)) {
throw new FileNotFoundException($pathname);
}
// Initialize the filenames.
$filenames = [];
// Open the directory.
if (false !== ($directory = opendir($pathname))) {
// Initialize the offset.
$offset = strlen($extension);
// Read the directory.
while (($file = readdir($directory)) !== false) {
// Determines if the file should be added.
if (false === in_array($file, [".", ".."]) && ((null === $extension) || 0 === substr_compare($file, $extension, -$offset))) {
$filenames[] = $file;
}
}
// Close the directory.
closedir($directory);
}
// Return the filenames.
return $filenames;
} | php | public static function getFilenames($pathname, $extension = null) {
// Check if the directory exists.
if (false === file_exists($pathname)) {
throw new FileNotFoundException($pathname);
}
// Initialize the filenames.
$filenames = [];
// Open the directory.
if (false !== ($directory = opendir($pathname))) {
// Initialize the offset.
$offset = strlen($extension);
// Read the directory.
while (($file = readdir($directory)) !== false) {
// Determines if the file should be added.
if (false === in_array($file, [".", ".."]) && ((null === $extension) || 0 === substr_compare($file, $extension, -$offset))) {
$filenames[] = $file;
}
}
// Close the directory.
closedir($directory);
}
// Return the filenames.
return $filenames;
} | [
"public",
"static",
"function",
"getFilenames",
"(",
"$",
"pathname",
",",
"$",
"extension",
"=",
"null",
")",
"{",
"// Check if the directory exists.",
"if",
"(",
"false",
"===",
"file_exists",
"(",
"$",
"pathname",
")",
")",
"{",
"throw",
"new",
"FileNotFoun... | Get the filenames.
@param string $pathname The pathname.
@param string $extension The file extension.
@return array Returns the filenames.
@throws FileNotFoundException Throws a file not found exception if the directory does not exists. | [
"Get",
"the",
"filenames",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/FileSystem/FileHelper.php#L139-L170 | train |
webeweb/core-library | src/FileSystem/FileHelper.php | FileHelper.getSize | public static function getSize($filename) {
if (false === file_exists($filename)) {
throw new FileNotFoundException($filename);
}
clearstatcache();
return filesize($filename);
} | php | public static function getSize($filename) {
if (false === file_exists($filename)) {
throw new FileNotFoundException($filename);
}
clearstatcache();
return filesize($filename);
} | [
"public",
"static",
"function",
"getSize",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"false",
"===",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"$",
"filename",
")",
";",
"}",
"clearstatcache",
"(",
... | Get a file size.
@param string $filename The filename.
@return int Returns the file size.
@throws FileNotFoundException Throws a File not found exception if the file does not exists. | [
"Get",
"a",
"file",
"size",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/FileSystem/FileHelper.php#L179-L185 | train |
webeweb/core-library | src/FileSystem/FileHelper.php | FileHelper.getUnits | public static function getUnits() {
return [
self::FILE_SIZE_UNIT_B,
self::FILE_SIZE_UNIT_KB,
self::FILE_SIZE_UNIT_MB,
self::FILE_SIZE_UNIT_GB,
self::FILE_SIZE_UNIT_TB,
self::FILE_SIZE_UNIT_PB,
self::FILE_SIZE_UNIT_EB,
self::FILE_SIZE_UNIT_ZB,
self::FILE_SIZE_UNIT_YB,
];
} | php | public static function getUnits() {
return [
self::FILE_SIZE_UNIT_B,
self::FILE_SIZE_UNIT_KB,
self::FILE_SIZE_UNIT_MB,
self::FILE_SIZE_UNIT_GB,
self::FILE_SIZE_UNIT_TB,
self::FILE_SIZE_UNIT_PB,
self::FILE_SIZE_UNIT_EB,
self::FILE_SIZE_UNIT_ZB,
self::FILE_SIZE_UNIT_YB,
];
} | [
"public",
"static",
"function",
"getUnits",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"FILE_SIZE_UNIT_B",
",",
"self",
"::",
"FILE_SIZE_UNIT_KB",
",",
"self",
"::",
"FILE_SIZE_UNIT_MB",
",",
"self",
"::",
"FILE_SIZE_UNIT_GB",
",",
"self",
"::",
"FILE_SIZE_UNIT... | Get the units.
@return array Returns the units. | [
"Get",
"the",
"units",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/FileSystem/FileHelper.php#L192-L204 | train |
webeweb/core-library | src/FileSystem/FileHelper.php | FileHelper.zip | public static function zip($source, $destination) {
// Check if the filename exists.
if (false === file_exists($source)) {
throw new FileNotFoundException($source);
}
// Initialize the ZIP archive.
$zip = new ZipArchive();
$zip->open($destination, ZipArchive::CREATE);
// Clean up.
$src = str_replace("\\\\", "/", realpath($source));
// Is file ? => Add it and return.
if (true === is_file($src)) {
$zip->addFromString(basename($src), static::getContents($src));
return $zip->close();
}
// Handle the files list.
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($src), RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $current) {
// Clean up.
$cur = str_replace("\\\\", "/", realpath($current));
// Initialize the ZIP path.
$zipPath = preg_replace("/^" . str_replace("/", "\/", $src . "/") . "/", "", $cur);
// Check the file type.
if (true === is_file($cur)) {
$zip->addFromString($zipPath, static::getContents($cur));
}
if (true === is_dir($cur)) {
$zip->addEmptyDir($zipPath);
}
}
} | php | public static function zip($source, $destination) {
// Check if the filename exists.
if (false === file_exists($source)) {
throw new FileNotFoundException($source);
}
// Initialize the ZIP archive.
$zip = new ZipArchive();
$zip->open($destination, ZipArchive::CREATE);
// Clean up.
$src = str_replace("\\\\", "/", realpath($source));
// Is file ? => Add it and return.
if (true === is_file($src)) {
$zip->addFromString(basename($src), static::getContents($src));
return $zip->close();
}
// Handle the files list.
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($src), RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $current) {
// Clean up.
$cur = str_replace("\\\\", "/", realpath($current));
// Initialize the ZIP path.
$zipPath = preg_replace("/^" . str_replace("/", "\/", $src . "/") . "/", "", $cur);
// Check the file type.
if (true === is_file($cur)) {
$zip->addFromString($zipPath, static::getContents($cur));
}
if (true === is_dir($cur)) {
$zip->addEmptyDir($zipPath);
}
}
} | [
"public",
"static",
"function",
"zip",
"(",
"$",
"source",
",",
"$",
"destination",
")",
"{",
"// Check if the filename exists.",
"if",
"(",
"false",
"===",
"file_exists",
"(",
"$",
"source",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"$",
... | Zip a file.
@param string $source The source filename.
@param string $destination The destination filename.
@return bool Returns true in case of success, false otherwise.
@throws FileNotFoundException Throws a file not found exception if the source filename is not found. | [
"Zip",
"a",
"file",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/FileSystem/FileHelper.php#L232-L270 | train |
shopgate/cart-integration-magento2-base | src/Helper/Address.php | Address.exists | public function exists($customerId, array $addressToCheck)
{
unset($addressToCheck['email']);
if (empty($addressToCheck['company'])) {
// company would be cast to an empty string, which does not match NULL in the database
unset($addressToCheck['company']);
}
$addressCollection = $this->addressFactory->create()
->getCollection()
->addFieldToFilter('parent_id', $customerId);
foreach ($addressToCheck as $addressField => $fieldValue) {
$addressCollection->addFieldToFilter(
$addressField,
$fieldValue
);
}
return $addressCollection->count() > 0;
} | php | public function exists($customerId, array $addressToCheck)
{
unset($addressToCheck['email']);
if (empty($addressToCheck['company'])) {
// company would be cast to an empty string, which does not match NULL in the database
unset($addressToCheck['company']);
}
$addressCollection = $this->addressFactory->create()
->getCollection()
->addFieldToFilter('parent_id', $customerId);
foreach ($addressToCheck as $addressField => $fieldValue) {
$addressCollection->addFieldToFilter(
$addressField,
$fieldValue
);
}
return $addressCollection->count() > 0;
} | [
"public",
"function",
"exists",
"(",
"$",
"customerId",
",",
"array",
"$",
"addressToCheck",
")",
"{",
"unset",
"(",
"$",
"addressToCheck",
"[",
"'email'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"addressToCheck",
"[",
"'company'",
"]",
")",
")",
... | Checks if provided address is also saved as an address for the given customer
by filtering its customer address
@param int $customerId
@param array $addressToCheck
@return bool
@throws \Magento\Framework\Exception\LocalizedException | [
"Checks",
"if",
"provided",
"address",
"is",
"also",
"saved",
"as",
"an",
"address",
"for",
"the",
"given",
"customer",
"by",
"filtering",
"its",
"customer",
"address"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Address.php#L54-L73 | train |
webeweb/core-library | src/Sorting/QuickSort.php | QuickSort.quickSort | private function quickSort($min, $max) {
$i = $min;
$j = $max;
$pivot = $this->values[$min + ($max - $min) / 2];
while ($i <= $j) {
while (true === $this->functor->compare($this->values[$i], $pivot)) {
++$i;
}
while (true === $this->functor->compare($pivot, $this->values[$j])) {
--$j;
}
if ($i <= $j) {
$this->swap($i, $j);
++$i;
--$j;
}
}
if ($min < $j) {
$this->quickSort($min, $j);
}
if ($i < $max) {
$this->quickSort($i, $max);
}
} | php | private function quickSort($min, $max) {
$i = $min;
$j = $max;
$pivot = $this->values[$min + ($max - $min) / 2];
while ($i <= $j) {
while (true === $this->functor->compare($this->values[$i], $pivot)) {
++$i;
}
while (true === $this->functor->compare($pivot, $this->values[$j])) {
--$j;
}
if ($i <= $j) {
$this->swap($i, $j);
++$i;
--$j;
}
}
if ($min < $j) {
$this->quickSort($min, $j);
}
if ($i < $max) {
$this->quickSort($i, $max);
}
} | [
"private",
"function",
"quickSort",
"(",
"$",
"min",
",",
"$",
"max",
")",
"{",
"$",
"i",
"=",
"$",
"min",
";",
"$",
"j",
"=",
"$",
"max",
";",
"$",
"pivot",
"=",
"$",
"this",
"->",
"values",
"[",
"$",
"min",
"+",
"(",
"$",
"max",
"-",
"$",... | Quick sort the values.
@param int $min The min index.
@param int $max The max index.
@return void | [
"Quick",
"sort",
"the",
"values",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Sorting/QuickSort.php#L72-L102 | train |
webeweb/core-library | src/Sorting/QuickSort.php | QuickSort.swap | private function swap($a, $b) {
$value = $this->values[$a];
$this->values[$a] = $this->values[$b];
$this->values[$b] = $value;
} | php | private function swap($a, $b) {
$value = $this->values[$a];
$this->values[$a] = $this->values[$b];
$this->values[$b] = $value;
} | [
"private",
"function",
"swap",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"values",
"[",
"$",
"a",
"]",
";",
"$",
"this",
"->",
"values",
"[",
"$",
"a",
"]",
"=",
"$",
"this",
"->",
"values",
"[",
"$",
"b"... | Swap two values.
@param int $a The first value index.
@param int $b The second value index.
@return void | [
"Swap",
"two",
"values",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Sorting/QuickSort.php#L142-L146 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/RSA.php | Crypt_RSA._decodeLength | function _decodeLength(&$string)
{
$length = ord($this->_string_shift($string));
if ($length & 0x80) { // definite length, long form
$length&= 0x7F;
$temp = $this->_string_shift($string, $length);
list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4));
}
return $length;
} | php | function _decodeLength(&$string)
{
$length = ord($this->_string_shift($string));
if ($length & 0x80) { // definite length, long form
$length&= 0x7F;
$temp = $this->_string_shift($string, $length);
list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4));
}
return $length;
} | [
"function",
"_decodeLength",
"(",
"&",
"$",
"string",
")",
"{",
"$",
"length",
"=",
"ord",
"(",
"$",
"this",
"->",
"_string_shift",
"(",
"$",
"string",
")",
")",
";",
"if",
"(",
"$",
"length",
"&",
"0x80",
")",
"{",
"// definite length, long form\r",
"... | DER-decode the length
DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See
{@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
@access private
@param string $string
@return int | [
"DER",
"-",
"decode",
"the",
"length"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/RSA.php#L1989-L1998 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/RSA.php | Crypt_RSA._rsaes_pkcs1_v1_5_encrypt | function _rsaes_pkcs1_v1_5_encrypt($m)
{
$mLen = strlen($m);
// Length checking
if ($mLen > $this->k - 11) {
user_error('Message too long');
return false;
}
// EME-PKCS1-v1_5 encoding
$psLen = $this->k - $mLen - 3;
$ps = '';
while (strlen($ps) != $psLen) {
$temp = crypt_random_string($psLen - strlen($ps));
$temp = str_replace("\x00", '', $temp);
$ps.= $temp;
}
$type = 2;
// see the comments of _rsaes_pkcs1_v1_5_decrypt() to understand why this is being done
if (defined('CRYPT_RSA_PKCS15_COMPAT') && (!isset($this->publicExponent) || $this->exponent !== $this->publicExponent)) {
$type = 1;
// "The padding string PS shall consist of k-3-||D|| octets. ... for block type 01, they shall have value FF"
$ps = str_repeat("\xFF", $psLen);
}
$em = chr(0) . chr($type) . $ps . chr(0) . $m;
// RSA encryption
$m = $this->_os2ip($em);
$c = $this->_rsaep($m);
$c = $this->_i2osp($c, $this->k);
// Output the ciphertext C
return $c;
} | php | function _rsaes_pkcs1_v1_5_encrypt($m)
{
$mLen = strlen($m);
// Length checking
if ($mLen > $this->k - 11) {
user_error('Message too long');
return false;
}
// EME-PKCS1-v1_5 encoding
$psLen = $this->k - $mLen - 3;
$ps = '';
while (strlen($ps) != $psLen) {
$temp = crypt_random_string($psLen - strlen($ps));
$temp = str_replace("\x00", '', $temp);
$ps.= $temp;
}
$type = 2;
// see the comments of _rsaes_pkcs1_v1_5_decrypt() to understand why this is being done
if (defined('CRYPT_RSA_PKCS15_COMPAT') && (!isset($this->publicExponent) || $this->exponent !== $this->publicExponent)) {
$type = 1;
// "The padding string PS shall consist of k-3-||D|| octets. ... for block type 01, they shall have value FF"
$ps = str_repeat("\xFF", $psLen);
}
$em = chr(0) . chr($type) . $ps . chr(0) . $m;
// RSA encryption
$m = $this->_os2ip($em);
$c = $this->_rsaep($m);
$c = $this->_i2osp($c, $this->k);
// Output the ciphertext C
return $c;
} | [
"function",
"_rsaes_pkcs1_v1_5_encrypt",
"(",
"$",
"m",
")",
"{",
"$",
"mLen",
"=",
"strlen",
"(",
"$",
"m",
")",
";",
"// Length checking\r",
"if",
"(",
"$",
"mLen",
">",
"$",
"this",
"->",
"k",
"-",
"11",
")",
"{",
"user_error",
"(",
"'Message too lo... | RSAES-PKCS1-V1_5-ENCRYPT
See {@link http://tools.ietf.org/html/rfc3447#section-7.2.1 RFC3447#section-7.2.1}.
@access private
@param string $m
@return string | [
"RSAES",
"-",
"PKCS1",
"-",
"V1_5",
"-",
"ENCRYPT"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/RSA.php#L2546-L2583 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/RSA.php | Crypt_RSA._rsassa_pkcs1_v1_5_verify | function _rsassa_pkcs1_v1_5_verify($m, $s)
{
// Length checking
if (strlen($s) != $this->k) {
user_error('Invalid signature');
return false;
}
// RSA verification
$s = $this->_os2ip($s);
$m2 = $this->_rsavp1($s);
if ($m2 === false) {
user_error('Invalid signature');
return false;
}
$em = $this->_i2osp($m2, $this->k);
if ($em === false) {
user_error('Invalid signature');
return false;
}
// EMSA-PKCS1-v1_5 encoding
$em2 = $this->_emsa_pkcs1_v1_5_encode($m, $this->k);
if ($em2 === false) {
user_error('RSA modulus too short');
return false;
}
// Compare
return $this->_equals($em, $em2);
} | php | function _rsassa_pkcs1_v1_5_verify($m, $s)
{
// Length checking
if (strlen($s) != $this->k) {
user_error('Invalid signature');
return false;
}
// RSA verification
$s = $this->_os2ip($s);
$m2 = $this->_rsavp1($s);
if ($m2 === false) {
user_error('Invalid signature');
return false;
}
$em = $this->_i2osp($m2, $this->k);
if ($em === false) {
user_error('Invalid signature');
return false;
}
// EMSA-PKCS1-v1_5 encoding
$em2 = $this->_emsa_pkcs1_v1_5_encode($m, $this->k);
if ($em2 === false) {
user_error('RSA modulus too short');
return false;
}
// Compare
return $this->_equals($em, $em2);
} | [
"function",
"_rsassa_pkcs1_v1_5_verify",
"(",
"$",
"m",
",",
"$",
"s",
")",
"{",
"// Length checking\r",
"if",
"(",
"strlen",
"(",
"$",
"s",
")",
"!=",
"$",
"this",
"->",
"k",
")",
"{",
"user_error",
"(",
"'Invalid signature'",
")",
";",
"return",
"false... | RSASSA-PKCS1-V1_5-VERIFY
See {@link http://tools.ietf.org/html/rfc3447#section-8.2.2 RFC3447#section-8.2.2}.
@access private
@param string $m
@return string | [
"RSASSA",
"-",
"PKCS1",
"-",
"V1_5",
"-",
"VERIFY"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/RSA.php#L2885-L2918 | train |
Raphhh/trex-reflection | src/CallableReflection.php | CallableReflection.getReflector | public function getReflector()
{
if ($this->isFunction() || $this->isClosure()) {
return new \ReflectionFunction($this->getCallable());
}
if ($this->isMethod()) {
return new \ReflectionMethod($this->getClassName(), $this->getMethodName());
}
if ($this->isInvokedObject()) {
return new \ReflectionMethod($this->getClassName(), '__invoke');
}
throw new \LogicException('Unknown callable reflection');
} | php | public function getReflector()
{
if ($this->isFunction() || $this->isClosure()) {
return new \ReflectionFunction($this->getCallable());
}
if ($this->isMethod()) {
return new \ReflectionMethod($this->getClassName(), $this->getMethodName());
}
if ($this->isInvokedObject()) {
return new \ReflectionMethod($this->getClassName(), '__invoke');
}
throw new \LogicException('Unknown callable reflection');
} | [
"public",
"function",
"getReflector",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFunction",
"(",
")",
"||",
"$",
"this",
"->",
"isClosure",
"(",
")",
")",
"{",
"return",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"this",
"->",
"getCallable",
"("... | Returns the appropriate class of the callable reflection.
@return \ReflectionFunctionAbstract
@throws \LogicException | [
"Returns",
"the",
"appropriate",
"class",
"of",
"the",
"callable",
"reflection",
"."
] | a3c36d498b58f0648b91e95d44ffea0548ae44cd | https://github.com/Raphhh/trex-reflection/blob/a3c36d498b58f0648b91e95d44ffea0548ae44cd/src/CallableReflection.php#L62-L74 | train |
xabbuh/panda-client | src/AbstractApi.php | AbstractApi.getCloudInstance | public static function getCloudInstance($accessKey, $secretKey, $apiHost, $cloudId)
{
$config = array(
'accounts' => array(
'default' => array(
'access_key' => $accessKey,
'secret_key' => $secretKey,
'api_host' => $apiHost,
),
),
'clouds' => array(
'default' => array(
'id' => $cloudId,
'account' => 'default',
)
),
);
/** @var \Xabbuh\PandaClient\AbstractApi $api */
$api = new static($config);
return $api->getCloud('default');
} | php | public static function getCloudInstance($accessKey, $secretKey, $apiHost, $cloudId)
{
$config = array(
'accounts' => array(
'default' => array(
'access_key' => $accessKey,
'secret_key' => $secretKey,
'api_host' => $apiHost,
),
),
'clouds' => array(
'default' => array(
'id' => $cloudId,
'account' => 'default',
)
),
);
/** @var \Xabbuh\PandaClient\AbstractApi $api */
$api = new static($config);
return $api->getCloud('default');
} | [
"public",
"static",
"function",
"getCloudInstance",
"(",
"$",
"accessKey",
",",
"$",
"secretKey",
",",
"$",
"apiHost",
",",
"$",
"cloudId",
")",
"{",
"$",
"config",
"=",
"array",
"(",
"'accounts'",
"=>",
"array",
"(",
"'default'",
"=>",
"array",
"(",
"'a... | Creates a cloud.
@param string $accessKey The access key
@param string $secretKey The secret key
@param string $apiHost The api host
@param string $cloudId The cloud id
@return \Xabbuh\PandaClient\Api\CloudInterface The cloud | [
"Creates",
"a",
"cloud",
"."
] | 0b0f530a47621353441e4de7f6303e5742fc7bd0 | https://github.com/xabbuh/panda-client/blob/0b0f530a47621353441e4de7f6303e5742fc7bd0/src/AbstractApi.php#L295-L317 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/X509.php | File_X509._mapInAttributes | function _mapInAttributes(&$root, $path, $asn1)
{
$attributes = &$this->_subArray($root, $path);
if (is_array($attributes)) {
for ($i = 0; $i < count($attributes); $i++) {
$id = $attributes[$i]['type'];
/* $value contains the DER encoding of an ASN.1 value
corresponding to the attribute type identified by type */
$map = $this->_getMapping($id);
if (is_array($attributes[$i]['value'])) {
$values = &$attributes[$i]['value'];
for ($j = 0; $j < count($values); $j++) {
$value = $asn1->encodeDER($values[$j], $this->AttributeValue);
$decoded = $asn1->decodeBER($value);
if (!is_bool($map)) {
$mapped = $asn1->asn1map($decoded[0], $map);
if ($mapped !== false) {
$values[$j] = $mapped;
}
if ($id == 'pkcs-9-at-extensionRequest' && $this->_isSubArrayValid($values, $j)) {
$this->_mapInExtensions($values, $j, $asn1);
}
} elseif ($map) {
$values[$j] = base64_encode($value);
}
}
}
}
}
} | php | function _mapInAttributes(&$root, $path, $asn1)
{
$attributes = &$this->_subArray($root, $path);
if (is_array($attributes)) {
for ($i = 0; $i < count($attributes); $i++) {
$id = $attributes[$i]['type'];
/* $value contains the DER encoding of an ASN.1 value
corresponding to the attribute type identified by type */
$map = $this->_getMapping($id);
if (is_array($attributes[$i]['value'])) {
$values = &$attributes[$i]['value'];
for ($j = 0; $j < count($values); $j++) {
$value = $asn1->encodeDER($values[$j], $this->AttributeValue);
$decoded = $asn1->decodeBER($value);
if (!is_bool($map)) {
$mapped = $asn1->asn1map($decoded[0], $map);
if ($mapped !== false) {
$values[$j] = $mapped;
}
if ($id == 'pkcs-9-at-extensionRequest' && $this->_isSubArrayValid($values, $j)) {
$this->_mapInExtensions($values, $j, $asn1);
}
} elseif ($map) {
$values[$j] = base64_encode($value);
}
}
}
}
}
} | [
"function",
"_mapInAttributes",
"(",
"&",
"$",
"root",
",",
"$",
"path",
",",
"$",
"asn1",
")",
"{",
"$",
"attributes",
"=",
"&",
"$",
"this",
"->",
"_subArray",
"(",
"$",
"root",
",",
"$",
"path",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"attr... | Map attribute values from ANY type to attribute-specific internal
format.
@param array ref $root
@param string $path
@param object $asn1
@access private | [
"Map",
"attribute",
"values",
"from",
"ANY",
"type",
"to",
"attribute",
"-",
"specific",
"internal",
"format",
"."
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/X509.php#L1739-L1769 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/X509.php | File_X509._mapOutAttributes | function _mapOutAttributes(&$root, $path, $asn1)
{
$attributes = &$this->_subArray($root, $path);
if (is_array($attributes)) {
$size = count($attributes);
for ($i = 0; $i < $size; $i++) {
/* [value] contains the DER encoding of an ASN.1 value
corresponding to the attribute type identified by type */
$id = $attributes[$i]['type'];
$map = $this->_getMapping($id);
if ($map === false) {
user_error($id . ' is not a currently supported attribute', E_USER_NOTICE);
unset($attributes[$i]);
} elseif (is_array($attributes[$i]['value'])) {
$values = &$attributes[$i]['value'];
for ($j = 0; $j < count($values); $j++) {
switch ($id) {
case 'pkcs-9-at-extensionRequest':
$this->_mapOutExtensions($values, $j, $asn1);
break;
}
if (!is_bool($map)) {
$temp = $asn1->encodeDER($values[$j], $map);
$decoded = $asn1->decodeBER($temp);
$values[$j] = $asn1->asn1map($decoded[0], $this->AttributeValue);
}
}
}
}
}
} | php | function _mapOutAttributes(&$root, $path, $asn1)
{
$attributes = &$this->_subArray($root, $path);
if (is_array($attributes)) {
$size = count($attributes);
for ($i = 0; $i < $size; $i++) {
/* [value] contains the DER encoding of an ASN.1 value
corresponding to the attribute type identified by type */
$id = $attributes[$i]['type'];
$map = $this->_getMapping($id);
if ($map === false) {
user_error($id . ' is not a currently supported attribute', E_USER_NOTICE);
unset($attributes[$i]);
} elseif (is_array($attributes[$i]['value'])) {
$values = &$attributes[$i]['value'];
for ($j = 0; $j < count($values); $j++) {
switch ($id) {
case 'pkcs-9-at-extensionRequest':
$this->_mapOutExtensions($values, $j, $asn1);
break;
}
if (!is_bool($map)) {
$temp = $asn1->encodeDER($values[$j], $map);
$decoded = $asn1->decodeBER($temp);
$values[$j] = $asn1->asn1map($decoded[0], $this->AttributeValue);
}
}
}
}
}
} | [
"function",
"_mapOutAttributes",
"(",
"&",
"$",
"root",
",",
"$",
"path",
",",
"$",
"asn1",
")",
"{",
"$",
"attributes",
"=",
"&",
"$",
"this",
"->",
"_subArray",
"(",
"$",
"root",
",",
"$",
"path",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"att... | Map attribute values from attribute-specific internal format to
ANY type.
@param array ref $root
@param string $path
@param object $asn1
@access private | [
"Map",
"attribute",
"values",
"from",
"attribute",
"-",
"specific",
"internal",
"format",
"to",
"ANY",
"type",
"."
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/X509.php#L1780-L1812 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/X509.php | File_X509._mapOutDNs | function _mapOutDNs(&$root, $path, $asn1)
{
$dns = &$this->_subArray($root, $path);
if (is_array($dns)) {
$size = count($dns);
for ($i = 0; $i < $size; $i++) {
for ($j = 0; $j < count($dns[$i]); $j++) {
$type = $dns[$i][$j]['type'];
$value = &$dns[$i][$j]['value'];
if (is_object($value) && strtolower(get_class($value)) == 'file_asn1_element') {
continue;
}
$map = $this->_getMapping($type);
if (!is_bool($map)) {
$value = new File_ASN1_Element($asn1->encodeDER($value, $map));
}
}
}
}
} | php | function _mapOutDNs(&$root, $path, $asn1)
{
$dns = &$this->_subArray($root, $path);
if (is_array($dns)) {
$size = count($dns);
for ($i = 0; $i < $size; $i++) {
for ($j = 0; $j < count($dns[$i]); $j++) {
$type = $dns[$i][$j]['type'];
$value = &$dns[$i][$j]['value'];
if (is_object($value) && strtolower(get_class($value)) == 'file_asn1_element') {
continue;
}
$map = $this->_getMapping($type);
if (!is_bool($map)) {
$value = new File_ASN1_Element($asn1->encodeDER($value, $map));
}
}
}
}
} | [
"function",
"_mapOutDNs",
"(",
"&",
"$",
"root",
",",
"$",
"path",
",",
"$",
"asn1",
")",
"{",
"$",
"dns",
"=",
"&",
"$",
"this",
"->",
"_subArray",
"(",
"$",
"root",
",",
"$",
"path",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"dns",
")",
")... | Map DN values from DN-specific internal format to
ANY type.
@param array ref $root
@param string $path
@param object $asn1
@access private | [
"Map",
"DN",
"values",
"from",
"DN",
"-",
"specific",
"internal",
"format",
"to",
"ANY",
"type",
"."
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/X509.php#L1853-L1874 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/X509.php | File_X509._decodeIP | function _decodeIP($ip)
{
$ip = base64_decode($ip);
list(, $ip) = unpack('N', $ip);
return long2ip($ip);
} | php | function _decodeIP($ip)
{
$ip = base64_decode($ip);
list(, $ip) = unpack('N', $ip);
return long2ip($ip);
} | [
"function",
"_decodeIP",
"(",
"$",
"ip",
")",
"{",
"$",
"ip",
"=",
"base64_decode",
"(",
"$",
"ip",
")",
";",
"list",
"(",
",",
"$",
"ip",
")",
"=",
"unpack",
"(",
"'N'",
",",
"$",
"ip",
")",
";",
"return",
"long2ip",
"(",
"$",
"ip",
")",
";"... | Decodes an IP address
Takes in a base64 encoded "blob" and returns a human readable IP address
@param string $ip
@access private
@return string | [
"Decodes",
"an",
"IP",
"address"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/X509.php#L2340-L2345 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/X509.php | File_X509.removeDNProp | function removeDNProp($propName)
{
if (empty($this->dn)) {
return;
}
if (($propName = $this->_translateDNProp($propName)) === false) {
return;
}
$dn = &$this->dn['rdnSequence'];
$size = count($dn);
for ($i = 0; $i < $size; $i++) {
if ($dn[$i][0]['type'] == $propName) {
unset($dn[$i]);
}
}
$dn = array_values($dn);
} | php | function removeDNProp($propName)
{
if (empty($this->dn)) {
return;
}
if (($propName = $this->_translateDNProp($propName)) === false) {
return;
}
$dn = &$this->dn['rdnSequence'];
$size = count($dn);
for ($i = 0; $i < $size; $i++) {
if ($dn[$i][0]['type'] == $propName) {
unset($dn[$i]);
}
}
$dn = array_values($dn);
} | [
"function",
"removeDNProp",
"(",
"$",
"propName",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"dn",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"(",
"$",
"propName",
"=",
"$",
"this",
"->",
"_translateDNProp",
"(",
"$",
"propName",
")",... | Remove Distinguished Name properties
@param string $propName
@access public | [
"Remove",
"Distinguished",
"Name",
"properties"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/X509.php#L2493-L2512 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/X509.php | File_X509.getChain | function getChain()
{
$chain = array($this->currentCert);
if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) {
return false;
}
if (empty($this->CAs)) {
return $chain;
}
while (true) {
$currentCert = $chain[count($chain) - 1];
for ($i = 0; $i < count($this->CAs); $i++) {
$ca = $this->CAs[$i];
if ($currentCert['tbsCertificate']['issuer'] === $ca['tbsCertificate']['subject']) {
$authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier', $currentCert);
$subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca);
switch (true) {
case !is_array($authorityKey):
case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID:
if ($currentCert === $ca) {
break 3;
}
$chain[] = $ca;
break 2;
}
}
}
if ($i == count($this->CAs)) {
break;
}
}
foreach ($chain as $key => $value) {
$chain[$key] = new File_X509();
$chain[$key]->loadX509($value);
}
return $chain;
} | php | function getChain()
{
$chain = array($this->currentCert);
if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) {
return false;
}
if (empty($this->CAs)) {
return $chain;
}
while (true) {
$currentCert = $chain[count($chain) - 1];
for ($i = 0; $i < count($this->CAs); $i++) {
$ca = $this->CAs[$i];
if ($currentCert['tbsCertificate']['issuer'] === $ca['tbsCertificate']['subject']) {
$authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier', $currentCert);
$subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca);
switch (true) {
case !is_array($authorityKey):
case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID:
if ($currentCert === $ca) {
break 3;
}
$chain[] = $ca;
break 2;
}
}
}
if ($i == count($this->CAs)) {
break;
}
}
foreach ($chain as $key => $value) {
$chain[$key] = new File_X509();
$chain[$key]->loadX509($value);
}
return $chain;
} | [
"function",
"getChain",
"(",
")",
"{",
"$",
"chain",
"=",
"array",
"(",
"$",
"this",
"->",
"currentCert",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"currentCert",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"currentCert",
"... | Get the certificate chain for the current cert
@access public
@return mixed | [
"Get",
"the",
"certificate",
"chain",
"for",
"the",
"current",
"cert"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/X509.php#L2866-L2903 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/X509.php | File_X509._removeExtension | function _removeExtension($id, $path = null)
{
$extensions = &$this->_extensions($this->currentCert, $path);
if (!is_array($extensions)) {
return false;
}
$result = false;
foreach ($extensions as $key => $value) {
if ($value['extnId'] == $id) {
unset($extensions[$key]);
$result = true;
}
}
$extensions = array_values($extensions);
return $result;
} | php | function _removeExtension($id, $path = null)
{
$extensions = &$this->_extensions($this->currentCert, $path);
if (!is_array($extensions)) {
return false;
}
$result = false;
foreach ($extensions as $key => $value) {
if ($value['extnId'] == $id) {
unset($extensions[$key]);
$result = true;
}
}
$extensions = array_values($extensions);
return $result;
} | [
"function",
"_removeExtension",
"(",
"$",
"id",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"extensions",
"=",
"&",
"$",
"this",
"->",
"_extensions",
"(",
"$",
"this",
"->",
"currentCert",
",",
"$",
"path",
")",
";",
"if",
"(",
"!",
"is_array",
"... | Remove an Extension
@param string $id
@param string $path optional
@access private
@return bool | [
"Remove",
"an",
"Extension"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/X509.php#L4096-L4114 | train |
webeweb/core-library | src/ThirdParty/SkiData/Parser/CustomerParser.php | CustomerParser.parseEntity | public function parseEntity(Customer $entity) {
$output = [
$this->encodeInteger($entity->getCustomerNumber(), 9),
$this->encodeString($entity->getTitle(), 10),
$this->encodeString($entity->getSurname(), 25),
$this->encodeString($entity->getFirstname(), 25),
$this->encodeString($entity->getStreet(), 25),
$this->encodeString($entity->getPCode(), 10),
$this->encodeString($entity->getCity(), 25),
$this->encodeString($entity->getCountry(), 3),
$this->encodeString($entity->getTaxCode(), 16),
$this->encodeString($entity->getIdDocumentNo(), 15),
$this->encodeString($entity->getTelephone(), 20),
$this->encodeString($entity->getRentalAgreementNo(), 20),
$this->encodeDate($entity->getBeginDate()),
$this->encodeDate($entity->getTerminationDate()),
$this->encodeInteger($entity->getDeposit(), 12),
$this->encodeInteger($entity->getMaximumLevel(), 4),
$this->encodeString($entity->getRemarks(), 50),
$this->encodeDateTime($entity->getDatetimeLastModification()),
$this->encodeBoolean($entity->getBlocked()),
$this->encodeDate($entity->getBlockedDate()),
$this->encodeBoolean($entity->getDeletedRecord()),
$this->encodeBoolean($entity->getTicketReturnAllowed()),
$this->encodeBoolean($entity->getGroupCounting()),
$this->encodeBoolean($entity->getEntryMaxLevelAllowed()),
$this->encodeBoolean($entity->getMaxLevelCarPark()),
$this->encodeString($entity->getRemarks2(), 50),
$this->encodeString($entity->getRemarks3(), 50),
$this->encodeString($entity->getDivision(), 25),
$this->encodeString($entity->getEmail(), 120),
$this->encodeBoolean($entity->getCountingNeutralCards()),
$this->encodeString($entity->getNationality(), 3),
$this->encodeString($entity->getAccountingNumber(), 20),
];
return implode(";", $output);
} | php | public function parseEntity(Customer $entity) {
$output = [
$this->encodeInteger($entity->getCustomerNumber(), 9),
$this->encodeString($entity->getTitle(), 10),
$this->encodeString($entity->getSurname(), 25),
$this->encodeString($entity->getFirstname(), 25),
$this->encodeString($entity->getStreet(), 25),
$this->encodeString($entity->getPCode(), 10),
$this->encodeString($entity->getCity(), 25),
$this->encodeString($entity->getCountry(), 3),
$this->encodeString($entity->getTaxCode(), 16),
$this->encodeString($entity->getIdDocumentNo(), 15),
$this->encodeString($entity->getTelephone(), 20),
$this->encodeString($entity->getRentalAgreementNo(), 20),
$this->encodeDate($entity->getBeginDate()),
$this->encodeDate($entity->getTerminationDate()),
$this->encodeInteger($entity->getDeposit(), 12),
$this->encodeInteger($entity->getMaximumLevel(), 4),
$this->encodeString($entity->getRemarks(), 50),
$this->encodeDateTime($entity->getDatetimeLastModification()),
$this->encodeBoolean($entity->getBlocked()),
$this->encodeDate($entity->getBlockedDate()),
$this->encodeBoolean($entity->getDeletedRecord()),
$this->encodeBoolean($entity->getTicketReturnAllowed()),
$this->encodeBoolean($entity->getGroupCounting()),
$this->encodeBoolean($entity->getEntryMaxLevelAllowed()),
$this->encodeBoolean($entity->getMaxLevelCarPark()),
$this->encodeString($entity->getRemarks2(), 50),
$this->encodeString($entity->getRemarks3(), 50),
$this->encodeString($entity->getDivision(), 25),
$this->encodeString($entity->getEmail(), 120),
$this->encodeBoolean($entity->getCountingNeutralCards()),
$this->encodeString($entity->getNationality(), 3),
$this->encodeString($entity->getAccountingNumber(), 20),
];
return implode(";", $output);
} | [
"public",
"function",
"parseEntity",
"(",
"Customer",
"$",
"entity",
")",
"{",
"$",
"output",
"=",
"[",
"$",
"this",
"->",
"encodeInteger",
"(",
"$",
"entity",
"->",
"getCustomerNumber",
"(",
")",
",",
"9",
")",
",",
"$",
"this",
"->",
"encodeString",
... | Parse a customer entity.
@param Customer $entity The customer.
@return string Returns the parsed customer.
@throws TooLongDataException Throws a too long data exception if a data is too long. | [
"Parse",
"a",
"customer",
"entity",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/CustomerParser.php#L42-L80 | train |
SaftIng/Saft | src/Saft/Rdf/LiteralPatternImpl.php | LiteralPatternImpl.matches | public function matches(Node $toMatch)
{
if ($toMatch->isConcrete()) {
if ($toMatch instanceof Literal) {
return $this->getValue() === $toMatch->getValue()
&& $this->getDatatype() === $toMatch->getDatatype()
&& $this->getLanguage() === $toMatch->getLanguage();
}
return false;
} else {
throw new \Exception('The node to match has to be a concrete node');
}
} | php | public function matches(Node $toMatch)
{
if ($toMatch->isConcrete()) {
if ($toMatch instanceof Literal) {
return $this->getValue() === $toMatch->getValue()
&& $this->getDatatype() === $toMatch->getDatatype()
&& $this->getLanguage() === $toMatch->getLanguage();
}
return false;
} else {
throw new \Exception('The node to match has to be a concrete node');
}
} | [
"public",
"function",
"matches",
"(",
"Node",
"$",
"toMatch",
")",
"{",
"if",
"(",
"$",
"toMatch",
"->",
"isConcrete",
"(",
")",
")",
"{",
"if",
"(",
"$",
"toMatch",
"instanceof",
"Literal",
")",
"{",
"return",
"$",
"this",
"->",
"getValue",
"(",
")"... | A literal matches only another literal if its value, datatype and language are equal.
@param Node $toMatch Node instance to apply the pattern on
@return bool true, if this pattern matches the node, false otherwise
@todo check if that could be deleted | [
"A",
"literal",
"matches",
"only",
"another",
"literal",
"if",
"its",
"value",
"datatype",
"and",
"language",
"are",
"equal",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/LiteralPatternImpl.php#L124-L137 | train |
orchestral/notifier | src/NotifierManager.php | NotifierManager.createOrchestraDriver | protected function createOrchestraDriver(): Notification
{
$mailer = $this->app->make('orchestra.mail');
$notifier = new Handlers\Orchestra($mailer);
if ($mailer->attached()) {
$notifier->attach($mailer->getMemoryProvider());
} else {
$notifier->attach($this->app->make('orchestra.memory')->makeOrFallback());
}
return $notifier;
} | php | protected function createOrchestraDriver(): Notification
{
$mailer = $this->app->make('orchestra.mail');
$notifier = new Handlers\Orchestra($mailer);
if ($mailer->attached()) {
$notifier->attach($mailer->getMemoryProvider());
} else {
$notifier->attach($this->app->make('orchestra.memory')->makeOrFallback());
}
return $notifier;
} | [
"protected",
"function",
"createOrchestraDriver",
"(",
")",
":",
"Notification",
"{",
"$",
"mailer",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'orchestra.mail'",
")",
";",
"$",
"notifier",
"=",
"new",
"Handlers",
"\\",
"Orchestra",
"(",
"$",
"mail... | Create Orchestra Platform driver.
@return \Orchestra\Contracts\Notification\Notification | [
"Create",
"Orchestra",
"Platform",
"driver",
"."
] | a0036f924c51ead67f3e339cd2688163876f3b59 | https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/NotifierManager.php#L25-L37 | train |
shopgate/cart-integration-magento2-base | src/Helper/Shopgate/Customer.php | Customer.getCustomFields | public function getCustomFields($object)
{
$customFields = [];
foreach ($object->getCustomFields() as $field) {
$customFields[$field->getInternalFieldName()] = $field->getValue();
}
return $customFields;
} | php | public function getCustomFields($object)
{
$customFields = [];
foreach ($object->getCustomFields() as $field) {
$customFields[$field->getInternalFieldName()] = $field->getValue();
}
return $customFields;
} | [
"public",
"function",
"getCustomFields",
"(",
"$",
"object",
")",
"{",
"$",
"customFields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"object",
"->",
"getCustomFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"customFields",
"[",
"$",
"field",
"->"... | Creates a custom field array
@param \ShopgateAddress | \ShopgateCustomer $object
todo-sg: refactor this method into Shopgate\Extended\Customer own class
@return array | [
"Creates",
"a",
"custom",
"field",
"array"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Shopgate/Customer.php#L103-L111 | train |
shopgate/cart-integration-magento2-base | src/Model/Forwarder.php | Forwarder.startup | public function startup()
{
/** @var \Shopgate\Base\Helper\Initializer\Forwarder $forwarderInitializer */
$manager = ObjectManager::getInstance();
$forwarderInitializer = $manager->get('Shopgate\Base\Helper\Initializer\Forwarder');
$this->config = $forwarderInitializer->getMainConfig();
$this->settingsApi = $forwarderInitializer->getSettingsInterface();
$this->exportApi = $forwarderInitializer->getExportInterface();
$this->importApi = $forwarderInitializer->getImportInterface();
$this->cronApi = $forwarderInitializer->getCronInterface();
$configInitializer = $forwarderInitializer->getConfigInitializer();
$this->storeManager = $configInitializer->getStoreManager();
$this->config->loadConfig();
} | php | public function startup()
{
/** @var \Shopgate\Base\Helper\Initializer\Forwarder $forwarderInitializer */
$manager = ObjectManager::getInstance();
$forwarderInitializer = $manager->get('Shopgate\Base\Helper\Initializer\Forwarder');
$this->config = $forwarderInitializer->getMainConfig();
$this->settingsApi = $forwarderInitializer->getSettingsInterface();
$this->exportApi = $forwarderInitializer->getExportInterface();
$this->importApi = $forwarderInitializer->getImportInterface();
$this->cronApi = $forwarderInitializer->getCronInterface();
$configInitializer = $forwarderInitializer->getConfigInitializer();
$this->storeManager = $configInitializer->getStoreManager();
$this->config->loadConfig();
} | [
"public",
"function",
"startup",
"(",
")",
"{",
"/** @var \\Shopgate\\Base\\Helper\\Initializer\\Forwarder $forwarderInitializer */",
"$",
"manager",
"=",
"ObjectManager",
"::",
"getInstance",
"(",
")",
";",
"$",
"forwarderInitializer",
"=",
"$",
"manager",
"->",
"get",
... | Gets called on initialization
@codeCoverageIgnore | [
"Gets",
"called",
"on",
"initialization"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Forwarder.php#L58-L72 | train |
mmoreram/SimpleDoctrineMapping | CompilerPass/Abstracts/AbstractMappingCompilerPass.php | AbstractMappingCompilerPass.addEntityMapping | protected function addEntityMapping(
ContainerBuilder $container,
$entityManagerName,
$entityNamespace,
$entityMappingFilePath,
$enable = true
) : self {
$entityMapping = $this->resolveEntityMapping(
$container,
$entityManagerName,
$entityNamespace,
$entityMappingFilePath,
$enable
);
if ($entityMapping instanceof EntityMapping) {
$this->registerLocatorConfigurator($container);
$this->registerLocator($container, $entityMapping);
$this->registerDriver($container, $entityMapping);
$this->addDriverInDriverChain($container, $entityMapping);
$this->addAliases($container, $entityMapping);
}
return $this;
} | php | protected function addEntityMapping(
ContainerBuilder $container,
$entityManagerName,
$entityNamespace,
$entityMappingFilePath,
$enable = true
) : self {
$entityMapping = $this->resolveEntityMapping(
$container,
$entityManagerName,
$entityNamespace,
$entityMappingFilePath,
$enable
);
if ($entityMapping instanceof EntityMapping) {
$this->registerLocatorConfigurator($container);
$this->registerLocator($container, $entityMapping);
$this->registerDriver($container, $entityMapping);
$this->addDriverInDriverChain($container, $entityMapping);
$this->addAliases($container, $entityMapping);
}
return $this;
} | [
"protected",
"function",
"addEntityMapping",
"(",
"ContainerBuilder",
"$",
"container",
",",
"$",
"entityManagerName",
",",
"$",
"entityNamespace",
",",
"$",
"entityMappingFilePath",
",",
"$",
"enable",
"=",
"true",
")",
":",
"self",
"{",
"$",
"entityMapping",
"... | Add mapping entity.
This method adds a new Driver into global MappingDriverChain with single
entity mapping information.
$entityManagerName must be an existing entityManager. By default doctrine
creates just one common EntityManager called default, but many can be
defined with different connection information
p.e. default
p.e. anotherEntityManager
$entityNamespace must be an existing namespace of Entity. This value also
can be a valid and existing container parameter, with an existing
namespace of Entity as value.
p.e. MyBundle\Entity\User
p.e. mybundle.entity.user.class
$entityMappingFilePath must be a path of an existing yml or xml file with
mapping information about $entityNamespace. This bundle uses Short Bundle
notation, with "@" symbol. This value also can be a valid and existing
container parameter, with a path of an existing yml or xml file as value.
p.e. @MyBundle/Resources/config/doctrine/User.orm.yml
p.e. @MyBundle/Resources/config/doctrine/User.orm.xml
p.e. mybundle.entity.user.mapping_file_path
Finally, $enable flag just allow you to add current mapping definition
into all Doctrine Map table, or just dismiss it. This is useful when you
want to give possibility to final user to enable or disable a mapping
class.
@param ContainerBuilder $container Container
@param string $entityManagerName EntityManager name
@param string $entityNamespace Entity namespace
@param string $entityMappingFilePath Entity Mapping file path
@param bool|string $enable Entity mapping must be included
@return AbstractMappingCompilerPass
@throws EntityManagerNotFoundException Entity Manager nod found | [
"Add",
"mapping",
"entity",
"."
] | 7b527eb4e4552fce600b094786d2f416948b1657 | https://github.com/mmoreram/SimpleDoctrineMapping/blob/7b527eb4e4552fce600b094786d2f416948b1657/CompilerPass/Abstracts/AbstractMappingCompilerPass.php#L77-L101 | train |
mmoreram/SimpleDoctrineMapping | CompilerPass/Abstracts/AbstractMappingCompilerPass.php | AbstractMappingCompilerPass.resolveEntityMapping | private function resolveEntityMapping(
ContainerBuilder $container,
string $entityManagerName,
string $entityNamespace,
string $entityMappingFilePath,
$enable = true
) : ? EntityMapping {
$enableEntityMapping = $this->resolveParameterName(
$container,
$enable
);
if (false === $enableEntityMapping) {
return null;
}
$entityNamespace = $this->resolveParameterName($container, $entityNamespace);
if (!class_exists($entityNamespace)) {
throw new ConfigurationInvalidException('Entity ' . $entityNamespace . ' not found');
}
$entityMappingFilePath = $this->resolveParameterName($container, $entityMappingFilePath);
$entityManagerName = $this->resolveParameterName($container, $entityManagerName);
$this->resolveEntityManagerName($container, $entityManagerName);
return new EntityMapping(
$entityNamespace,
$entityMappingFilePath,
$entityManagerName
);
} | php | private function resolveEntityMapping(
ContainerBuilder $container,
string $entityManagerName,
string $entityNamespace,
string $entityMappingFilePath,
$enable = true
) : ? EntityMapping {
$enableEntityMapping = $this->resolveParameterName(
$container,
$enable
);
if (false === $enableEntityMapping) {
return null;
}
$entityNamespace = $this->resolveParameterName($container, $entityNamespace);
if (!class_exists($entityNamespace)) {
throw new ConfigurationInvalidException('Entity ' . $entityNamespace . ' not found');
}
$entityMappingFilePath = $this->resolveParameterName($container, $entityMappingFilePath);
$entityManagerName = $this->resolveParameterName($container, $entityManagerName);
$this->resolveEntityManagerName($container, $entityManagerName);
return new EntityMapping(
$entityNamespace,
$entityMappingFilePath,
$entityManagerName
);
} | [
"private",
"function",
"resolveEntityMapping",
"(",
"ContainerBuilder",
"$",
"container",
",",
"string",
"$",
"entityManagerName",
",",
"string",
"$",
"entityNamespace",
",",
"string",
"$",
"entityMappingFilePath",
",",
"$",
"enable",
"=",
"true",
")",
":",
"?",
... | Resolve EntityMapping inputs and build a consistent EntityMapping object.
This method returns null if the current entity has not been added
@param ContainerBuilder $container
@param string $entityManagerName
@param string $entityNamespace
@param string $entityMappingFilePath
@param string|bool $enable
@return EntityMapping|null
@throws ConfigurationInvalidException Configuration invalid
@throws EntityManagerNotFoundException Entity Manager not found | [
"Resolve",
"EntityMapping",
"inputs",
"and",
"build",
"a",
"consistent",
"EntityMapping",
"object",
"."
] | 7b527eb4e4552fce600b094786d2f416948b1657 | https://github.com/mmoreram/SimpleDoctrineMapping/blob/7b527eb4e4552fce600b094786d2f416948b1657/CompilerPass/Abstracts/AbstractMappingCompilerPass.php#L119-L150 | train |
mmoreram/SimpleDoctrineMapping | CompilerPass/Abstracts/AbstractMappingCompilerPass.php | AbstractMappingCompilerPass.registerLocatorConfigurator | private function registerLocatorConfigurator(ContainerBuilder $container)
{
$locatorConfiguratorId = 'simple_doctrine_mapping.locator_configurator';
if ($container->hasDefinition($locatorConfiguratorId)) {
return;
}
$locatorConfigurator = new Definition('Mmoreram\SimpleDoctrineMapping\Configurator\LocatorConfigurator');
$locatorConfigurator->setPublic(true);
$locatorConfigurator->setArguments([
new Reference('kernel'),
]);
$container->setDefinition($locatorConfiguratorId, $locatorConfigurator);
} | php | private function registerLocatorConfigurator(ContainerBuilder $container)
{
$locatorConfiguratorId = 'simple_doctrine_mapping.locator_configurator';
if ($container->hasDefinition($locatorConfiguratorId)) {
return;
}
$locatorConfigurator = new Definition('Mmoreram\SimpleDoctrineMapping\Configurator\LocatorConfigurator');
$locatorConfigurator->setPublic(true);
$locatorConfigurator->setArguments([
new Reference('kernel'),
]);
$container->setDefinition($locatorConfiguratorId, $locatorConfigurator);
} | [
"private",
"function",
"registerLocatorConfigurator",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"locatorConfiguratorId",
"=",
"'simple_doctrine_mapping.locator_configurator'",
";",
"if",
"(",
"$",
"container",
"->",
"hasDefinition",
"(",
"$",
"locatorConfi... | Register locator configurator.
@param ContainerBuilder $container | [
"Register",
"locator",
"configurator",
"."
] | 7b527eb4e4552fce600b094786d2f416948b1657 | https://github.com/mmoreram/SimpleDoctrineMapping/blob/7b527eb4e4552fce600b094786d2f416948b1657/CompilerPass/Abstracts/AbstractMappingCompilerPass.php#L157-L171 | train |
mmoreram/SimpleDoctrineMapping | CompilerPass/Abstracts/AbstractMappingCompilerPass.php | AbstractMappingCompilerPass.registerLocator | private function registerLocator(
ContainerBuilder $container,
EntityMapping $entityMapping
) {
/**
* Locator.
*/
$locatorId = 'simple_doctrine_mapping.locator.' . $entityMapping->getUniqueIdentifier();
$locator = new Definition('Mmoreram\SimpleDoctrineMapping\Locator\SimpleDoctrineMappingLocator');
$locator->setPublic(false);
$locator->setArguments([
$entityMapping->getEntityNamespace(),
[$entityMapping->getEntityMappingFilePath()],
]);
$locator->setConfigurator([
new Reference('simple_doctrine_mapping.locator_configurator'),
'configure',
]);
$container->setDefinition($locatorId, $locator);
} | php | private function registerLocator(
ContainerBuilder $container,
EntityMapping $entityMapping
) {
/**
* Locator.
*/
$locatorId = 'simple_doctrine_mapping.locator.' . $entityMapping->getUniqueIdentifier();
$locator = new Definition('Mmoreram\SimpleDoctrineMapping\Locator\SimpleDoctrineMappingLocator');
$locator->setPublic(false);
$locator->setArguments([
$entityMapping->getEntityNamespace(),
[$entityMapping->getEntityMappingFilePath()],
]);
$locator->setConfigurator([
new Reference('simple_doctrine_mapping.locator_configurator'),
'configure',
]);
$container->setDefinition($locatorId, $locator);
} | [
"private",
"function",
"registerLocator",
"(",
"ContainerBuilder",
"$",
"container",
",",
"EntityMapping",
"$",
"entityMapping",
")",
"{",
"/**\n * Locator.\n */",
"$",
"locatorId",
"=",
"'simple_doctrine_mapping.locator.'",
".",
"$",
"entityMapping",
"->",
... | Register the locator.
@param ContainerBuilder $container
@param EntityMapping $entityMapping | [
"Register",
"the",
"locator",
"."
] | 7b527eb4e4552fce600b094786d2f416948b1657 | https://github.com/mmoreram/SimpleDoctrineMapping/blob/7b527eb4e4552fce600b094786d2f416948b1657/CompilerPass/Abstracts/AbstractMappingCompilerPass.php#L179-L198 | train |
mmoreram/SimpleDoctrineMapping | CompilerPass/Abstracts/AbstractMappingCompilerPass.php | AbstractMappingCompilerPass.addDriverInDriverChain | private function addDriverInDriverChain(
ContainerBuilder $container,
EntityMapping $entityMapping
) {
$chainDriverDefinition = $container
->getDefinition(
'doctrine.orm.' . $entityMapping->getEntityManagerName() . '_metadata_driver'
);
$container->setParameter(
'doctrine.orm.metadata.driver_chain.class',
'Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain'
);
$chainDriverDefinition->addMethodCall('addDriver', [
new Reference(
'doctrine.orm.' . $entityMapping->getUniqueIdentifier() . '_metadata_driver'
),
$entityMapping->getEntityNamespace(),
]);
} | php | private function addDriverInDriverChain(
ContainerBuilder $container,
EntityMapping $entityMapping
) {
$chainDriverDefinition = $container
->getDefinition(
'doctrine.orm.' . $entityMapping->getEntityManagerName() . '_metadata_driver'
);
$container->setParameter(
'doctrine.orm.metadata.driver_chain.class',
'Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain'
);
$chainDriverDefinition->addMethodCall('addDriver', [
new Reference(
'doctrine.orm.' . $entityMapping->getUniqueIdentifier() . '_metadata_driver'
),
$entityMapping->getEntityNamespace(),
]);
} | [
"private",
"function",
"addDriverInDriverChain",
"(",
"ContainerBuilder",
"$",
"container",
",",
"EntityMapping",
"$",
"entityMapping",
")",
"{",
"$",
"chainDriverDefinition",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"'doctrine.orm.'",
".",
"$",
"entityMappi... | Register and override the DriverChain definition.
@param ContainerBuilder $container
@param EntityMapping $entityMapping
@throws EntityManagerNotFoundException Entity Manager nod found | [
"Register",
"and",
"override",
"the",
"DriverChain",
"definition",
"."
] | 7b527eb4e4552fce600b094786d2f416948b1657 | https://github.com/mmoreram/SimpleDoctrineMapping/blob/7b527eb4e4552fce600b094786d2f416948b1657/CompilerPass/Abstracts/AbstractMappingCompilerPass.php#L233-L253 | train |
mmoreram/SimpleDoctrineMapping | CompilerPass/Abstracts/AbstractMappingCompilerPass.php | AbstractMappingCompilerPass.addAliases | private function addAliases(
ContainerBuilder $container,
EntityMapping $entityMapping
) {
$entityMappingFilePath = $entityMapping->getEntityMappingFilePath();
if (strpos($entityMappingFilePath, '@') === 0) {
$bundleName = trim(explode('/', $entityMappingFilePath, 2)[0]);
$className = explode('\\', $entityMapping->getEntityNamespace());
unset($className[count($className) - 1]);
$configurationServiceDefinition = $container
->getDefinition(
'doctrine.orm.' . $entityMapping->getEntityManagerName() . '_configuration'
);
$configurationServiceDefinition->addMethodCall('addEntityNamespace', [
$bundleName,
implode('\\', $className),
]);
}
} | php | private function addAliases(
ContainerBuilder $container,
EntityMapping $entityMapping
) {
$entityMappingFilePath = $entityMapping->getEntityMappingFilePath();
if (strpos($entityMappingFilePath, '@') === 0) {
$bundleName = trim(explode('/', $entityMappingFilePath, 2)[0]);
$className = explode('\\', $entityMapping->getEntityNamespace());
unset($className[count($className) - 1]);
$configurationServiceDefinition = $container
->getDefinition(
'doctrine.orm.' . $entityMapping->getEntityManagerName() . '_configuration'
);
$configurationServiceDefinition->addMethodCall('addEntityNamespace', [
$bundleName,
implode('\\', $className),
]);
}
} | [
"private",
"function",
"addAliases",
"(",
"ContainerBuilder",
"$",
"container",
",",
"EntityMapping",
"$",
"entityMapping",
")",
"{",
"$",
"entityMappingFilePath",
"=",
"$",
"entityMapping",
"->",
"getEntityMappingFilePath",
"(",
")",
";",
"if",
"(",
"strpos",
"("... | Add aliases for short Doctrine accessing mode.
This method will make a vitual association between the bundle proposing
the entity and the entity namespace, even if both elements are in
different packages (Bundle + Component).
Only useful and working when the relation between a bundle and the entity
folder path [[ Bundle (*) => (1) Entity path ]]
@param ContainerBuilder $container
@param EntityMapping $entityMapping | [
"Add",
"aliases",
"for",
"short",
"Doctrine",
"accessing",
"mode",
"."
] | 7b527eb4e4552fce600b094786d2f416948b1657 | https://github.com/mmoreram/SimpleDoctrineMapping/blob/7b527eb4e4552fce600b094786d2f416948b1657/CompilerPass/Abstracts/AbstractMappingCompilerPass.php#L268-L287 | train |
mmoreram/SimpleDoctrineMapping | CompilerPass/Abstracts/AbstractMappingCompilerPass.php | AbstractMappingCompilerPass.resolveEntityManagerName | private function resolveEntityManagerName(
ContainerBuilder $container,
string $entityManagerName
) {
if (!$container->has('doctrine.orm.' . $entityManagerName . '_metadata_driver')) {
throw new EntityManagerNotFoundException($entityManagerName);
}
} | php | private function resolveEntityManagerName(
ContainerBuilder $container,
string $entityManagerName
) {
if (!$container->has('doctrine.orm.' . $entityManagerName . '_metadata_driver')) {
throw new EntityManagerNotFoundException($entityManagerName);
}
} | [
"private",
"function",
"resolveEntityManagerName",
"(",
"ContainerBuilder",
"$",
"container",
",",
"string",
"$",
"entityManagerName",
")",
"{",
"if",
"(",
"!",
"$",
"container",
"->",
"has",
"(",
"'doctrine.orm.'",
".",
"$",
"entityManagerName",
".",
"'_metadata_... | Throws an exception if given entityName is not available or does
not exist.
@param ContainerBuilder $container
@param string $entityManagerName
@throws EntityManagerNotFoundException Entity manager not found | [
"Throws",
"an",
"exception",
"if",
"given",
"entityName",
"is",
"not",
"available",
"or",
"does",
"not",
"exist",
"."
] | 7b527eb4e4552fce600b094786d2f416948b1657 | https://github.com/mmoreram/SimpleDoctrineMapping/blob/7b527eb4e4552fce600b094786d2f416948b1657/CompilerPass/Abstracts/AbstractMappingCompilerPass.php#L324-L331 | train |
webeweb/core-library | src/Network/CURL/Configuration/CURLConfiguration.php | CURLConfiguration.removeHeader | public function removeHeader($name) {
if (true === array_key_exists($name, $this->headers)) {
unset($this->headers[$name]);
}
} | php | public function removeHeader($name) {
if (true === array_key_exists($name, $this->headers)) {
unset($this->headers[$name]);
}
} | [
"public",
"function",
"removeHeader",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"true",
"===",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"headers",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
"... | Remove an header.
@param string $name The header name.
@return void | [
"Remove",
"an",
"header",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/CURL/Configuration/CURLConfiguration.php#L333-L337 | train |
milesj/transit | src/Transit/File.php | File.dimensions | public function dimensions() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
$dims = null;
if (!$file->isImage()) {
return $dims;
}
$data = @getimagesize($file->path());
if ($data && is_array($data)) {
$dims = array(
'width' => $data[0],
'height' => $data[1]
);
}
if (!$data) {
$image = @imagecreatefromstring(file_get_contents($file->path()));
$dims = array(
'width' => @imagesx($image),
'height' => @imagesy($image)
);
}
return $dims;
});
} | php | public function dimensions() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
$dims = null;
if (!$file->isImage()) {
return $dims;
}
$data = @getimagesize($file->path());
if ($data && is_array($data)) {
$dims = array(
'width' => $data[0],
'height' => $data[1]
);
}
if (!$data) {
$image = @imagecreatefromstring(file_get_contents($file->path()));
$dims = array(
'width' => @imagesx($image),
'height' => @imagesy($image)
);
}
return $dims;
});
} | [
"public",
"function",
"dimensions",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"_cache",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"file",
")",
"{",
"/** @type \\Transit\\File $file */",
"$",
"dims",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"file",
... | Return the dimensions of the file if it is an image.
@return array | [
"Return",
"the",
"dimensions",
"of",
"the",
"file",
"if",
"it",
"is",
"an",
"image",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L121-L150 | train |
milesj/transit | src/Transit/File.php | File.exif | public function exif(array $fields = array()) {
if (!function_exists('exif_read_data')) {
return array();
}
return $this->_cache(__FUNCTION__, function($file) use ($fields) {
/** @type \Transit\File $file */
$exif = array();
$fields = $fields + array(
'make' => 'Make',
'model' => 'Model',
'exposure' => 'ExposureTime',
'orientation' => 'Orientation',
'fnumber' => 'FNumber',
'date' => 'DateTime',
'iso' => 'ISOSpeedRatings',
'focal' => 'FocalLength',
'latitude' => 'GPSLatitude',
'longitude' => 'GPSLongitude'
);
if ($file->supportsExif()) {
if ($data = @exif_read_data($file->path())) {
foreach ($fields as $key => $find) {
$value = '';
if (!empty($data[$find])) {
// Convert DMS (degrees, minutes, seconds) to decimals
if ($key === 'latitude' || $key === 'longitude'){
$deg = $data[$find][0];
$min = $data[$find][1];
$sec = $data[$find][2];
$value = $deg + ((($min * 60) + $sec) / 3600);
} else {
$value = $data[$find];
}
}
$exif[$key] = $value;
}
}
}
// Return empty values for files that don't support exif
if (!$exif) {
$exif = array_map(function() {
return '';
}, $fields);
}
return $exif;
});
} | php | public function exif(array $fields = array()) {
if (!function_exists('exif_read_data')) {
return array();
}
return $this->_cache(__FUNCTION__, function($file) use ($fields) {
/** @type \Transit\File $file */
$exif = array();
$fields = $fields + array(
'make' => 'Make',
'model' => 'Model',
'exposure' => 'ExposureTime',
'orientation' => 'Orientation',
'fnumber' => 'FNumber',
'date' => 'DateTime',
'iso' => 'ISOSpeedRatings',
'focal' => 'FocalLength',
'latitude' => 'GPSLatitude',
'longitude' => 'GPSLongitude'
);
if ($file->supportsExif()) {
if ($data = @exif_read_data($file->path())) {
foreach ($fields as $key => $find) {
$value = '';
if (!empty($data[$find])) {
// Convert DMS (degrees, minutes, seconds) to decimals
if ($key === 'latitude' || $key === 'longitude'){
$deg = $data[$find][0];
$min = $data[$find][1];
$sec = $data[$find][2];
$value = $deg + ((($min * 60) + $sec) / 3600);
} else {
$value = $data[$find];
}
}
$exif[$key] = $value;
}
}
}
// Return empty values for files that don't support exif
if (!$exif) {
$exif = array_map(function() {
return '';
}, $fields);
}
return $exif;
});
} | [
"public",
"function",
"exif",
"(",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'exif_read_data'",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_cache",
"(",... | Attempt to read and determine correct exif data.
@param array $fields
@returns array | [
"Attempt",
"to",
"read",
"and",
"determine",
"correct",
"exif",
"data",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L167-L221 | train |
milesj/transit | src/Transit/File.php | File.ext | public function ext() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
// @version 1.1.1 Removed because of fileinfo bug
// return MimeType::getExtFromType($file->type(), true);
// @version 1.2.0 Allow support for $_FILES array
$path = $file->data('name') ?: $file->path();
return mb_strtolower(pathinfo($path, PATHINFO_EXTENSION));
});
} | php | public function ext() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
// @version 1.1.1 Removed because of fileinfo bug
// return MimeType::getExtFromType($file->type(), true);
// @version 1.2.0 Allow support for $_FILES array
$path = $file->data('name') ?: $file->path();
return mb_strtolower(pathinfo($path, PATHINFO_EXTENSION));
});
} | [
"public",
"function",
"ext",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"_cache",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"file",
")",
"{",
"/** @type \\Transit\\File $file */",
"// @version 1.1.1 Removed because of fileinfo bug",
"// return MimeType::getExtFromT... | Return the extension.
@return string | [
"Return",
"the",
"extension",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L228-L240 | train |
milesj/transit | src/Transit/File.php | File.height | public function height() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
if (!$file->isImage()) {
return null;
}
$height = 0;
if ($dims = $file->dimensions()) {
$height = $dims['height'];
}
return $height;
});
} | php | public function height() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
if (!$file->isImage()) {
return null;
}
$height = 0;
if ($dims = $file->dimensions()) {
$height = $dims['height'];
}
return $height;
});
} | [
"public",
"function",
"height",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"_cache",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"file",
")",
"{",
"/** @type \\Transit\\File $file */",
"if",
"(",
"!",
"$",
"file",
"->",
"isImage",
"(",
")",
")",
"{"... | Return the image height.
@return int | [
"Return",
"the",
"image",
"height",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L247-L263 | train |
milesj/transit | src/Transit/File.php | File.move | public function move($path, $overwrite = false) {
$path = str_replace('\\', '/', $path);
if (substr($path, -1) !== '/') {
$path .= '/';
}
// Don't move to the same folder
if (realpath($path) === realpath($this->dir())) {
return true;
}
if (!file_exists($path)) {
mkdir($path, 0777, true);
} else if (!is_writable($path)) {
chmod($path, 0777);
}
// Determine name and overwrite
$name = $this->name();
$ext = $this->ext();
if (!$overwrite) {
$no = 1;
while (file_exists($path . $name . '.' . $ext)) {
$name = $this->name() . '-' . $no;
$no++;
}
}
// Move the file
$targetPath = $path . $name . '.' . $ext;
if (rename($this->path(), $targetPath)) {
$this->reset($targetPath);
return true;
}
return false;
} | php | public function move($path, $overwrite = false) {
$path = str_replace('\\', '/', $path);
if (substr($path, -1) !== '/') {
$path .= '/';
}
// Don't move to the same folder
if (realpath($path) === realpath($this->dir())) {
return true;
}
if (!file_exists($path)) {
mkdir($path, 0777, true);
} else if (!is_writable($path)) {
chmod($path, 0777);
}
// Determine name and overwrite
$name = $this->name();
$ext = $this->ext();
if (!$overwrite) {
$no = 1;
while (file_exists($path . $name . '.' . $ext)) {
$name = $this->name() . '-' . $no;
$no++;
}
}
// Move the file
$targetPath = $path . $name . '.' . $ext;
if (rename($this->path(), $targetPath)) {
$this->reset($targetPath);
return true;
}
return false;
} | [
"public",
"function",
"move",
"(",
"$",
"path",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"path",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"-",
"1",
")",
"!... | Move the file to a new directory.
If a file with the same name already exists, either overwrite or increment file name.
@param string $path
@param bool $overwrite
@return bool | [
"Move",
"the",
"file",
"to",
"a",
"new",
"directory",
".",
"If",
"a",
"file",
"with",
"the",
"same",
"name",
"already",
"exists",
"either",
"overwrite",
"or",
"increment",
"file",
"name",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L340-L382 | train |
milesj/transit | src/Transit/File.php | File.rename | public function rename($name = '', $append = '', $prepend = '', $overwrite = false) {
if (is_callable($name)) {
$name = call_user_func_array($name, array($this->name(), $this));
} else {
$name = $name ?: $this->name();
}
// Add boundaries
$name = (string) $prepend . $name . (string) $append;
// Remove unwanted characters
$name = preg_replace('/[^_\-\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/imu', '-', $name);
// Rename file
$ext = $this->ext() ?: MimeType::getExtFromType($this->type(), true);
$newName = $name;
// Don't overwrite
if (!$overwrite) {
$no = 1;
while (file_exists($this->dir() . $newName . '.' . $ext)) {
$newName = $name . '-' . $no;
$no++;
}
}
$targetPath = $this->dir() . $newName . '.' . $ext;
if (rename($this->path(), $targetPath)) {
$this->reset($targetPath);
return true;
}
return false;
} | php | public function rename($name = '', $append = '', $prepend = '', $overwrite = false) {
if (is_callable($name)) {
$name = call_user_func_array($name, array($this->name(), $this));
} else {
$name = $name ?: $this->name();
}
// Add boundaries
$name = (string) $prepend . $name . (string) $append;
// Remove unwanted characters
$name = preg_replace('/[^_\-\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/imu', '-', $name);
// Rename file
$ext = $this->ext() ?: MimeType::getExtFromType($this->type(), true);
$newName = $name;
// Don't overwrite
if (!$overwrite) {
$no = 1;
while (file_exists($this->dir() . $newName . '.' . $ext)) {
$newName = $name . '-' . $no;
$no++;
}
}
$targetPath = $this->dir() . $newName . '.' . $ext;
if (rename($this->path(), $targetPath)) {
$this->reset($targetPath);
return true;
}
return false;
} | [
"public",
"function",
"rename",
"(",
"$",
"name",
"=",
"''",
",",
"$",
"append",
"=",
"''",
",",
"$",
"prepend",
"=",
"''",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"... | Rename the file within the current directory.
@param string $name
@param string $append
@param string $prepend
@param bool $overwrite
@return bool | [
"Rename",
"the",
"file",
"within",
"the",
"current",
"directory",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L414-L450 | train |
milesj/transit | src/Transit/File.php | File.reset | public function reset($path = '') {
clearstatcache();
$this->_cache = array();
if ($path) {
$this->_data['name'] = basename($path);
$this->_path = $path;
}
return $this;
} | php | public function reset($path = '') {
clearstatcache();
$this->_cache = array();
if ($path) {
$this->_data['name'] = basename($path);
$this->_path = $path;
}
return $this;
} | [
"public",
"function",
"reset",
"(",
"$",
"path",
"=",
"''",
")",
"{",
"clearstatcache",
"(",
")",
";",
"$",
"this",
"->",
"_cache",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"'name'",
"]",
"... | Reset all cache.
@param string $path
@return \Transit\File | [
"Reset",
"all",
"cache",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L458-L469 | train |
milesj/transit | src/Transit/File.php | File.supportsExif | public function supportsExif() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
if (!$file->isImage()) {
return false;
}
return in_array($file->type(), array('image/jpeg', 'image/tiff'));
});
} | php | public function supportsExif() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
if (!$file->isImage()) {
return false;
}
return in_array($file->type(), array('image/jpeg', 'image/tiff'));
});
} | [
"public",
"function",
"supportsExif",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"_cache",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"file",
")",
"{",
"/** @type \\Transit\\File $file */",
"if",
"(",
"!",
"$",
"file",
"->",
"isImage",
"(",
")",
")",... | Checks if the file supports exif data.
@return bool | [
"Checks",
"if",
"the",
"file",
"supports",
"exif",
"data",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L485-L495 | train |
milesj/transit | src/Transit/File.php | File.width | public function width() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
if (!$file->isImage()) {
return null;
}
$width = 0;
if ($dims = $file->dimensions()) {
$width = $dims['width'];
}
return $width;
});
} | php | public function width() {
return $this->_cache(__FUNCTION__, function($file) {
/** @type \Transit\File $file */
if (!$file->isImage()) {
return null;
}
$width = 0;
if ($dims = $file->dimensions()) {
$width = $dims['width'];
}
return $width;
});
} | [
"public",
"function",
"width",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"_cache",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"file",
")",
"{",
"/** @type \\Transit\\File $file */",
"if",
"(",
"!",
"$",
"file",
"->",
"isImage",
"(",
")",
")",
"{",... | Return the image width.
@return int | [
"Return",
"the",
"image",
"width",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L553-L569 | train |
milesj/transit | src/Transit/File.php | File.toArray | public function toArray() {
$data = array(
'basename' => $this->basename(),
'dir' => $this->dir(),
'ext' => $this->ext(),
'name' => $this->name(),
'path' => $this->path(),
'size' => $this->size(),
'type' => $this->type(),
'height' => $this->height(),
'width' => $this->width()
);
// Include exif data
foreach ($this->exif() as $key => $value) {
$data['exif.' . $key] = $value;
}
return $data;
} | php | public function toArray() {
$data = array(
'basename' => $this->basename(),
'dir' => $this->dir(),
'ext' => $this->ext(),
'name' => $this->name(),
'path' => $this->path(),
'size' => $this->size(),
'type' => $this->type(),
'height' => $this->height(),
'width' => $this->width()
);
// Include exif data
foreach ($this->exif() as $key => $value) {
$data['exif.' . $key] = $value;
}
return $data;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'basename'",
"=>",
"$",
"this",
"->",
"basename",
"(",
")",
",",
"'dir'",
"=>",
"$",
"this",
"->",
"dir",
"(",
")",
",",
"'ext'",
"=>",
"$",
"this",
"->",
"ext",
"("... | Return all File information as an array.
@return array | [
"Return",
"all",
"File",
"information",
"as",
"an",
"array",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L576-L595 | train |
milesj/transit | src/Transit/File.php | File._cache | protected function _cache($key, Closure $callback) {
if (isset($this->_cache[$key])) {
return $this->_cache[$key];
}
// Requires 5.4
// Closure::bind($callback, $this, __CLASS__);
$this->_cache[$key] = $callback($this);
return $this->_cache[$key];
} | php | protected function _cache($key, Closure $callback) {
if (isset($this->_cache[$key])) {
return $this->_cache[$key];
}
// Requires 5.4
// Closure::bind($callback, $this, __CLASS__);
$this->_cache[$key] = $callback($this);
return $this->_cache[$key];
} | [
"protected",
"function",
"_cache",
"(",
"$",
"key",
",",
"Closure",
"$",
"callback",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_cache",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_cache",
"[",
"$",
"key",
"]",... | Cache the results of a callback.
@param string $key
@param \Closure $callback
@return mixed | [
"Cache",
"the",
"results",
"of",
"a",
"callback",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/File.php#L613-L624 | train |
milesj/transit | src/Transit/MimeType.php | MimeType.getExtFromType | public static function getExtFromType($type, $primary = false) {
$exts = array();
foreach (self::$_types as $ext => $mimeType) {
$isPrimary = false;
if (is_array($mimeType)) {
$mimeType = $mimeType[0];
$isPrimary = $mimeType[1];
}
if ($mimeType == $type) {
if ($primary && $isPrimary) {
return $ext;
}
$exts[] = $ext;
}
}
if ($primary && isset($exts[0])) {
return $exts[0];
}
return $exts;
} | php | public static function getExtFromType($type, $primary = false) {
$exts = array();
foreach (self::$_types as $ext => $mimeType) {
$isPrimary = false;
if (is_array($mimeType)) {
$mimeType = $mimeType[0];
$isPrimary = $mimeType[1];
}
if ($mimeType == $type) {
if ($primary && $isPrimary) {
return $ext;
}
$exts[] = $ext;
}
}
if ($primary && isset($exts[0])) {
return $exts[0];
}
return $exts;
} | [
"public",
"static",
"function",
"getExtFromType",
"(",
"$",
"type",
",",
"$",
"primary",
"=",
"false",
")",
"{",
"$",
"exts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"_types",
"as",
"$",
"ext",
"=>",
"$",
"mimeType",
")",
"{... | Return all extensions that have the same mime type.
@param string $type
@param bool $primary
@return array|string
static | [
"Return",
"all",
"extensions",
"that",
"have",
"the",
"same",
"mime",
"type",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1003-L1028 | train |
milesj/transit | src/Transit/MimeType.php | MimeType.getTypeFromExt | public static function getTypeFromExt($ext) {
if (isset(self::$_types[$ext])) {
$mime = self::$_types[$ext];
if (is_array($mime)) {
$mime = $mime[0];
}
return $mime;
}
throw new InvalidArgumentException(sprintf('Invalid extension %s', $ext));
} | php | public static function getTypeFromExt($ext) {
if (isset(self::$_types[$ext])) {
$mime = self::$_types[$ext];
if (is_array($mime)) {
$mime = $mime[0];
}
return $mime;
}
throw new InvalidArgumentException(sprintf('Invalid extension %s', $ext));
} | [
"public",
"static",
"function",
"getTypeFromExt",
"(",
"$",
"ext",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_types",
"[",
"$",
"ext",
"]",
")",
")",
"{",
"$",
"mime",
"=",
"self",
"::",
"$",
"_types",
"[",
"$",
"ext",
"]",
";",
"i... | Return a mime type based on extension.
@param string $ext
@return string
@throws InvalidArgumentException
static | [
"Return",
"a",
"mime",
"type",
"based",
"on",
"extension",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1038-L1050 | train |
milesj/transit | src/Transit/MimeType.php | MimeType.getApplicationList | public static function getApplicationList() {
if (self::$_application) {
return self::$_application;
}
self::$_application = self::_getList('application');
return self::$_application;
} | php | public static function getApplicationList() {
if (self::$_application) {
return self::$_application;
}
self::$_application = self::_getList('application');
return self::$_application;
} | [
"public",
"static",
"function",
"getApplicationList",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_application",
")",
"{",
"return",
"self",
"::",
"$",
"_application",
";",
"}",
"self",
"::",
"$",
"_application",
"=",
"self",
"::",
"_getList",
"(",
"'a... | Return a list of all application mime types.
@return array | [
"Return",
"a",
"list",
"of",
"all",
"application",
"mime",
"types",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1066-L1074 | train |
milesj/transit | src/Transit/MimeType.php | MimeType.getAudioList | public static function getAudioList() {
if (self::$_audio) {
return self::$_audio;
}
self::$_audio = self::_getList('audio');
return self::$_audio;
} | php | public static function getAudioList() {
if (self::$_audio) {
return self::$_audio;
}
self::$_audio = self::_getList('audio');
return self::$_audio;
} | [
"public",
"static",
"function",
"getAudioList",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_audio",
")",
"{",
"return",
"self",
"::",
"$",
"_audio",
";",
"}",
"self",
"::",
"$",
"_audio",
"=",
"self",
"::",
"_getList",
"(",
"'audio'",
")",
";",
... | Return a list of all audio mime types.
@return array | [
"Return",
"a",
"list",
"of",
"all",
"audio",
"mime",
"types",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1081-L1089 | train |
milesj/transit | src/Transit/MimeType.php | MimeType.getImageList | public static function getImageList() {
if (self::$_image) {
return self::$_image;
}
self::$_image = self::_getList('image');
return self::$_image;
} | php | public static function getImageList() {
if (self::$_image) {
return self::$_image;
}
self::$_image = self::_getList('image');
return self::$_image;
} | [
"public",
"static",
"function",
"getImageList",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_image",
")",
"{",
"return",
"self",
"::",
"$",
"_image",
";",
"}",
"self",
"::",
"$",
"_image",
"=",
"self",
"::",
"_getList",
"(",
"'image'",
")",
";",
... | Return a list of all image mime types.
@return array | [
"Return",
"a",
"list",
"of",
"all",
"image",
"mime",
"types",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1096-L1104 | train |
milesj/transit | src/Transit/MimeType.php | MimeType.getTextList | public static function getTextList() {
if (self::$_text) {
return self::$_text;
}
self::$_text = self::_getList('text');
return self::$_text;
} | php | public static function getTextList() {
if (self::$_text) {
return self::$_text;
}
self::$_text = self::_getList('text');
return self::$_text;
} | [
"public",
"static",
"function",
"getTextList",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_text",
")",
"{",
"return",
"self",
"::",
"$",
"_text",
";",
"}",
"self",
"::",
"$",
"_text",
"=",
"self",
"::",
"_getList",
"(",
"'text'",
")",
";",
"retu... | Return a list of all text mime types.
@return array | [
"Return",
"a",
"list",
"of",
"all",
"text",
"mime",
"types",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1111-L1119 | train |
milesj/transit | src/Transit/MimeType.php | MimeType.getVideoList | public static function getVideoList() {
if (self::$_video) {
return self::$_video;
}
self::$_video = self::_getList('video');
return self::$_video;
} | php | public static function getVideoList() {
if (self::$_video) {
return self::$_video;
}
self::$_video = self::_getList('video');
return self::$_video;
} | [
"public",
"static",
"function",
"getVideoList",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_video",
")",
"{",
"return",
"self",
"::",
"$",
"_video",
";",
"}",
"self",
"::",
"$",
"_video",
"=",
"self",
"::",
"_getList",
"(",
"'video'",
")",
";",
... | Return a list of all video mime types.
@return array | [
"Return",
"a",
"list",
"of",
"all",
"video",
"mime",
"types",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1126-L1134 | train |
milesj/transit | src/Transit/MimeType.php | MimeType.getSubTypeList | public static function getSubTypeList($type) {
if (empty(self::$_subTypes[$type])) {
throw new InvalidArgumentException(sprintf('Sub-type %s does not exist', $type));
}
$types = array();
foreach (self::$_subTypes[$type] as $ext) {
$types[$ext] = self::getTypeFromExt($ext);
}
return $types;
} | php | public static function getSubTypeList($type) {
if (empty(self::$_subTypes[$type])) {
throw new InvalidArgumentException(sprintf('Sub-type %s does not exist', $type));
}
$types = array();
foreach (self::$_subTypes[$type] as $ext) {
$types[$ext] = self::getTypeFromExt($ext);
}
return $types;
} | [
"public",
"static",
"function",
"getSubTypeList",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"_subTypes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Sub-type %s does... | Return a list of all sub-type mime types.
@param string $type
@return array
@throws \InvalidArgumentException | [
"Return",
"a",
"list",
"of",
"all",
"sub",
"-",
"type",
"mime",
"types",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1143-L1155 | train |
milesj/transit | src/Transit/MimeType.php | MimeType.isSubType | public static function isSubType($subType, $mimeType) {
return in_array(self::_findMimeType($mimeType), self::getSubTypeList($subType));
} | php | public static function isSubType($subType, $mimeType) {
return in_array(self::_findMimeType($mimeType), self::getSubTypeList($subType));
} | [
"public",
"static",
"function",
"isSubType",
"(",
"$",
"subType",
",",
"$",
"mimeType",
")",
"{",
"return",
"in_array",
"(",
"self",
"::",
"_findMimeType",
"(",
"$",
"mimeType",
")",
",",
"self",
"::",
"getSubTypeList",
"(",
"$",
"subType",
")",
")",
";"... | Return true if the mime type is part of a sub-type.
@param string $subType
@param string $mimeType
@return bool | [
"Return",
"true",
"if",
"the",
"mime",
"type",
"is",
"part",
"of",
"a",
"sub",
"-",
"type",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1214-L1216 | train |
milesj/transit | src/Transit/MimeType.php | MimeType._getList | protected static function _getList($type) {
$types = array();
foreach (self::$_types as $ext => $mimeType) {
if (is_array($mimeType)) {
$mimeType = $mimeType[0];
}
if (strpos($mimeType, $type) === 0) {
$types[$ext] = $mimeType;
}
}
return $types;
} | php | protected static function _getList($type) {
$types = array();
foreach (self::$_types as $ext => $mimeType) {
if (is_array($mimeType)) {
$mimeType = $mimeType[0];
}
if (strpos($mimeType, $type) === 0) {
$types[$ext] = $mimeType;
}
}
return $types;
} | [
"protected",
"static",
"function",
"_getList",
"(",
"$",
"type",
")",
"{",
"$",
"types",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"_types",
"as",
"$",
"ext",
"=>",
"$",
"mimeType",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
... | Generate a list of mime types that start with the defined type.
@param string $type
@return array | [
"Generate",
"a",
"list",
"of",
"mime",
"types",
"that",
"start",
"with",
"the",
"defined",
"type",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1224-L1238 | train |
milesj/transit | src/Transit/MimeType.php | MimeType._findMimeType | protected static function _findMimeType($mimeType) {
if ($mimeType instanceof File) {
$mimeType = $mimeType->type();
} else if (strpos($mimeType, '/') === false) {
$mimeType = self::getTypeFromExt($mimeType);
}
return $mimeType;
} | php | protected static function _findMimeType($mimeType) {
if ($mimeType instanceof File) {
$mimeType = $mimeType->type();
} else if (strpos($mimeType, '/') === false) {
$mimeType = self::getTypeFromExt($mimeType);
}
return $mimeType;
} | [
"protected",
"static",
"function",
"_findMimeType",
"(",
"$",
"mimeType",
")",
"{",
"if",
"(",
"$",
"mimeType",
"instanceof",
"File",
")",
"{",
"$",
"mimeType",
"=",
"$",
"mimeType",
"->",
"type",
"(",
")",
";",
"}",
"else",
"if",
"(",
"strpos",
"(",
... | Find the actual mime type based on the ext or File object.
@param string $mimeType
@return string | [
"Find",
"the",
"actual",
"mime",
"type",
"based",
"on",
"the",
"ext",
"or",
"File",
"object",
"."
] | 2454f464e26cd1aa9c900c0535fceb731562c2e5 | https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/MimeType.php#L1257-L1266 | train |
shopgate/cart-integration-magento2-base | src/Helper/Quote.php | Quote.setExternalCoupons | protected function setExternalCoupons()
{
$quote = $this->quoteCouponHelper->setCoupon();
$this->quote->loadActive($quote->getEntityId());
} | php | protected function setExternalCoupons()
{
$quote = $this->quoteCouponHelper->setCoupon();
$this->quote->loadActive($quote->getEntityId());
} | [
"protected",
"function",
"setExternalCoupons",
"(",
")",
"{",
"$",
"quote",
"=",
"$",
"this",
"->",
"quoteCouponHelper",
"->",
"setCoupon",
"(",
")",
";",
"$",
"this",
"->",
"quote",
"->",
"loadActive",
"(",
"$",
"quote",
"->",
"getEntityId",
"(",
")",
"... | Assign coupons to the quote | [
"Assign",
"coupons",
"to",
"the",
"quote"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Quote.php#L143-L147 | train |
shopgate/cart-integration-magento2-base | src/Helper/Quote.php | Quote.setItems | protected function setItems()
{
foreach ($this->sgBase->getItems() as $item) {
if ($item->isSgCoupon()) {
continue;
}
$info = $item->getInternalOrderInfo();
$amountNet = $item->getUnitAmount();
$amountGross = $item->getUnitAmountWithTax();
try {
$product = $this->productHelper->loadById($info->getProductId());
} catch (\Exception $e) {
$product = null;
}
if (!is_object($product) || !$product->getId() || $product->getStatus() != MageStatus::STATUS_ENABLED) {
$this->log->error('Product with ID ' . $info->getProductId() . ' could not be loaded.');
$this->log->error('SG item number: ' . $item->getItemNumber());
$item->setUnhandledError(\ShopgateLibraryException::CART_ITEM_PRODUCT_NOT_FOUND, 'product not found');
continue;
}
try {
$quoteItem = $this->getQuoteItem($item, $product);
if ($this->useShopgatePrices()) {
if ($this->taxData->priceIncludesTax($this->storeManager->getStore())) {
$quoteItem->setCustomPrice($amountGross);
$quoteItem->setOriginalCustomPrice($amountGross);
} else {
$quoteItem->setCustomPrice($amountNet);
$quoteItem->setOriginalCustomPrice($amountNet);
}
}
$quoteItem->setTaxPercent($item->getTaxPercent());
if (!$item->isSimple()) {
$productWeight = $product->getTypeInstance()->getWeight($product);
$quoteItem->setWeight($productWeight);
}
$quoteItem->setRowWeight($quoteItem->getWeight() * $quoteItem->getQty());
$this->quote->setItemsCount($this->quote->getItemsCount() + 1);
} catch (\Exception $e) {
$this->log->error(
"Error importing product to quote by id: {$product->getId()}, error: {$e->getMessage()}"
);
$this->log->error('SG item number: ' . $item->getItemNumber());
$item->setMagentoError($e->getMessage());
}
}
/**
* Magento's flow is to save Quote on addItem, then on saveOrder load quote again. We mimic this here.
*/
$this->quoteRepository->save($this->quote);
$this->quote = $this->quoteRepository->get($this->quote->getId());
} | php | protected function setItems()
{
foreach ($this->sgBase->getItems() as $item) {
if ($item->isSgCoupon()) {
continue;
}
$info = $item->getInternalOrderInfo();
$amountNet = $item->getUnitAmount();
$amountGross = $item->getUnitAmountWithTax();
try {
$product = $this->productHelper->loadById($info->getProductId());
} catch (\Exception $e) {
$product = null;
}
if (!is_object($product) || !$product->getId() || $product->getStatus() != MageStatus::STATUS_ENABLED) {
$this->log->error('Product with ID ' . $info->getProductId() . ' could not be loaded.');
$this->log->error('SG item number: ' . $item->getItemNumber());
$item->setUnhandledError(\ShopgateLibraryException::CART_ITEM_PRODUCT_NOT_FOUND, 'product not found');
continue;
}
try {
$quoteItem = $this->getQuoteItem($item, $product);
if ($this->useShopgatePrices()) {
if ($this->taxData->priceIncludesTax($this->storeManager->getStore())) {
$quoteItem->setCustomPrice($amountGross);
$quoteItem->setOriginalCustomPrice($amountGross);
} else {
$quoteItem->setCustomPrice($amountNet);
$quoteItem->setOriginalCustomPrice($amountNet);
}
}
$quoteItem->setTaxPercent($item->getTaxPercent());
if (!$item->isSimple()) {
$productWeight = $product->getTypeInstance()->getWeight($product);
$quoteItem->setWeight($productWeight);
}
$quoteItem->setRowWeight($quoteItem->getWeight() * $quoteItem->getQty());
$this->quote->setItemsCount($this->quote->getItemsCount() + 1);
} catch (\Exception $e) {
$this->log->error(
"Error importing product to quote by id: {$product->getId()}, error: {$e->getMessage()}"
);
$this->log->error('SG item number: ' . $item->getItemNumber());
$item->setMagentoError($e->getMessage());
}
}
/**
* Magento's flow is to save Quote on addItem, then on saveOrder load quote again. We mimic this here.
*/
$this->quoteRepository->save($this->quote);
$this->quote = $this->quoteRepository->get($this->quote->getId());
} | [
"protected",
"function",
"setItems",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sgBase",
"->",
"getItems",
"(",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"isSgCoupon",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"... | Assigns Shopgate cart items to quote | [
"Assigns",
"Shopgate",
"cart",
"items",
"to",
"quote"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Quote.php#L152-L210 | train |
shopgate/cart-integration-magento2-base | src/Helper/Quote.php | Quote.setCustomer | protected function setCustomer()
{
$this->quoteCustomer->setEntity($this->quote);
$this->quoteCustomer->setAddress($this->quote);
$this->quoteCustomer->resetGuest($this->quote);
} | php | protected function setCustomer()
{
$this->quoteCustomer->setEntity($this->quote);
$this->quoteCustomer->setAddress($this->quote);
$this->quoteCustomer->resetGuest($this->quote);
} | [
"protected",
"function",
"setCustomer",
"(",
")",
"{",
"$",
"this",
"->",
"quoteCustomer",
"->",
"setEntity",
"(",
"$",
"this",
"->",
"quote",
")",
";",
"$",
"this",
"->",
"quoteCustomer",
"->",
"setAddress",
"(",
"$",
"this",
"->",
"quote",
")",
";",
... | Assigns Shopgate cart customer to quote | [
"Assigns",
"Shopgate",
"cart",
"customer",
"to",
"quote"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Quote.php#L279-L284 | train |
hypeJunction/hypeApps | classes/hypeJunction/Util/ItemCollection.php | ItemCollection.add | public function add($data = null) {
if (is_array($data)) {
foreach ($data as $elem) {
$this->add($elem);
}
} else {
$guid = $this->toGUID($data);
if ($guid) {
array_push($this->guids, $guid);
sort($this->guids);
}
}
return $this;
} | php | public function add($data = null) {
if (is_array($data)) {
foreach ($data as $elem) {
$this->add($elem);
}
} else {
$guid = $this->toGUID($data);
if ($guid) {
array_push($this->guids, $guid);
sort($this->guids);
}
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"elem",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"elem",
")",
";",
"}",... | Add new elements
@param mixed $data Element(s)
@return \hypeJunction\Inbox\Group | [
"Add",
"new",
"elements"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Util/ItemCollection.php#L29-L42 | train |
hypeJunction/hypeApps | classes/hypeJunction/Util/ItemCollection.php | ItemCollection.toGUID | protected function toGUID($entity = null) {
if ($entity instanceof ElggEntity) {
return (int) $entity->getGUID();
} else if ($this->exists($entity)) {
return (int) $entity;
}
return false;
} | php | protected function toGUID($entity = null) {
if ($entity instanceof ElggEntity) {
return (int) $entity->getGUID();
} else if ($this->exists($entity)) {
return (int) $entity;
}
return false;
} | [
"protected",
"function",
"toGUID",
"(",
"$",
"entity",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"entity",
"instanceof",
"ElggEntity",
")",
"{",
"return",
"(",
"int",
")",
"$",
"entity",
"->",
"getGUID",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"th... | Get guids from an entity attribute
@param ElggEntity|int $entity Entity or GUID
@return int | [
"Get",
"guids",
"from",
"an",
"entity",
"attribute"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Util/ItemCollection.php#L67-L74 | train |
shopgate/cart-integration-magento2-base | src/Model/Redirect/Route/Tags/Product.php | Product.generate | public function generate($pageTitle)
{
$tags = parent::generate($pageTitle);
$product = $this->registry->registry('current_product');
if (!$product instanceof MagentoProduct) {
$this->logger->error('Could not retrieve mage product from registry');
return $tags;
}
/** @var \Magento\Store\Model\Store $store */
$store = $this->storeManager->getStore();
$image = $product->getMediaGalleryImages()->getFirstItem();
$imageUrl = is_object($image) ? $image->getData('url') : '';
$name = $product->getName();
$description = $product->getDescription();
$availableText = $product->isInStock() ? 'instock' : 'oos';
$categoryName = $this->getCategoryName();
$defaultCurrency = $store->getCurrentCurrency()->getCode();
$eanIdentifier = $this->config->getConfigByPath(ExportInterface::PATH_PROD_EAN_CODE)->getValue();
$ean = (string) $product->getData($eanIdentifier);
$taxClassId = $product->getTaxClassId();
$storeId = $store->getId();
$taxRate = $this->taxCalculation->getDefaultCalculatedRate($taxClassId, null, $storeId);
$priceIsGross = $this->taxConfig->priceIncludesTax($this->storeManager->getStore());
$price = $product->getFinalPrice();
$priceNet = $priceIsGross ? round($price / (1 + $taxRate), 2) : round($price, 2);
$priceGross = !$priceIsGross ? round($price * (1 + $taxRate), 2) : round($price, 2);
$productTags = [
TagGenerator::SITE_PARAMETER_PRODUCT_IMAGE => $imageUrl,
TagGenerator::SITE_PARAMETER_PRODUCT_NAME => $name,
TagGenerator::SITE_PARAMETER_PRODUCT_DESCRIPTION_SHORT => $description,
TagGenerator::SITE_PARAMETER_PRODUCT_EAN => $ean,
TagGenerator::SITE_PARAMETER_PRODUCT_AVAILABILITY => $availableText,
TagGenerator::SITE_PARAMETER_PRODUCT_CATEGORY => $categoryName,
TagGenerator::SITE_PARAMETER_PRODUCT_PRICE => $priceGross,
TagGenerator::SITE_PARAMETER_PRODUCT_PRETAX_PRICE => $priceNet
];
if ($priceGross || $priceNet) {
$productTags[TagGenerator::SITE_PARAMETER_PRODUCT_CURRENCY] = $defaultCurrency;
$productTags[TagGenerator::SITE_PARAMETER_PRODUCT_PRETAX_CURRENCY] = $defaultCurrency;
}
$tags = array_merge($tags, $productTags);
return $tags;
} | php | public function generate($pageTitle)
{
$tags = parent::generate($pageTitle);
$product = $this->registry->registry('current_product');
if (!$product instanceof MagentoProduct) {
$this->logger->error('Could not retrieve mage product from registry');
return $tags;
}
/** @var \Magento\Store\Model\Store $store */
$store = $this->storeManager->getStore();
$image = $product->getMediaGalleryImages()->getFirstItem();
$imageUrl = is_object($image) ? $image->getData('url') : '';
$name = $product->getName();
$description = $product->getDescription();
$availableText = $product->isInStock() ? 'instock' : 'oos';
$categoryName = $this->getCategoryName();
$defaultCurrency = $store->getCurrentCurrency()->getCode();
$eanIdentifier = $this->config->getConfigByPath(ExportInterface::PATH_PROD_EAN_CODE)->getValue();
$ean = (string) $product->getData($eanIdentifier);
$taxClassId = $product->getTaxClassId();
$storeId = $store->getId();
$taxRate = $this->taxCalculation->getDefaultCalculatedRate($taxClassId, null, $storeId);
$priceIsGross = $this->taxConfig->priceIncludesTax($this->storeManager->getStore());
$price = $product->getFinalPrice();
$priceNet = $priceIsGross ? round($price / (1 + $taxRate), 2) : round($price, 2);
$priceGross = !$priceIsGross ? round($price * (1 + $taxRate), 2) : round($price, 2);
$productTags = [
TagGenerator::SITE_PARAMETER_PRODUCT_IMAGE => $imageUrl,
TagGenerator::SITE_PARAMETER_PRODUCT_NAME => $name,
TagGenerator::SITE_PARAMETER_PRODUCT_DESCRIPTION_SHORT => $description,
TagGenerator::SITE_PARAMETER_PRODUCT_EAN => $ean,
TagGenerator::SITE_PARAMETER_PRODUCT_AVAILABILITY => $availableText,
TagGenerator::SITE_PARAMETER_PRODUCT_CATEGORY => $categoryName,
TagGenerator::SITE_PARAMETER_PRODUCT_PRICE => $priceGross,
TagGenerator::SITE_PARAMETER_PRODUCT_PRETAX_PRICE => $priceNet
];
if ($priceGross || $priceNet) {
$productTags[TagGenerator::SITE_PARAMETER_PRODUCT_CURRENCY] = $defaultCurrency;
$productTags[TagGenerator::SITE_PARAMETER_PRODUCT_PRETAX_CURRENCY] = $defaultCurrency;
}
$tags = array_merge($tags, $productTags);
return $tags;
} | [
"public",
"function",
"generate",
"(",
"$",
"pageTitle",
")",
"{",
"$",
"tags",
"=",
"parent",
"::",
"generate",
"(",
"$",
"pageTitle",
")",
";",
"$",
"product",
"=",
"$",
"this",
"->",
"registry",
"->",
"registry",
"(",
"'current_product'",
")",
";",
... | Generates page specific tags + generic tags
@param string $pageTitle
@return array
@throws \Magento\Framework\Exception\LocalizedException | [
"Generates",
"page",
"specific",
"tags",
"+",
"generic",
"tags"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Redirect/Route/Tags/Product.php#L80-L129 | train |
SaftIng/Saft | src/Saft/Rdf/AbstractLiteral.php | AbstractLiteral.toNQuads | public function toNQuads()
{
$string = '"'.$this->encodeStringLitralForNQuads($this->getValue()).'"';
if ($this->getLanguage() !== null) {
$string .= '@'.$this->getLanguage();
} elseif ($this->getDatatype() !== null) {
$string .= '^^<'.$this->getDatatype().'>';
}
return $string;
} | php | public function toNQuads()
{
$string = '"'.$this->encodeStringLitralForNQuads($this->getValue()).'"';
if ($this->getLanguage() !== null) {
$string .= '@'.$this->getLanguage();
} elseif ($this->getDatatype() !== null) {
$string .= '^^<'.$this->getDatatype().'>';
}
return $string;
} | [
"public",
"function",
"toNQuads",
"(",
")",
"{",
"$",
"string",
"=",
"'\"'",
".",
"$",
"this",
"->",
"encodeStringLitralForNQuads",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
".",
"'\"'",
";",
"if",
"(",
"$",
"this",
"->",
"getLanguage",
"(",
... | Transform this Node instance to a n-quads string, if possible.
@return string N-quads string representation of this instance
@api
@since 0.1 | [
"Transform",
"this",
"Node",
"instance",
"to",
"a",
"n",
"-",
"quads",
"string",
"if",
"possible",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/AbstractLiteral.php#L155-L166 | train |
webeweb/core-library | src/Network/HTTP/HTTPHelper.php | HTTPHelper.getHTTPMethods | public static function getHTTPMethods() {
return[
self::HTTP_METHOD_DELETE,
self::HTTP_METHOD_GET,
self::HTTP_METHOD_HEAD,
self::HTTP_METHOD_OPTIONS,
self::HTTP_METHOD_PATCH,
self::HTTP_METHOD_POST,
self::HTTP_METHOD_PUT,
];
} | php | public static function getHTTPMethods() {
return[
self::HTTP_METHOD_DELETE,
self::HTTP_METHOD_GET,
self::HTTP_METHOD_HEAD,
self::HTTP_METHOD_OPTIONS,
self::HTTP_METHOD_PATCH,
self::HTTP_METHOD_POST,
self::HTTP_METHOD_PUT,
];
} | [
"public",
"static",
"function",
"getHTTPMethods",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"HTTP_METHOD_DELETE",
",",
"self",
"::",
"HTTP_METHOD_GET",
",",
"self",
"::",
"HTTP_METHOD_HEAD",
",",
"self",
"::",
"HTTP_METHOD_OPTIONS",
",",
"self",
"::",
"HTTP_ME... | Get the HTTP methods.
@return array Returns the HTTP methods. | [
"Get",
"the",
"HTTP",
"methods",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/HTTP/HTTPHelper.php#L27-L37 | train |
webeweb/core-library | src/Network/HTTP/HTTPHelper.php | HTTPHelper.getHTTPStatus | public static function getHTTPStatus() {
return [
self::HTTP_STATUS_CONTINUE,
self::HTTP_STATUS_SWITCHING_PROTOCOLS,
self::HTTP_STATUS_PROCESSING,
self::HTTP_STATUS_OK,
self::HTTP_STATUS_CREATED,
self::HTTP_STATUS_ACCEPTED,
self::HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION,
self::HTTP_STATUS_NO_CONTENT,
self::HTTP_STATUS_RESET_CONTENT,
self::HTTP_STATUS_PARTIAL_CONTENT,
self::HTTP_STATUS_MULTI_STATUS,
self::HTTP_STATUS_ALREADY_REPORTED,
self::HTTP_STATUS_IM_USED,
self::HTTP_STATUS_MULTIPLE_CHOICES,
self::HTTP_STATUS_MOVED_PERMANENTLY,
self::HTTP_STATUS_MOVED_TEMPORARILY,
self::HTTP_STATUS_SEE_OTHER,
self::HTTP_STATUS_NOT_MODIFIED,
self::HTTP_STATUS_USE_PROXY,
self::HTTP_STATUS_TEMPORARY_REDIRECT,
self::HTTP_STATUS_PERMANENT_REDIRECT,
self::HTTP_STATUS_BAD_REQUEST,
self::HTTP_STATUS_UNAUTHORIZED,
self::HTTP_STATUS_PAYMENT_REQUIRED,
self::HTTP_STATUS_FORBIDDEN,
self::HTTP_STATUS_NOT_FOUND,
self::HTTP_STATUS_METHOD_NOT_ALLOWED,
self::HTTP_STATUS_NOT_ACCEPTABLE,
self::HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED,
self::HTTP_STATUS_REQUEST_TIME_OUT,
self::HTTP_STATUS_CONFLICT,
self::HTTP_STATUS_GONE,
self::HTTP_STATUS_LENGTH_REQUIRED,
self::HTTP_STATUS_PRECONDITION_FAILED,
self::HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE,
self::HTTP_STATUS_REQUEST_URI_TOO_LONG,
self::HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE,
self::HTTP_STATUS_REQUESTED_RANGE_UNSATISFIABLE,
self::HTTP_STATUS_EXPECTATION_FAILED,
self::HTTP_STATUS_UNPROCESSABLE_ENTITY,
self::HTTP_STATUS_LOCKED,
self::HTTP_STATUS_METHOD_FAILURE,
self::HTTP_STATUS_UPGRADE_REQUIRED,
self::HTTP_STATUS_PRECONDITION_REQUIRED,
self::HTTP_STATUS_TOO_MANY_REQUESTS,
self::HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE,
self::HTTP_STATUS_INTERNAL_SERVER_ERROR,
self::HTTP_STATUS_NOT_IMPLEMENTED,
self::HTTP_STATUS_BAD_GATEWAY_OU_PROXY_ERROR,
self::HTTP_STATUS_SERVICE_UNAVAILABLE,
self::HTTP_STATUS_GATEWAY_TIME_OUT,
self::HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED,
self::HTTP_STATUS_VARIANT_ALSO_NEGOTIATES,
self::HTTP_STATUS_INSUFFICIENT_STORAGE,
self::HTTP_STATUS_LOOP_DETECTED,
self::HTTP_STATUS_NOT_EXTENDED,
self::HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED,
];
} | php | public static function getHTTPStatus() {
return [
self::HTTP_STATUS_CONTINUE,
self::HTTP_STATUS_SWITCHING_PROTOCOLS,
self::HTTP_STATUS_PROCESSING,
self::HTTP_STATUS_OK,
self::HTTP_STATUS_CREATED,
self::HTTP_STATUS_ACCEPTED,
self::HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION,
self::HTTP_STATUS_NO_CONTENT,
self::HTTP_STATUS_RESET_CONTENT,
self::HTTP_STATUS_PARTIAL_CONTENT,
self::HTTP_STATUS_MULTI_STATUS,
self::HTTP_STATUS_ALREADY_REPORTED,
self::HTTP_STATUS_IM_USED,
self::HTTP_STATUS_MULTIPLE_CHOICES,
self::HTTP_STATUS_MOVED_PERMANENTLY,
self::HTTP_STATUS_MOVED_TEMPORARILY,
self::HTTP_STATUS_SEE_OTHER,
self::HTTP_STATUS_NOT_MODIFIED,
self::HTTP_STATUS_USE_PROXY,
self::HTTP_STATUS_TEMPORARY_REDIRECT,
self::HTTP_STATUS_PERMANENT_REDIRECT,
self::HTTP_STATUS_BAD_REQUEST,
self::HTTP_STATUS_UNAUTHORIZED,
self::HTTP_STATUS_PAYMENT_REQUIRED,
self::HTTP_STATUS_FORBIDDEN,
self::HTTP_STATUS_NOT_FOUND,
self::HTTP_STATUS_METHOD_NOT_ALLOWED,
self::HTTP_STATUS_NOT_ACCEPTABLE,
self::HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED,
self::HTTP_STATUS_REQUEST_TIME_OUT,
self::HTTP_STATUS_CONFLICT,
self::HTTP_STATUS_GONE,
self::HTTP_STATUS_LENGTH_REQUIRED,
self::HTTP_STATUS_PRECONDITION_FAILED,
self::HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE,
self::HTTP_STATUS_REQUEST_URI_TOO_LONG,
self::HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE,
self::HTTP_STATUS_REQUESTED_RANGE_UNSATISFIABLE,
self::HTTP_STATUS_EXPECTATION_FAILED,
self::HTTP_STATUS_UNPROCESSABLE_ENTITY,
self::HTTP_STATUS_LOCKED,
self::HTTP_STATUS_METHOD_FAILURE,
self::HTTP_STATUS_UPGRADE_REQUIRED,
self::HTTP_STATUS_PRECONDITION_REQUIRED,
self::HTTP_STATUS_TOO_MANY_REQUESTS,
self::HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE,
self::HTTP_STATUS_INTERNAL_SERVER_ERROR,
self::HTTP_STATUS_NOT_IMPLEMENTED,
self::HTTP_STATUS_BAD_GATEWAY_OU_PROXY_ERROR,
self::HTTP_STATUS_SERVICE_UNAVAILABLE,
self::HTTP_STATUS_GATEWAY_TIME_OUT,
self::HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED,
self::HTTP_STATUS_VARIANT_ALSO_NEGOTIATES,
self::HTTP_STATUS_INSUFFICIENT_STORAGE,
self::HTTP_STATUS_LOOP_DETECTED,
self::HTTP_STATUS_NOT_EXTENDED,
self::HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED,
];
} | [
"public",
"static",
"function",
"getHTTPStatus",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"HTTP_STATUS_CONTINUE",
",",
"self",
"::",
"HTTP_STATUS_SWITCHING_PROTOCOLS",
",",
"self",
"::",
"HTTP_STATUS_PROCESSING",
",",
"self",
"::",
"HTTP_STATUS_OK",
",",
"self",
... | Get the HTTP status.
@return array Returns the HTTP status. | [
"Get",
"the",
"HTTP",
"status",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/HTTP/HTTPHelper.php#L44-L104 | train |
webeweb/core-library | src/Network/FTP/SFTPClient.php | SFTPClient.connect | public function connect() {
$host = $this->getAuthenticator()->getHost();
$port = $this->getAuthenticator()->getPort();
$this->setConnection(ssh2_connect($host, $port));
if (false === $this->getConnection()) {
throw $this->newFTPException("connection failed");
}
return $this;
} | php | public function connect() {
$host = $this->getAuthenticator()->getHost();
$port = $this->getAuthenticator()->getPort();
$this->setConnection(ssh2_connect($host, $port));
if (false === $this->getConnection()) {
throw $this->newFTPException("connection failed");
}
return $this;
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"getAuthenticator",
"(",
")",
"->",
"getHost",
"(",
")",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"getAuthenticator",
"(",
")",
"->",
"getPort",
"(",
")",
";",
"$... | Opens this SFTP connection.
@return SFTPClient Returns this SFTP client.
@throws FTPException Throws a FTP exception if an I/O error occurs. | [
"Opens",
"this",
"SFTP",
"connection",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/FTP/SFTPClient.php#L64-L72 | train |
webeweb/core-library | src/Network/FTP/SFTPClient.php | SFTPClient.getSFTP | private function getSFTP() {
if (null === $this->sftp) {
$this->sftp = ssh2_sftp($this->getConnection());
}
return $this->sftp;
} | php | private function getSFTP() {
if (null === $this->sftp) {
$this->sftp = ssh2_sftp($this->getConnection());
}
return $this->sftp;
} | [
"private",
"function",
"getSFTP",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"sftp",
")",
"{",
"$",
"this",
"->",
"sftp",
"=",
"ssh2_sftp",
"(",
"$",
"this",
"->",
"getConnection",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
... | Get the SFTP resource.
@return mixed Returns the SFTP resource. | [
"Get",
"the",
"SFTP",
"resource",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/FTP/SFTPClient.php#L93-L98 | train |
webeweb/core-library | src/Network/FTP/SFTPClient.php | SFTPClient.login | public function login() {
$username = $this->getAuthenticator()->getPasswordAuthentication()->getUsername();
$password = $this->getAuthenticator()->getPasswordAuthentication()->getPassword();
if (false === ssh2_auth_password($this->getConnection(), $username, $password)) {
throw $this->newFTPException("login failed");
}
return $this;
} | php | public function login() {
$username = $this->getAuthenticator()->getPasswordAuthentication()->getUsername();
$password = $this->getAuthenticator()->getPasswordAuthentication()->getPassword();
if (false === ssh2_auth_password($this->getConnection(), $username, $password)) {
throw $this->newFTPException("login failed");
}
return $this;
} | [
"public",
"function",
"login",
"(",
")",
"{",
"$",
"username",
"=",
"$",
"this",
"->",
"getAuthenticator",
"(",
")",
"->",
"getPasswordAuthentication",
"(",
")",
"->",
"getUsername",
"(",
")",
";",
"$",
"password",
"=",
"$",
"this",
"->",
"getAuthenticator... | Logs in to this SFTP connection.
@return SFTPClient Returns this SFTP client.
@throws FTPException Throws a FTP exception if an I/O error occurs. | [
"Logs",
"in",
"to",
"this",
"SFTP",
"connection",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/FTP/SFTPClient.php#L106-L113 | train |
webeweb/core-library | src/Network/FTP/SFTPClient.php | SFTPClient.rename | public function rename($oldName, $newName) {
if (false === ssh2_sftp_rename($this->getSFTP(), $oldName, $newName)) {
throw $this->newFTPException(sprintf("rename %s into %s failed", $oldName, $newName));
}
return $this;
} | php | public function rename($oldName, $newName) {
if (false === ssh2_sftp_rename($this->getSFTP(), $oldName, $newName)) {
throw $this->newFTPException(sprintf("rename %s into %s failed", $oldName, $newName));
}
return $this;
} | [
"public",
"function",
"rename",
"(",
"$",
"oldName",
",",
"$",
"newName",
")",
"{",
"if",
"(",
"false",
"===",
"ssh2_sftp_rename",
"(",
"$",
"this",
"->",
"getSFTP",
"(",
")",
",",
"$",
"oldName",
",",
"$",
"newName",
")",
")",
"{",
"throw",
"$",
"... | Renames a file or a directory on the SFTP server.
@param string $oldName The old file/directory name.
@param string $newName The new name.
@return SFTPClient Returns this SFTP client.
@throws FTPException Throws a FTP exception if an I/O error occurs. | [
"Renames",
"a",
"file",
"or",
"a",
"directory",
"on",
"the",
"SFTP",
"server",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/FTP/SFTPClient.php#L154-L159 | train |
inc2734/wp-github-theme-updater | src/App/Model/Upgrader.php | Upgrader.pre_install | public function pre_install( $bool, $hook_extra ) {
if ( ! isset( $hook_extra['theme'] ) || $this->theme_name !== $hook_extra['theme'] ) {
return $bool;
}
global $wp_filesystem;
$theme_dir = trailingslashit( get_theme_root( $this->theme_name ) ) . $this->theme_name;
if ( ! $wp_filesystem->is_writable( $theme_dir ) ) {
return new \WP_Error();
}
return $bool;
} | php | public function pre_install( $bool, $hook_extra ) {
if ( ! isset( $hook_extra['theme'] ) || $this->theme_name !== $hook_extra['theme'] ) {
return $bool;
}
global $wp_filesystem;
$theme_dir = trailingslashit( get_theme_root( $this->theme_name ) ) . $this->theme_name;
if ( ! $wp_filesystem->is_writable( $theme_dir ) ) {
return new \WP_Error();
}
return $bool;
} | [
"public",
"function",
"pre_install",
"(",
"$",
"bool",
",",
"$",
"hook_extra",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"hook_extra",
"[",
"'theme'",
"]",
")",
"||",
"$",
"this",
"->",
"theme_name",
"!==",
"$",
"hook_extra",
"[",
"'theme'",
"]",
... | Correspondence when the theme can not be updated
@param bool $bool
@param array $hook_extra
@return bool|WP_Error. | [
"Correspondence",
"when",
"the",
"theme",
"can",
"not",
"be",
"updated"
] | f9727530f2d62b2bf0ca909704d9b9b790d4e9a5 | https://github.com/inc2734/wp-github-theme-updater/blob/f9727530f2d62b2bf0ca909704d9b9b790d4e9a5/src/App/Model/Upgrader.php#L33-L46 | train |
inc2734/wp-github-theme-updater | src/App/Model/Upgrader.php | Upgrader.source_selection | public function source_selection( $source, $remote_source, $install, $hook_extra ) {
if ( ! isset( $hook_extra['theme'] ) || $this->theme_name !== $hook_extra['theme'] ) {
return $source;
}
global $wp_filesystem;
$slash_count = substr_count( $this->theme_name, '/' );
if ( $slash_count ) {
add_action( 'switch_theme', [ $this, '_re_activate' ], 10, 3 );
}
$source_theme_dir = untrailingslashit( WP_CONTENT_DIR ) . '/upgrade';
if ( $wp_filesystem->is_writable( $source_theme_dir ) && $wp_filesystem->is_writable( $source ) ) {
$newsource = trailingslashit( $source_theme_dir ) . trailingslashit( $this->theme_name );
if ( $wp_filesystem->move( $source, $newsource, true ) ) {
return $newsource;
}
}
return new \WP_Error();
} | php | public function source_selection( $source, $remote_source, $install, $hook_extra ) {
if ( ! isset( $hook_extra['theme'] ) || $this->theme_name !== $hook_extra['theme'] ) {
return $source;
}
global $wp_filesystem;
$slash_count = substr_count( $this->theme_name, '/' );
if ( $slash_count ) {
add_action( 'switch_theme', [ $this, '_re_activate' ], 10, 3 );
}
$source_theme_dir = untrailingslashit( WP_CONTENT_DIR ) . '/upgrade';
if ( $wp_filesystem->is_writable( $source_theme_dir ) && $wp_filesystem->is_writable( $source ) ) {
$newsource = trailingslashit( $source_theme_dir ) . trailingslashit( $this->theme_name );
if ( $wp_filesystem->move( $source, $newsource, true ) ) {
return $newsource;
}
}
return new \WP_Error();
} | [
"public",
"function",
"source_selection",
"(",
"$",
"source",
",",
"$",
"remote_source",
",",
"$",
"install",
",",
"$",
"hook_extra",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"hook_extra",
"[",
"'theme'",
"]",
")",
"||",
"$",
"this",
"->",
"theme_n... | Expand the theme
@param string $source
@param string $remote_source
@param WP_Upgrader $install
@param array $args['hook_extra']
@return $source|WP_Error. | [
"Expand",
"the",
"theme"
] | f9727530f2d62b2bf0ca909704d9b9b790d4e9a5 | https://github.com/inc2734/wp-github-theme-updater/blob/f9727530f2d62b2bf0ca909704d9b9b790d4e9a5/src/App/Model/Upgrader.php#L57-L78 | train |
webeweb/core-library | src/ThirdParty/SkiData/Parser/StartRecordFormatParser.php | StartRecordFormatParser.parseEntity | public function parseEntity(StartRecordFormat $entity) {
$output = [
$this->encodeInteger($entity->getVersionRecordStructure(), 6),
$this->encodeInteger($entity->getFacilityNumber(), 7),
$this->encodeDate($entity->getDateFile()),
$this->encodeInteger($entity->getNumberRecords(), 5),
$this->encodeString($entity->getCurrency(), 6),
];
return implode(";", $output);
} | php | public function parseEntity(StartRecordFormat $entity) {
$output = [
$this->encodeInteger($entity->getVersionRecordStructure(), 6),
$this->encodeInteger($entity->getFacilityNumber(), 7),
$this->encodeDate($entity->getDateFile()),
$this->encodeInteger($entity->getNumberRecords(), 5),
$this->encodeString($entity->getCurrency(), 6),
];
return implode(";", $output);
} | [
"public",
"function",
"parseEntity",
"(",
"StartRecordFormat",
"$",
"entity",
")",
"{",
"$",
"output",
"=",
"[",
"$",
"this",
"->",
"encodeInteger",
"(",
"$",
"entity",
"->",
"getVersionRecordStructure",
"(",
")",
",",
"6",
")",
",",
"$",
"this",
"->",
"... | Parse a start record format entity.
@param StartRecordFormat $entity The start record format.
@return string Returns the parsed start record format.
@throws TooLongDataException Throws a too long data exception if a data is too long. | [
"Parse",
"a",
"start",
"record",
"format",
"entity",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/StartRecordFormatParser.php#L41-L52 | train |
bakaphp/database | src/HashTable.php | HashTable.onConstruct | public function onConstruct($app)
{
//if not null
if (!is_null($app)) {
$key = $this->settingsKey;
$this->$key = $app;
}
} | php | public function onConstruct($app)
{
//if not null
if (!is_null($app)) {
$key = $this->settingsKey;
$this->$key = $app;
}
} | [
"public",
"function",
"onConstruct",
"(",
"$",
"app",
")",
"{",
"//if not null",
"if",
"(",
"!",
"is_null",
"(",
"$",
"app",
")",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"settingsKey",
";",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"app",
";... | Set the current hash id to work with the obj
@param mixed $app
@return void | [
"Set",
"the",
"current",
"hash",
"id",
"to",
"work",
"with",
"the",
"obj"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/HashTable.php#L67-L74 | train |
bakaphp/database | src/HashTable.php | HashTable.getSettingsKey | public function getSettingsKey(): string
{
$key = $this->settingsKey;
if (empty($this->$key)) {
throw new Exception("No settings key is set on the constructor");
}
return $this->$key;
} | php | public function getSettingsKey(): string
{
$key = $this->settingsKey;
if (empty($this->$key)) {
throw new Exception("No settings key is set on the constructor");
}
return $this->$key;
} | [
"public",
"function",
"getSettingsKey",
"(",
")",
":",
"string",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"settingsKey",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"No settings key is... | get the current setting id
@return string | [
"get",
"the",
"current",
"setting",
"id"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/HashTable.php#L81-L90 | train |
bakaphp/database | src/HashTable.php | HashTable.get | public function get(string $key)
{
$hash = self::findFirst([
'conditions' => "{$this->settingsKey} = ?0 and key = ?1",
'bind' => [$this->getSettingsKey(), $key]
]);
if ($hash) {
return $hash->value;
}
return null;
} | php | public function get(string $key)
{
$hash = self::findFirst([
'conditions' => "{$this->settingsKey} = ?0 and key = ?1",
'bind' => [$this->getSettingsKey(), $key]
]);
if ($hash) {
return $hash->value;
}
return null;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
")",
"{",
"$",
"hash",
"=",
"self",
"::",
"findFirst",
"(",
"[",
"'conditions'",
"=>",
"\"{$this->settingsKey} = ?0 and key = ?1\"",
",",
"'bind'",
"=>",
"[",
"$",
"this",
"->",
"getSettingsKey",
"(",
"... | Get the vehicle settings
@param Vehicle $vehicle [description]
@param string $key [description]
@return mixed | [
"Get",
"the",
"vehicle",
"settings"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/HashTable.php#L109-L121 | train |
bakaphp/database | src/HashTable.php | HashTable.set | public function set(string $key, string $value) : self
{
if (!$setting = $this->get($key)) {
$setting = new self($this->getSettingsKey());
}
$setting->key = $key;
$setting->value = $value;
if (!$setting->save()) {
throw new Exception(current($setting->getMessages()));
}
return $setting;
} | php | public function set(string $key, string $value) : self
{
if (!$setting = $this->get($key)) {
$setting = new self($this->getSettingsKey());
}
$setting->key = $key;
$setting->value = $value;
if (!$setting->save()) {
throw new Exception(current($setting->getMessages()));
}
return $setting;
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"value",
")",
":",
"self",
"{",
"if",
"(",
"!",
"$",
"setting",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
")",
"{",
"$",
"setting",
"=",
"new",
"self",
"(",
... | Set the vehicle key
@param Vehicle $vehicle [description]
@param string $key [description]
@param string $value [description] | [
"Set",
"the",
"vehicle",
"key"
] | b227de7c27e819abadf56cfd66ff08dab2797d62 | https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/HashTable.php#L129-L143 | train |
SaftIng/Saft | src/Saft/Addition/Virtuoso/Store/Virtuoso.php | Virtuoso.openConnection | protected function openConnection()
{
// connection still closed
if (null === $this->connection) {
// check for dsn parameter. it is usually the ODBC identifier, e.g. VOS.
// for more information have a look into /etc/odbc.ini (*NIX systems)
if (false === isset($this->configuration['dsn'])) {
throw new \Exception('Parameter dsn is not set.');
}
// check for username parameter
if (false === isset($this->configuration['username'])) {
throw new \Exception('Parameter username is not set.');
}
// check for password parameter
if (false === isset($this->configuration['password'])) {
throw new \Exception('Parameter password is not set.');
}
/*
* Setup ODBC connection using PDO-ODBC
*/
$this->connection = new \PDO(
'odbc:'.(string) $this->configuration['dsn'],
(string) $this->configuration['username'],
(string) $this->configuration['password']
);
$this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
}
return $this->connection;
} | php | protected function openConnection()
{
// connection still closed
if (null === $this->connection) {
// check for dsn parameter. it is usually the ODBC identifier, e.g. VOS.
// for more information have a look into /etc/odbc.ini (*NIX systems)
if (false === isset($this->configuration['dsn'])) {
throw new \Exception('Parameter dsn is not set.');
}
// check for username parameter
if (false === isset($this->configuration['username'])) {
throw new \Exception('Parameter username is not set.');
}
// check for password parameter
if (false === isset($this->configuration['password'])) {
throw new \Exception('Parameter password is not set.');
}
/*
* Setup ODBC connection using PDO-ODBC
*/
$this->connection = new \PDO(
'odbc:'.(string) $this->configuration['dsn'],
(string) $this->configuration['username'],
(string) $this->configuration['password']
);
$this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
}
return $this->connection;
} | [
"protected",
"function",
"openConnection",
"(",
")",
"{",
"// connection still closed",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"connection",
")",
"{",
"// check for dsn parameter. it is usually the ODBC identifier, e.g. VOS.",
"// for more information have a look into /etc/... | Returns the current connection resource. The resource is created lazily if it doesn't exist.
@return \PDO instance of \PDO representing an open PDO-ODBC connection
@throws \PDOException if connection could not be established | [
"Returns",
"the",
"current",
"connection",
"resource",
".",
"The",
"resource",
"is",
"created",
"lazily",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/Virtuoso/Store/Virtuoso.php#L271-L303 | train |
SaftIng/Saft | src/Saft/Addition/Virtuoso/Store/Virtuoso.php | Virtuoso.sqlQuery | public function sqlQuery($queryString)
{
try {
// execute query
$query = $this->connection->prepare(
$queryString,
[\PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY]
);
$query->execute();
return $query;
} catch (\PDOException $e) {
throw new \Exception($e->getMessage());
}
} | php | public function sqlQuery($queryString)
{
try {
// execute query
$query = $this->connection->prepare(
$queryString,
[\PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY]
);
$query->execute();
return $query;
} catch (\PDOException $e) {
throw new \Exception($e->getMessage());
}
} | [
"public",
"function",
"sqlQuery",
"(",
"$",
"queryString",
")",
"{",
"try",
"{",
"// execute query",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"$",
"queryString",
",",
"[",
"\\",
"PDO",
"::",
"ATTR_CURSOR",
"=>",
"\\",
"PD... | Executes a SQL query on the database.
@param string $queryString SPARQL- or SQL query to execute
@return \PDOStatement instance of PDOStatement which contains the result of the previous query
@throws \Exception If $queryString is invalid | [
"Executes",
"a",
"SQL",
"query",
"on",
"the",
"database",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/Virtuoso/Store/Virtuoso.php#L508-L522 | train |
SaftIng/Saft | src/Saft/Addition/Virtuoso/Store/Virtuoso.php | Virtuoso.transformEntryToNode | public function transformEntryToNode($entry)
{
/*
* An $entry looks like:
* array(
* 'type' => 'uri',
* 'value' => '...'
* )
*/
// it seems that for instance Virtuoso returns type=literal for bnodes,
// so we manually fix that here to avoid that problem, if other stores act
// the same
if (isset($entry['value'])
&& true === is_string($entry['value'])
&& false !== strpos($entry['value'], '_:')) {
$entry['type'] = 'bnode';
}
$newEntry = null;
switch ($entry['type']) {
/*
* Literal (language'd)
*/
case 'literal':
if (isset($entry['xml:lang'])) {
$newEntry = $this->nodeFactory->createLiteral(
$entry['value'],
'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString',
$entry['xml:lang']
);
// if a literal was created, but with no language information, it seems to confuse
// it when loading, therefor check if lang was explicitly given, otherwise handle it
// as it were a normal string.
} else {
$newEntry = $this->nodeFactory->createLiteral(
$entry['value']
);
}
break;
/*
* Typed-Literal
*/
case 'typed-literal':
$newEntry = $this->nodeFactory->createLiteral($entry['value'], $entry['datatype']);
break;
/*
* NamedNode
*/
case 'uri':
$newEntry = $this->nodeFactory->createNamedNode($entry['value']);
break;
/*
* BlankNode
*/
case 'bnode':
$newEntry = $this->nodeFactory->createBlankNode($entry['value']);
break;
default:
throw new \Exception('Unknown type given: '.$entry['type']);
break;
}
return $newEntry;
} | php | public function transformEntryToNode($entry)
{
/*
* An $entry looks like:
* array(
* 'type' => 'uri',
* 'value' => '...'
* )
*/
// it seems that for instance Virtuoso returns type=literal for bnodes,
// so we manually fix that here to avoid that problem, if other stores act
// the same
if (isset($entry['value'])
&& true === is_string($entry['value'])
&& false !== strpos($entry['value'], '_:')) {
$entry['type'] = 'bnode';
}
$newEntry = null;
switch ($entry['type']) {
/*
* Literal (language'd)
*/
case 'literal':
if (isset($entry['xml:lang'])) {
$newEntry = $this->nodeFactory->createLiteral(
$entry['value'],
'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString',
$entry['xml:lang']
);
// if a literal was created, but with no language information, it seems to confuse
// it when loading, therefor check if lang was explicitly given, otherwise handle it
// as it were a normal string.
} else {
$newEntry = $this->nodeFactory->createLiteral(
$entry['value']
);
}
break;
/*
* Typed-Literal
*/
case 'typed-literal':
$newEntry = $this->nodeFactory->createLiteral($entry['value'], $entry['datatype']);
break;
/*
* NamedNode
*/
case 'uri':
$newEntry = $this->nodeFactory->createNamedNode($entry['value']);
break;
/*
* BlankNode
*/
case 'bnode':
$newEntry = $this->nodeFactory->createBlankNode($entry['value']);
break;
default:
throw new \Exception('Unknown type given: '.$entry['type']);
break;
}
return $newEntry;
} | [
"public",
"function",
"transformEntryToNode",
"(",
"$",
"entry",
")",
"{",
"/*\n * An $entry looks like:\n * array(\n * 'type' => 'uri',\n * 'value' => '...'\n * )\n */",
"// it seems that for instance Virtuoso returns type=literal for bnod... | Helper function which transforms an result entry to its proper Node instance.
@param array $entry
@return Node instance of Node
@unstable | [
"Helper",
"function",
"which",
"transforms",
"an",
"result",
"entry",
"to",
"its",
"proper",
"Node",
"instance",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/Virtuoso/Store/Virtuoso.php#L532-L602 | train |
keboola/php-temp | src/Temp.php | Temp.getTmpPath | private function getTmpPath(): string
{
$tmpDir = sys_get_temp_dir();
if (!empty($this->prefix)) {
$tmpDir .= '/' . $this->prefix;
}
$tmpDir .= '/' . $this->id;
return $tmpDir;
} | php | private function getTmpPath(): string
{
$tmpDir = sys_get_temp_dir();
if (!empty($this->prefix)) {
$tmpDir .= '/' . $this->prefix;
}
$tmpDir .= '/' . $this->id;
return $tmpDir;
} | [
"private",
"function",
"getTmpPath",
"(",
")",
":",
"string",
"{",
"$",
"tmpDir",
"=",
"sys_get_temp_dir",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"prefix",
")",
")",
"{",
"$",
"tmpDir",
".=",
"'/'",
".",
"$",
"this",
"->",
... | Get path to the temporary folder.
@return string | [
"Get",
"path",
"to",
"the",
"temporary",
"folder",
"."
] | cbdb4dd0dfe548d7bffd74a0e66294981aea49ce | https://github.com/keboola/php-temp/blob/cbdb4dd0dfe548d7bffd74a0e66294981aea49ce/src/Temp.php#L53-L61 | train |
keboola/php-temp | src/Temp.php | Temp.createTmpFile | public function createTmpFile(string $suffix = ''): \SplFileInfo
{
$file = uniqid();
if ($suffix) {
$file .= '-' . $suffix;
}
return $this->createFile($file);
} | php | public function createTmpFile(string $suffix = ''): \SplFileInfo
{
$file = uniqid();
if ($suffix) {
$file .= '-' . $suffix;
}
return $this->createFile($file);
} | [
"public",
"function",
"createTmpFile",
"(",
"string",
"$",
"suffix",
"=",
"''",
")",
":",
"\\",
"SplFileInfo",
"{",
"$",
"file",
"=",
"uniqid",
"(",
")",
";",
"if",
"(",
"$",
"suffix",
")",
"{",
"$",
"file",
".=",
"'-'",
".",
"$",
"suffix",
";",
... | Create a randomly named temporary file.
@param string $suffix filename suffix
@throws \Exception
@return \SplFileInfo | [
"Create",
"a",
"randomly",
"named",
"temporary",
"file",
"."
] | cbdb4dd0dfe548d7bffd74a0e66294981aea49ce | https://github.com/keboola/php-temp/blob/cbdb4dd0dfe548d7bffd74a0e66294981aea49ce/src/Temp.php#L83-L90 | train |
keboola/php-temp | src/Temp.php | Temp.createFile | public function createFile(string $fileName): \SplFileInfo
{
$fileInfo = new \SplFileInfo($this->getTmpFolder() . '/' . $fileName);
$pathName = $fileInfo->getPathname();
if (!file_exists(dirname($pathName))) {
$this->fileSystem->mkdir(dirname($pathName), self::FILE_MODE);
}
$this->fileSystem->touch($pathName);
$this->fileSystem->chmod($pathName, self::FILE_MODE);
return $fileInfo;
} | php | public function createFile(string $fileName): \SplFileInfo
{
$fileInfo = new \SplFileInfo($this->getTmpFolder() . '/' . $fileName);
$pathName = $fileInfo->getPathname();
if (!file_exists(dirname($pathName))) {
$this->fileSystem->mkdir(dirname($pathName), self::FILE_MODE);
}
$this->fileSystem->touch($pathName);
$this->fileSystem->chmod($pathName, self::FILE_MODE);
return $fileInfo;
} | [
"public",
"function",
"createFile",
"(",
"string",
"$",
"fileName",
")",
":",
"\\",
"SplFileInfo",
"{",
"$",
"fileInfo",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"this",
"->",
"getTmpFolder",
"(",
")",
".",
"'/'",
".",
"$",
"fileName",
")",
";",
"$",... | Creates a named temporary file.
@param string $fileName
@return \SplFileInfo
@throws \Exception | [
"Creates",
"a",
"named",
"temporary",
"file",
"."
] | cbdb4dd0dfe548d7bffd74a0e66294981aea49ce | https://github.com/keboola/php-temp/blob/cbdb4dd0dfe548d7bffd74a0e66294981aea49ce/src/Temp.php#L99-L109 | train |
GrahamDeprecated/Laravel-Core | src/CoreServiceProvider.php | CoreServiceProvider.setupListeners | protected function setupListeners()
{
$subscriber = $this->app->make(CommandSubscriber::class);
$this->app->events->subscribe($subscriber);
} | php | protected function setupListeners()
{
$subscriber = $this->app->make(CommandSubscriber::class);
$this->app->events->subscribe($subscriber);
} | [
"protected",
"function",
"setupListeners",
"(",
")",
"{",
"$",
"subscriber",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"CommandSubscriber",
"::",
"class",
")",
";",
"$",
"this",
"->",
"app",
"->",
"events",
"->",
"subscribe",
"(",
"$",
"subscribe... | Setup the listeners.
@return void | [
"Setup",
"the",
"listeners",
"."
] | 9240e0757186f7fc0dd81ab445a997cb106b508e | https://github.com/GrahamDeprecated/Laravel-Core/blob/9240e0757186f7fc0dd81ab445a997cb106b508e/src/CoreServiceProvider.php#L45-L50 | train |
GrahamDeprecated/Laravel-Core | src/CoreServiceProvider.php | CoreServiceProvider.registerUpdateCommand | protected function registerUpdateCommand()
{
$this->app->singleton('command.appupdate', function (Container $app) {
$events = $app['events'];
return new AppUpdate($events);
});
} | php | protected function registerUpdateCommand()
{
$this->app->singleton('command.appupdate', function (Container $app) {
$events = $app['events'];
return new AppUpdate($events);
});
} | [
"protected",
"function",
"registerUpdateCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.appupdate'",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"events",
"=",
"$",
"app",
"[",
"'events'",
"]",
";",
... | Register the updated command class.
@return void | [
"Register",
"the",
"updated",
"command",
"class",
"."
] | 9240e0757186f7fc0dd81ab445a997cb106b508e | https://github.com/GrahamDeprecated/Laravel-Core/blob/9240e0757186f7fc0dd81ab445a997cb106b508e/src/CoreServiceProvider.php#L70-L77 | train |
GrahamDeprecated/Laravel-Core | src/CoreServiceProvider.php | CoreServiceProvider.registerInstallCommand | protected function registerInstallCommand()
{
$this->app->singleton('command.appinstall', function (Container $app) {
$events = $app['events'];
return new AppInstall($events);
});
} | php | protected function registerInstallCommand()
{
$this->app->singleton('command.appinstall', function (Container $app) {
$events = $app['events'];
return new AppInstall($events);
});
} | [
"protected",
"function",
"registerInstallCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.appinstall'",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"events",
"=",
"$",
"app",
"[",
"'events'",
"]",
";",
... | Register the install command class.
@return void | [
"Register",
"the",
"install",
"command",
"class",
"."
] | 9240e0757186f7fc0dd81ab445a997cb106b508e | https://github.com/GrahamDeprecated/Laravel-Core/blob/9240e0757186f7fc0dd81ab445a997cb106b508e/src/CoreServiceProvider.php#L84-L91 | train |
GrahamDeprecated/Laravel-Core | src/CoreServiceProvider.php | CoreServiceProvider.registerResetCommand | protected function registerResetCommand()
{
$this->app->singleton('command.appreset', function (Container $app) {
$events = $app['events'];
return new AppReset($events);
});
} | php | protected function registerResetCommand()
{
$this->app->singleton('command.appreset', function (Container $app) {
$events = $app['events'];
return new AppReset($events);
});
} | [
"protected",
"function",
"registerResetCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.appreset'",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"events",
"=",
"$",
"app",
"[",
"'events'",
"]",
";",
"r... | Register the reset command class.
@return void | [
"Register",
"the",
"reset",
"command",
"class",
"."
] | 9240e0757186f7fc0dd81ab445a997cb106b508e | https://github.com/GrahamDeprecated/Laravel-Core/blob/9240e0757186f7fc0dd81ab445a997cb106b508e/src/CoreServiceProvider.php#L98-L105 | train |
shopgate/cart-integration-magento2-base | src/Helper/Settings/Country/Retriever.php | Retriever.getAllowedAddressCountries | public function getAllowedAddressCountries()
{
$allowedShippingCountries = $this->getAllowedShippingCountries();
$allowedShippingCountriesMap = array_map(
function ($country) {
return $country['country'];
},
$allowedShippingCountries
);
$allowedAddressCountries = [];
foreach ($this->mainShipHelper->getMageShippingCountries() as $addressCountry) {
$state = array_search($addressCountry, $allowedShippingCountriesMap, true);
$states = $state !== false ? $allowedShippingCountries[$state]['state'] : ['All'];
$allowedAddressCountries[] =
[
'country' => $addressCountry,
'state' => $states
];
}
return $allowedAddressCountries;
} | php | public function getAllowedAddressCountries()
{
$allowedShippingCountries = $this->getAllowedShippingCountries();
$allowedShippingCountriesMap = array_map(
function ($country) {
return $country['country'];
},
$allowedShippingCountries
);
$allowedAddressCountries = [];
foreach ($this->mainShipHelper->getMageShippingCountries() as $addressCountry) {
$state = array_search($addressCountry, $allowedShippingCountriesMap, true);
$states = $state !== false ? $allowedShippingCountries[$state]['state'] : ['All'];
$allowedAddressCountries[] =
[
'country' => $addressCountry,
'state' => $states
];
}
return $allowedAddressCountries;
} | [
"public",
"function",
"getAllowedAddressCountries",
"(",
")",
"{",
"$",
"allowedShippingCountries",
"=",
"$",
"this",
"->",
"getAllowedShippingCountries",
"(",
")",
";",
"$",
"allowedShippingCountriesMap",
"=",
"array_map",
"(",
"function",
"(",
"$",
"country",
")",... | Returns Merchant API ready array of Country, State pairs of
allowed addresses by Magento
@return array() - array(['country'=>'US', 'state'=> 'All'], [...]) | [
"Returns",
"Merchant",
"API",
"ready",
"array",
"of",
"Country",
"State",
"pairs",
"of",
"allowed",
"addresses",
"by",
"Magento"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Country/Retriever.php#L58-L81 | train |
shopgate/cart-integration-magento2-base | src/Helper/Settings/Country/Retriever.php | Retriever.getAllowedShippingCountries | public function getAllowedShippingCountries()
{
$allowedShippingCountriesRaw = $this->getAllowedShippingCountriesRaw();
$allowedShippingCountries = [];
foreach ($allowedShippingCountriesRaw as $countryCode => $states) {
$states = empty($states) ? ['All' => true] : $states;
$states = array_filter(
array_keys($states),
function ($st) {
return is_string($st) ? $st : 'All';
}
);
$states = in_array('All', $states, true) ? ['All'] : $states;
array_walk(
$states,
function (&$state, $key, $country) {
$state = $state === 'All' ? $state : $country . '-' . $state;
},
$countryCode
);
$allowedShippingCountries[] =
[
'country' => $countryCode,
'state' => $states
];
}
return $allowedShippingCountries;
} | php | public function getAllowedShippingCountries()
{
$allowedShippingCountriesRaw = $this->getAllowedShippingCountriesRaw();
$allowedShippingCountries = [];
foreach ($allowedShippingCountriesRaw as $countryCode => $states) {
$states = empty($states) ? ['All' => true] : $states;
$states = array_filter(
array_keys($states),
function ($st) {
return is_string($st) ? $st : 'All';
}
);
$states = in_array('All', $states, true) ? ['All'] : $states;
array_walk(
$states,
function (&$state, $key, $country) {
$state = $state === 'All' ? $state : $country . '-' . $state;
},
$countryCode
);
$allowedShippingCountries[] =
[
'country' => $countryCode,
'state' => $states
];
}
return $allowedShippingCountries;
} | [
"public",
"function",
"getAllowedShippingCountries",
"(",
")",
"{",
"$",
"allowedShippingCountriesRaw",
"=",
"$",
"this",
"->",
"getAllowedShippingCountriesRaw",
"(",
")",
";",
"$",
"allowedShippingCountries",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"allowedShippin... | Returns Merchant API ready array of Country, State pairs of
allowed shipping addresses by Magento
@return array() - array(['country'=>'US', 'state'=> 'All'], ...) | [
"Returns",
"Merchant",
"API",
"ready",
"array",
"of",
"Country",
"State",
"pairs",
"of",
"allowed",
"shipping",
"addresses",
"by",
"Magento"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Country/Retriever.php#L89-L121 | train |
shopgate/cart-integration-magento2-base | src/Helper/Settings/Country/Retriever.php | Retriever.getAllowedShippingCountriesRaw | private function getAllowedShippingCountriesRaw()
{
$allowedCountries = array_fill_keys($this->mainShipHelper->getMageShippingCountries(), []);
$carriers = $this->mainShipHelper->getActiveCarriers();
$countries = [];
/**
* @var AbstractCarrier $carrier
*/
foreach ($carriers as $carrier) {
/* skip shopgate cause its a container carrier */
if ($carrier->getCarrierCode() === Shipping\Carrier\Shopgate::CODE) {
continue;
}
/* if any carrier is using the allowed_countries collection, merge this into the result */
if ($carrier->getConfigData('sallowspecific') === '0') {
$countries = array_merge_recursive($countries, $allowedCountries);
continue;
}
/* fetching active shipping targets from rates direct from the database */
if ($carrier->getCarrierCode() === Shipping\Carrier\TableRate::CODE) {
$collection = $this->tableRate->getTableRateCollection();
$countryHolder = [];
/** @var Tablerate $rate */
foreach ($collection as $rate) {
$countryHolder[$rate->getData('dest_country_id')][$rate->getData('dest_region') ? : 'All'] = true;
}
$countries = array_merge_recursive($countryHolder, $countries);
continue;
}
$specificCountries = $carrier->getConfigData('specificcountry');
$countries = array_merge_recursive(
$countries,
array_fill_keys(explode(",", $specificCountries), [])
);
}
foreach ($countries as $countryCode => $item) {
if (!isset($allowedCountries[$countryCode])) {
unset($countries[$countryCode]);
}
}
return $countries;
} | php | private function getAllowedShippingCountriesRaw()
{
$allowedCountries = array_fill_keys($this->mainShipHelper->getMageShippingCountries(), []);
$carriers = $this->mainShipHelper->getActiveCarriers();
$countries = [];
/**
* @var AbstractCarrier $carrier
*/
foreach ($carriers as $carrier) {
/* skip shopgate cause its a container carrier */
if ($carrier->getCarrierCode() === Shipping\Carrier\Shopgate::CODE) {
continue;
}
/* if any carrier is using the allowed_countries collection, merge this into the result */
if ($carrier->getConfigData('sallowspecific') === '0') {
$countries = array_merge_recursive($countries, $allowedCountries);
continue;
}
/* fetching active shipping targets from rates direct from the database */
if ($carrier->getCarrierCode() === Shipping\Carrier\TableRate::CODE) {
$collection = $this->tableRate->getTableRateCollection();
$countryHolder = [];
/** @var Tablerate $rate */
foreach ($collection as $rate) {
$countryHolder[$rate->getData('dest_country_id')][$rate->getData('dest_region') ? : 'All'] = true;
}
$countries = array_merge_recursive($countryHolder, $countries);
continue;
}
$specificCountries = $carrier->getConfigData('specificcountry');
$countries = array_merge_recursive(
$countries,
array_fill_keys(explode(",", $specificCountries), [])
);
}
foreach ($countries as $countryCode => $item) {
if (!isset($allowedCountries[$countryCode])) {
unset($countries[$countryCode]);
}
}
return $countries;
} | [
"private",
"function",
"getAllowedShippingCountriesRaw",
"(",
")",
"{",
"$",
"allowedCountries",
"=",
"array_fill_keys",
"(",
"$",
"this",
"->",
"mainShipHelper",
"->",
"getMageShippingCountries",
"(",
")",
",",
"[",
"]",
")",
";",
"$",
"carriers",
"=",
"$",
"... | Collects the raw allowed countries from Magento | [
"Collects",
"the",
"raw",
"allowed",
"countries",
"from",
"Magento"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Country/Retriever.php#L126-L174 | train |
SaftIng/Saft | src/Saft/Store/BasicTriplePatternStore.php | BasicTriplePatternStore.getGraphs | public function getGraphs()
{
$graphs = [];
foreach (array_keys($this->statements) as $graphUri) {
if ('http://saft/defaultGraph/' == $graphUri) {
$graphs[$graphUri] = $this->nodeFactory->createNamedNode($graphUri);
}
}
return $graphs;
} | php | public function getGraphs()
{
$graphs = [];
foreach (array_keys($this->statements) as $graphUri) {
if ('http://saft/defaultGraph/' == $graphUri) {
$graphs[$graphUri] = $this->nodeFactory->createNamedNode($graphUri);
}
}
return $graphs;
} | [
"public",
"function",
"getGraphs",
"(",
")",
"{",
"$",
"graphs",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"statements",
")",
"as",
"$",
"graphUri",
")",
"{",
"if",
"(",
"'http://saft/defaultGraph/'",
"==",
"$",
"graphUri"... | Has no function and returns an empty array.
@return array Empty array | [
"Has",
"no",
"function",
"and",
"returns",
"an",
"empty",
"array",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Store/BasicTriplePatternStore.php#L96-L107 | train |
SaftIng/Saft | src/Saft/Store/BasicTriplePatternStore.php | BasicTriplePatternStore.getMatchingStatements | public function getMatchingStatements(Statement $statement, Node $graph = null, array $options = [])
{
if (null !== $graph) {
$graphUri = $graph->getUri();
// no graph information given, use default graph
} elseif (null === $graph && null === $statement->getGraph()) {
$graphUri = 'http://saft/defaultGraph/';
// no graph given, use graph information from $statement
} elseif (null === $graph && $statement->getGraph()->isNamed()) {
$graphUri = $statement->getGraph()->getUri();
// no graph given, use graph information from $statement
} elseif (null === $graph && false == $statement->getGraph()->isNamed()) {
$graphUri = 'http://saft/defaultGraph/';
}
if (false == isset($this->statements[$graphUri])) {
$this->statements[$graphUri] = [];
}
// if not default graph was requested
if ('http://saft/defaultGraph/' != $graphUri) {
return new StatementSetResultImpl($this->statements[$graphUri]);
// if default graph was requested, return matching statements from all graphs
} else {
$_statements = [];
foreach ($this->statements as $graphUri => $statements) {
foreach ($statements as $statement) {
if ('http://saft/defaultGraph/' == $graphUri) {
$graph = null;
} else {
$graph = $this->nodeFactory->createNamedNode($graphUri);
}
$_statements[] = $this->statementFactory->createStatement(
$statement->getSubject(),
$statement->getPredicate(),
$statement->getObject(),
$graph
);
}
}
return new StatementSetResultImpl($_statements);
}
} | php | public function getMatchingStatements(Statement $statement, Node $graph = null, array $options = [])
{
if (null !== $graph) {
$graphUri = $graph->getUri();
// no graph information given, use default graph
} elseif (null === $graph && null === $statement->getGraph()) {
$graphUri = 'http://saft/defaultGraph/';
// no graph given, use graph information from $statement
} elseif (null === $graph && $statement->getGraph()->isNamed()) {
$graphUri = $statement->getGraph()->getUri();
// no graph given, use graph information from $statement
} elseif (null === $graph && false == $statement->getGraph()->isNamed()) {
$graphUri = 'http://saft/defaultGraph/';
}
if (false == isset($this->statements[$graphUri])) {
$this->statements[$graphUri] = [];
}
// if not default graph was requested
if ('http://saft/defaultGraph/' != $graphUri) {
return new StatementSetResultImpl($this->statements[$graphUri]);
// if default graph was requested, return matching statements from all graphs
} else {
$_statements = [];
foreach ($this->statements as $graphUri => $statements) {
foreach ($statements as $statement) {
if ('http://saft/defaultGraph/' == $graphUri) {
$graph = null;
} else {
$graph = $this->nodeFactory->createNamedNode($graphUri);
}
$_statements[] = $this->statementFactory->createStatement(
$statement->getSubject(),
$statement->getPredicate(),
$statement->getObject(),
$graph
);
}
}
return new StatementSetResultImpl($_statements);
}
} | [
"public",
"function",
"getMatchingStatements",
"(",
"Statement",
"$",
"statement",
",",
"Node",
"$",
"graph",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"graph",
")",
"{",
"$",
"graphUri",
"=",
... | It basically returns all stored statements.
@param Statement $statement it can be either a concrete or pattern-statement
@param Node $graph optional Overrides target graph. If set, you will get all
matching statements of that graph.
@param array $options optional It contains key-value pairs and should provide additional
introductions for the store and/or its adapter(s)
@return SetResult it contains Statement instances of all matching statements of the given graph | [
"It",
"basically",
"returns",
"all",
"stored",
"statements",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Store/BasicTriplePatternStore.php#L205-L254 | train |
BerliozFramework/Berlioz | src/Services/Logger.php | Logger.writeLogs | private function writeLogs(): void
{
// Write logs
$fileName = $this->getApp()->getConfig()->getDirectory(ConfigInterface::DIR_VAR_LOGS) . '/Berlioz.log';
if (is_resource($this->fp) || is_resource($this->fp = @fopen($fileName, 'a'))) {
if (count($this->logs) > 0) {
foreach ($this->logs as $key => $log) {
if (!$log['written']) {
$line = sprintf("%-26s %-11s %s\n",
\DateTime::createFromFormat('U.u', number_format($log['time'], 6, '.', ''))
->format('Y-m-d H:i:s.u'),
'[' . $log['level'] . ']',
$log['message']);
if (@fwrite($this->fp, $line) !== false) {
$this->logs[$key]['written'] = true;
}
}
}
}
unset($log);
}
} | php | private function writeLogs(): void
{
// Write logs
$fileName = $this->getApp()->getConfig()->getDirectory(ConfigInterface::DIR_VAR_LOGS) . '/Berlioz.log';
if (is_resource($this->fp) || is_resource($this->fp = @fopen($fileName, 'a'))) {
if (count($this->logs) > 0) {
foreach ($this->logs as $key => $log) {
if (!$log['written']) {
$line = sprintf("%-26s %-11s %s\n",
\DateTime::createFromFormat('U.u', number_format($log['time'], 6, '.', ''))
->format('Y-m-d H:i:s.u'),
'[' . $log['level'] . ']',
$log['message']);
if (@fwrite($this->fp, $line) !== false) {
$this->logs[$key]['written'] = true;
}
}
}
}
unset($log);
}
} | [
"private",
"function",
"writeLogs",
"(",
")",
":",
"void",
"{",
"// Write logs",
"$",
"fileName",
"=",
"$",
"this",
"->",
"getApp",
"(",
")",
"->",
"getConfig",
"(",
")",
"->",
"getDirectory",
"(",
"ConfigInterface",
"::",
"DIR_VAR_LOGS",
")",
".",
"'/Berl... | Write log on file.
@return void | [
"Write",
"log",
"on",
"file",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Logger.php#L143-L166 | train |
BerliozFramework/Berlioz | src/Services/Logger.php | Logger.needToLog | private function needToLog(string $level): bool
{
$logLevels = [LogLevel::EMERGENCY => 0,
LogLevel::ALERT => 1,
LogLevel::CRITICAL => 2,
LogLevel::ERROR => 3,
LogLevel::WARNING => 4,
LogLevel::NOTICE => 5,
LogLevel::INFO => 6,
LogLevel::DEBUG => 7];
if (isset($logLevels[$this->getApp()->getConfig()->getLogLevel()])) {
return isset($logLevels[$level]) && $logLevels[$level] <= $logLevels[$this->getApp()->getConfig()->getLogLevel()];
} else {
return false;
}
} | php | private function needToLog(string $level): bool
{
$logLevels = [LogLevel::EMERGENCY => 0,
LogLevel::ALERT => 1,
LogLevel::CRITICAL => 2,
LogLevel::ERROR => 3,
LogLevel::WARNING => 4,
LogLevel::NOTICE => 5,
LogLevel::INFO => 6,
LogLevel::DEBUG => 7];
if (isset($logLevels[$this->getApp()->getConfig()->getLogLevel()])) {
return isset($logLevels[$level]) && $logLevels[$level] <= $logLevels[$this->getApp()->getConfig()->getLogLevel()];
} else {
return false;
}
} | [
"private",
"function",
"needToLog",
"(",
"string",
"$",
"level",
")",
":",
"bool",
"{",
"$",
"logLevels",
"=",
"[",
"LogLevel",
"::",
"EMERGENCY",
"=>",
"0",
",",
"LogLevel",
"::",
"ALERT",
"=>",
"1",
",",
"LogLevel",
"::",
"CRITICAL",
"=>",
"2",
",",
... | Need to log ?
@param string $level
@return bool | [
"Need",
"to",
"log",
"?"
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Logger.php#L175-L191 | train |
hypeJunction/hypeApps | classes/hypeJunction/Apps/Config.php | Config.getCroppableSizes | public function getCroppableSizes() {
return array(
self::SIZE_LARGE,
self::SIZE_MEDIUM,
self::SIZE_SMALL,
self::SIZE_TINY,
self::SIZE_TOPBAR,
);
} | php | public function getCroppableSizes() {
return array(
self::SIZE_LARGE,
self::SIZE_MEDIUM,
self::SIZE_SMALL,
self::SIZE_TINY,
self::SIZE_TOPBAR,
);
} | [
"public",
"function",
"getCroppableSizes",
"(",
")",
"{",
"return",
"array",
"(",
"self",
"::",
"SIZE_LARGE",
",",
"self",
"::",
"SIZE_MEDIUM",
",",
"self",
"::",
"SIZE_SMALL",
",",
"self",
"::",
"SIZE_TINY",
",",
"self",
"::",
"SIZE_TOPBAR",
",",
")",
";"... | Returns an array of croppable size names
@return array | [
"Returns",
"an",
"array",
"of",
"croppable",
"size",
"names"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Apps/Config.php#L52-L60 | train |
liues1992/php-protobuf-generator | src/Gary/Protobuf/Internal/DescriptorTrait.php | DescriptorTrait.getSourceCodePath | public function getSourceCodePath()
{
if ($this->path === null) {
$path = [];
$current = $this;
while ($current && !$current instanceof FileDescriptor) {
$parent = $current->getContaining();
if (!$parent) {
throw new \Exception("parent cannot be null");
}
array_unshift($path, $current->getIndex());
// field number in definition:descriptor.proto
$name = $this->getClassShortName($current);
$pname = $this->getClassShortName($parent);
if (isset(self::$pathMap[$name])) {
if (is_int(self::$pathMap[$name])) {
$fieldNumber = self::$pathMap[$name];
} else {
if (isset(self::$pathMap[$name][$pname])) {
$fieldNumber = self::$pathMap[$name][$pname];
} else {
throw new \Exception("unimplemented situation $name $pname");
}
}
} else {
throw new \Exception("unimplemented situation $name $pname");
}
array_unshift($path, $fieldNumber);
$current = $parent;
}
$this->path = $path;
} else {
$path = $this->path;
}
return $path;
} | php | public function getSourceCodePath()
{
if ($this->path === null) {
$path = [];
$current = $this;
while ($current && !$current instanceof FileDescriptor) {
$parent = $current->getContaining();
if (!$parent) {
throw new \Exception("parent cannot be null");
}
array_unshift($path, $current->getIndex());
// field number in definition:descriptor.proto
$name = $this->getClassShortName($current);
$pname = $this->getClassShortName($parent);
if (isset(self::$pathMap[$name])) {
if (is_int(self::$pathMap[$name])) {
$fieldNumber = self::$pathMap[$name];
} else {
if (isset(self::$pathMap[$name][$pname])) {
$fieldNumber = self::$pathMap[$name][$pname];
} else {
throw new \Exception("unimplemented situation $name $pname");
}
}
} else {
throw new \Exception("unimplemented situation $name $pname");
}
array_unshift($path, $fieldNumber);
$current = $parent;
}
$this->path = $path;
} else {
$path = $this->path;
}
return $path;
} | [
"public",
"function",
"getSourceCodePath",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"path",
"===",
"null",
")",
"{",
"$",
"path",
"=",
"[",
"]",
";",
"$",
"current",
"=",
"$",
"this",
";",
"while",
"(",
"$",
"current",
"&&",
"!",
"$",
"curren... | see protobuf's descriptor.proto for the concept of path
@return array
@throws \Exception | [
"see",
"protobuf",
"s",
"descriptor",
".",
"proto",
"for",
"the",
"concept",
"of",
"path"
] | 0bae264906b9e8fd989784e482e09bd0aa649991 | https://github.com/liues1992/php-protobuf-generator/blob/0bae264906b9e8fd989784e482e09bd0aa649991/src/Gary/Protobuf/Internal/DescriptorTrait.php#L81-L116 | train |
BerliozFramework/Berlioz | src/Controller/RestController.php | RestController.response | protected function response($mixed): ResponseInterface
{
$statusCode = 200;
$reasonPhrase = '';
$headers['Content-Type'] = ['application/json'];
$body = new Stream();
// Booleans
if (is_bool($mixed)) {
if ($mixed == false) {
$statusCode = 500;
}
} else {
// Array
if (is_array($mixed)) {
$body->write(json_encode($mixed));
} else {
// Exception
if ($mixed instanceof \Exception) {
if ($mixed instanceof RoutingException) {
$statusCode = $mixed->getCode();
$reasonPhrase = $mixed->getMessage();
} else {
$statusCode = 500;
}
$body->write(json_encode(['errno' => $mixed->getCode(), 'error' => $mixed->getMessage()]));
} else {
// Object
if (is_object($mixed)) {
if ($mixed instanceof \JsonSerializable) {
$body->write(json_encode($mixed));
} else {
throw new BerliozException('Parameter object must implement \JsonSerializable interface to be converted');
}
} else {
$statusCode = 500;
}
}
}
}
// Response
return new Response($body, $statusCode, $headers, $reasonPhrase);
} | php | protected function response($mixed): ResponseInterface
{
$statusCode = 200;
$reasonPhrase = '';
$headers['Content-Type'] = ['application/json'];
$body = new Stream();
// Booleans
if (is_bool($mixed)) {
if ($mixed == false) {
$statusCode = 500;
}
} else {
// Array
if (is_array($mixed)) {
$body->write(json_encode($mixed));
} else {
// Exception
if ($mixed instanceof \Exception) {
if ($mixed instanceof RoutingException) {
$statusCode = $mixed->getCode();
$reasonPhrase = $mixed->getMessage();
} else {
$statusCode = 500;
}
$body->write(json_encode(['errno' => $mixed->getCode(), 'error' => $mixed->getMessage()]));
} else {
// Object
if (is_object($mixed)) {
if ($mixed instanceof \JsonSerializable) {
$body->write(json_encode($mixed));
} else {
throw new BerliozException('Parameter object must implement \JsonSerializable interface to be converted');
}
} else {
$statusCode = 500;
}
}
}
}
// Response
return new Response($body, $statusCode, $headers, $reasonPhrase);
} | [
"protected",
"function",
"response",
"(",
"$",
"mixed",
")",
":",
"ResponseInterface",
"{",
"$",
"statusCode",
"=",
"200",
";",
"$",
"reasonPhrase",
"=",
"''",
";",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"[",
"'application/json'",
"]",
";",
"$",
... | Response to the client.
@param bool|object|array|\Exception $mixed Data
@return \Psr\Http\Message\ResponseInterface
@throws \Berlioz\Core\Exception\BerliozException If parameter object does'nt implement \JsonSerializable
interface to be converted | [
"Response",
"to",
"the",
"client",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Controller/RestController.php#L52-L96 | train |
hypeJunction/hypeApps | classes/hypeJunction/Services/Uploader.php | Uploader.handle | public function handle($input = '', array $attributes = array(), array $options = array()) {
$result = array();
$uploads = $this->getUploads($input);
$filestore_prefix = elgg_extract('filestore_prefix', $options, $this->config->getDefaultFilestorePrefix());
unset($options['filestore_prefix']);
foreach ($uploads as $props) {
$upload = new \hypeJunction\Files\Upload($props);
$upload->save($attributes, $filestore_prefix);
if ($upload->file instanceof \ElggEntity && $upload->simpletype == 'image') {
$this->iconFactory->create($upload->file, null, $options);
}
$result[] = $upload;
}
return $result;
} | php | public function handle($input = '', array $attributes = array(), array $options = array()) {
$result = array();
$uploads = $this->getUploads($input);
$filestore_prefix = elgg_extract('filestore_prefix', $options, $this->config->getDefaultFilestorePrefix());
unset($options['filestore_prefix']);
foreach ($uploads as $props) {
$upload = new \hypeJunction\Files\Upload($props);
$upload->save($attributes, $filestore_prefix);
if ($upload->file instanceof \ElggEntity && $upload->simpletype == 'image') {
$this->iconFactory->create($upload->file, null, $options);
}
$result[] = $upload;
}
return $result;
} | [
"public",
"function",
"handle",
"(",
"$",
"input",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"uploads",
"="... | Create new ElggFile entities from uploaded files
@param string $input Name of the file input
@param array $attributes Attributes and metadata for saving files
@param array $options Additional factory options (including entity attributes such as type, subtype, owner_guid, container_guid, access_id etc
'icon_sizes' ARR Optional. An array of icon sizes to create (for image uploads)
'coords' ARR Optional. Coordinates for icon cropping
'filestore_prefix' STR Optional. Custom prefix on Elgg filestore
'icon_filestore_prefix' STR Optional. Custom prefix for created icons on Elgg filestore
@return \ElggFile[] | [
"Create",
"new",
"ElggFile",
"entities",
"from",
"uploaded",
"files"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Services/Uploader.php#L42-L63 | train |
hypeJunction/hypeApps | classes/hypeJunction/Services/Uploader.php | Uploader.getFriendlyUploadError | public function getFriendlyUploadError($error_code = '') {
switch ($error_code) {
case UPLOAD_ERR_OK:
return '';
case UPLOAD_ERR_INI_SIZE:
$key = 'ini_size';
break;
case UPLOAD_ERR_FORM_SIZE:
$key = 'form_size';
break;
case UPLOAD_ERR_PARTIAL:
$key = 'partial';
break;
case UPLOAD_ERR_NO_FILE:
$key = 'no_file';
break;
case UPLOAD_ERR_NO_TMP_DIR:
$key = 'no_tmp_dir';
break;
case UPLOAD_ERR_CANT_WRITE:
$key = 'cant_write';
break;
case UPLOAD_ERR_EXTENSION:
$key = 'extension';
break;
default:
$key = 'unknown';
break;
}
return elgg_echo("upload:error:$key");
} | php | public function getFriendlyUploadError($error_code = '') {
switch ($error_code) {
case UPLOAD_ERR_OK:
return '';
case UPLOAD_ERR_INI_SIZE:
$key = 'ini_size';
break;
case UPLOAD_ERR_FORM_SIZE:
$key = 'form_size';
break;
case UPLOAD_ERR_PARTIAL:
$key = 'partial';
break;
case UPLOAD_ERR_NO_FILE:
$key = 'no_file';
break;
case UPLOAD_ERR_NO_TMP_DIR:
$key = 'no_tmp_dir';
break;
case UPLOAD_ERR_CANT_WRITE:
$key = 'cant_write';
break;
case UPLOAD_ERR_EXTENSION:
$key = 'extension';
break;
default:
$key = 'unknown';
break;
}
return elgg_echo("upload:error:$key");
} | [
"public",
"function",
"getFriendlyUploadError",
"(",
"$",
"error_code",
"=",
"''",
")",
"{",
"switch",
"(",
"$",
"error_code",
")",
"{",
"case",
"UPLOAD_ERR_OK",
":",
"return",
"''",
";",
"case",
"UPLOAD_ERR_INI_SIZE",
":",
"$",
"key",
"=",
"'ini_size'",
";"... | Returns a human-readable message for PHP's upload error codes
@param int $error_code The code as stored in $_FILES['name']['error']
@return string | [
"Returns",
"a",
"human",
"-",
"readable",
"message",
"for",
"PHP",
"s",
"upload",
"error",
"codes"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Services/Uploader.php#L121-L160 | train |
silverstripe/silverstripe-securityreport | src/Subsites/SubsiteMemberReportExtension.php | SubsiteMemberReportExtension.getSubsiteDescription | public function getSubsiteDescription()
{
$subsites = Subsite::accessible_sites(
$this->owner->config()->get('subsite_description_permission'),
true,
"Main site",
$this->owner
);
return implode(', ', $subsites->column('Title'));
} | php | public function getSubsiteDescription()
{
$subsites = Subsite::accessible_sites(
$this->owner->config()->get('subsite_description_permission'),
true,
"Main site",
$this->owner
);
return implode(', ', $subsites->column('Title'));
} | [
"public",
"function",
"getSubsiteDescription",
"(",
")",
"{",
"$",
"subsites",
"=",
"Subsite",
"::",
"accessible_sites",
"(",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"get",
"(",
"'subsite_description_permission'",
")",
",",
"true",
",",
"... | Describes the subsites this user has SITETREE_EDIT_ALL access to
@return string | [
"Describes",
"the",
"subsites",
"this",
"user",
"has",
"SITETREE_EDIT_ALL",
"access",
"to"
] | 38ee887986edf878f40a8dfa7df5c37df42a5dee | https://github.com/silverstripe/silverstripe-securityreport/blob/38ee887986edf878f40a8dfa7df5c37df42a5dee/src/Subsites/SubsiteMemberReportExtension.php#L39-L48 | train |
contextio/PHP-ContextIO | src/ContextIO/ContextIO.php | ContextIO.checkFilterParams | protected function checkFilterParams($givenParams, $validParams, $requiredParams = array())
{
$filteredParams = array();
foreach ($givenParams as $name => $value) {
if (in_array(strtolower($name), $validParams)) {
$filteredParams[ strtolower($name) ] = $value;
} else {
return false;
}
}
foreach ($requiredParams as $name) {
if (!array_key_exists(strtolower($name), $filteredParams)) {
return false;
}
}
return $filteredParams;
} | php | protected function checkFilterParams($givenParams, $validParams, $requiredParams = array())
{
$filteredParams = array();
foreach ($givenParams as $name => $value) {
if (in_array(strtolower($name), $validParams)) {
$filteredParams[ strtolower($name) ] = $value;
} else {
return false;
}
}
foreach ($requiredParams as $name) {
if (!array_key_exists(strtolower($name), $filteredParams)) {
return false;
}
}
return $filteredParams;
} | [
"protected",
"function",
"checkFilterParams",
"(",
"$",
"givenParams",
",",
"$",
"validParams",
",",
"$",
"requiredParams",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filteredParams",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"givenParams",
"as",
"$",... | Checks whether all set params are valid and all required params are set.
@param array $givenParams
@param array $validParams
@param array $requiredParams
@return array|bool | [
"Checks",
"whether",
"all",
"set",
"params",
"are",
"valid",
"and",
"all",
"required",
"params",
"are",
"set",
"."
] | 037e7c52683def87e639030d11c49da83f5c07dc | https://github.com/contextio/PHP-ContextIO/blob/037e7c52683def87e639030d11c49da83f5c07dc/src/ContextIO/ContextIO.php#L1715-L1732 | train |
mothership-gmbh/state_machine | src/WorkflowAbstract.php | WorkflowAbstract.initializeStates | protected function initializeStates()
{
if (!array_key_exists('states', $this->vars)) {
throw new WorkflowException("You must define some states:\n", 99, NULL);
}
//check if all the methods for each status is callable
$methods_not_implemented = '';
try {
foreach ($this->vars['states'] as $status) {
array_push($this->states, new Status($status));
/*
* The initial state will never be executed but only the transitions, therefore it will be excluded
* from the list of methods which must be implemented
*/
if (!method_exists($this, $status['name'])
&& $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_INITIAL
&& $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_EXCEPTION) {
$methods_not_implemented .= $status['name'] . "\n";
}
}
} catch (StatusException $ex) {
throw new WorkflowException("Error in one state of the workflow:\n" . $ex->getMessage(), 79);
}
if (strlen($methods_not_implemented) > 0) {
throw new WorkflowException(
"This methods are not implemented in the workflow:\n" .
$methods_not_implemented, 79, NULL
);
}
} | php | protected function initializeStates()
{
if (!array_key_exists('states', $this->vars)) {
throw new WorkflowException("You must define some states:\n", 99, NULL);
}
//check if all the methods for each status is callable
$methods_not_implemented = '';
try {
foreach ($this->vars['states'] as $status) {
array_push($this->states, new Status($status));
/*
* The initial state will never be executed but only the transitions, therefore it will be excluded
* from the list of methods which must be implemented
*/
if (!method_exists($this, $status['name'])
&& $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_INITIAL
&& $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_EXCEPTION) {
$methods_not_implemented .= $status['name'] . "\n";
}
}
} catch (StatusException $ex) {
throw new WorkflowException("Error in one state of the workflow:\n" . $ex->getMessage(), 79);
}
if (strlen($methods_not_implemented) > 0) {
throw new WorkflowException(
"This methods are not implemented in the workflow:\n" .
$methods_not_implemented, 79, NULL
);
}
} | [
"protected",
"function",
"initializeStates",
"(",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'states'",
",",
"$",
"this",
"->",
"vars",
")",
")",
"{",
"throw",
"new",
"WorkflowException",
"(",
"\"You must define some states:\\n\"",
",",
"99",
",",
"NU... | Initialize the states
@throws WorkflowException
@return void | [
"Initialize",
"the",
"states"
] | 317ee68bb4e64a18a176f4e0c93a5c9c71946f71 | https://github.com/mothership-gmbh/state_machine/blob/317ee68bb4e64a18a176f4e0c93a5c9c71946f71/src/WorkflowAbstract.php#L106-L138 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.